| 1 | /*
|
|---|
| 2 | * Implementation of CLSID_FilterGraph.
|
|---|
| 3 | *
|
|---|
| 4 | * hidenori@a2.ctktv.ne.jp
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | #include "config.h"
|
|---|
| 8 |
|
|---|
| 9 | #include "windef.h"
|
|---|
| 10 | #include "winbase.h"
|
|---|
| 11 | #include "wingdi.h"
|
|---|
| 12 | #include "winerror.h"
|
|---|
| 13 | #include "wine/obj_base.h"
|
|---|
| 14 | #include "wine/obj_oleaut.h"
|
|---|
| 15 | #include "strmif.h"
|
|---|
| 16 | #include "control.h"
|
|---|
| 17 | #include "uuids.h"
|
|---|
| 18 |
|
|---|
| 19 | #include "debugtools.h"
|
|---|
| 20 | DEFAULT_DEBUG_CHANNEL(quartz);
|
|---|
| 21 |
|
|---|
| 22 | #include "quartz_private.h"
|
|---|
| 23 | #include "fgraph.h"
|
|---|
| 24 |
|
|---|
| 25 | /* can I use offsetof safely? - FIXME? */
|
|---|
| 26 | static QUARTZ_IFEntry IFEntries[] =
|
|---|
| 27 | {
|
|---|
| 28 | { &IID_IPersist, offsetof(CFilterGraph,persist)-offsetof(CFilterGraph,unk) },
|
|---|
| 29 | { &IID_IDispatch, offsetof(CFilterGraph,disp)-offsetof(CFilterGraph,unk) },
|
|---|
| 30 | { &IID_IFilterGraph, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
|
|---|
| 31 | { &IID_IGraphBuilder, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
|
|---|
| 32 | { &IID_IFilterGraph2, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
|
|---|
| 33 | { &IID_IGraphVersion, offsetof(CFilterGraph,graphversion)-offsetof(CFilterGraph,unk) },
|
|---|
| 34 | { &IID_IMediaControl, offsetof(CFilterGraph,mediacontrol)-offsetof(CFilterGraph,unk) },
|
|---|
| 35 | { &IID_IMediaFilter, offsetof(CFilterGraph,mediafilter)-offsetof(CFilterGraph,unk) },
|
|---|
| 36 | { &IID_IMediaEvent, offsetof(CFilterGraph,mediaevent)-offsetof(CFilterGraph,unk) },
|
|---|
| 37 | { &IID_IMediaEventEx, offsetof(CFilterGraph,mediaevent)-offsetof(CFilterGraph,unk) },
|
|---|
| 38 | { &IID_IMediaEventSink, offsetof(CFilterGraph,mediaeventsink)-offsetof(CFilterGraph,unk) },
|
|---|
| 39 | { &IID_IMediaPosition, offsetof(CFilterGraph,mediaposition)-offsetof(CFilterGraph,unk) },
|
|---|
| 40 | { &IID_IMediaSeeking, offsetof(CFilterGraph,mediaseeking)-offsetof(CFilterGraph,unk) },
|
|---|
| 41 | { &IID_IBasicVideo, offsetof(CFilterGraph,basvid)-offsetof(CFilterGraph,unk) },
|
|---|
| 42 | { &IID_IBasicVideo2, offsetof(CFilterGraph,basvid)-offsetof(CFilterGraph,unk) },
|
|---|
| 43 | { &IID_IBasicAudio, offsetof(CFilterGraph,basaud)-offsetof(CFilterGraph,unk) },
|
|---|
| 44 | { &IID_IVideoWindow, offsetof(CFilterGraph,vidwin)-offsetof(CFilterGraph,unk) },
|
|---|
| 45 | };
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | struct FGInitEntry
|
|---|
| 49 | {
|
|---|
| 50 | HRESULT (*pInit)(CFilterGraph*);
|
|---|
| 51 | void (*pUninit)(CFilterGraph*);
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | static const struct FGInitEntry FGRAPH_Init[] =
|
|---|
| 55 | {
|
|---|
| 56 | #define FGENT(a) {&CFilterGraph_Init##a,&CFilterGraph_Uninit##a},
|
|---|
| 57 |
|
|---|
| 58 | FGENT(IPersist)
|
|---|
| 59 | FGENT(IDispatch)
|
|---|
| 60 | FGENT(IFilterGraph2)
|
|---|
| 61 | FGENT(IGraphVersion)
|
|---|
| 62 | FGENT(IMediaControl)
|
|---|
| 63 | FGENT(IMediaFilter)
|
|---|
| 64 | FGENT(IMediaEventEx)
|
|---|
| 65 | FGENT(IMediaEventSink)
|
|---|
| 66 | FGENT(IMediaPosition)
|
|---|
| 67 | FGENT(IMediaSeeking)
|
|---|
| 68 | FGENT(IBasicVideo2)
|
|---|
| 69 | FGENT(IBasicAudio)
|
|---|
| 70 | FGENT(IVideoWindow)
|
|---|
| 71 |
|
|---|
| 72 | #undef FGENT
|
|---|
| 73 | { NULL, NULL },
|
|---|
| 74 | };
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | static void QUARTZ_DestroyFilterGraph(IUnknown* punk)
|
|---|
| 78 | {
|
|---|
| 79 | CFilterGraph_THIS(punk,unk);
|
|---|
| 80 | int i;
|
|---|
| 81 |
|
|---|
| 82 | /* At first, call Stop. */
|
|---|
| 83 | IMediaControl_Stop( CFilterGraph_IMediaControl(This) );
|
|---|
| 84 | IMediaFilter_Stop( CFilterGraph_IMediaFilter(This) );
|
|---|
| 85 |
|
|---|
| 86 | i = 0;
|
|---|
| 87 | while ( FGRAPH_Init[i].pInit != NULL )
|
|---|
| 88 | {
|
|---|
| 89 | FGRAPH_Init[i].pUninit( This );
|
|---|
| 90 | i++;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | TRACE( "succeeded.\n" );
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | HRESULT QUARTZ_CreateFilterGraph(IUnknown* punkOuter,void** ppobj)
|
|---|
| 97 | {
|
|---|
| 98 | CFilterGraph* pfg;
|
|---|
| 99 | HRESULT hr;
|
|---|
| 100 | int i;
|
|---|
| 101 |
|
|---|
| 102 | TRACE("(%p,%p)\n",punkOuter,ppobj);
|
|---|
| 103 |
|
|---|
| 104 | pfg = (CFilterGraph*)QUARTZ_AllocObj( sizeof(CFilterGraph) );
|
|---|
| 105 | if ( pfg == NULL )
|
|---|
| 106 | return E_OUTOFMEMORY;
|
|---|
| 107 |
|
|---|
| 108 | QUARTZ_IUnkInit( &pfg->unk, punkOuter );
|
|---|
| 109 |
|
|---|
| 110 | i = 0;
|
|---|
| 111 | hr = NOERROR;
|
|---|
| 112 | while ( FGRAPH_Init[i].pInit != NULL )
|
|---|
| 113 | {
|
|---|
| 114 | hr = FGRAPH_Init[i].pInit( pfg );
|
|---|
| 115 | if ( FAILED(hr) )
|
|---|
| 116 | break;
|
|---|
| 117 | i++;
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | if ( FAILED(hr) )
|
|---|
| 121 | {
|
|---|
| 122 | while ( --i >= 0 )
|
|---|
| 123 | FGRAPH_Init[i].pUninit( pfg );
|
|---|
| 124 | QUARTZ_FreeObj( pfg );
|
|---|
| 125 | return hr;
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | pfg->unk.pEntries = IFEntries;
|
|---|
| 129 | pfg->unk.dwEntries = sizeof(IFEntries)/sizeof(IFEntries[0]);
|
|---|
| 130 | pfg->unk.pOnFinalRelease = QUARTZ_DestroyFilterGraph;
|
|---|
| 131 |
|
|---|
| 132 | *ppobj = (void*)(&pfg->unk);
|
|---|
| 133 |
|
|---|
| 134 | return S_OK;
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|