source: trunk/src/testing/app/hd-video-player/Utils.h @ 4

Revision 4, 6.3 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Copyright (C) 2004 Electronic Visualization Laboratory,
5 * University of Illinois at Chicago
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above
15 *    copyright notice, this list of conditions and the following disclaimer
16 *    in the documentation and/or other materials provided with the distribution.
17 *  * Neither the name of the University of Illinois at Chicago nor
18 *    the names of its contributors may be used to endorse or promote
19 *    products derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/
34 *
35 *****************************************************************************/
36
37//------------------------------------------------------------------------------------
38// $Id: Utils.h,v 1.6 2006/03/21 07:00:57 ivanr Exp $
39//
40// Desc: DirectShow utility class header
41//
42// Copyright (c) Blackmagic Design 2005. All rights reserved.
43//------------------------------------------------------------------------------------
44
45#pragma once
46
47#include <string>
48#include <dvdmedia.h>
49
50//------------------------------------------------------------------------------------
51// CDSUtils - Directshow utility class
52//------------------------------------------------------------------------------------
53class CDSUtils
54{
55public:
56        static HRESULT AddFilter(IGraphBuilder* pGraph, const GUID &clsid, LPCWSTR pName, IBaseFilter** ppFilter);
57        static HRESULT AddFilter2(IGraphBuilder* pGraph, const GUID &clsid, LPCWSTR pName, IBaseFilter** ppFilter);
58
59        static HRESULT GetUnconnectedPin(IBaseFilter* pFilter, PIN_DIRECTION PinDir, IPin** ppPin);
60        static HRESULT GetPin(IBaseFilter* pFilter, const wchar_t* pName, IPin** ppPin);
61        static HRESULT GetPin(IBaseFilter* pFilter, const GUID* pFormat, PIN_DIRECTION PinDir, IPin** ppPin);
62
63        static HRESULT ConnectFilters(IGraphBuilder* pGraph, IBaseFilter* pUpstream, wchar_t* pUpstreamPinName, IBaseFilter* pDownstream, wchar_t* pDownstreamPinName);
64        static HRESULT ConnectFilters(IGraphBuilder* pGraph, IBaseFilter* pUpstream, IBaseFilter* pDownstream, const GUID* pFormat);
65        static HRESULT RenderFilter(IGraphBuilder* pGraph, IBaseFilter* pUpstream, wchar_t* pUpstreamPinName);
66
67        static HRESULT DisconnectAllPins(IGraphBuilder* pGraph);
68
69        static HRESULT FindFilterInterface(IBaseFilter* pFilter, const IID& riid, void** ppvInterface);
70        static HRESULT FindPinInterface(IBaseFilter* pFilter, wchar_t* pName, const IID& riid, void** ppvInterface);
71        static HRESULT FindPinInterface(IBaseFilter* pFilter, const GUID* pFormat, PIN_DIRECTION PinDir, const IID& riid, void** ppvInterface);
72
73        static HRESULT AddGraphToRot(IUnknown* pUnkGraph, DWORD* pdwRegister);
74        static void RemoveGraphFromRot(DWORD pdwRegister);
75};
76
77//------------------------------------------------------------------------------------
78// CRegUtils - Registry utility class
79//------------------------------------------------------------------------------------
80class CRegUtils
81{
82public:
83        CRegUtils();
84        ~CRegUtils();
85
86        LONG Open(LPCTSTR lpSubKey);
87        LONG Create(LPCTSTR lpSubKey);
88        void Close();
89
90        LONG SetString(LPCTSTR valueName, const BYTE* lpData, DWORD cbData);
91        LONG GetString(LPCTSTR valueName, LPBYTE lpData, DWORD cbData);
92
93        LONG SetBinary(LPCTSTR valueName, const BYTE* lpData, DWORD cbData);
94        LONG GetBinary(LPCTSTR valueName, LPBYTE lpData, DWORD cbData);
95
96        LONG SetDword(LPCTSTR valueName, const BYTE* lpData, DWORD cbData);
97        LONG GetDword(LPCTSTR valueName, LPBYTE lpData, DWORD cbData);
98
99private:
100        std::string m_subKeyName;
101        HKEY m_hKey;
102};
103
104//------------------------------------------------------------------------------------
105// CUtils - utility class
106//------------------------------------------------------------------------------------
107class CUtils
108{
109public:
110        static BITMAPINFOHEADER* GetBMIHeader(const AM_MEDIA_TYPE* pamt);
111        static BITMAPINFOHEADER* GetBMIHeader(const CMediaType& mt);
112        static REFERENCE_TIME GetAvgTimePerFrame(const AM_MEDIA_TYPE* pamt);
113        static unsigned long GetImageSize(BITMAPINFOHEADER* pbmih);
114};
115
116//------------------------------------------------------------------------------
117// UNITS = 10 ^ 7
118// UNITS / 30 = 30 fps;
119// UNITS / 20 = 20 fps, etc
120const REFERENCE_TIME FPS_30 = UNITS / 30;
121const REFERENCE_TIME FPS_2997 = UNITS * 1001 / 30000;
122const REFERENCE_TIME FPS_25 = UNITS / 25;
123const REFERENCE_TIME FPS_24 = UNITS / 24;
124const REFERENCE_TIME FPS_23976 = UNITS * 1001 / 24000;
125const REFERENCE_TIME FPS_20 = UNITS / 20;
126const REFERENCE_TIME FPS_10 = UNITS / 10;
127const REFERENCE_TIME FPS_5  = UNITS / 5;
128const REFERENCE_TIME FPS_4  = UNITS / 4;
129const REFERENCE_TIME FPS_3  = UNITS / 3;
130const REFERENCE_TIME FPS_2  = UNITS / 2;
131const REFERENCE_TIME FPS_1  = UNITS / 1;
132
133//------------------------------------------------------------------------------
134#define SAFE_DELETE(p)                  { if(p) { delete (p);     (p)=NULL; } }
135#define SAFE_DELETE_ARRAY(p)    { if(p) { delete [] (p);     (p)=NULL; } }
136#define SAFE_RELEASE(p)                 { if(p) { (p)->Release(); (p)=NULL; } }
137#define SIZEOF_ARRAY(x)                 (sizeof(x)/sizeof((x)[0]))
Note: See TracBrowser for help on using the repository browser.