static void test_MFCreateMediaType(void) { HRESULT hr; IMFMediaType *mediatype; hr = MFStartup(MAKELONG( MF_API_VERSION, 0xdead ), MFSTARTUP_FULL); ok(hr == MF_E_BAD_STARTUP_VERSION, "got 0x%08x\n", hr); hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); ok(hr == S_OK, "got 0x%08x\n", hr); if(0) { /* Crash on Windows Vista/7 */ hr = MFCreateMediaType(NULL); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); } hr = MFCreateMediaType(&mediatype); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); IMFMediaType_Release(mediatype); MFShutdown(); }
int CountCaptureDevices() { HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(hr)) return 0; hr = MFStartup(MF_VERSION); if (FAILED(hr)) return 0; // choose device IMFAttributes *attributes = NULL; hr = MFCreateAttributes(&attributes, 1); ScopedRelease<IMFAttributes> attributes_s(attributes); if (FAILED(hr)) return 0; hr = attributes->SetGUID( MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID ); if (FAILED(hr)) return 0; ChooseDeviceParam param = { 0 }; hr = MFEnumDeviceSources(attributes, ¶m.mDevices, ¶m.mCount); if (FAILED(hr)) return 0; return param.mCount; }
static int MediaFoundation_init(void) { HRESULT hr = S_OK; /* Initialize the COM library. */ hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if(FAILED(hr)) { // std::cerr << "SSMF: failed to initialize COM" << std::endl; SNDERR("WindowsMediaFoundation: Failed to initialize COM"); return 0; } // hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); hr = MFStartup(MF_VERSION, MFSTARTUP_NOSOCKET); if(S_OK == hr) { return 1; } else { SNDERR("WindowsMediaFoundation: MFStartup failed"); return 0; } } /* MediaFoundation_init */
void MFPlayer::init(HWND handle) { HRESULT ret; // Initialize M$ bullshit //ret = CoInitializeEx(NULL, COINIT_MULTITHREADED); //assert(ret == S_OK); ret = MFStartup(MF_VERSION); assert(ret == S_OK); // Create factory IMFMediaEngineClassFactory *pMediaEngineClassFactory = nullptr; ret = CoCreateInstance(CLSID_MFMediaEngineClassFactory, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pMediaEngineClassFactory)); assert(ret == S_OK); // Create notify m_pPlayerNodify = new MFPlayerNotify(shared_from_this()); // Create attributes IMFAttributes *pAttributes = nullptr; ret = MFCreateAttributes(&pAttributes, 1); assert(ret == S_OK); ret = pAttributes->SetUnknown(MF_MEDIA_ENGINE_CALLBACK, m_pPlayerNodify); assert(ret == S_OK); ret = pAttributes->SetUINT64(MF_MEDIA_ENGINE_PLAYBACK_HWND, reinterpret_cast<UINT64>(handle)); assert(ret == S_OK); // Create player ret = pMediaEngineClassFactory->CreateInstance(0, pAttributes, &m_pMediaEngine); assert(ret == S_OK); // Release bullshits pAttributes->Release(); pMediaEngineClassFactory->Release(); }
/** IModuleInterface implementation */ virtual void StartupModule() override { bool bLoadSuccessful = true; // now attempt to load the delay loaded DLLs if (LoadLibraryW(TEXT("shlwapi.dll")) == NULL) { UE_LOG(LogWindowsMoviePlayer, Warning, TEXT("Could not load shlwapi.dll") ); bLoadSuccessful = false; } if (LoadLibraryW(TEXT("mf.dll")) == NULL) { UE_LOG(LogWindowsMoviePlayer, Warning, TEXT("Could not load mf.dll")); bLoadSuccessful = false; } if (LoadLibraryW(TEXT("mfplat.dll")) == NULL) { UE_LOG(LogWindowsMoviePlayer, Warning, TEXT("Could not load mfplat.dll")); bLoadSuccessful = false; } if (LoadLibraryW(TEXT("mfplay.dll")) == NULL) { UE_LOG(LogWindowsMoviePlayer, Warning, TEXT("Could not load mfplay.dll")); bLoadSuccessful = false; } if( bLoadSuccessful ) { HRESULT Hr = MFStartup(MF_VERSION); check(SUCCEEDED(Hr)); MovieStreamer = MakeShareable(new FMediaFoundationMovieStreamer); GetMoviePlayer()->RegisterMovieStreamer(MovieStreamer); } }
/** IModuleInterface implementation */ virtual void StartupModule() override { bool bLoadSuccessful = true; // now attempt to load the delay loaded DLLs if (!LoadMediaLibrary(TEXT("shlwapi.dll"))) { bLoadSuccessful = false; } if (!LoadMediaLibrary(TEXT("mf.dll"))) { bLoadSuccessful = false; } if (!LoadMediaLibrary(TEXT("mfplat.dll"))) { bLoadSuccessful = false; } if (!LoadMediaLibrary(TEXT("mfplay.dll"))) { bLoadSuccessful = false; } if( bLoadSuccessful ) { HRESULT Hr = MFStartup(MF_VERSION); check(SUCCEEDED(Hr)); MovieStreamer = MakeShareable(new FMediaFoundationMovieStreamer); GetMoviePlayer()->RegisterMovieStreamer(MovieStreamer); } }
void Player_::initialize(const ev::Init& ev) { // Start up Media Foundation platform. THROW_IF_ERR(MFStartup(MF_VERSION)); m_hCloseEvent = CreateEvent(NULL, FALSE, FALSE, NULL); THROW_IF_ERR(HRESULT_FROM_WIN32(GetLastError())); }
ofxWMFVideoPlayer::ofxWMFVideoPlayer() : _player(NULL) { if (_instanceCount == 0) { if (!ofIsGLProgrammableRenderer()) { if (wglewIsSupported("WGL_NV_DX_interop")) { ofLogVerbose("ofxWMFVideoPlayer") << "WGL_NV_DX_interop supported"; } else { ofLogError("ofxWMFVideoPlayer") << "WGL_NV_DX_interop not supported. Upgrade your graphc drivers and try again."; return; } } HRESULT hr = MFStartup(MF_VERSION); if (!SUCCEEDED(hr)) { ofLog(OF_LOG_ERROR, "ofxWMFVideoPlayer: Error while loading MF"); } } _id = _instanceCount; _instanceCount++; this->InitInstance(); _waitingForLoad = false; _waitForLoadedToPlay = false; _sharedTextureCreated = false; _wantToSetVolume = false; _currentVolume = 1.0; _frameRate = 0.0f; }
virtual void StartupModule() override { // load required libraries IMediaModule* MediaModule = FModuleManager::LoadModulePtr<IMediaModule>("Media"); if (MediaModule == nullptr) { UE_LOG(LogWmfMedia, Log, TEXT("Failed to load Media module")); return; } if (!LoadRequiredLibraries()) { UE_LOG(LogWmfMedia, Log, TEXT("Failed to load required Windows Media Foundation libraries")); return; } // initialize Windows Media Foundation HRESULT Result = MFStartup(MF_VERSION); if (FAILED(Result)) { UE_LOG(LogWmfMedia, Log, TEXT("Failed to initialize Windows Media Foundation, Error %i"), Result); return; } // initialize supported media formats SupportedFileTypes.Add(TEXT("3g2"), LOCTEXT("Format3g2", "3G2 Multimedia Stream")); SupportedFileTypes.Add(TEXT("3gp"), LOCTEXT("Format3gp", "3GP Video Stream")); SupportedFileTypes.Add(TEXT("3gp2"), LOCTEXT("Format3gp2", "3GPP2 Multimedia File")); SupportedFileTypes.Add(TEXT("3gpp"), LOCTEXT("Format3gpp", "3GPP Multimedia File")); SupportedFileTypes.Add(TEXT("aac"), LOCTEXT("FormatAac", "MPEG-2 Advanced Audio Coding File")); SupportedFileTypes.Add(TEXT("adts"), LOCTEXT("FormatAdts", "Audio Data Transport Stream")); SupportedFileTypes.Add(TEXT("asf"), LOCTEXT("FormatAsf", "ASF Media File")); SupportedFileTypes.Add(TEXT("avi"), LOCTEXT("FormatAvi", "Audio Video Interleave File")); SupportedFileTypes.Add(TEXT("m4v"), LOCTEXT("FormatM4v", "Apple MPEG-4 Video")); SupportedFileTypes.Add(TEXT("mov"), LOCTEXT("FormatMov", "Apple QuickTime Movie")); SupportedFileTypes.Add(TEXT("mp4"), LOCTEXT("FormatMp4", "MPEG-4 Movie")); SupportedFileTypes.Add(TEXT("sami"), LOCTEXT("FormatSami", "Synchronized Accessible Media Interchange (SAMI) File")); SupportedFileTypes.Add(TEXT("smi"), LOCTEXT("FormatSmi", "Synchronized Multimedia Integration (SMIL) File")); SupportedFileTypes.Add(TEXT("wmv"), LOCTEXT("FormatWmv", "Windows Media Video")); // initialize supported URI schemes SupportedUriSchemes.Add(TEXT("http://")); SupportedUriSchemes.Add(TEXT("httpd://")); SupportedUriSchemes.Add(TEXT("https://")); SupportedUriSchemes.Add(TEXT("mms://")); SupportedUriSchemes.Add(TEXT("rtsp://")); SupportedUriSchemes.Add(TEXT("rtspt://")); SupportedUriSchemes.Add(TEXT("rtspu://")); // register factory MediaModule->RegisterPlayerFactory(*this); Initialized = true; }
void GetCaptureDeviceName(int aDevice, char * aNamebuffer, int aBufferlength) { int i; if (!aNamebuffer || aBufferlength <= 0) return; aNamebuffer[0] = 0; HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(hr)) return; hr = MFStartup(MF_VERSION); if (FAILED(hr)) return; // choose device IMFAttributes *attributes = NULL; hr = MFCreateAttributes(&attributes, 1); ScopedRelease<IMFAttributes> attributes_s(attributes); if (FAILED(hr)) return; hr = attributes->SetGUID( MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID ); if (FAILED(hr)) return; ChooseDeviceParam param = { 0 }; hr = MFEnumDeviceSources(attributes, ¶m.mDevices, ¶m.mCount); if (FAILED(hr)) return; if (aDevice < (signed)param.mCount) { WCHAR *name = 0; UINT32 namelen = 255; hr = param.mDevices[aDevice]->GetAllocatedString( MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &name, &namelen ); if (SUCCEEDED(hr) && name) { i = 0; while (i < aBufferlength - 1 && i < (signed)namelen && name[i] != 0) { aNamebuffer[i] = (char)name[i]; i++; } aNamebuffer[i] = 0; CoTaskMemFree(name); } } }
SoundSource::OpenResult SoundSourceMediaFoundation::tryOpen(const AudioSourceConfig& audioSrcCfg) { if (SUCCEEDED(m_hrCoInitialize)) { qWarning() << "Cannot reopen MediaFoundation file" << getUrlString(); return OpenResult::FAILED; } const QString fileName(getLocalFileName()); if (sDebug) { qDebug() << "open()" << fileName; } // Initialize the COM library. m_hrCoInitialize = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(m_hrCoInitialize)) { qWarning() << "SSMF: failed to initialize COM"; return OpenResult::FAILED; } // Initialize the Media Foundation platform. m_hrMFStartup = MFStartup(MF_VERSION); if (FAILED(m_hrCoInitialize)) { qWarning() << "SSMF: failed to initialize Media Foundation"; return OpenResult::FAILED; } // Create the source reader to read the input file. // Note: we cannot use QString::toStdWString since QT 4 is compiled with // '/Zc:wchar_t-' flag and QT 5 not const ushort* const fileNameUtf16 = fileName.utf16(); static_assert(sizeof(wchar_t) == sizeof(ushort), "QString::utf16(): wchar_t and ushort have different sizes"); HRESULT hr = MFCreateSourceReaderFromURL( reinterpret_cast<const wchar_t*>(fileNameUtf16), nullptr, &m_pReader); if (FAILED(hr)) { qWarning() << "SSMF: Error opening input file:" << fileName; return OpenResult::FAILED; } if (!configureAudioStream(audioSrcCfg)) { qWarning() << "SSMF: Error configuring audio stream."; return OpenResult::FAILED; } if (!readProperties()) { qWarning() << "SSMF::readProperties failed"; return OpenResult::FAILED; } //Seek to position 0, which forces us to skip over all the header frames. //This makes sure we're ready to just let the Analyzer rip and it'll //get the number of samples it expects (ie. no header frames). seekSampleFrame(0); return OpenResult::SUCCEEDED; }
extern "C" bool obs_module_load(void) { MFStartup(MF_VERSION, MFSTARTUP_FULL); RegisterMFAACEncoder(); RegisterMFH264Encoders(); return true; }
MediaFoundationCaptureLibrary::MediaFoundationCaptureLibrary(void) { HRESULT hr = MFStartup(MF_VERSION); if(!SUCCEEDED(hr)) { LOG_ERROR("MEDIA FOUNDATION: Unable to start up the media foundation framework."); } }
INT WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ LPWSTR /*lpCmdLine*/, _In_ INT nCmdShow) { bool bCoInit = false, bMFStartup = false; // Initialize the common controls const INITCOMMONCONTROLSEX icex = { sizeof(INITCOMMONCONTROLSEX), ICC_WIN95_CLASSES }; InitCommonControlsEx(&icex); // Note: The shell common File dialog requires apartment threading. HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(hr)) { goto done; } bCoInit = true; hr = MFStartup(MF_VERSION); if (FAILED(hr)) { goto done; } bMFStartup = true; HWND hwnd = CreateMainWindow(hInstance); if (hwnd == 0) { ShowError(NULL, L"CreateMainWindow failed.", hr); goto done; } ShowWindow(hwnd, nCmdShow); // Run the message loop. MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } done: if (FAILED(hr)) { ShowError(NULL, L"Failed to start application", hr); } if (bMFStartup) { MFShutdown(); } if (bCoInit) { CoUninitialize(); } return 0; }
int main(int argc, char** argv) { if_failed_return(CoInitializeEx(0, COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY), GetLastError()); if_failed_return_result(MFStartup(MF_VERSION)); if_failed_return_result(mf_enumerate_cameras(mf_get_media_types)); if_failed_return_result(MFShutdown()); if_failed_return_result(ds_enumerate_cameras(ds_get_media_types)); getchar(); CoUninitialize(); return 0; }
MfVideoEncoder::MfVideoEncoder(const std::wstring& filename) : mFilename(filename) { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); auto hr = MFStartup(MF_VERSION); if (!SUCCEEDED(hr)) { throw TempleException("Unable to initialize Media Foundation: {}", hr); } }
extern "C" bool obs_module_load(void) { CoInitializeEx(0, COINIT_MULTITHREADED); MFStartup(MF_VERSION, MFSTARTUP_FULL); RegisterMFAACEncoder(); RegisterMFH264Encoders(); return true; }
void MFPlayer::init(const OTextureRef& pRenderTarget) { m_pRenderTarget = pRenderTarget; auto pRendererD3D11 = std::dynamic_pointer_cast<ORendererD3D11>(oRenderer); HRESULT ret; // Initialize M$ bullshit //ret = CoInitializeEx(NULL, COINIT_MULTITHREADED); //assert(ret == S_OK); ret = MFStartup(MF_VERSION); assert(ret == S_OK); // Create factory IMFMediaEngineClassFactory *pMediaEngineClassFactory = nullptr; ret = CoCreateInstance(CLSID_MFMediaEngineClassFactory, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pMediaEngineClassFactory)); assert(ret == S_OK); // Create notify m_pPlayerNodify = new MFPlayerNotify(shared_from_this()); // Create attributes IMFAttributes *pAttributes = nullptr; ret = MFCreateAttributes(&pAttributes, 1); assert(ret == S_OK); ret = pAttributes->SetUnknown(MF_MEDIA_ENGINE_CALLBACK, m_pPlayerNodify); assert(ret == S_OK); ID3D10Multithread *pMultithread = nullptr; ID3D11Device *pDevice = pRendererD3D11->getDevice(); ret = pDevice->QueryInterface(IID_PPV_ARGS(&pMultithread)); assert(ret == S_OK); pMultithread->SetMultithreadProtected(TRUE); pMultithread->Release(); UINT resetToken = 0; ret = MFCreateDXGIDeviceManager(&resetToken, &m_pDXGIManager); assert(ret == S_OK); ret = m_pDXGIManager->ResetDevice(pRendererD3D11->getDevice(), resetToken); assert(ret == S_OK); ret = pAttributes->SetUnknown(MF_MEDIA_ENGINE_DXGI_MANAGER, m_pDXGIManager); assert(ret == S_OK); ret = pAttributes->SetUINT32(MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, DXGI_FORMAT_R8G8B8A8_UNORM); assert(ret == S_OK); // Create player ret = pMediaEngineClassFactory->CreateInstance(MF_MEDIA_ENGINE_WAITFORSTABLE_STATE, pAttributes, &m_pMediaEngine); assert(ret == S_OK); // Release bullshits pAttributes->Release(); pMediaEngineClassFactory->Release(); }
HRESULT VideoEncoder::Initialize() { HRESULT hr = S_OK; this->m_logFileStream = ofstream(this->m_logFile); if (this->m_inputFile == L"") { this->m_logFileStream << "输入短影配置文件无效." << endl; return ERROR_FILE_INVALID; } // 初始化 COM. hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); // COM 未被调用代码初始化. 因此我们初始化它. if (SUCCEEDED(hr)) { this->m_logFileStream << "COM初始化成功." << endl; this->m_COMInitializedInDll = true; } // COM被调用代码初始化. else if (hr == RPC_E_CHANGED_MODE || hr == S_FALSE) { this->m_COMInitializedInDll = false; } // COM初始化失败. else { return hr; } // 创建WIC 工厂 CheckHR(CoCreateInstance( CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&this->m_pIWICFactory) )); // 启动Media Foundation. CheckHR(MFStartup(MF_VERSION)); cleanup: if (!SUCCEEDED(hr)) { DWORD error = GetLastError(); this->m_logFileStream << "意外错误: " << error << endl; } return hr; }
VideoCapture::VideoCapture() { MFStartup(MF_VERSION); this->Config = NULL; this->Devices = NULL; this->Source = NULL; this->DeviceCount = 0; this->SourceReader = NULL; this->CallBack = NULL; this->InputMediaType = NULL; }
Result SoundSourceMediaFoundation::tryOpen(const Mixxx::AudioSourceConfig& audioSrcCfg) { if (SUCCEEDED(m_hrCoInitialize)) { qWarning() << "Cannot reopen MediaFoundation file" << getUrlString(); return ERR; } const QString fileName(getLocalFileName()); if (sDebug) { qDebug() << "open()" << fileName; } // Initialize the COM library. m_hrCoInitialize = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(m_hrCoInitialize)) { qWarning() << "SSMF: failed to initialize COM"; return ERR; } // Initialize the Media Foundation platform. m_hrMFStartup = MFStartup(MF_VERSION); if (FAILED(m_hrCoInitialize)) { qWarning() << "SSMF: failed to initialize Media Foundation"; return ERR; } QString qurlStr(fileName); // http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/35c6a451-3507-40c8-9d1c-8d4edde7c0cc // gives maximum path + file length as 248 + 260, using that -bkgood m_wcFilename = new wchar_t[248 + 260]; int wcFilenameLength(fileName.toWCharArray(m_wcFilename)); // toWCharArray does not append a null terminator to the string! m_wcFilename[wcFilenameLength] = '\0'; // Create the source reader to read the input file. HRESULT hr = MFCreateSourceReaderFromURL(m_wcFilename, NULL, &m_pReader); if (FAILED(hr)) { qWarning() << "SSMF: Error opening input file:" << fileName; return ERR; } if (!configureAudioStream(audioSrcCfg)) { qWarning() << "SSMF: Error configuring audio stream."; return ERR; } //Seek to position 0, which forces us to skip over all the header frames. //This makes sure we're ready to just let the Analyser rip and it'll //get the number of samples it expects (ie. no header frames). seekSampleFrame(0); return OK; }
int SoundSourceMediaFoundation::open() { if (sDebug) { qDebug() << "open()" << m_qFilename; } QString qurlStr(m_qFilename); int wcFilenameLength(m_qFilename.toWCharArray(m_wcFilename)); // toWCharArray does not append a null terminator to the string! m_wcFilename[wcFilenameLength] = '\0'; HRESULT hr(S_OK); // Initialize the COM library. hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(hr)) { qWarning() << "SSMF: failed to initialize COM"; return ERR; } // Initialize the Media Foundation platform. hr = MFStartup(MF_VERSION); if (FAILED(hr)) { qWarning() << "SSMF: failed to initialize Media Foundation"; return ERR; } // Create the source reader to read the input file. hr = MFCreateSourceReaderFromURL(m_wcFilename, NULL, &m_pReader); if (FAILED(hr)) { qWarning() << "SSMF: Error opening input file:" << m_qFilename; return ERR; } if (!configureAudioStream()) { qWarning() << "SSMF: Error configuring audio stream."; return ERR; } if (!readProperties()) { qWarning() << "SSMF::readProperties failed"; return ERR; } //Seek to position 0, which forces us to skip over all the header frames. //This makes sure we're ready to just let the Analyser rip and it'll //get the number of samples it expects (ie. no header frames). seek(0); return OK; }
MFPlayerService::MFPlayerService(QObject *parent) : QMediaService(parent) , m_session(0) #ifndef Q_WS_SIMULATOR , m_videoWindowControl(0) #endif , m_videoRendererControl(0) { CoInitialize(NULL); MFStartup(MF_VERSION); m_session = new MFPlayerSession(this); m_player = new MFPlayerControl(m_session); m_audioEndpointControl = new MFAudioEndpointControl(this); m_metaDataControl = new MFMetaDataControl(this); }
MfVideoOut::MfVideoOut(const char *devName) : Base_Video_Out() { HRESULT hr = MFStartup(MF_VERSION); if(!SUCCEEDED(hr)) throw std::runtime_error("Media foundation startup failed"); hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if(hr == RPC_E_CHANGED_MODE) throw std::runtime_error("CoInitializeEx failed"); }
CASFManager::CASFManager(HRESULT* hr) : m_nRefCount(1), m_CurrentStreamID (0), m_guidCurrentMediaType (GUID_NULL), m_fileinfo(NULL), m_pDecoder (NULL), m_pContentInfo (NULL), m_pIndexer (NULL), m_pSplitter (NULL), m_pDataBuffer (NULL), m_pByteStream(NULL), m_cbDataOffset(0), m_cbDataLength(0) { //Initialize Media Foundation *hr = MFStartup(MF_VERSION); }
//---------------------------------------------------------------------------- tTVPMFPlayer::tTVPMFPlayer() { CoInitialize(NULL); MFStartup( MF_VERSION ); BuildWindow = NULL; OwnerWindow = NULL; CallbackWindow = NULL; Visible = false; Rect.left = 0; Rect.top = 0; Rect.right = 320; Rect.bottom = 240; RefCount = 1; Shutdown = false; PlayerCallback = new tTVPPlayerCallback(this); PlayerCallback->AddRef(); FPSNumerator = 1; FPSDenominator = 1; //Stream = NULL; HnsDuration = 0; //StartPositionSpecify = false; }
EXTERN_C DLLEXPORT int WolframLibrary_initialize(WolframLibraryData libData) { // Initialize the COM library hr = CoInitialize(NULL); if (FAILED(hr)) { libData->Message("cominitfail"); return LIBRARY_FUNCTION_ERROR; } // Initialize Media Foundation. hr = MFStartup(MF_VERSION); if (FAILED(hr)) { libData->Message("mfinitfail"); return LIBRARY_FUNCTION_ERROR; } return LIBRARY_NO_ERROR; }
int mf_coinit() { HRESULT hr = S_OK; hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); if (hr != RPC_S_OK) { ReportError(L"Failed to initialize COM", hr); return -1; } // lite startup is faster and all what we need is included hr = MFStartup(MF_VERSION, MFSTARTUP_LITE); if (hr != S_OK) { // Do you know you can't initialize MF in test mode or safe mode? ReportError(L"Failed to initialize Media Foundation", hr); return -1; } return 0; }
int main() { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); MFStartup(MF_VERSION); TaskScheduler* scheduler = BasicTaskScheduler::createNew(); UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler); in_addr dstAddr = { 127, 0, 0, 1 }; Groupsock rtpGroupsock(*env, dstAddr, 1233, 255); rtpGroupsock.addDestination(dstAddr, 1234, 0); RTPSink * rtpSink = H264VideoRTPSink::createNew(*env, &rtpGroupsock, 96); MediaFoundationH264LiveSource * mediaFoundationH264Source = MediaFoundationH264LiveSource::createNew(*env); rtpSink->startPlaying(*mediaFoundationH264Source, NULL, NULL); // This function call does not return. env->taskScheduler().doEventLoop(); return 0; }
HRESULT CPlayer::Initialize() { HRESULT hr = S_OK; if (m_hCloseEvent) { return MF_E_ALREADY_INITIALIZED; } // Start up Media Foundation platform. CHECK_HR(hr = MFStartup(MF_VERSION)); m_hCloseEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if (m_hCloseEvent == NULL) { CHECK_HR(hr = HRESULT_FROM_WIN32(GetLastError())); } done: return hr; }