Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,400 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,117 people online right now. Registration is fast and FREE... Join Now!




DirectX SDK9 / VC++6.0

 
Reply to this topicStart new topic

DirectX SDK9 / VC++6.0, Troubleshoot: ICaptureGraphBuilder2

cchan
29 Sep, 2006 - 01:57 PM
Post #1

New D.I.C Head
*

Joined: 29 Sep, 2006
Posts: 1


My Contributions
Hi Could someone help me out on this problem. I have been stuck on this for ages and couldnt find anything to solve it.

The following is my unfinished code I am using to capture video.

**************************************************
CODE
#include "stdio.h"
#include "dshow.h"
#include "strmif.h"

void main()
{
    
    //******INITIALIZE**********************************
    HRESULT hr = CoInitialize(NULL);
    if (FAILED(hr))
    {
        // Add error-handling code here. (Omitted for clarity.)
    }
    //**************************************************

    //************CREAT FILTER GRAPH MANAGER***********************
    IGraphBuilder *pGraph;
    hr = CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
    //**********************************************************
    
    //IMediaControl controls streaming.
    //It contains methods for stopping and starting the graph.
    IMediaControl *pControl;

    //IMediaEvent has methods for getting events from the Filter Graph Manager.
    //In this example, the interface is used to wait for playback to complete.
    IMediaEvent   *pEvent;

    hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
    hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
    
    //*****BUILD FILTER GRAPH**********************
    //hr = pGraph->RenderFile(L"C:\\A.avi", NULL);
    //*********************************************

        //IGraphBuilder *pGraph = NULL;
    ICaptureGraphBuilder2 *pBuild = NULL;
    

        // Create the Capture Graph Builder.
    hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pGraph);

    // Initialize the Capture Graph Builder.

    hr=pBuild->SetFiltergraph(pGraph);

    //************RUN**************************
    hr = pControl->Run();
    //****************************************

    //***************HOLD TILL FINISH VIDEO********************
    long evCode = 0;
    pEvent->WaitForCompletion(INFINITE, &evCode);
    //*********************************************************

    //****RELEASE INTERFACE POINTERS AND CLOSE COM LIBRARY*******
    pControl->Release();
    pEvent->Release();
    pGraph->Release();
    CoUninitialize();
    //***********************************************************

}

********************************************************
The code builds fine, but when I run it, it crashes out without telling me what errors there are.
I tested out each line of the code and it seems to crash out (terminates prematurely when I initialize the capture graph builder:


hr=pBuild->SetFiltergraph(pGraph);


Any help on this would be greatly greatly greatly appreciated,
Thank you for any little help in advance!!!

cchan

This post has been edited by Dark_Nexus: 1 Oct, 2006 - 02:17 PM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 03:07AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month