#include <dshow.h>
#include "SM_Video.h"

namespace Video
{

    class VideoRender : public CBaseVideoRender
    {
    public:
        CTextureRenderer(LPUNKNOWN pUnk,HRESULT *phr);
        ~CTextureRenderer();

        HRESULT CheckMediaType(const CMediaType *pmt )
        {
        }

        HRESULT SetMediaType(const CMediaType *pmt )
        {
        }
            
        HRESULT DoRenderSample(IMediaSample *pMediaSample)
        {
        }
    };
    
	

    
int Init        ()
{
    IGraphBuilder *pGraph;
    IMediaControl *pMediaControl;
    IMediaEvent   *pEvent;


    pGraph=0;
    pMediaControl=0;
    pEvent=0;

    CoInitialize(NULL);
    CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
                        IID_IGraphBuilder, (void **)&pGraph);

    if (!pGraph)
    {
        return -1;
    }

    pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);

    if (!pMediaControl)
    {
        return -1;
    }

    pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);

    if (!pEvent)
    {
        return -1;
    }


    pGraph->RenderFile(L"data/videos/TalkSml.avi", NULL);

    // Run the graph.
    pMediaControl->Run();

    // Wait for completion. 
    long evCode;
    pEvent->WaitForCompletion(INFINITE, &evCode);



    return 0;
}

int Shutdown    ()
{
    return 0;
}

}