From Jason Beverage, "Here is a small change to the DirectShow plugin to support finding the
video and sound pins by type rather than searching for them by name since the names of the pins can change based on what kind of file you are opening. This also removes the need for an explicit check to see if the file is a .wmv file. Also changes to the directshow plugin's CMakeLists.txt. It is not necessary to link against d3dx9 to build the plugin. "
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user