本文整理汇总了C++中IGraphBuilder::RenderFile方法的典型用法代码示例。如果您正苦于以下问题:C++ IGraphBuilder::RenderFile方法的具体用法?C++ IGraphBuilder::RenderFile怎么用?C++ IGraphBuilder::RenderFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphBuilder
的用法示例。
在下文中一共展示了IGraphBuilder::RenderFile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main()
{
int option;
IGraphBuilder *pGraph = NULL; //Creem l'apuntador al graf de filtres
IMediaControl *pControl = NULL; //creem l'apuntador a un controlador per ayurar i iniciar el graf
IMediaEvent *pEvent = NULL; // apunta a l'objecte necessari per obtenir events del filter graph manager
//IBaseFilter *pGrabberF = NULL;
//ISampleGrabber *pGrabber = NULL;
HRESULT hr = CoInitialize(NULL); // Inicialitzem la llibreria COM
if ( FAILED(hr) ){
printf("ERROR - Could not initialize COM library");
return;
}
// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return;
}
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
// Build the graph. IMPORTANT: Change this string to a file on your system.
cout<<"introduce 1:chicken 2:futbol 3: video futbol audio chicken: \n";
cin>>option;
switch(option)
{
case 1: hr = pGraph->RenderFile(L"C:\\Users\\Victor\\Downloads\\chicken.wmv", NULL);
break;
case 2: hr = pGraph->RenderFile(L"C:\\Users\\Victor\\Downloads\\futbol.mpg", NULL);
break;
case 3: // Create the Sample Grabber filter.
break;
}
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
// Note: Do not use INFINITE in a real application, because it
// can block indefinitely.
}
}
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
}
示例2: play_movie
void play_movie( HWND hwnd )
{
IGraphBuilder *pGraph;
IMediaControl *pMediaControl;
IMediaEvent *pEvent;
IBasicVideo *pBasic;
IVideoWindow *pVidWin = NULL;
RECT grc;
long width, height;
CoInitialize(NULL);
// Create the filter graph manager and query for interfaces.
CoCreateInstance(
CLSID_FilterGraph,
NULL,
CLSCTX_INPROC_SERVER,
IID_IGraphBuilder,
(void **)&pGraph);
pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin);
pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
pGraph->QueryInterface(IID_IBasicVideo, (void**)&pBasic );
// Build the graph. IMPORTANT: Change string to a file on your system.
pGraph->RenderFile(L"e:\\alpha\\running.avi", NULL);
pBasic->GetVideoSize( &width, &height );
printf( "video frames are %d x %d\n", width, height );
pVidWin->put_Owner((OAHWND)hwnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
GetClientRect( hwnd, &grc );
pVidWin->SetWindowPosition(10, 10, width, height);
printf( "window is %d x %d\n", grc.right, grc.bottom );
// Run the graph.
pMediaControl->Run();
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
pVidWin->put_Visible(OAFALSE);
pVidWin->put_Owner(NULL);
// Clean up.
pBasic->Release();
pVidWin->Release();
pMediaControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
}
示例3: PlayMovie
void Video::PlayMovie(string path)
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
IVideoWindow *pVideo = NULL;
// Initialize the COM library.
CoInitialize(NULL);
// Create the filter graph manager and query for interfaces.
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
// Build the graph
int len;
int slength = (int)path.length() + 1;
len = MultiByteToWideChar(CP_ACP, 0, path.c_str(), slength, 0, 0);
wchar_t* buf = new wchar_t[len];
MultiByteToWideChar(CP_ACP, 0, path.c_str(), slength, buf, len);
std::wstring r(buf);
delete[] buf;
pGraph->RenderFile(LPCWSTR(r.c_str()), NULL);
// set the owner window
pGraph->QueryInterface(IID_IVideoWindow, (void **) &pVideo);
pVideo->put_Owner((OAHWND)window);
pVideo->put_WindowStyle( WS_CHILD );
pVideo->put_Left(0);
pVideo->put_Top(0);
pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
pControl->Run();
long evCode;
pEvent->WaitForCompletion(-1, &evCode);
// release controls
pControl->Release();
pEvent->Release();
pGraph->Release();
pVideo->Release();
CoUninitialize();
}
示例4: texture
video::video(std::wstring path): texture(1,1,false,GL_LINEAR,GL_REPEAT), rendered(false), isPlaying(false) {
printf("Opening video \"%ls\"\n", path.c_str());
IGraphBuilder * graph;
IBaseFilter * base;
__int64 clipLength;
CoInitialize(0);
CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC, IID_IGraphBuilder, (void**)&graph);
HRESULT hr = S_OK;
graph->QueryInterface(IID_IMediaControl, (void**)&mediaControl);
graph->QueryInterface(IID_IMediaSeeking, (void**)&mediaSeeking);
grabber = new textureGrabber(0, &hr);
grabber->AddRef();
grabber->QueryInterface(IID_IBaseFilter, (void**)&base);
graph->AddFilter(base, L"peisikVideoSystem OpenGL texture renderer");
hr = graph->RenderFile(path.c_str(), 0);
grabber->setTexture(&texture);
graph->Release();
base->Release();
if(SUCCEEDED(hr) && grabber->width)
{
printf("Video succesfully rendered\n");
mediaSeeking->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME);
mediaSeeking->GetDuration(&clipLength);
length = (long double)(clipLength)/(long double)10000000.0;
__int64 position = 0;
mediaSeeking->SetPositions(&position, AM_SEEKING_AbsolutePositioning, &position, AM_SEEKING_NoPositioning);
rendered = true;
}
else
printf("Couldn't find a working video graph\n");
}
示例5: Hog
bool CHogVideo::Hog()
{
if (!m_pGraph && !m_pMediaControl && !m_pVideoWindow)
return false;
this->UnHog();
HRESULT hr = NULL;
IGraphBuilder *pGraph = (IGraphBuilder*) m_pGraph;
IMediaControl *pMediaControl = (IMediaControl*) m_pMediaControl;
IVideoWindow *pVideoWindow = (IVideoWindow*) m_pVideoWindow;
// Build the graph. IMPORTANT: Change string to a file on your system.
hr = pGraph->RenderFile(m_wszFilename, NULL);
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pMediaControl->Run();
// Hide the window
pVideoWindow->put_WindowState(SW_HIDE);
pVideoWindow->put_AutoShow(OAFALSE);
pVideoWindow->put_Visible(OAFALSE);
pVideoWindow->put_Top(-100);
pVideoWindow->put_Left(-100);
pVideoWindow->put_Width(0);
pVideoWindow->put_Height(0);
if (SUCCEEDED(hr))
{
// Hog the resource.
pMediaControl->Pause();
return true;
}
else
return false;
}
else
return false;
}
示例6: video_add
int video_add(string fname) {
enigma::VideoStruct* videoStruct = new enigma::VideoStruct();
IGraphBuilder *pGraph = NULL;
// Initialize the COM library.
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
MessageBox(NULL, "Failed to initialize COM library.", "ERROR", MB_ICONERROR | MB_OK);
return -1;
}
// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
MessageBox(NULL, "Failed to create the Filter Graph Manager.", "ERROR", MB_ICONERROR | MB_OK);
return -1;
}
// Build the graph.
hr = pGraph->RenderFile(std::wstring(fname.begin(), fname.end()).c_str(), NULL);
IVideoWindow *pVidWin = NULL;
pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin);
pVidWin->put_Owner((OAHWND)enigma::hWnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
videoStruct->pGraph = pGraph;
enigma::videoStructs.push_back(videoStruct);
return enigma::videoStructs.size() - 1;
}
示例7: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
//Get some param--------------
HRESULT hr1;
IBasicVideo *pVideo=NULL;
IBasicAudio *pAudio=NULL;
IVideoWindow *pWindow=NULL;
IMediaSeeking *pSeeking=NULL;
// Init COM
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr)){
printf("Error - Can't init COM.");
return -1;
}
// Create FilterGraph
hr=CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER,IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr)){
printf("Error - Can't create Filter Graph.");
return -1;
}
// Query Interface
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
// RenderFile
hr = pGraph->RenderFile(L"cuc_ieschool.mov", NULL);
if (FAILED(hr)){
printf("Error - Can't Render File.");
return -1;
}
#if OUTPUT_INFO
//Get some information----------
long video_w=0,video_h=0,video_bitrate=0,audio_volume=0;
long long duration_1=0,position_1=0;
REFTIME avgtimeperframe=0;
float framerate=0,duration_sec=0,progress=0,position_sec=0;
//Video
hr1=pGraph->QueryInterface(IID_IBasicVideo, (void **)&pVideo);
pVideo->get_VideoWidth(&video_w);
pVideo->get_VideoHeight(&video_h);
pVideo->get_AvgTimePerFrame(&avgtimeperframe);
framerate=1/avgtimeperframe;
//pVideo->get_BitRate(&video_bitrate);
//Audio
hr1=pGraph->QueryInterface(IID_IBasicAudio, (void **)&pAudio);
//Mute
//pAudio->put_Volume(-10000);
printf("Some Information:\n");
printf("Video Resolution:\t%dx%d\n",video_w,video_h);
printf("Video Framerate:\t%.3f\n",framerate);
//Window
hr1=pGraph->QueryInterface(IID_IVideoWindow, (void **)&pWindow);
pWindow->put_Caption(L"Simplest DirectShow Player");
//pWindow->put_Width(480);
//pWindow->put_Height(272);
//Seek
hr1=pGraph->QueryInterface(IID_IMediaSeeking, (void **)&pSeeking);
pSeeking->GetDuration(&duration_1);
//time unit:100ns=0.0000001s
duration_sec=(float)duration_1/10000000.0;
printf("Duration:\t%.2f s\n",duration_sec);
//pSeeking->SetPositions();
//PlayBack Rate
//pSeeking->SetRate(2.0);
//Show Filter in FilterGpagh
show_filters_in_filtergraph(pGraph);
//----------------------
#endif
printf("Progress Info\n");
printf("Position\tProgress\n");
if (SUCCEEDED(hr)){
// Run
hr = pControl->Run();
if (SUCCEEDED(hr)){
long evCode=0;
//pEvent->WaitForCompletion(INFINITE, &evCode);
while(evCode!=EC_COMPLETE){
//Info
#if OUTPUT_INFO
pSeeking->GetCurrentPosition(&position_1);
position_sec=(float)position_1/10000000.0;
progress=position_sec*100/duration_sec;
printf("%7.2fs\t%5.2f%%\n",position_sec,progress);
#endif
//1000ms
pEvent->WaitForCompletion(1000, &evCode);
}
}
}
// Release resource
pControl->Release();
pEvent->Release();
pGraph->Release();
//.........这里部分代码省略.........
示例8: player
int JukeboxDS::player()
{
if( FAILED(CoInitialize(NULL)) )
return -1;
IGraphBuilder * pGB = NULL;
IMediaControl * pMC = NULL;
IBasicAudio * pBA = NULL;
IMediaEvent * pME = NULL;
while( m_Active )
{
// check the state of the music, if stopped move onto the next file
if ( pME != NULL )
{
long eventCode;
if ( pME->WaitForCompletion( 0, &eventCode ) == S_OK )
nextTrack(); // current song has ended, next track
}
// check for a volume change
if ( m_UpdateVolume.signaled() )
{
m_UpdateVolume.clear();
if ( pBA != NULL )
{
// set the volume
long pv = (100 - m_Volume) * -100;
pBA->put_Volume( pv );
}
}
if (! m_TrackEvent.wait( 250 ) )
{
AutoLock lock( &m_Lock );
if ( m_PlayLists.isValid( m_ActiveList ) && m_PlayLists[ m_ActiveList ].files.isValid( m_CurrentTrack ) )
{
// get the filename of the current track
CharString file = m_PlayLists[ m_ActiveList ].files[ m_CurrentTrack ];
// release the previous interfaces
RELEASEQI( pGB );
RELEASEQI( pMC );
RELEASEQI( pBA );
RELEASEQI( pME );
// Create DirectShow Graph
if ( FAILED( CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&pGB) ) )
return -1;
try {
// load the first file
if ( FAILED( pGB->RenderFile( String( file ), NULL ) ) )
return -1;
}
catch( ... )
{
// driver failure, don't crash the game due to a bad codec..
return -1;
}
// Get the IMediaControl Interface
if ( FAILED( pGB->QueryInterface(IID_IMediaControl, (void **)&pMC ) ) )
return -1;
// Get the IBasicAudio interface
if ( FAILED( pGB->QueryInterface(IID_IBasicAudio, (void **)&pBA) ) )
return -1;
// Get the IBasicAudio interface
if ( FAILED( pGB->QueryInterface(IID_IMediaEvent, (void **)&pME) ) )
return -1;
// set the volume
long pv = (100 - m_Volume) * -100;
pBA->put_Volume( pv );
// play the music
pMC->Run();
}
}
}
RELEASEQI( pGB );
RELEASEQI( pMC );
RELEASEQI( pBA );
RELEASEQI( pME );
CoUninitialize();
return 0;
}
示例9: SplashThread
int SplashThread(void *arg)
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
if (options.playsnd)
{
// Initialize the COM library.
CoInitialize(NULL);
// Create the filter graph manager and query for interfaces.
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
// Get MediaControl Interface
pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
// Build the graph. IMPORTANT: Change this string to a file on your system.
pGraph->RenderFile(szSoundFile, NULL);
// Run the graph.
pControl->Run();
}
WNDCLASSEX wcl;
wcl.cbSize = sizeof(wcl);
wcl.lpfnWndProc = SplashWindowProc;
wcl.style = 0;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hInstance = hInst;
wcl.hIcon = NULL;
wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszMenuName = NULL;
wcl.lpszClassName = _T(SPLASH_CLASS);
wcl.hIconSm = NULL;
RegisterClassEx(&wcl);
RECT DesktopRect;
int w = GetSystemMetrics(SM_CXSCREEN);
int h = GetSystemMetrics(SM_CYSCREEN);
DesktopRect.left = 0;
DesktopRect.top = 0;
DesktopRect.right = w;
DesktopRect.bottom = h;
RECT WindowRect;
WindowRect.left = (DesktopRect.left + DesktopRect.right - SplashBmp->getWidth()) / 2;
WindowRect.top = (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2;
WindowRect.right = WindowRect.left + SplashBmp->getWidth();
WindowRect.bottom = WindowRect.top + SplashBmp->getHeight();
hwndSplash = CreateWindowEx(
WS_EX_TOOLWINDOW | WS_EX_TOPMOST,//dwStyleEx
_T(SPLASH_CLASS), //Class name
NULL, //Title
DS_SETFONT | DS_FIXEDSYS | WS_POPUP, //dwStyle
WindowRect.left, // x
WindowRect.top, // y
SplashBmp->getWidth(), // Width
SplashBmp->getHeight(), // Height
HWND_DESKTOP, //Parent
NULL, //menu handle
hInst, //Instance
NULL);
RECT rc; GetWindowRect(hwndSplash, &rc);
POINT ptDst = {rc.left, rc.top};
POINT ptSrc = {0, 0};
SIZE sz = {rc.right - rc.left, rc.bottom - rc.top};
bool splashWithMarkers = false;
BLENDFUNCTION blend;
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.SourceConstantAlpha = 0;
blend.AlphaFormat = AC_SRC_ALPHA;
if (options.showversion)
{
// locate text markers:
int i, x = -1, y = -1;
int splashWidth = SplashBmp->getWidth();
for (i = 0; i < splashWidth; ++i)
if (SplashBmp->getRow(0)[i] & 0xFF000000)
{
if (x < 0)
{
x = i-1; // 1 pixel for marker line
splashWithMarkers = true;
} else
{
x = -1;
splashWithMarkers = false;
break;
}
}
int splashHeight = SplashBmp->getHeight();
for (i = 0; splashWithMarkers && (i < splashHeight); ++i)
//.........这里部分代码省略.........
示例10: Load
bool CPlaylist::Load()
{
IGraphBuilder * pGraph = NULL;
IAMPlayList * pPlaylist = NULL;
HRESULT hr;
bool bResult;
if (NULL != m_pList || true == m_bTransient)
{
return true;
}
//
// Make sure that this is one of our playlist read the last played element
//
bResult = LoadParam();
hr = CoCreateInstance(CLSID_FilterGraph,
NULL,
CLSCTX_INPROC_SERVER,
IID_IGraphBuilder,
(void**) &pGraph);
if (SUCCEEDED(hr))
{
hr = pGraph->RenderFile(m_pszPath, NULL);
}
if (SUCCEEDED(hr))
{
IEnumFilters * pEnum = NULL;
IBaseFilter * pFilter = NULL;
hr = pGraph->EnumFilters(&pEnum);
if (pEnum)
{
while (!pPlaylist && pEnum->Next(1, &pFilter, NULL) == S_OK)
{
hr = pFilter->QueryInterface(IID_IAMPlayList, (void**)&pPlaylist);
pFilter->Release();
}
if (!pPlaylist)
{
hr = E_NOINTERFACE;
}
pEnum->Release();
}
}
if (SUCCEEDED(hr))
{
DWORD dwCount;
IAMPlayListItem * pItem = NULL;
if(pPlaylist)
hr = pPlaylist->GetItemCount(&dwCount);
else
hr = E_FAIL;
if (SUCCEEDED(hr))
{
for (DWORD i = 0; i < dwCount; i++)
{
hr = pPlaylist->GetItem(i, &pItem);
if (SUCCEEDED(hr))
{
BSTR pszSource = NULL;
hr = pItem->GetSourceURL(0, &pszSource);
if (SUCCEEDED(hr))
{
InsertTrack(i, pszSource);
}
pItem->Release();
}
}
}
}
if (pPlaylist)
{
pPlaylist->Release();
}
if (pGraph)
{
pGraph->Release();
}
if (SUCCEEDED(hr))
{
return true;
}
else
//.........这里部分代码省略.........