[Opalvoip-svn] SF.net SVN: opalvoip: [18738] ptlib/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <sh...@us...> - 2007-10-22 18:33:46
|
Revision: 18738 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=18738&view=rev Author: shorne Date: 2007-10-22 11:33:45 -0700 (Mon, 22 Oct 2007) Log Message: ----------- Visual Studio Support Modified Paths: -------------- ptlib/trunk/include/ptclib/pvfiledev.h ptlib/trunk/src/ptlib/msos/vidinput_directx.cxx Modified: ptlib/trunk/include/ptclib/pvfiledev.h =================================================================== --- ptlib/trunk/include/ptclib/pvfiledev.h 2007-10-22 13:51:31 UTC (rev 18737) +++ ptlib/trunk/include/ptclib/pvfiledev.h 2007-10-22 18:33:45 UTC (rev 18738) @@ -152,6 +152,13 @@ virtual PStringList GetDeviceNames() const { return GetInputDeviceNames(); } + /**Retrieve a list of Device Capabilities + */ + static BOOL GetDeviceCapabilities( + const PString & /*deviceName*/, ///< Name of device + InputDeviceCapabilities & /*caps*/ ///< List of supported capabilities + ) { return FALSE; } + /**Get the maximum frame size in bytes. Note a particular device may be able to provide variable length Modified: ptlib/trunk/src/ptlib/msos/vidinput_directx.cxx =================================================================== --- ptlib/trunk/src/ptlib/msos/vidinput_directx.cxx 2007-10-22 13:51:31 UTC (rev 18737) +++ ptlib/trunk/src/ptlib/msos/vidinput_directx.cxx 2007-10-22 18:33:45 UTC (rev 18738) @@ -38,8 +38,8 @@ #ifdef _MSC_VER #ifndef _WIN32_WCE -#pragma comment(lib,"strmbase.lib") #pragma comment(lib,"strmiids.lib") +#pragma comment(lib,"quartz.lib") #endif #endif @@ -54,6 +54,28 @@ PCREATE_VIDINPUT_PLUGIN(DirectShow); + +static void MyDeleteMediaType(AM_MEDIA_TYPE *pmt) +{ + if (pmt == NULL) + return; + + if (pmt->cbFormat != 0) + { + CoTaskMemFree((PVOID)pmt->pbFormat); + pmt->cbFormat = 0; + pmt->pbFormat = NULL; + } + if (pmt->pUnk != NULL) + { + // Uncessessary because pUnk should not be used, but safest. + pmt->pUnk->Release(); + pmt->pUnk = NULL; + } + + CoTaskMemFree(pmt); +} + PVideoInputDevice_DirectShow::PVideoInputDevice_DirectShow() { PTRACE(1,"PVidDirectShow\tPVideoInputDevice_DirectShow: constructor" ); @@ -228,7 +250,6 @@ PStringList PVideoInputDevice_DirectShow::GetInputDeviceNames() { HRESULT hr; - IBaseFilter * pSrc = NULL; IMoniker *pMoniker =NULL; ICreateDevEnum *pDevEnum =NULL; IEnumMoniker *pClassEnum = NULL; @@ -265,16 +286,8 @@ return list; } - while (1) + while (hr = pClassEnum->Next(1, &pMoniker, &cFetched), hr==S_OK) { - // Get the next device - hr = pClassEnum->Next(1, &pMoniker, &cFetched); - if (hr != S_OK) - { - PTRACE(4, "PVidDirectShow\tGetInputDeviceNames() No more video capture device"); - break; - } - // Get the property bag IPropertyBag *pPropBag; @@ -317,7 +330,7 @@ /* FIXME: If the device is already open, close it */ if (IsOpen()) - Close(); + return TRUE; deviceName = devName; @@ -447,7 +460,6 @@ BOOL PVideoInputDevice_DirectShow::Stop() { - HRESULT hr; PTRACE(1,"PVidDirectShow\tStop()"); @@ -475,19 +487,20 @@ void PVideoInputDevice_DirectShow::FlipVertical(BYTE *buffer) { unsigned int bytesPerLine = frameBytes / frameHeight; - BYTE templine[bytesPerLine]; + BYTE * templine = new BYTE[bytesPerLine]; BYTE *s = buffer; BYTE *d = buffer + frameBytes - bytesPerLine; unsigned int i; for (i=0; i<frameHeight/2; i++) { - memcpy(templine, s, bytesPerLine); + memcpy(&templine, s, bytesPerLine); memcpy(s, d, bytesPerLine); - memcpy(d, templine, bytesPerLine); + memcpy(d, &templine, bytesPerLine); s += bytesPerLine; d -= bytesPerLine; } + delete templine; } /* @@ -621,9 +634,9 @@ AM_MEDIA_TYPE *pMediaFormat; int iCount, iSize; VIDEO_STREAM_CONFIG_CAPS scc; - unsigned int i; + int i; BOOL was_capturing = FALSE; - OAFilterState filterState; + OAFilterState filterState = State_Stopped; PTRACE(4, "PVidDirectShow\tSetFormat(\"" << (wanted_format.IsEmpty()?"Not changed":wanted_format) <<"\", " @@ -662,7 +675,7 @@ return FALSE; } - for (i=0; i<iCount; i++, DeleteMediaType(pMediaFormat)) + for (i=0; i<iCount; i++, MyDeleteMediaType(pMediaFormat)) { pMediaFormat = NULL; hr = pStreamConfig->GetStreamCaps(i, &pMediaFormat, (BYTE *)&scc); @@ -764,7 +777,7 @@ } #endif - DeleteMediaType(pMediaFormat); + MyDeleteMediaType(pMediaFormat); pStreamConfig->Release(); return TRUE; } @@ -1025,6 +1038,12 @@ } +BOOL PVideoInputDevice_DirectShow::GetDeviceCapabilities(const PString & /*deviceName*/,InputDeviceCapabilities & /*caps*/) +{ + // To do! + return FALSE; +} + /* * * @@ -1036,7 +1055,7 @@ AM_MEDIA_TYPE *pMediaFormat; int iCount, iSize; VIDEO_STREAM_CONFIG_CAPS scc; - unsigned int i; + int i; PTRACE(1, "PVidDirectShow\tListSupportedFormats()"); @@ -1087,7 +1106,7 @@ << (10000000.0/VideoInfo->AvgTimePerFrame) << "fps)"); } - DeleteMediaType(pMediaFormat); + MyDeleteMediaType(pMediaFormat); } pStreamConfig->Release(); @@ -1145,8 +1164,10 @@ } - DeleteMediaType(pMediaFormat); + MyDeleteMediaType(pMediaFormat); pStreamConfig->Release(); + + return TRUE; } @@ -1207,8 +1228,13 @@ if (dwMsgLen) return string; +#ifdef __MINGW32__ // This function is not recognised in Windows snprintf(string, sizeof(string), "0x%8.8x", hr); - return string; + return string; +#else + return PString(); +#endif + } static HRESULT SetDevice(const PString & devName, IBaseFilter ** ppSrcFilter) @@ -1312,20 +1338,17 @@ } -struct pwlib_fmt -{ +struct { char *pwlib_format; GUID media_format; -}; - -static struct pwlib_fmt formats[] = +} formats[] = { {(char*) "Grey", MEDIASUBTYPE_RGB8 }, {(char*) "BGR32", MEDIASUBTYPE_RGB32}, /* Microsoft assumes that we are in little endian */ {(char*) "BGR24", MEDIASUBTYPE_RGB24}, {(char*) "RGB565", MEDIASUBTYPE_RGB565}, {(char*) "RGB555", MEDIASUBTYPE_RGB555}, - {(char*) "YUV420P", MEDIASUBTYPE_I420}, + {(char*) "YUV420P", MEDIASUBTYPE_IYUV}, {(char*) "YUV422P", MEDIASUBTYPE_YUYV}, {(char*) "YUV411", MEDIASUBTYPE_Y411}, {(char*) "YUV411P", MEDIASUBTYPE_Y41P}, @@ -1416,7 +1439,7 @@ return "BGR24"; else if (guid == MEDIASUBTYPE_RGB32) return "BGR32"; - else if (guid == MEDIASUBTYPE_I420) + else if (guid == MEDIASUBTYPE_IYUV) return "I420"; else return guid_to_string(guid); /* FIXME: memory leak */ @@ -1437,29 +1460,4 @@ return strdup(guid_string); } -#ifdef __MINGW32__ - -static void DeleteMediaType(AM_MEDIA_TYPE *pmt) -{ - if (pmt == NULL) - return; - - if (pmt->cbFormat != 0) - { - CoTaskMemFree((PVOID)pmt->pbFormat); - pmt->cbFormat = 0; - pmt->pbFormat = NULL; - } - if (pmt->pUnk != NULL) - { - // Uncessessary because pUnk should not be used, but safest. - pmt->pUnk->Release(); - pmt->pUnk = NULL; - } - - CoTaskMemFree(pmt); -} - -#endif - #endif /*P_DIRECTSHOW*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |