void RegisterSourceFilterPattern(const char* Pattern, const GUID SourceFilterGUID, const GUID MajorType, const GUID Subtype) { // Identification by content : // HKEY_CLASSES_ROOT\MediaType\{major type}\{subtype} HKEY Key; DWORD Disp; TCHAR RegistryKeyName[256]; TCHAR CLSIDString[CHARS_IN_GUID], CLSIDString2[CHARS_IN_GUID]; GUID2String(CLSIDString, MajorType); GUID2String(CLSIDString2, Subtype); wsprintf(RegistryKeyName, "Media Type\\%s\\%s", CLSIDString, CLSIDString2); if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CLASSES_ROOT, RegistryKeyName, 0, "REG_SZ", REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &Key, &Disp)) { GUID2String(CLSIDString,SourceFilterGUID); RegSetValueEx(Key, "Source Filter", 0, REG_SZ, (CONST BYTE *) CLSIDString, strlen(CLSIDString)); // The pattern use the following format : offset,cb,mask,val RegSetValueEx(Key, "0", 0, REG_SZ, (CONST BYTE *) Pattern, strlen(Pattern)); RegCloseKey(Key); } }
void UnRegisterSourceFilterPattern(const GUID MajorType, const GUID Subtype) { TCHAR RegistryKeyName[256]; TCHAR CLSIDString[CHARS_IN_GUID], CLSIDString2[CHARS_IN_GUID]; GUID2String(CLSIDString, MajorType); GUID2String(CLSIDString2, Subtype); wsprintf(RegistryKeyName, "Media Type\\%s\\%s", CLSIDString, CLSIDString2); RegDeleteKey(HKEY_CLASSES_ROOT, RegistryKeyName); }
void _TraceGUID(GUID guid, LPCTSTR msg) { TCHAR buf[40]; GUID2String(guid, buf); _Trace(FALSE, msg); _Trace(buf); }
void PS3::PrintInfo() { std::cout << "GUID:\t" << GUID2String( GetGUID(), '-', true ) << std::endl; std::cout << "Framerate:\t" << _frameRate << std::endl; std::cout << "Running:\t" << _bRunning << std::endl; std::cout << "Capturing:\t" << _bCapture << std::endl; std::cout << "Window title:\t" << _windowTitle << std::endl; std::cout << "Horizontal flip:\t" << _bHFlip << std::endl; std::cout << "Vertical flip:\t" << _bVFlip << std::endl; std::cout << "FPS:\t" << GetFPS() << std::endl; std::cout << "Width:\t" << GetWidth() << std::endl; std::cout << "Height:\t" << GetHeight() << std::endl; std::cout << "FrameCount:\t" << GetFrameCount() << std::endl; }
void RegisterSourceFilterExtension(const char* Extension, const GUID SourceFilterGUID, const GUID MediaType, const GUID Subtype) { // Identification by extension // HKEY_CLASSES_ROOT\Media Type\Extensions\.ext HKEY Key; DWORD Disp; TCHAR RegistryKeyName[256]; TCHAR CLSIDString[CHARS_IN_GUID]; wsprintf(RegistryKeyName, "Media Type\\Extensions\\%s", Extension); if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CLASSES_ROOT, RegistryKeyName, 0, "REG_SZ", REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &Key, &Disp)) { GUID2String(CLSIDString, SourceFilterGUID); RegSetValueEx(Key, "Source Filter", 0, REG_SZ, (CONST BYTE *) CLSIDString, strlen(CLSIDString)); if(!IsEqualGUID(MediaType,CLSID_NULL)) { GUID2String(CLSIDString, MediaType); RegSetValueEx(Key, "Media Type", 0, REG_SZ, (CONST BYTE *) CLSIDString, strlen(CLSIDString)); } if(!IsEqualGUID(MediaType,CLSID_NULL)) { GUID2String(CLSIDString, Subtype); RegSetValueEx(Key, "Subtype", 0, REG_SZ, (CONST BYTE *) CLSIDString, strlen(CLSIDString)); } RegCloseKey(Key); } }
HRESULT CTSParserInputPin::CheckMediaType(const CMediaType *pMediaType) { char guid[128]; m_bIsSagePushSource = ( pMediaType->formattype == FORMAT_SAGETVInfo ); GUID2String( &pMediaType->formattype, guid, sizeof(guid) ); DbgLog((LOG_TRACE, 2, TEXT("Connected Inpin formattype:%s, cbFormat:%d, isSagePush:%d"), guid, pMediaType->cbFormat, m_bIsSagePushSource ) ); if( *(pMediaType->Type()) == MEDIATYPE_Stream ) { return S_OK; } return VFW_E_INVALIDMEDIATYPE; } // CheckMediaType
static HRESULT _get_default_sink( IDispatch * iDisp, const char * szEvent, IID * piid ) { ITypeInfo * iTI; ITypeInfo * iTISink; TYPEATTR * pTypeAttr; HREFTYPE hRefType; HRESULT hr; int iFlags, i; if( ! szEvent ) { IProvideClassInfo2 * iPCI2; IProvideClassInfo * iPCI; /* Method 1: using IProvideClassInfo2 */ hr = HB_VTBL( iDisp )->QueryInterface( HB_THIS_( iDisp ) HB_ID_REF( IID_IProvideClassInfo2 ), ( void ** ) ( void * ) &iPCI2 ); if( hr == S_OK ) { HB_TRACE( HB_TR_DEBUG, ( "_get_default_sink IProvideClassInfo2 OK" ) ); hr = HB_VTBL( iPCI2 )->GetGUID( HB_THIS_( iPCI2 ) GUIDKIND_DEFAULT_SOURCE_DISP_IID, piid ); HB_VTBL( iPCI2 )->Release( HB_THIS( iPCI2 ) ); if( hr == S_OK ) return S_OK; } else HB_TRACE( HB_TR_DEBUG, ( "_get_default_sink IProvideClassInfo2 obtain error %08lX", hr ) ); /* Method 2: using IProvideClassInfo and searching for default source in ITypeInfo */ hr = HB_VTBL( iDisp )->QueryInterface( HB_THIS_( iDisp ) HB_ID_REF( IID_IProvideClassInfo ), ( void ** ) ( void * ) &iPCI ); if( hr == S_OK ) { HB_TRACE( HB_TR_DEBUG, ( "_get_default_sink IProvideClassInfo OK" ) ); iTI = NULL; hr = HB_VTBL( iPCI )->GetClassInfo( HB_THIS_( iPCI ) & iTI ); if( hr == S_OK ) { pTypeAttr = NULL; hr = HB_VTBL( iTI )->GetTypeAttr( HB_THIS_( iTI ) & pTypeAttr ); if( hr == S_OK ) { for( i = 0; i < pTypeAttr->cImplTypes; i++ ) { hr = HB_VTBL( iTI )->GetImplTypeFlags( HB_THIS_( iTI ) i, &iFlags ); if( hr == S_OK && ( iFlags & IMPLTYPEFLAG_FDEFAULT ) && ( iFlags & IMPLTYPEFLAG_FSOURCE ) ) { if( HB_VTBL( iTI )->GetRefTypeOfImplType( HB_THIS_( iTI ) i, &hRefType ) == S_OK && HB_VTBL( iTI )->GetRefTypeInfo( HB_THIS_( iTI ) hRefType, &iTISink ) == S_OK ) { HB_TRACE( HB_TR_DEBUG, ( "_get_default_sink Method 2: default source is found" ) ); hr = HB_VTBL( iTISink )->GetTypeAttr( HB_THIS_( iTISink ) & pTypeAttr ); if( hr == S_OK ) { *piid = pTypeAttr->guid; HB_VTBL( iTISink )->ReleaseTypeAttr( HB_THIS_( iTISink ) pTypeAttr ); HB_VTBL( iTI )->ReleaseTypeAttr( HB_THIS_( iTI ) pTypeAttr ); HB_VTBL( iPCI )->Release( HB_THIS( iPCI ) ); return S_OK; } } } } HB_VTBL( iTI )->ReleaseTypeAttr( HB_THIS_( iTI ) pTypeAttr ); } } HB_VTBL( iPCI )->Release( HB_THIS( iPCI ) ); } else HB_TRACE( HB_TR_DEBUG, ( "_get_default_sink IProvideClassInfo obtain error %08lX", hr ) ); } /* Method 3: using CoClass */ hr = HB_VTBL( iDisp )->GetTypeInfo( HB_THIS_( iDisp ) 0, LOCALE_SYSTEM_DEFAULT, &iTI ); if( hr == S_OK ) { ITypeLib * iTL = NULL; TYPEATTR * pTypeAttr2; hr = HB_VTBL( iTI )->GetContainingTypeLib( HB_THIS_( iTI ) & iTL, NULL ); HB_VTBL( iTI )->Release( HB_THIS( iTI ) ); if( hr == S_OK ) { int iCount = HB_VTBL( iTL )->GetTypeInfoCount( HB_THIS( iTL ) ); for( i = 0; i < iCount; i++ ) { hr = HB_VTBL( iTL )->GetTypeInfo( HB_THIS_( iTL ) i, &iTI ); if( hr == S_OK ) { hr = HB_VTBL( iTI )->GetTypeAttr( HB_THIS_( iTI ) & pTypeAttr ); if( hr == S_OK ) { if( pTypeAttr->typekind == TKIND_COCLASS ) { int j; for( j = 0; j < pTypeAttr->cImplTypes; j++ ) { if( szEvent ) { if( HB_VTBL( iTI )->GetRefTypeOfImplType( HB_THIS_( iTI ) j, &hRefType ) == S_OK && HB_VTBL( iTI )->GetRefTypeInfo( HB_THIS_( iTI ) hRefType, &iTISink ) == S_OK ) { BSTR bstr; hr = HB_VTBL( iTISink )->GetDocumentation( HB_THIS_( iTISink ) - 1, &bstr, NULL, NULL, NULL ); if( hr == S_OK ) { char str[ 256 ]; int iLen; iLen = WideCharToMultiByte( CP_ACP, 0, bstr, -1, str, sizeof( str ), NULL, NULL ); if( iLen > 0 ) { str[ iLen - 1 ] = '\0'; if( ! strcmp( szEvent, str ) ) { hr = HB_VTBL( iTISink )->GetTypeAttr( HB_THIS_( iTISink ) & pTypeAttr2 ); if( hr == S_OK ) { *piid = pTypeAttr2->guid; HB_VTBL( iTISink )->ReleaseTypeAttr( HB_THIS_( iTISink ) pTypeAttr2 ); HB_VTBL( iTISink )->Release( HB_THIS( iTISink ) ); HB_VTBL( iTI )->ReleaseTypeAttr( HB_THIS_( iTI ) pTypeAttr ); HB_VTBL( iTI )->Release( HB_THIS( iTI ) ); HB_VTBL( iTL )->Release( HB_THIS( iTL ) ); return S_OK; } } } } HB_VTBL( iTISink )->Release( HB_THIS( iTISink ) ); } } else /* szEvent == NULL */ { hr = HB_VTBL( iTI )->GetImplTypeFlags( HB_THIS_( iTI ) j, &iFlags ); if( hr == S_OK && ( iFlags & IMPLTYPEFLAG_FDEFAULT ) && ( iFlags & IMPLTYPEFLAG_FSOURCE ) ) { if( HB_VTBL( iTI )->GetRefTypeOfImplType( HB_THIS_( iTI ) j, &hRefType ) == S_OK && HB_VTBL( iTI )->GetRefTypeInfo( HB_THIS_( iTI ) hRefType, &iTISink ) == S_OK ) { hr = HB_VTBL( iTISink )->GetTypeAttr( HB_THIS_( iTISink ) & pTypeAttr2 ); if( hr == S_OK ) { #if 0 /* Debug code. You can also comment out iFlags condition, to list more interfaces [Mindaugas] */ BSTR bstr; char str[ 256 ]; int iLen; HB_VTBL( iTISink )->GetDocumentation( HB_THIS_( iTISink ) - 1, &bstr, NULL, NULL, NULL ); iLen = WideCharToMultiByte( CP_ACP, 0, bstr, -1, str, sizeof( str ), NULL, NULL ); str[ iLen - 1 ] = '\0'; HB_TRACE( HB_TR_DEBUG, ( "_get_default_sink Method 3: iFlags=%d guid=%s class=%s", iFlags, GUID2String( &( pTypeAttr2->guid ) ), str ) ); #endif *piid = pTypeAttr2->guid; HB_VTBL( iTISink )->ReleaseTypeAttr( HB_THIS_( iTISink ) pTypeAttr2 ); HB_VTBL( iTI )->ReleaseTypeAttr( HB_THIS_( iTI ) pTypeAttr ); HB_VTBL( iTI )->Release( HB_THIS( iTI ) ); HB_VTBL( iTL )->Release( HB_THIS( iTL ) ); return S_OK; } } } } } } HB_VTBL( iTI )->ReleaseTypeAttr( HB_THIS_( iTI ) pTypeAttr ); } HB_VTBL( iTI )->Release( HB_THIS( iTI ) ); } } HB_VTBL( iTL )->Release( HB_THIS( iTL ) ); } } return E_NOINTERFACE; }
//! Get the GUID of the camera [return string] std::string PS3::GetGUIDStr() const { return GUID2String( GetGUID() ); }