diff --git a/src/osgPlugins/directshow/CMakeLists.txt b/src/osgPlugins/directshow/CMakeLists.txt index 184ad1d84..1097a60d8 100644 --- a/src/osgPlugins/directshow/CMakeLists.txt +++ b/src/osgPlugins/directshow/CMakeLists.txt @@ -48,7 +48,7 @@ INCLUDE_DIRECTORIES( ${DIRECTSHOW_INLUDE_DIRS} ) SET (TARGET_EXTERNAL_LIBRARIES - quartz comsuppw winmm d3d9 d3dx9 kernel32 user32 gdi32 winspool shell32 ole32 oleaut32 uuid comdlg32 advapi32 + quartz comsuppw winmm d3d9 kernel32 user32 gdi32 winspool shell32 ole32 oleaut32 uuid comdlg32 advapi32 ) SET(TARGET_SRC diff --git a/src/osgPlugins/directshow/DirectShowTexture.cpp b/src/osgPlugins/directshow/DirectShowTexture.cpp index 1866daea4..10d2cc003 100644 --- a/src/osgPlugins/directshow/DirectShowTexture.cpp +++ b/src/osgPlugins/directshow/DirectShowTexture.cpp @@ -1448,20 +1448,13 @@ bool CTextureRenderer::openFile(const std::string& file) std::string lowercase = file; std::transform(lowercase.begin(), lowercase.end(), lowercase.begin(), tolower); - if (lowercase.rfind(".wmv") != std::string::npos) - { - hr = _graphBuilder->AddSourceFilter(wFileName, L"Windows Media source filter", &_fileSource); - if (!checkError(prefixForMessage, hr)) - return false; - hr = _fileSource?_fileSource->FindPin(L"Raw Video 1", &videoOutputPin):0; - } - else - { - hr = _graphBuilder->AddSourceFilter(wFileName, L"File Source", &_fileSource); - if (!checkError(prefixForMessage, hr)) - return false; - hr = _fileSource?_fileSource->FindPin(L"Output", &videoOutputPin):0; - } + + hr = _graphBuilder->AddSourceFilter(wFileName, L"Source", &_fileSource); + if (!checkError(prefixForMessage, hr)) + return false; + + //Find the video pin + hr = _fileSource? ::GetPin(_fileSource, &MEDIATYPE_Video, PINDIR_OUTPUT, &videoOutputPin):0; if (!checkError(prefixForMessage, hr)) return false; @@ -1478,26 +1471,26 @@ bool CTextureRenderer::openFile(const std::string& file) if (!checkError(prefixForMessage, hr)) return false; - - if (lowercase.rfind(".avi") == std::string::npos) // not an avi, dont try to connect sounds - return true; - // check if we find the sounds output pin on the streams - IBaseFilter* AVISpliterFilter = 0; - hr = _graphBuilder->FindFilterByName(L"AVI Splitter", &AVISpliterFilter); + IBaseFilter* soundFilter; + hr = _graphBuilder->FindFilterByName(L"AVI Splitter", &soundFilter); if (FAILED(hr)) { - OSG_WARN << prefixForMessage << " did not find AVI SPlitter to connect sound, " << getErrorMessage(hr) << std::endl; + //Could not find the AVI Splitter filter, try the main source itself + soundFilter = _fileSource; } - if (AVISpliterFilter) + + if (soundFilter) { IPin* soundStreamPinOut = 0; - hr = AVISpliterFilter->FindPin(L"Stream 01",&soundStreamPinOut); - AVISpliterFilter->Release(); AVISpliterFilter = 0; + //Try to find the audio pin + hr = ::GetPin(soundFilter, &MEDIATYPE_Audio, PINDIR_OUTPUT, &soundStreamPinOut); + if (soundFilter != _fileSource) soundFilter->Release(); + soundFilter = 0; if (FAILED(hr)) { - OSG_WARN << prefixForMessage << " can't find Stream 01 pin on AVIS Splitter, maybe the flux does have sound, " << getErrorMessage(hr) << std::endl; + OSG_WARN << prefixForMessage << " can't find audio pin" << getErrorMessage(hr) << std::endl; } if (soundStreamPinOut)