source: trunk/Utilities/MediaFoundation/StockDirectShowAdapter01/Module.h @ 327

Last change on this file since 327 was 327, checked in by roman, 10 years ago
File size: 2.9 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2014
3// Created by Roman Ryltsov roman@alax.info
4
5#pragma once
6
7#import "libid:B9EC374B-834B-4DA9-BFB5-C1872CE736FF" raw_interfaces_only // AlaxInfoDirectShowSpy
8#include "rodshow.h"
9
10////////////////////////////////////////////////////////////
11// CModule
12
13class CModule :
14        public CAtlExeModuleT<CModule>
15{
16public:
17// CModule
18        CModule()
19        {
20                AtlTraceSetDefaultSettings();
21                _Z4_THIS();
22                _W(CExceptionFilter::Initialize());
23        }
24        ~CModule()
25        {
26                _Z4_THIS();
27                CExceptionFilter::Terminate();
28        }
29        HRESULT PreMessageLoop(INT nShowCommand)
30        {
31                const HRESULT nResult = __super::PreMessageLoop(nShowCommand);
32                return SUCCEEDED(nResult) ? S_OK : nResult;
33        }
34        VOID RunMessageLoop()
35        {
36                CGenericFilterGraph FilterGraph;
37                FilterGraph.CoCreateInstance();
38                const CComQIPtr<AlaxInfoDirectShowSpy::ISpy> pSpy = FilterGraph.m_pFilterGraph;
39                static LPCTSTR g_pszPath = 
40                        //_T("E:\\Media\\Robotica_1080.wmv");
41                        _T("E:\\Torrents\\Äèñêîòåêà 80-õ.2012.HDTV.1080i.ts");
42
43                // NOTE:
44                //   {0344ec28-5339-4124-a186-2e8eef168785} MFSourceFilter
45                //   {14d7a407-396b-44b3-be85-5199a0f0f80a} Media Foundation DShow Source Resolver
46                //   {743a6e3b-a5df-43ed-b615-4256add790b8} MFPsiFilter
47                //   {eb4d075a-65c0-476b-956c-c605eade03f7} DemuxRender
48                //   {f792beee-aeaf-4ebb-ab14-8bc5c8c695a8} Media Foundation MP2demux
49
50                //CInProcessServerLibrary Library;
51                CComPtr<IBaseFilter> pSourceBaseFilter;
52                {
53                        class _declspec(uuid("{0344EC28-5339-4124-A186-2E8EEF168785}")) MediaFoundationSource;
54                        //Library.Initialize(_T("mfds.dll"));
55                        //__C(Library.CreateInstance(pSourceBaseFilter, __uuidof(MediaFoundationSource)));
56                        __C(pSourceBaseFilter.CoCreateInstance(__uuidof(MediaFoundationSource)));
57                        __C(FilterGraph.AddFilter(pSourceBaseFilter, _T("Source")));
58                        __C(FilterGraph.LoadFileSourceFilter(pSourceBaseFilter, g_pszPath));
59                }
60                CComPtr<IBaseFilter> pDemultiplexerBaseFilter;
61                {
62                        class _declspec(uuid("{F792BEEE-AEAF-4EBB-AB14-8BC5C8C695A8}")) MediaFoundationMpeg2Demultiplexer;
63                        __C(pDemultiplexerBaseFilter.CoCreateInstance(__uuidof(MediaFoundationMpeg2Demultiplexer)));
64                        __C(FilterGraph.AddFilter(pDemultiplexerBaseFilter, _T("MPEG-2 Demultiplexer")));
65                        __C(FilterGraph.Connect(_FilterGraphHelper::GetFilterPin(pSourceBaseFilter, PINDIR_OUTPUT), _FilterGraphHelper::GetFilterPin(pDemultiplexerBaseFilter, PINDIR_INPUT)));
66                        //pSpy->DoPropertyFrameModal((LONG) (LONG_PTR) GetActiveWindow());
67                        _FilterGraphHelper::CPinArray PinArray;
68                        _FilterGraphHelper::GetFilterPins(pDemultiplexerBaseFilter, PINDIR_OUTPUT, PinArray);
69                        for(auto&& pPin: PinArray)
70                        {
71                                const HRESULT nRenderResult = FilterGraph.m_pFilterGraph->Render(pPin);
72                                _Z45_DSHRESULT(nRenderResult);
73                        }
74                }
75                __C(FilterGraph.m_pMediaControl->Run());
76                Sleep(15000);
77        }
78};
79
Note: See TracBrowser for help on using the repository browser.