1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#include "StdAfx.h"
#include "strmif.h"
#include "MediaReader.h"
#pragma once
#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x0501
#pragma warning(disable : 4995)
#ifdef _DEBUG
#pragma comment(lib, "strmbasd")
#else
#pragma comment(lib, "strmbase")
#endif
#include <windows.h>
#include <stdio.h>
#include "dshow.h"
#include "MediaReader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
MediaReader::MediaReader(void),
{
g_pGraph = NULL;
g_pControl = NULL;
g_pEvent = NULL;
g_pSeek = NULL;
g_pIVideoWindow= NULL;
g_pIVideoFrameStep=NULL;
g_pIBasicVideo=NULL;
g_pIBasicAudio=NULL;
HRESULT hr = S_OK;
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the COM Initializing",MB_ICONERROR);
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,IID_IGraphBuilder, (void**)&g_pGraph);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the Instance Creation",MB_ICONERROR);
hr = g_pGraph->QueryInterface(IID_IMediaControl, (void **)&g_pControl);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the linking of Media Control",MB_ICONERROR);
hr = g_pGraph->QueryInterface(IID_IMediaEvent, (void **)&g_pEvent);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the linking of Media Event",MB_ICONERROR);
hr = g_pGraph->QueryInterface(IID_IMediaSeeking, (void **)&g_pSeek);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the linking of Media Seeking",MB_ICONERROR);
hr = g_pGraph->QueryInterface(IID_IMediaPosition, (void **)&g_pPosition);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the linking of Media Position",MB_ICONERROR);
hr = g_pGraph->QueryInterface(IID_IVideoWindow, (void **)&g_pIVideoWindow);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the linking of Media Position",MB_ICONERROR);
hr = g_pGraph->QueryInterface(IID_IVideoFrameStep, (void **)&g_pIVideoFrameStep);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the linking of Video Frame Step",MB_ICONERROR);
hr = g_pGraph->QueryInterface(IID_IBasicVideo, (void **)&g_pIBasicVideo);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the linking of Basic Video",MB_ICONERROR);
hr = g_pGraph->QueryInterface(IID_IBasicAudio, (void **)&g_pIBasicAudio);
if(FAILED(hr))
AfxMessageBox("Error: An error has occured during the linking of Basic Audio",MB_ICONERROR);
g_pGraph->RenderFile(L"Title 1-Chapter 1-0.avi", NULL);
g_pSeek->SetTimeFormat(&TIME_FORMAT_FRAME);
SetState(Uninitialized);
}
void MediaReader::ReleaseInterface()
{
if(g_pSeek)
g_pSeek->Release();
if(g_pPosition)
g_pPosition->Release();
if(g_pEvent)
g_pEvent->Release();
if(g_pControl)
g_pControl->Release();
if(g_pIVideoWindow)
g_pIVideoWindow->Release();
if(g_pGraph)
g_pGraph->Release();
}
[/LEFT] |
Partager