Skip to content
Browse files

Moved dshowhelper, DXUtil, fontEngine and Win7RefreshRateHelper under…

… dshow folder
  • Loading branch information...
1 parent 9fefbac commit 93bcda09af899592ebdbdba310e7fab549f3e900 @tourettes tourettes committed Jan 6, 2013
Showing with 4,880 additions and 4,841 deletions.
  1. +6 −6 {mediaportal/Core.cpp → DirectShowFilters}/DXUtil/DXUtil.vcxproj
  2. 0 {mediaportal/Core.cpp → DirectShowFilters}/DXUtil/source/DXUtil.cpp
  3. 0 {mediaportal/Core.cpp → DirectShowFilters}/DXUtil/source/stdafx.cpp
  4. 0 {mediaportal/Core.cpp → DirectShowFilters}/DXUtil/source/stdafx.h
  5. +1 −1 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/dshowhelper.sln
  6. +6 −6 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/dshowhelper.vcxproj
  7. +431 −431 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/DX9AllocatorPresenter.cpp
  8. +139 −139 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/DX9AllocatorPresenter.h
  9. +1 −1 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/EVRCustomPresenter.cpp
  10. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/EVRCustomPresenter.h
  11. +400 −400 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/GrabBitmaps.cpp
  12. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/IAVSyncClock.h
  13. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/MyQueue.h
  14. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/OuterEVR.cpp
  15. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/OuterEVR.h
  16. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/Scheduler.cpp
  17. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/Scheduler.h
  18. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/StatsRenderer.cpp
  19. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/StatsRenderer.h
  20. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/StdAfx.h
  21. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/TimeSource.cpp
  22. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/TimeSource.h
  23. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/autoint.h
  24. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/callback.h
  25. +1 −1 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/debugallocs.h
  26. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/dllmodul.cpp
  27. +1,326 −1,326 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/dshowhelper.cpp
  28. +24 −24 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/dshowhelper.def
  29. +77 −77 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/dshowhelper.h
  30. 0 {mediaportal/Core.cpp → DirectShowFilters}/DirectShowHelper/source/qedit.h
  31. +146 −24 DirectShowFilters/Filters.sln
  32. +0 −83 DirectShowFilters/MPAudioswitcher/MPAudioSwitcher.vcxproj
  33. +1 −1 {mediaportal/Core.cpp → DirectShowFilters}/Win7RefreshRateHelper/Win7RefreshRateHelper.sln
  34. +8 −8 {mediaportal/Core.cpp → DirectShowFilters}/Win7RefreshRateHelper/Win7RefreshRateHelper.vcxproj
  35. +1 −1 {mediaportal/Core.cpp → DirectShowFilters}/Win7RefreshRateHelper/source/Win7RefreshRateHelper.cpp
  36. 0 {mediaportal/Core.cpp → DirectShowFilters}/Win7RefreshRateHelper/source/Win7RefreshRateHelper.def
  37. +1 −1 {mediaportal/Core.cpp → DirectShowFilters}/Win7RefreshRateHelper/source/Win7RefreshRateHelper.h
  38. +6 −6 {mediaportal/Core.cpp → DirectShowFilters}/fontEngine/fontEngine.vcxproj
  39. +1 −1 {mediaportal/Core.cpp → DirectShowFilters}/fontEngine/source/TransformMatrix.h
  40. +2,179 −2,179 {mediaportal/Core.cpp → DirectShowFilters}/fontEngine/source/fontEngine.cpp
  41. +24 −24 {mediaportal/Core.cpp → DirectShowFilters}/fontEngine/source/fontEngine.def
  42. +52 −52 {mediaportal/Core.cpp → DirectShowFilters}/fontEngine/source/fontEngine.h
  43. +20 −20 {mediaportal/Core.cpp → DirectShowFilters}/fontEngine/source/stdafx.cpp
  44. +29 −29 {mediaportal/Core.cpp → DirectShowFilters}/fontEngine/source/stdafx.h
  45. BIN mediaportal/Core.cpp/DXUtil/bin/Debug/dxutil.dll
  46. BIN mediaportal/Core.cpp/DXUtil/bin/Debug/dxutil.pdb
  47. BIN mediaportal/Core.cpp/DXUtil/bin/Debug/vc100.pdb
  48. BIN mediaportal/Core.cpp/DXUtil/bin/Release/dxutil.dll
  49. BIN mediaportal/Core.cpp/DirectShowHelper/bin/Debug/dshowhelper.dll
  50. BIN mediaportal/Core.cpp/DirectShowHelper/bin/Debug/dshowhelper.pdb
  51. BIN mediaportal/Core.cpp/DirectShowHelper/bin/Debug/vc100.pdb
  52. BIN mediaportal/Core.cpp/DirectShowHelper/bin/Release/dshowhelper.dll
  53. BIN mediaportal/Core.cpp/Win7RefreshRateHelper/bin/Debug/Win7RefreshRateHelper.dll
  54. BIN mediaportal/Core.cpp/Win7RefreshRateHelper/bin/Debug/Win7RefreshRateHelper.pdb
  55. BIN mediaportal/Core.cpp/Win7RefreshRateHelper/bin/Debug/vc100.pdb
  56. BIN mediaportal/Core.cpp/Win7RefreshRateHelper/bin/Release/Win7RefreshRateHelper.dll
  57. BIN mediaportal/Core.cpp/Win7RefreshRateHelper/bin/Release/vc90.idb
  58. BIN mediaportal/Core.cpp/fontEngine/bin/Debug/fontEngine.dll
  59. BIN mediaportal/Core.cpp/fontEngine/bin/Debug/fontEngine.pdb
  60. BIN mediaportal/Core.cpp/fontEngine/bin/Debug/vc100.pdb
  61. BIN mediaportal/Core.cpp/fontEngine/bin/Release/fontEngine.dll
View
12 mediaportal/Core.cpp/DXUtil/DXUtil.vcxproj → DirectShowFilters/DXUtil/DXUtil.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -53,7 +53,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>$(DSHOW_BASE); $(WINDOWS_SDK)Include; $(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>(SolutionDir)baseclasses; $(WINDOWS_SDK)Include; $(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;DXUTIL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -68,7 +68,7 @@
</ClCompile>
<Link>
<OutputFile>bin\Debug/dxutil.dll</OutputFile>
- <AdditionalLibraryDirectories>$(DSHOW_BASE)Debug;$(DXSDK_DIR)lib\x86;$(WINDOWS_SDK)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>(SolutionDir)baseclasses\debug;$(DXSDK_DIR)lib\x86;$(WINDOWS_SDK)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>bin\Debug/dxutil.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
@@ -81,7 +81,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
- <AdditionalIncludeDirectories>$(DSHOW_BASE); $(WINDOWS_SDK)Include; $(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>(SolutionDir)baseclasses; $(WINDOWS_SDK)Include; $(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DXUTIL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -94,7 +94,7 @@
</ClCompile>
<Link>
<OutputFile>bin\Release/dxutil.dll</OutputFile>
- <AdditionalLibraryDirectories>$(DSHOW_BASE)Release; $(DXSDK_DIR)lib\x86;$(WINDOWS_SDK)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>(SolutionDir)baseclasses\release; $(DXSDK_DIR)lib\x86;$(WINDOWS_SDK)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<ProgramDatabaseFile>bin\Release/dxutil.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
@@ -120,4 +120,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project>
View
0 ...aportal/Core.cpp/DXUtil/source/DXUtil.cpp → DirectShowFilters/DXUtil/source/DXUtil.cpp
File renamed without changes.
View
0 ...aportal/Core.cpp/DXUtil/source/stdafx.cpp → DirectShowFilters/DXUtil/source/stdafx.cpp
File renamed without changes.
View
0 mediaportal/Core.cpp/DXUtil/source/stdafx.h → DirectShowFilters/DXUtil/source/stdafx.h
File renamed without changes.
View
2 ...Core.cpp/DirectShowHelper/dshowhelper.sln → ...wFilters/DirectShowHelper/dshowhelper.sln
@@ -1,4 +1,4 @@
-
+
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectShowHelper", "dshowhelper.vcxproj", "{7C2419B3-501B-4B10-B3D4-E81BEB16843F}"
View
12 ....cpp/DirectShowHelper/dshowhelper.vcxproj → ...ters/DirectShowHelper/dshowhelper.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -53,7 +53,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>$(DSHOW_BASE); $(WINDOWS_SDK)Include; $(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(SolutionDir)baseclasses; $(WINDOWS_SDK)Include; $(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;DSHOWHELPER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -70,7 +70,7 @@
<Link>
<AdditionalDependencies>strmbasd.lib;winmm.lib;comsupp.lib;dxguid.lib;d3d9.lib;d3dx9.lib;mfuuid.lib;dxva2.lib;evr.lib;mf.lib;strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\Debug/dshowhelper.dll</OutputFile>
- <AdditionalLibraryDirectories>$(DSHOW_BASE)Debug; $(DXSDK_DIR)lib\x86;$(WINDOWS_SDK)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>$(SolutionDir)baseclasses\debug; $(DXSDK_DIR)lib\x86;$(WINDOWS_SDK)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<ModuleDefinitionFile>./source/dshowhelper.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -88,7 +88,7 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- <AdditionalIncludeDirectories>$(DSHOW_BASE); $(WINDOWS_SDK)Include; $(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(SolutionDir)baseclasses; $(WINDOWS_SDK)Include; $(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DSHOWHELPER_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
@@ -103,7 +103,7 @@
<Link>
<AdditionalDependencies>strmbase.lib;winmm.lib;comsupp.lib;dxguid.lib;d3d9.lib;d3dx9.lib;mfuuid.lib;dxva2.lib;evr.lib;mf.lib;strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>bin\Release/dshowhelper.dll</OutputFile>
- <AdditionalLibraryDirectories>$(DSHOW_BASE)Release; $(DXSDK_DIR)lib\x86;$(WINDOWS_SDK)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>$(SolutionDir)baseclasses\release; $(DXSDK_DIR)lib\x86;$(WINDOWS_SDK)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<ModuleDefinitionFile>./source/dshowhelper.def</ModuleDefinitionFile>
@@ -152,4 +152,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project>
View
862 ...owHelper/source/DX9AllocatorPresenter.cpp → ...owHelper/source/DX9AllocatorPresenter.cpp
@@ -1,431 +1,431 @@
-// Copyright (C) 2005-2010 Team MediaPortal
-// http://www.team-mediaportal.com
-//
-// MediaPortal is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 2 of the License, or
-// (at your option) any later version.
-//
-// MediaPortal is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
-
-#pragma warning(disable: 4244)
-
-#include <streams.h>
-#include <atlbase.h>
-#include <d3dx9.h>
-#include <vmr9.h>
-
-#include "dx9allocatorpresenter.h"
-
-// For more details for memory leak detection see the alloctracing.h header
-#include "..\..\alloctracing.h"
-
-void Log(const char *fmt, ...) ;
-
-CVMR9AllocatorPresenter::CVMR9AllocatorPresenter(IDirect3DDevice9* direct3dDevice, IVMR9Callback* callback, HMONITOR monitor)
-: m_refCount(1)
-{
- Log("----------v0.4---------------------------");
- m_hMonitor = monitor;
- m_pD3DDev = direct3dDevice;
- m_pCallback = callback;
- m_surfaceCount = 0;
- m_UseOffScreenSurface = false;
- m_pSurfaces = NULL;
-}
-
-CVMR9AllocatorPresenter::~CVMR9AllocatorPresenter()
-{
- Log("CVMR9AllocatorPresenter dtor");
- m_pIVMRSurfAllocNotify = NULL;
- m_pD3DDev = NULL;
- Log("CVMR9AllocatorPresenter dtor exit");
-}
-
-void CVMR9AllocatorPresenter::UseOffScreenSurface(bool yesNo)
-{
- m_UseOffScreenSurface=yesNo;
-}
-
-// IUnknown
-HRESULT CVMR9AllocatorPresenter::QueryInterface(
- REFIID riid,
- void** ppvObject)
-{
- HRESULT hr = E_NOINTERFACE;
-
- if( ppvObject == NULL )
- {
- hr = E_POINTER;
- }
- else if (riid == IID_IVMRSurfaceAllocator9)
- {
- *ppvObject = static_cast<IVMRSurfaceAllocator9*>(this);
- AddRef();
- hr = S_OK;
- }
- else if (riid == IID_IVMRImagePresenter9)
- {
- *ppvObject = static_cast<IVMRImagePresenter9*>(this);
- AddRef();
- hr = S_OK;
- }
- else if (riid == IID_IVMRWindowlessControl9)
- {
- *ppvObject = static_cast<IVMRWindowlessControl9*>(this);
- AddRef();
- hr = S_OK;
- }
- else if (riid == IID_IUnknown)
- {
- *ppvObject = static_cast<IUnknown*>(static_cast<IVMRSurfaceAllocator9*>(this));
- AddRef();
- hr = S_OK;
- }
-
- return hr;
-}
-
-ULONG CVMR9AllocatorPresenter::AddRef()
-{
- return InterlockedIncrement(&m_refCount);
-}
-
-ULONG CVMR9AllocatorPresenter::Release()
-{
- Log("CVMR9AllocatorPresenter::Release()");
- ULONG ret = InterlockedDecrement(&m_refCount);
- if( ret == 0 )
- {
- Log("CVMR9AllocatorPresenter::Cleanup()");
- delete this;
- }
- return ret;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers)
-{
- previousEndFrame=0;
- if(!lpAllocInfo || !lpNumBuffers)
- return E_POINTER;
-
- if(!m_pIVMRSurfAllocNotify)
- return E_FAIL;
-
- Log("vmr9:InitializeDevice() %dx%d AR %d:%d flags:%d buffers:%d fmt:(%x) %c%c%c%c",
- lpAllocInfo->dwWidth,lpAllocInfo->dwHeight,
- lpAllocInfo->szAspectRatio.cx,lpAllocInfo->szAspectRatio.cy,
- lpAllocInfo->dwFlags,
- *lpNumBuffers,
- lpAllocInfo->Format,
- ((char)lpAllocInfo->Format&0xff),
- ((char)(lpAllocInfo->Format>>8)&0xff),
- ((char)(lpAllocInfo->Format>>16)&0xff),
- ((char)(lpAllocInfo->Format>>24)&0xff));
- if (m_UseOffScreenSurface)
- lpAllocInfo->dwFlags =VMR9AllocFlag_OffscreenSurface;
-
- m_surfaceCount=*lpNumBuffers;
-
- HRESULT hr;
-
- m_pSurfaces = new IDirect3DSurface9* [m_surfaceCount];
-
-
- DWORD dwFlags=lpAllocInfo->dwFlags;
- Log("vmr9:flags:");
- if (dwFlags & VMR9AllocFlag_3DRenderTarget) Log("vmr9: 3drendertarget");
- if (dwFlags & VMR9AllocFlag_DXVATarget) Log("vmr9: DXVATarget");
- if (dwFlags & VMR9AllocFlag_OffscreenSurface) Log("vmr9: OffscreenSurface");
- if (dwFlags & VMR9AllocFlag_RGBDynamicSwitch) Log("vmr9: RGBDynamicSwitch");
- if (dwFlags & VMR9AllocFlag_TextureSurface) Log("vmr9: TextureSurface");
-
- lpAllocInfo->dwFlags = VMR9AllocFlag_TextureSurface | VMR9AllocFlag_3DRenderTarget;
- lpAllocInfo->Format = D3DFMT_UNKNOWN;
-
- hr = m_pIVMRSurfAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, m_pSurfaces);
- if(FAILED(hr))
- {
- Log("vmr9:InitializeDevice() AllocateSurfaceHelper returned:0x%x",hr);
- return hr;
- }
- m_iVideoWidth=lpAllocInfo->dwWidth;
- m_iVideoHeight=lpAllocInfo->dwHeight;
- m_iARX=lpAllocInfo->szAspectRatio.cx;
- m_iARY=lpAllocInfo->szAspectRatio.cy;
-
- Log("vmr9:InitializeDevice() done()");
- return hr;
-}
-
-
-STDMETHODIMP CVMR9AllocatorPresenter::TerminateDevice(DWORD_PTR dwUserID)
-{
- Log("vmr9:TerminateDevice()");
- DeleteSurfaces();
- return S_OK;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface)
-{
- ULONG refcnt;
- if (!lplpSurface)
- {
- Log("vmr9:GetSurface() invalid pointer");
- return E_POINTER;
- }
-
- if (SurfaceIndex >= m_surfaceCount )
- {
- Log("vmr9:GetSurface() invalid SurfaceIndex:%d",SurfaceIndex);
- return E_FAIL;
- }
- *lplpSurface = m_pSurfaces[SurfaceIndex];
- refcnt = m_pSurfaces[SurfaceIndex]->AddRef();
- return S_OK;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify)
-{
- //CAutoLock cAutoLock(this);
-
- Log("vmr9:AdviseNotify()");
- m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
-
- HRESULT hr;
- if(FAILED(hr = m_pIVMRSurfAllocNotify->SetD3DDevice(m_pD3DDev, m_hMonitor)))
- {
- Log("vmr9:AdviseNotify() failed to set d3d device:%x",hr);
- return hr;
- }
- return S_OK;
-}
-
-// IVMRImagePresenter9
-
-STDMETHODIMP CVMR9AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
-{
- //CAutoLock cAutoLock(this);
- //ASSERT(m_pD3DDev);
-
- Log("vmr9:StartPresenting()");
- return m_pD3DDev ? S_OK : E_FAIL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID)
-{
- Log("vmr9:StopPresenting()");
- return S_OK;
-}
-
-
-STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo)
-{
- HRESULT hr;
- static long frameCounter = 0;
- frameCounter++;
-
- if (!m_pIVMRSurfAllocNotify)
- {
- Log("vmr9:PresentImage() allocNotify not set");
- return E_FAIL;
- }
- if (!lpPresInfo || !lpPresInfo->lpSurf)
- {
- Log("vmr9:PresentImage() no surface");
- return E_POINTER;
- }
-
- try
- {
- /*
- if (lpPresInfo->rtStart>previousEndFrame)
- {
- Log("vmr9:Paint() begin:%d", lpPresInfo->rtStart);
- Log(" end: %d",lpPresInfo->rtEnd);
- Log(" prev: %d",previousEndFrame);
- }*/
- previousEndFrame=lpPresInfo->rtEnd;
- //CAutoLock cAutoLock(this);
-
- m_fps = 10000000.0 / (lpPresInfo->rtEnd - lpPresInfo->rtStart);
-
- m_iARX=lpPresInfo->szAspectRatio.cx;
- m_iARY=lpPresInfo->szAspectRatio.cy;
- Paint(lpPresInfo->lpSurf, lpPresInfo->szAspectRatio);
- }
- catch(...)
- {
- Log("vmr9:PresentImage() exception");
- }
- hr = S_OK;
-
- return hr;
-}
-
-void CVMR9AllocatorPresenter::ReleaseCallBack()
-{
- m_pCallback=NULL;
-}
-void CVMR9AllocatorPresenter::DeleteSurfaces()
-{
- Log("vmr9:DeleteSurfaces()");
-
- if (m_pCallback!=NULL)
- {
- m_pCallback->PresentImage(0,0,0,0,0,0);
- }
- if (m_pSurfaces != NULL)
- {
- Log("vmr9:DeleteSurfaces() m_surfaceCount %d",m_surfaceCount);
- for(ULONG i = 0; i < m_surfaceCount; ++i )
- {
- if (m_pSurfaces[i] != NULL)
- {
- ULONG refcnt = m_pSurfaces[i]->Release();
- Log("vmr9:DeleteSurfaces #%d->%d",i,refcnt);
- m_pSurfaces[i] = NULL;
- }
- }
- delete m_pSurfaces;
- m_pSurfaces = NULL;
- }
- CAutoLock cAutoLock(this);
-
-}
-
-void CVMR9AllocatorPresenter::Paint(IDirect3DSurface9* pSurface, SIZE szAspectRatio)
-{
- try
- {
- if (m_pCallback==NULL || pSurface == NULL)
- return;
-
- CComPtr<IDirect3DTexture9> pTexture = NULL;
- pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
- m_pCallback->PresentImage(m_iVideoWidth, m_iVideoHeight, m_iARX,m_iARY, (DWORD)(IDirect3DTexture9*)pTexture, (DWORD)(IDirect3DSurface9*)pSurface);
- }
- catch(...)
- {
- Log("vmr9:Paint() invalid exception");
- }
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::GetNativeVideoSize(
- /* [out] */ LONG *lpWidth,
- /* [out] */ LONG *lpHeight,
- /* [out] */ LONG *lpARWidth,
- /* [out] */ LONG *lpARHeight)
-{
- *lpWidth=m_iVideoWidth;
- *lpHeight=m_iVideoHeight;
- *lpARWidth=m_iARX;
- *lpARHeight=m_iARY;
- return S_OK;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::GetMinIdealVideoSize(
- /* [out] */ LONG *lpWidth,
- /* [out] */ LONG *lpHeight)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::GetMaxIdealVideoSize(
- /* [out] */ LONG *lpWidth,
- /* [out] */ LONG *lpHeight)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::SetVideoPosition(
- /* [in] */ const LPRECT lpSRCRect,
- /* [in] */ const LPRECT lpDSTRect)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::GetVideoPosition(
- /* [out] */ LPRECT lpSRCRect,
- /* [out] */ LPRECT lpDSTRect)
-{
- lpSRCRect->left=0;
- lpSRCRect->top=0;
- lpSRCRect->right=m_iVideoWidth;
- lpSRCRect->bottom=m_iVideoHeight;
-
- lpDSTRect->left=0;
- lpDSTRect->top=0;
- lpDSTRect->right=m_iVideoWidth;
- lpDSTRect->bottom=m_iVideoHeight;
-
- return S_OK;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::GetAspectRatioMode(
- /* [out] */ DWORD *lpAspectRatioMode)
-{
- *lpAspectRatioMode=VMR_ARMODE_NONE;
- return S_OK;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::SetAspectRatioMode(
- /* [in] */ DWORD AspectRatioMode)
-{
- return S_OK;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::SetVideoClippingWindow(
- /* [in] */ HWND hwnd)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::RepaintVideo(
- /* [in] */ HWND hwnd,
- /* [in] */ HDC hdc)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::DisplayModeChanged( void)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::GetCurrentImage(
- /* [out] */ BYTE **lpDib)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::SetBorderColor(
- /* [in] */ COLORREF Clr)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::GetBorderColor(
- /* [out] */ COLORREF *lpClr)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::SetColorKey(
- /* [in] */ COLORREF Clr)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR9AllocatorPresenter::GetColorKey(
- /* [out] */ COLORREF *lpClr)
-{
- if(lpClr) *lpClr = 0;
- return S_OK;
-}
+// Copyright (C) 2005-2010 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+#pragma warning(disable: 4244)
+
+#include <streams.h>
+#include <atlbase.h>
+#include <d3dx9.h>
+#include <vmr9.h>
+
+#include "dx9allocatorpresenter.h"
+
+// For more details for memory leak detection see the alloctracing.h header
+#include "..\..\alloctracing.h"
+
+void Log(const char *fmt, ...) ;
+
+CVMR9AllocatorPresenter::CVMR9AllocatorPresenter(IDirect3DDevice9* direct3dDevice, IVMR9Callback* callback, HMONITOR monitor)
+: m_refCount(1)
+{
+ Log("----------v0.4---------------------------");
+ m_hMonitor = monitor;
+ m_pD3DDev = direct3dDevice;
+ m_pCallback = callback;
+ m_surfaceCount = 0;
+ m_UseOffScreenSurface = false;
+ m_pSurfaces = NULL;
+}
+
+CVMR9AllocatorPresenter::~CVMR9AllocatorPresenter()
+{
+ Log("CVMR9AllocatorPresenter dtor");
+ m_pIVMRSurfAllocNotify = NULL;
+ m_pD3DDev = NULL;
+ Log("CVMR9AllocatorPresenter dtor exit");
+}
+
+void CVMR9AllocatorPresenter::UseOffScreenSurface(bool yesNo)
+{
+ m_UseOffScreenSurface=yesNo;
+}
+
+// IUnknown
+HRESULT CVMR9AllocatorPresenter::QueryInterface(
+ REFIID riid,
+ void** ppvObject)
+{
+ HRESULT hr = E_NOINTERFACE;
+
+ if( ppvObject == NULL )
+ {
+ hr = E_POINTER;
+ }
+ else if (riid == IID_IVMRSurfaceAllocator9)
+ {
+ *ppvObject = static_cast<IVMRSurfaceAllocator9*>(this);
+ AddRef();
+ hr = S_OK;
+ }
+ else if (riid == IID_IVMRImagePresenter9)
+ {
+ *ppvObject = static_cast<IVMRImagePresenter9*>(this);
+ AddRef();
+ hr = S_OK;
+ }
+ else if (riid == IID_IVMRWindowlessControl9)
+ {
+ *ppvObject = static_cast<IVMRWindowlessControl9*>(this);
+ AddRef();
+ hr = S_OK;
+ }
+ else if (riid == IID_IUnknown)
+ {
+ *ppvObject = static_cast<IUnknown*>(static_cast<IVMRSurfaceAllocator9*>(this));
+ AddRef();
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+ULONG CVMR9AllocatorPresenter::AddRef()
+{
+ return InterlockedIncrement(&m_refCount);
+}
+
+ULONG CVMR9AllocatorPresenter::Release()
+{
+ Log("CVMR9AllocatorPresenter::Release()");
+ ULONG ret = InterlockedDecrement(&m_refCount);
+ if( ret == 0 )
+ {
+ Log("CVMR9AllocatorPresenter::Cleanup()");
+ delete this;
+ }
+ return ret;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers)
+{
+ previousEndFrame=0;
+ if(!lpAllocInfo || !lpNumBuffers)
+ return E_POINTER;
+
+ if(!m_pIVMRSurfAllocNotify)
+ return E_FAIL;
+
+ Log("vmr9:InitializeDevice() %dx%d AR %d:%d flags:%d buffers:%d fmt:(%x) %c%c%c%c",
+ lpAllocInfo->dwWidth,lpAllocInfo->dwHeight,
+ lpAllocInfo->szAspectRatio.cx,lpAllocInfo->szAspectRatio.cy,
+ lpAllocInfo->dwFlags,
+ *lpNumBuffers,
+ lpAllocInfo->Format,
+ ((char)lpAllocInfo->Format&0xff),
+ ((char)(lpAllocInfo->Format>>8)&0xff),
+ ((char)(lpAllocInfo->Format>>16)&0xff),
+ ((char)(lpAllocInfo->Format>>24)&0xff));
+ if (m_UseOffScreenSurface)
+ lpAllocInfo->dwFlags =VMR9AllocFlag_OffscreenSurface;
+
+ m_surfaceCount=*lpNumBuffers;
+
+ HRESULT hr;
+
+ m_pSurfaces = new IDirect3DSurface9* [m_surfaceCount];
+
+
+ DWORD dwFlags=lpAllocInfo->dwFlags;
+ Log("vmr9:flags:");
+ if (dwFlags & VMR9AllocFlag_3DRenderTarget) Log("vmr9: 3drendertarget");
+ if (dwFlags & VMR9AllocFlag_DXVATarget) Log("vmr9: DXVATarget");
+ if (dwFlags & VMR9AllocFlag_OffscreenSurface) Log("vmr9: OffscreenSurface");
+ if (dwFlags & VMR9AllocFlag_RGBDynamicSwitch) Log("vmr9: RGBDynamicSwitch");
+ if (dwFlags & VMR9AllocFlag_TextureSurface) Log("vmr9: TextureSurface");
+
+ lpAllocInfo->dwFlags = VMR9AllocFlag_TextureSurface | VMR9AllocFlag_3DRenderTarget;
+ lpAllocInfo->Format = D3DFMT_UNKNOWN;
+
+ hr = m_pIVMRSurfAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, m_pSurfaces);
+ if(FAILED(hr))
+ {
+ Log("vmr9:InitializeDevice() AllocateSurfaceHelper returned:0x%x",hr);
+ return hr;
+ }
+ m_iVideoWidth=lpAllocInfo->dwWidth;
+ m_iVideoHeight=lpAllocInfo->dwHeight;
+ m_iARX=lpAllocInfo->szAspectRatio.cx;
+ m_iARY=lpAllocInfo->szAspectRatio.cy;
+
+ Log("vmr9:InitializeDevice() done()");
+ return hr;
+}
+
+
+STDMETHODIMP CVMR9AllocatorPresenter::TerminateDevice(DWORD_PTR dwUserID)
+{
+ Log("vmr9:TerminateDevice()");
+ DeleteSurfaces();
+ return S_OK;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface)
+{
+ ULONG refcnt;
+ if (!lplpSurface)
+ {
+ Log("vmr9:GetSurface() invalid pointer");
+ return E_POINTER;
+ }
+
+ if (SurfaceIndex >= m_surfaceCount )
+ {
+ Log("vmr9:GetSurface() invalid SurfaceIndex:%d",SurfaceIndex);
+ return E_FAIL;
+ }
+ *lplpSurface = m_pSurfaces[SurfaceIndex];
+ refcnt = m_pSurfaces[SurfaceIndex]->AddRef();
+ return S_OK;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify)
+{
+ //CAutoLock cAutoLock(this);
+
+ Log("vmr9:AdviseNotify()");
+ m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
+
+ HRESULT hr;
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->SetD3DDevice(m_pD3DDev, m_hMonitor)))
+ {
+ Log("vmr9:AdviseNotify() failed to set d3d device:%x",hr);
+ return hr;
+ }
+ return S_OK;
+}
+
+// IVMRImagePresenter9
+
+STDMETHODIMP CVMR9AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
+{
+ //CAutoLock cAutoLock(this);
+ //ASSERT(m_pD3DDev);
+
+ Log("vmr9:StartPresenting()");
+ return m_pD3DDev ? S_OK : E_FAIL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID)
+{
+ Log("vmr9:StopPresenting()");
+ return S_OK;
+}
+
+
+STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo)
+{
+ HRESULT hr;
+ static long frameCounter = 0;
+ frameCounter++;
+
+ if (!m_pIVMRSurfAllocNotify)
+ {
+ Log("vmr9:PresentImage() allocNotify not set");
+ return E_FAIL;
+ }
+ if (!lpPresInfo || !lpPresInfo->lpSurf)
+ {
+ Log("vmr9:PresentImage() no surface");
+ return E_POINTER;
+ }
+
+ try
+ {
+ /*
+ if (lpPresInfo->rtStart>previousEndFrame)
+ {
+ Log("vmr9:Paint() begin:%d", lpPresInfo->rtStart);
+ Log(" end: %d",lpPresInfo->rtEnd);
+ Log(" prev: %d",previousEndFrame);
+ }*/
+ previousEndFrame=lpPresInfo->rtEnd;
+ //CAutoLock cAutoLock(this);
+
+ m_fps = 10000000.0 / (lpPresInfo->rtEnd - lpPresInfo->rtStart);
+
+ m_iARX=lpPresInfo->szAspectRatio.cx;
+ m_iARY=lpPresInfo->szAspectRatio.cy;
+ Paint(lpPresInfo->lpSurf, lpPresInfo->szAspectRatio);
+ }
+ catch(...)
+ {
+ Log("vmr9:PresentImage() exception");
+ }
+ hr = S_OK;
+
+ return hr;
+}
+
+void CVMR9AllocatorPresenter::ReleaseCallBack()
+{
+ m_pCallback=NULL;
+}
+void CVMR9AllocatorPresenter::DeleteSurfaces()
+{
+ Log("vmr9:DeleteSurfaces()");
+
+ if (m_pCallback!=NULL)
+ {
+ m_pCallback->PresentImage(0,0,0,0,0,0);
+ }
+ if (m_pSurfaces != NULL)
+ {
+ Log("vmr9:DeleteSurfaces() m_surfaceCount %d",m_surfaceCount);
+ for(ULONG i = 0; i < m_surfaceCount; ++i )
+ {
+ if (m_pSurfaces[i] != NULL)
+ {
+ ULONG refcnt = m_pSurfaces[i]->Release();
+ Log("vmr9:DeleteSurfaces #%d->%d",i,refcnt);
+ m_pSurfaces[i] = NULL;
+ }
+ }
+ delete m_pSurfaces;
+ m_pSurfaces = NULL;
+ }
+ CAutoLock cAutoLock(this);
+
+}
+
+void CVMR9AllocatorPresenter::Paint(IDirect3DSurface9* pSurface, SIZE szAspectRatio)
+{
+ try
+ {
+ if (m_pCallback==NULL || pSurface == NULL)
+ return;
+
+ CComPtr<IDirect3DTexture9> pTexture = NULL;
+ pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
+ m_pCallback->PresentImage(m_iVideoWidth, m_iVideoHeight, m_iARX,m_iARY, (DWORD)(IDirect3DTexture9*)pTexture, (DWORD)(IDirect3DSurface9*)pSurface);
+ }
+ catch(...)
+ {
+ Log("vmr9:Paint() invalid exception");
+ }
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::GetNativeVideoSize(
+ /* [out] */ LONG *lpWidth,
+ /* [out] */ LONG *lpHeight,
+ /* [out] */ LONG *lpARWidth,
+ /* [out] */ LONG *lpARHeight)
+{
+ *lpWidth=m_iVideoWidth;
+ *lpHeight=m_iVideoHeight;
+ *lpARWidth=m_iARX;
+ *lpARHeight=m_iARY;
+ return S_OK;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::GetMinIdealVideoSize(
+ /* [out] */ LONG *lpWidth,
+ /* [out] */ LONG *lpHeight)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::GetMaxIdealVideoSize(
+ /* [out] */ LONG *lpWidth,
+ /* [out] */ LONG *lpHeight)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::SetVideoPosition(
+ /* [in] */ const LPRECT lpSRCRect,
+ /* [in] */ const LPRECT lpDSTRect)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::GetVideoPosition(
+ /* [out] */ LPRECT lpSRCRect,
+ /* [out] */ LPRECT lpDSTRect)
+{
+ lpSRCRect->left=0;
+ lpSRCRect->top=0;
+ lpSRCRect->right=m_iVideoWidth;
+ lpSRCRect->bottom=m_iVideoHeight;
+
+ lpDSTRect->left=0;
+ lpDSTRect->top=0;
+ lpDSTRect->right=m_iVideoWidth;
+ lpDSTRect->bottom=m_iVideoHeight;
+
+ return S_OK;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::GetAspectRatioMode(
+ /* [out] */ DWORD *lpAspectRatioMode)
+{
+ *lpAspectRatioMode=VMR_ARMODE_NONE;
+ return S_OK;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::SetAspectRatioMode(
+ /* [in] */ DWORD AspectRatioMode)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::SetVideoClippingWindow(
+ /* [in] */ HWND hwnd)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::RepaintVideo(
+ /* [in] */ HWND hwnd,
+ /* [in] */ HDC hdc)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::DisplayModeChanged( void)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::GetCurrentImage(
+ /* [out] */ BYTE **lpDib)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::SetBorderColor(
+ /* [in] */ COLORREF Clr)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::GetBorderColor(
+ /* [out] */ COLORREF *lpClr)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::SetColorKey(
+ /* [in] */ COLORREF Clr)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR9AllocatorPresenter::GetColorKey(
+ /* [out] */ COLORREF *lpClr)
+{
+ if(lpClr) *lpClr = 0;
+ return S_OK;
+}
View
278 ...ShowHelper/source/DX9AllocatorPresenter.h → ...ShowHelper/source/DX9AllocatorPresenter.h
@@ -1,139 +1,139 @@
-// Copyright (C) 2005-2010 Team MediaPortal
-// http://www.team-mediaportal.com
-//
-// MediaPortal is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 2 of the License, or
-// (at your option) any later version.
-//
-// MediaPortal is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
-
-#pragma once
-
-#pragma warning(push, 2)
-#pragma warning(disable : 4995)
-
-#include <vector>
-#include "callback.h"
-
-#pragma warning(pop)
-using namespace std;
-
-
-class CVMR9AllocatorPresenter
- : public CCritSec
- , public IVMRSurfaceAllocator9
- , public IVMRImagePresenter9
- , public IVMRWindowlessControl9
-{
-
-public:
- CVMR9AllocatorPresenter(IDirect3DDevice9* direct3dDevice,IVMR9Callback* callback,HMONITOR monitor);
- virtual ~CVMR9AllocatorPresenter();
- void UseOffScreenSurface(bool yesNo);
-
- // IVMRSurfaceAllocator9
- virtual HRESULT STDMETHODCALLTYPE InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers);
- virtual HRESULT STDMETHODCALLTYPE TerminateDevice(DWORD_PTR dwID);
- virtual HRESULT STDMETHODCALLTYPE GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface);
- virtual HRESULT STDMETHODCALLTYPE AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify);
-
- // IVMRImagePresenter9
- virtual HRESULT STDMETHODCALLTYPE StartPresenting(DWORD_PTR dwUserID);
- virtual HRESULT STDMETHODCALLTYPE StopPresenting(DWORD_PTR dwUserID);
- virtual HRESULT STDMETHODCALLTYPE PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo);
-
- //IVMRWindowlessControl
- virtual HRESULT STDMETHODCALLTYPE GetNativeVideoSize(
- /* [out] */ LONG *lpWidth,
- /* [out] */ LONG *lpHeight,
- /* [out] */ LONG *lpARWidth,
- /* [out] */ LONG *lpARHeight) ;
-
- virtual HRESULT STDMETHODCALLTYPE GetMinIdealVideoSize(
- /* [out] */ LONG *lpWidth,
- /* [out] */ LONG *lpHeight) ;
-
- virtual HRESULT STDMETHODCALLTYPE GetMaxIdealVideoSize(
- /* [out] */ LONG *lpWidth,
- /* [out] */ LONG *lpHeight) ;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoPosition(
- /* [in] */ const LPRECT lpSRCRect,
- /* [in] */ const LPRECT lpDSTRect) ;
-
- virtual HRESULT STDMETHODCALLTYPE GetVideoPosition(
- /* [out] */ LPRECT lpSRCRect,
- /* [out] */ LPRECT lpDSTRect) ;
-
- virtual HRESULT STDMETHODCALLTYPE GetAspectRatioMode(
- /* [out] */ DWORD *lpAspectRatioMode) ;
-
- virtual HRESULT STDMETHODCALLTYPE SetAspectRatioMode(
- /* [in] */ DWORD AspectRatioMode) ;
-
- virtual HRESULT STDMETHODCALLTYPE SetVideoClippingWindow(
- /* [in] */ HWND hwnd) ;
-
- virtual HRESULT STDMETHODCALLTYPE RepaintVideo(
- /* [in] */ HWND hwnd,
- /* [in] */ HDC hdc) ;
-
- virtual HRESULT STDMETHODCALLTYPE DisplayModeChanged( void) ;
-
- virtual HRESULT STDMETHODCALLTYPE GetCurrentImage(
- /* [out] */ BYTE **lpDib) ;
-
- virtual HRESULT STDMETHODCALLTYPE SetBorderColor(
- /* [in] */ COLORREF Clr) ;
-
- virtual HRESULT STDMETHODCALLTYPE GetBorderColor(
- /* [out] */ COLORREF *lpClr) ;
-
- virtual HRESULT STDMETHODCALLTYPE SetColorKey(
- /* [in] */ COLORREF Clr) ;
-
- virtual HRESULT STDMETHODCALLTYPE GetColorKey(
- /* [out] */ COLORREF *lpClr) ;
- // IUnknown
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(
- REFIID riid,
- void** ppvObject);
-
- virtual ULONG STDMETHODCALLTYPE AddRef();
- virtual ULONG STDMETHODCALLTYPE Release();
- void DrawTexture(FLOAT fx, FLOAT fy, FLOAT nw, FLOAT nh, FLOAT uoff, FLOAT voff, FLOAT umax, FLOAT vmax, long color);
- void ReleaseCallBack();
-
-protected:
- void Paint(IDirect3DSurface9* pSurface,SIZE aspecRatio);
- void DeleteSurfaces();
- HRESULT AllocVideoSurface();
-
- CComPtr<IVMRSurfaceAllocatorNotify9> m_pIVMRSurfAllocNotify;
-
- CComPtr<IDirect3DDevice9> m_pD3DDev;
- CComPtr<IDirect3D9> m_pD3D;
- IDirect3DSurface9** m_pSurfaces;
-
- long m_refCount;
- DWORD m_surfaceCount;
- HMONITOR m_hMonitor;
- IVMR9Callback* m_pCallback;
- int m_iVideoWidth, m_iVideoHeight;
- int m_iARX, m_iARY;
- //CRect m_WindowRect;
- //CRect m_VideoRect;
- bool m_fVMRSyncFix;
- double m_fps ;
- long previousEndFrame;
- D3DTEXTUREFILTERTYPE m_Filter;
- bool m_bfirstFrame;
- bool m_UseOffScreenSurface;
-};
+// Copyright (C) 2005-2010 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+#pragma once
+
+#pragma warning(push, 2)
+#pragma warning(disable : 4995)
+
+#include <vector>
+#include "callback.h"
+
+#pragma warning(pop)
+using namespace std;
+
+
+class CVMR9AllocatorPresenter
+ : public CCritSec
+ , public IVMRSurfaceAllocator9
+ , public IVMRImagePresenter9
+ , public IVMRWindowlessControl9
+{
+
+public:
+ CVMR9AllocatorPresenter(IDirect3DDevice9* direct3dDevice,IVMR9Callback* callback,HMONITOR monitor);
+ virtual ~CVMR9AllocatorPresenter();
+ void UseOffScreenSurface(bool yesNo);
+
+ // IVMRSurfaceAllocator9
+ virtual HRESULT STDMETHODCALLTYPE InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers);
+ virtual HRESULT STDMETHODCALLTYPE TerminateDevice(DWORD_PTR dwID);
+ virtual HRESULT STDMETHODCALLTYPE GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface);
+ virtual HRESULT STDMETHODCALLTYPE AdviseNotify(IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify);
+
+ // IVMRImagePresenter9
+ virtual HRESULT STDMETHODCALLTYPE StartPresenting(DWORD_PTR dwUserID);
+ virtual HRESULT STDMETHODCALLTYPE StopPresenting(DWORD_PTR dwUserID);
+ virtual HRESULT STDMETHODCALLTYPE PresentImage(DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo);
+
+ //IVMRWindowlessControl
+ virtual HRESULT STDMETHODCALLTYPE GetNativeVideoSize(
+ /* [out] */ LONG *lpWidth,
+ /* [out] */ LONG *lpHeight,
+ /* [out] */ LONG *lpARWidth,
+ /* [out] */ LONG *lpARHeight) ;
+
+ virtual HRESULT STDMETHODCALLTYPE GetMinIdealVideoSize(
+ /* [out] */ LONG *lpWidth,
+ /* [out] */ LONG *lpHeight) ;
+
+ virtual HRESULT STDMETHODCALLTYPE GetMaxIdealVideoSize(
+ /* [out] */ LONG *lpWidth,
+ /* [out] */ LONG *lpHeight) ;
+
+ virtual HRESULT STDMETHODCALLTYPE SetVideoPosition(
+ /* [in] */ const LPRECT lpSRCRect,
+ /* [in] */ const LPRECT lpDSTRect) ;
+
+ virtual HRESULT STDMETHODCALLTYPE GetVideoPosition(
+ /* [out] */ LPRECT lpSRCRect,
+ /* [out] */ LPRECT lpDSTRect) ;
+
+ virtual HRESULT STDMETHODCALLTYPE GetAspectRatioMode(
+ /* [out] */ DWORD *lpAspectRatioMode) ;
+
+ virtual HRESULT STDMETHODCALLTYPE SetAspectRatioMode(
+ /* [in] */ DWORD AspectRatioMode) ;
+
+ virtual HRESULT STDMETHODCALLTYPE SetVideoClippingWindow(
+ /* [in] */ HWND hwnd) ;
+
+ virtual HRESULT STDMETHODCALLTYPE RepaintVideo(
+ /* [in] */ HWND hwnd,
+ /* [in] */ HDC hdc) ;
+
+ virtual HRESULT STDMETHODCALLTYPE DisplayModeChanged( void) ;
+
+ virtual HRESULT STDMETHODCALLTYPE GetCurrentImage(
+ /* [out] */ BYTE **lpDib) ;
+
+ virtual HRESULT STDMETHODCALLTYPE SetBorderColor(
+ /* [in] */ COLORREF Clr) ;
+
+ virtual HRESULT STDMETHODCALLTYPE GetBorderColor(
+ /* [out] */ COLORREF *lpClr) ;
+
+ virtual HRESULT STDMETHODCALLTYPE SetColorKey(
+ /* [in] */ COLORREF Clr) ;
+
+ virtual HRESULT STDMETHODCALLTYPE GetColorKey(
+ /* [out] */ COLORREF *lpClr) ;
+ // IUnknown
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(
+ REFIID riid,
+ void** ppvObject);
+
+ virtual ULONG STDMETHODCALLTYPE AddRef();
+ virtual ULONG STDMETHODCALLTYPE Release();
+ void DrawTexture(FLOAT fx, FLOAT fy, FLOAT nw, FLOAT nh, FLOAT uoff, FLOAT voff, FLOAT umax, FLOAT vmax, long color);
+ void ReleaseCallBack();
+
+protected:
+ void Paint(IDirect3DSurface9* pSurface,SIZE aspecRatio);
+ void DeleteSurfaces();
+ HRESULT AllocVideoSurface();
+
+ CComPtr<IVMRSurfaceAllocatorNotify9> m_pIVMRSurfAllocNotify;
+
+ CComPtr<IDirect3DDevice9> m_pD3DDev;
+ CComPtr<IDirect3D9> m_pD3D;
+ IDirect3DSurface9** m_pSurfaces;
+
+ long m_refCount;
+ DWORD m_surfaceCount;
+ HMONITOR m_hMonitor;
+ IVMR9Callback* m_pCallback;
+ int m_iVideoWidth, m_iVideoHeight;
+ int m_iARX, m_iARY;
+ //CRect m_WindowRect;
+ //CRect m_VideoRect;
+ bool m_fVMRSyncFix;
+ double m_fps ;
+ long previousEndFrame;
+ D3DTEXTUREFILTERTYPE m_Filter;
+ bool m_bfirstFrame;
+ bool m_UseOffScreenSurface;
+};
View
2 ...tShowHelper/source/EVRCustomPresenter.cpp → ...tShowHelper/source/EVRCustomPresenter.cpp
@@ -2131,7 +2131,7 @@ HRESULT STDMETHODCALLTYPE MPEVRCustomPresenter::ProcessMessage(MFVP_MESSAGE_TYPE
case MFVP_MESSAGE_STEP:
// Requests a frame step. The lower DWORD of the ulParam parameter contains the number of frames to step.
- // If the value is N, the presenter should skip N –1 frames and display the N th frame. When that frame
+ // If the value is N, the presenter should skip N ?1 frames and display the N th frame. When that frame
// has been displayed, the presenter should send an EC_STEP_COMPLETE event to the EVR. If the presenter
// is not paused when it receives this message, it should return MF_E_INVALIDREQUEST.
Log("ProcessMessage MFVP_MESSAGE_STEP");
View
0 ...ectShowHelper/source/EVRCustomPresenter.h → ...ectShowHelper/source/EVRCustomPresenter.h
File renamed without changes.
View
800 ...p/DirectShowHelper/source/GrabBitmaps.cpp → ...s/DirectShowHelper/source/GrabBitmaps.cpp
@@ -1,400 +1,400 @@
-// Copyright (C) 2005-2010 Team MediaPortal
-// http://www.team-mediaportal.com
-//
-// MediaPortal is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 2 of the License, or
-// (at your option) any later version.
-//
-// MediaPortal is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
-
-#pragma warning(disable: 4244 4996)
-
-#include <streams.h>
-#include <atlbase.h>
-#pragma include_alias( "dxtrans.h", "qedit.h" )
-#define __IDxtCompositor_INTERFACE_DEFINED__
-#define __IDxtAlphaSetter_INTERFACE_DEFINED__
-#define __IDxtJpeg_INTERFACE_DEFINED__
-#define __IDxtKey_INTERFACE_DEFINED__
-#include "qedit.h"
-
-// For more details for memory leak detection see the alloctracing.h header
-#include "..\..\alloctracing.h"
-
-// Function prototypes
-int GrabBitmaps(TCHAR * szFile);
-HRESULT GetPin(IBaseFilter * pFilter, PIN_DIRECTION dirrequired, int iNum, IPin **ppPin);
-IPin * GetInPin ( IBaseFilter *pFilter, int Num );
-IPin * GetOutPin( IBaseFilter *pFilter, int Num );
-
-// Constants
-#define NUM_FRAMES_TO_GRAB 1
-
-extern void Log(const char *fmt, ...) ;
-
-//
-// Implementation of CSampleGrabberCB object
-//
-// Note: this object is a SEMI-COM object, and can only be created statically.
-
-class CSampleGrabberCB : public ISampleGrabberCB
-{
-
-public:
-
- // These will get set by the main thread below. We need to
- // know this in order to write out the bmp
- long Width;
- long Height;
-
- // Fake out any COM ref counting
- //
- STDMETHODIMP_(ULONG) AddRef() { return 2; }
- STDMETHODIMP_(ULONG) Release() { return 1; }
-
- // Fake out any COM QI'ing
- //
- STDMETHODIMP QueryInterface(REFIID riid, void ** ppv)
- {
- CheckPointer(ppv,E_POINTER);
-
- if( riid == IID_ISampleGrabberCB || riid == IID_IUnknown )
- {
- *ppv = (void *) static_cast<ISampleGrabberCB*> ( this );
- return NOERROR;
- }
-
- return E_NOINTERFACE;
- }
-
-
- // We don't implement this one
- //
- STDMETHODIMP SampleCB( double SampleTime, IMediaSample * pSample )
- {
- return 0;
- }
-
-
- // The sample grabber is calling us back on its deliver thread.
- // This is NOT the main app thread!
- //
- STDMETHODIMP BufferCB( double SampleTime, BYTE * pBuffer, long BufferSize )
- {
- try
- {
- Log("grab:callback");
- //
- // Convert the buffer into a bitmap
- //
- TCHAR szFilename[MAX_PATH];
- _tcscpy(szFilename, _T("temp.bmp"));
- DeleteFile(szFilename);
- // Create a file to hold the bitmap
- HANDLE hf = CreateFile(szFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL );
-
- if( hf == INVALID_HANDLE_VALUE )
- {
- return 0;
- }
-
- Log("grab:Found a sample at time %ld ms\t[%s]", long( SampleTime * 1000 ), szFilename );
-
- // Write out the file header
- //
- BITMAPFILEHEADER bfh;
- memset( &bfh, 0, sizeof( bfh ) );
- bfh.bfType = 'MB';
- bfh.bfSize = sizeof( bfh ) + BufferSize + sizeof( BITMAPINFOHEADER );
- bfh.bfOffBits = sizeof( BITMAPINFOHEADER ) + sizeof( BITMAPFILEHEADER );
-
- DWORD Written = 0;
- WriteFile( hf, &bfh, sizeof( bfh ), &Written, NULL );
-
- // Write the bitmap format
- //
- BITMAPINFOHEADER bih;
- memset( &bih, 0, sizeof( bih ) );
- bih.biSize = sizeof( bih );
- bih.biWidth = Width;
- bih.biHeight = Height;
- bih.biPlanes = 1;
- bih.biBitCount = 24;
-
- Written = 0;
- WriteFile( hf, &bih, sizeof( bih ), &Written, NULL );
-
- // Write the bitmap bits
- //
- Written = 0;
- WriteFile( hf, pBuffer, BufferSize, &Written, NULL );
-
- CloseHandle( hf );
- }
- catch(...)
- {
- Log("grab:bufferCb: exception");
- }
- return 0;
- }
-};
-
-
-
-
-int GrabBitmaps(TCHAR * szFile )
-{
- try
- {
- USES_CONVERSION;
- CComPtr< ISampleGrabber > pGrabber;
- CComPtr< IBaseFilter > pSource;
- CComPtr< IGraphBuilder > pGraph;
- CComPtr< IVideoWindow > pVideoWindow;
- HRESULT hr;
-
- if (!szFile)
- return -1;
-
- Log("grab: bitmaps from %s.", szFile);
-
- // Create the sample grabber
- //
- pGrabber.CoCreateInstance( CLSID_SampleGrabber );
- if( !pGrabber )
- {
- Log("grab:Could not create CLSID_SampleGrabber" );
- return -1;
- }
- CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabberBase( pGrabber );
-
- // Create the file reader
- //
- pSource.CoCreateInstance( CLSID_StreamBufferSource );//CLSID_AsyncReader
- if( !pSource )
- {
- Log("grab:Could not create source filter") ;
- return -1;
- }
-
- // Create the graph
- //
- pGraph.CoCreateInstance( CLSID_FilterGraph );
- if( !pGraph )
- {
- Log("grab:Could not not create the graph" );
- return -1;
- }
-
-// hr = AddGraphToRot(pGraph, &g_dwGraphRegister);
- // Put them in the graph
- //
- hr = pGraph->AddFilter( pSource, L"Source" );
- if (!SUCCEEDED(hr))
- {
- Log("grab:Could add streambuffersource to grab" );
- }
- hr = pGraph->AddFilter( pGrabberBase, L"Grabber" );
-
- if (!SUCCEEDED(hr))
- {
- Log("grab:Could add samplegrabber to grab" );
- }
- // Load the source
- //
- CComQIPtr< IFileSourceFilter, &IID_IFileSourceFilter > pLoad( pSource );
- hr = pLoad->Load( T2W( szFile ), NULL );
- if( FAILED( hr ) )
- {
- Log("grab:Could not load the media file") ;
- return -1;
- }
-
- // Tell the grabber to grab 24-bit video. Must do this
- // before connecting it
- //
- CMediaType GrabType;
- GrabType.SetType( &MEDIATYPE_Video );
- GrabType.SetSubtype( &MEDIASUBTYPE_RGB24);//&MEDIASUBTYPE_RGB24 );
- hr = pGrabber->SetMediaType( &GrabType );
-
- if (!SUCCEEDED(hr))
- {
- Log("grab:Could set media type on samplegrabber" );
- }
- // Get the output pin and the input pin
- //
- CComPtr< IPin > pSourcePin;
- CComPtr< IPin > pGrabPin;
-
- pSourcePin = GetOutPin( pSource, 1 );
- pGrabPin = GetInPin( pGrabberBase, 0 );
-
- // ... and connect them
- //
- hr = pGraph->Connect( pSourcePin, pGrabPin );
- if( FAILED( hr ) )
- {
- Log("grab:Could not connect source filter to grabber" );
- return -1;
- }
-
- // This semi-COM object will receive sample callbacks for us
- //
- CSampleGrabberCB CB;
-
- // Ask for the connection media type so we know its size
- //
- AM_MEDIA_TYPE mt;
- hr = pGrabber->GetConnectedMediaType( &mt );
-
- VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
- CB.Width = vih->bmiHeader.biWidth;
- CB.Height = vih->bmiHeader.biHeight;
- FreeMediaType( mt );
-
- // Render the grabber output pin (to a video renderer)
- //
- CComPtr <IPin> pGrabOutPin = GetOutPin( pGrabberBase, 0 );
- hr = pGraph->Render( pGrabOutPin );
- if( FAILED( hr ) )
- {
- Log("grab:Could not render grabber output pin" );
- return -1;
- }
-
- // Don't buffer the samples as they pass through
- //
- hr = pGrabber->SetBufferSamples( FALSE );
-
- // Only grab one at a time, stop stream after
- // grabbing one sample
- //
- hr = pGrabber->SetOneShot( TRUE );
-
- // Set the callback, so we can grab the one sample
- //
- hr = pGrabber->SetCallback( &CB, 1 );
-
- // Get the seeking interface, so we can seek to a location
- //
- CComQIPtr< IMediaSeeking, &IID_IMediaSeeking > pSeeking( pGraph );
-
- // Query the graph for the IVideoWindow interface and use it to
- // disable AutoShow. This will prevent the ActiveMovie window from
- // being displayed while we grab bitmaps from the running movie.
- CComQIPtr< IVideoWindow, &IID_IVideoWindow > pWindow = pGraph;
- if (pWindow)
- {
- hr = pWindow->put_AutoShow(OAFALSE);
- }
-
- // Find a limited number of frames
- //
-
- CComQIPtr< IMediaFilter, &IID_IMediaFilter > mediaFilt( pGraph );
- mediaFilt->SetSyncSource(NULL);
- // for( int i = 0 ; i < NUM_FRAMES_TO_GRAB ; i++ )
- {
-
-
- Log("grab:seek.");
- REFERENCE_TIME Start = (30) * UNITS;
-
- // set position
- LONGLONG duration;
- pSeeking->GetDuration(&duration);
- if ( duration > (10*60*UNITS) )
- Start = (10*60*UNITS) ;
-
- hr = pSeeking->SetPositions( &Start, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning );
-
- Log("grab:run.");
- // activate the threads
- CComQIPtr< IMediaControl, &IID_IMediaControl > pControl( pGraph );
- hr = pControl->Run( );
-
- Log("grab:wait.");
- // wait for the graph to settle
- CComQIPtr< IMediaEvent, &IID_IMediaEvent > pEvent( pGraph );
- long EvCode = 0;
-
- // 15 sec timeout
- hr = pEvent->WaitForCompletion( 15*1000, &EvCode );
-
- Log("grab:done.");
- // callback wrote the sample
- pControl->Stop();
- }
-
- Log("Sample grabbing complete.");
- }
- catch(...)
- {
- Log("grab:exception.");
- }
- return 0;
-}
-
-
-HRESULT GetPin( IBaseFilter * pFilter, PIN_DIRECTION dirrequired, int iNum, IPin **ppPin)
-{
- CComPtr< IEnumPins > pEnum;
- *ppPin = NULL;
-
- HRESULT hr = pFilter->EnumPins(&pEnum);
- if(FAILED(hr))
- return hr;
-
- ULONG ulFound;
- IPin *pPin;
- hr = E_FAIL;
-
- while(S_OK == pEnum->Next(1, &pPin, &ulFound))
- {
- PIN_DIRECTION pindir = (PIN_DIRECTION)3;
-
- pPin->QueryDirection(&pindir);
- if(pindir == dirrequired)
- {
- if(iNum == 0)
- {
- *ppPin = pPin; // Return the pin's interface
- hr = S_OK; // Found requested pin, so clear error
- break;
- }
- iNum--;
- }
-
- pPin->Release();
- }
-
- return hr;
-}
-
-
-IPin * GetInPin( IBaseFilter * pFilter, int nPin )
-{
- CComPtr<IPin> pComPin=0;
- GetPin(pFilter, PINDIR_INPUT, nPin, &pComPin);
- return pComPin;
-}
-
-
-IPin * GetOutPin( IBaseFilter * pFilter, int nPin )
-{
- CComPtr<IPin> pComPin=0;
- GetPin(pFilter, PINDIR_OUTPUT, nPin, &pComPin);
- return pComPin;
-}
-
-
-
-
+// Copyright (C) 2005-2010 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+#pragma warning(disable: 4244 4996)
+
+#include <streams.h>
+#include <atlbase.h>
+#pragma include_alias( "dxtrans.h", "qedit.h" )
+#define __IDxtCompositor_INTERFACE_DEFINED__
+#define __IDxtAlphaSetter_INTERFACE_DEFINED__
+#define __IDxtJpeg_INTERFACE_DEFINED__
+#define __IDxtKey_INTERFACE_DEFINED__
+#include "qedit.h"
+
+// For more details for memory leak detection see the alloctracing.h header
+#include "..\..\alloctracing.h"
+
+// Function prototypes
+int GrabBitmaps(TCHAR * szFile);
+HRESULT GetPin(IBaseFilter * pFilter, PIN_DIRECTION dirrequired, int iNum, IPin **ppPin);
+IPin * GetInPin ( IBaseFilter *pFilter, int Num );
+IPin * GetOutPin( IBaseFilter *pFilter, int Num );
+
+// Constants
+#define NUM_FRAMES_TO_GRAB 1
+
+extern void Log(const char *fmt, ...) ;
+
+//
+// Implementation of CSampleGrabberCB object
+//
+// Note: this object is a SEMI-COM object, and can only be created statically.
+
+class CSampleGrabberCB : public ISampleGrabberCB
+{
+
+public:
+
+ // These will get set by the main thread below. We need to
+ // know this in order to write out the bmp
+ long Width;
+ long Height;
+
+ // Fake out any COM ref counting
+ //
+ STDMETHODIMP_(ULONG) AddRef() { return 2; }
+ STDMETHODIMP_(ULONG) Release() { return 1; }
+
+ // Fake out any COM QI'ing
+ //
+ STDMETHODIMP QueryInterface(REFIID riid, void ** ppv)
+ {
+ CheckPointer(ppv,E_POINTER);
+
+ if( riid == IID_ISampleGrabberCB || riid == IID_IUnknown )
+ {
+ *ppv = (void *) static_cast<ISampleGrabberCB*> ( this );
+ return NOERROR;
+ }
+
+ return E_NOINTERFACE;
+ }
+
+
+ // We don't implement this one
+ //
+ STDMETHODIMP SampleCB( double SampleTime, IMediaSample * pSample )
+ {
+ return 0;
+ }
+
+
+ // The sample grabber is calling us back on its deliver thread.
+ // This is NOT the main app thread!
+ //
+ STDMETHODIMP BufferCB( double SampleTime, BYTE * pBuffer, long BufferSize )
+ {
+ try
+ {
+ Log("grab:callback");
+ //
+ // Convert the buffer into a bitmap
+ //
+ TCHAR szFilename[MAX_PATH];
+ _tcscpy(szFilename, _T("temp.bmp"));
+ DeleteFile(szFilename);
+ // Create a file to hold the bitmap
+ HANDLE hf = CreateFile(szFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL );
+
+ if( hf == INVALID_HANDLE_VALUE )
+ {
+ return 0;
+ }
+
+ Log("grab:Found a sample at time %ld ms\t[%s]", long( SampleTime * 1000 ), szFilename );
+
+ // Write out the file header
+ //
+ BITMAPFILEHEADER bfh;
+ memset( &bfh, 0, sizeof( bfh ) );
+ bfh.bfType = 'MB';
+ bfh.bfSize = sizeof( bfh ) + BufferSize + sizeof( BITMAPINFOHEADER );
+ bfh.bfOffBits = sizeof( BITMAPINFOHEADER ) + sizeof( BITMAPFILEHEADER );
+
+ DWORD Written = 0;
+ WriteFile( hf, &bfh, sizeof( bfh ), &Written, NULL );
+
+ // Write the bitmap format
+ //
+ BITMAPINFOHEADER bih;
+ memset( &bih, 0, sizeof( bih ) );
+ bih.biSize = sizeof( bih );
+ bih.biWidth = Width;
+ bih.biHeight = Height;
+ bih.biPlanes = 1;
+ bih.biBitCount = 24;
+
+ Written = 0;
+ WriteFile( hf, &bih, sizeof( bih ), &Written, NULL );
+
+ // Write the bitmap bits
+ //
+ Written = 0;
+ WriteFile( hf, pBuffer, BufferSize, &Written, NULL );
+
+ CloseHandle( hf );
+ }
+ catch(...)
+ {
+ Log("grab:bufferCb: exception");
+ }
+ return 0;
+ }
+};
+
+
+
+
+int GrabBitmaps(TCHAR * szFile )
+{
+ try
+ {
+ USES_CONVERSION;
+ CComPtr< ISampleGrabber > pGrabber;
+ CComPtr< IBaseFilter > pSource;
+ CComPtr< IGraphBuilder > pGraph;
+ CComPtr< IVideoWindow > pVideoWindow;
+ HRESULT hr;
+
+ if (!szFile)
+ return -1;
+
+ Log("grab: bitmaps from %s.", szFile);
+
+ // Create the sample grabber
+ //
+ pGrabber.CoCreateInstance( CLSID_SampleGrabber );
+ if( !pGrabber )
+ {
+ Log("grab:Could not create CLSID_SampleGrabber" );
+ return -1;
+ }
+ CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabberBase( pGrabber );
+
+ // Create the file reader
+ //
+ pSource.CoCreateInstance( CLSID_StreamBufferSource );//CLSID_AsyncReader
+ if( !pSource )
+ {
+ Log("grab:Could not create source filter") ;
+ return -1;
+ }
+
+ // Create the graph
+ //
+ pGraph.CoCreateInstance( CLSID_FilterGraph );
+ if( !pGraph )
+ {
+ Log("grab:Could not not create the graph" );
+ return -1;
+ }
+
+// hr = AddGraphToRot(pGraph, &g_dwGraphRegister);
+ // Put them in the graph
+ //
+ hr = pGraph->AddFilter( pSource, L"Source" );
+ if (!SUCCEEDED(hr))
+ {
+ Log("grab:Could add streambuffersource to grab" );
+ }
+ hr = pGraph->AddFilter( pGrabberBase, L"Grabber" );
+
+ if (!SUCCEEDED(hr))
+ {
+ Log("grab:Could add samplegrabber to grab" );
+ }
+ // Load the source
+ //
+ CComQIPtr< IFileSourceFilter, &IID_IFileSourceFilter > pLoad( pSource );
+ hr = pLoad->Load( T2W( szFile ), NULL );
+ if( FAILED( hr ) )
+ {
+ Log("grab:Could not load the media file") ;
+ return -1;
+ }
+
+ // Tell the grabber to grab 24-bit video. Must do this
+ // before connecting it
+ //
+ CMediaType GrabType;
+ GrabType.SetType( &MEDIATYPE_Video );
+ GrabType.SetSubtype( &MEDIASUBTYPE_RGB24);//&MEDIASUBTYPE_RGB24 );
+ hr = pGrabber->SetMediaType( &GrabType );
+
+ if (!SUCCEEDED(hr))
+ {
+ Log("grab:Could set media type on samplegrabber" );
+ }
+ // Get the output pin and the input pin
+ //
+ CComPtr< IPin > pSourcePin;
+ CComPtr< IPin > pGrabPin;
+
+ pSourcePin = GetOutPin( pSource, 1 );
+ pGrabPin = GetInPin( pGrabberBase, 0 );
+
+ // ... and connect them
+ //
+ hr = pGraph->Connect( pSourcePin, pGrabPin );
+ if( FAILED( hr ) )
+ {
+ Log("grab:Could not connect source filter to grabber" );
+ return -1;
+ }
+
+ // This semi-COM object will receive sample callbacks for us
+ //
+ CSampleGrabberCB CB;
+
+ // Ask for the connection media type so we know its size
+ //
+ AM_MEDIA_TYPE mt;
+ hr = pGrabber->GetConnectedMediaType( &mt );
+
+ VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
+ CB.Width = vih->bmiHeader.biWidth;
+ CB.Height = vih->bmiHeader.biHeight;
+ FreeMediaType( mt );
+
+ // Render the grabber output pin (to a video renderer)
+ //
+ CComPtr <IPin> pGrabOutPin = GetOutPin( pGrabberBase, 0 );
+ hr = pGraph->Render( pGrabOutPin );
+ if( FAILED( hr ) )
+ {
+ Log("grab:Could not render grabber output pin" );
+ return -1;
+ }
+
+ // Don't buffer the samples as they pass through
+ //
+ hr = pGrabber->SetBufferSamples( FALSE );
+
+ // Only grab one at a time, stop stream after
+ // grabbing one sample
+ //
+ hr = pGrabber->SetOneShot( TRUE );
+
+ // Set the callback, so we can grab the one sample
+ //
+ hr = pGrabber->SetCallback( &CB, 1 );
+
+ // Get the seeking interface, so we can seek to a location
+ //
+ CComQIPtr< IMediaSeeking, &IID_IMediaSeeking > pSeeking( pGraph );
+
+ // Query the graph for the IVideoWindow interface and use it to
+ // disable AutoShow. This will prevent the ActiveMovie window from
+ // being displayed while we grab bitmaps from the running movie.
+ CComQIPtr< IVideoWindow, &IID_IVideoWindow > pWindow = pGraph;
+ if (pWindow)
+ {
+ hr = pWindow->put_AutoShow(OAFALSE);
+ }
+
+ // Find a limited number of frames
+ //
+
+ CComQIPtr< IMediaFilter, &IID_IMediaFilter > mediaFilt( pGraph );
+ mediaFilt->SetSyncSource(NULL);
+ // for( int i = 0 ; i < NUM_FRAMES_TO_GRAB ; i++ )
+ {
+
+
+ Log("grab:seek.");
+ REFERENCE_TIME Start = (30) * UNITS;
+
+ // set position
+ LONGLONG duration;
+ pSeeking->GetDuration(&duration);
+ if ( duration > (10*60*UNITS) )
+ Start = (10*60*UNITS) ;
+
+ hr = pSeeking->SetPositions( &Start, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning );
+
+ Log("grab:run.");
+ // activate the threads
+ CComQIPtr< IMediaControl, &IID_IMediaControl > pControl( pGraph );
+ hr = pControl->Run( );
+
+ Log("grab:wait.");
+ // wait for the graph to settle
+ CComQIPtr< IMediaEvent, &IID_IMediaEvent > pEvent( pGraph );
+ long EvCode = 0;
+
+ // 15 sec timeout
+ hr = pEvent->WaitForCompletion( 15*1000, &EvCode );
+
+ Log("grab:done.");
+ // callback wrote the sample
+ pControl->Stop();
+ }
+
+ Log("Sample grabbing complete.");
+ }
+ catch(...)
+ {
+ Log("grab:exception.");
+ }
+ return 0;
+}
+
+
+HRESULT GetPin( IBaseFilter * pFilter, PIN_DIRECTION dirrequired, int iNum, IPin **ppPin)
+{
+ CComPtr< IEnumPins > pEnum;
+ *ppPin = NULL;
+
+ HRESULT hr = pFilter->EnumPins(&pEnum);
+ if(FAILED(hr))
+ return hr;
+
+ ULONG ulFound;
+ IPin *pPin;
+ hr = E_FAIL;
+
+ while(S_OK == pEnum->Next(1, &pPin, &ulFound))
+ {
+ PIN_DIRECTION pindir = (PIN_DIRECTION)3;
+
+ pPin->QueryDirection(&pindir);
+ if(pindir == dirrequired)
+ {
+ if(iNum == 0)
+ {
+ *ppPin = pPin; // Return the pin's interface
+ hr = S_OK; // Found requested pin, so clear error
+ break;
+ }
+ iNum--;
+ }
+
+ pPin->Release();
+ }
+
+ return hr;
+}
+
+
+IPin * GetInPin( IBaseFilter * pFilter, int nPin )
+{
+ CComPtr<IPin> pComPin=0;
+ GetPin(pFilter, PINDIR_INPUT, nPin, &pComPin);
+ return pComPin;
+}
+
+
+IPin * GetOutPin( IBaseFilter * pFilter, int nPin )
+{
+ CComPtr<IPin> pComPin=0;
+ GetPin(pFilter, PINDIR_OUTPUT, nPin, &pComPin);
+ return pComPin;
+}
+
+
+
+
View
0 ...pp/DirectShowHelper/source/IAVSyncClock.h → ...rs/DirectShowHelper/source/IAVSyncClock.h
File renamed without changes.
View
0 ...ore.cpp/DirectShowHelper/source/MyQueue.h → ...Filters/DirectShowHelper/source/MyQueue.h
File renamed without changes.
View
0 ....cpp/DirectShowHelper/source/OuterEVR.cpp → ...ters/DirectShowHelper/source/OuterEVR.cpp
File renamed without changes.
View
0 ...re.cpp/DirectShowHelper/source/OuterEVR.h → ...ilters/DirectShowHelper/source/OuterEVR.h
File renamed without changes.
View
0 ...cpp/DirectShowHelper/source/Scheduler.cpp → ...ers/DirectShowHelper/source/Scheduler.cpp
File renamed without changes.
View
0 ...e.cpp/DirectShowHelper/source/Scheduler.h → ...lters/DirectShowHelper/source/Scheduler.h
File renamed without changes.
View
0 ...DirectShowHelper/source/StatsRenderer.cpp → ...DirectShowHelper/source/StatsRenderer.cpp
File renamed without changes.
View
0 ...p/DirectShowHelper/source/StatsRenderer.h → ...s/DirectShowHelper/source/StatsRenderer.h
File renamed without changes.
View
0 ...Core.cpp/DirectShowHelper/source/StdAfx.h → ...wFilters/DirectShowHelper/source/StdAfx.h
File renamed without changes.
View
0 ...pp/DirectShowHelper/source/TimeSource.cpp → ...rs/DirectShowHelper/source/TimeSource.cpp
File renamed without changes.
View
0 ....cpp/DirectShowHelper/source/TimeSource.h → ...ters/DirectShowHelper/source/TimeSource.h
File renamed without changes.
View
0 ...ore.cpp/DirectShowHelper/source/autoint.h → ...Filters/DirectShowHelper/source/autoint.h
File renamed without changes.
View
0 ...re.cpp/DirectShowHelper/source/callback.h → ...ilters/DirectShowHelper/source/callback.h
File renamed without changes.
View
2 ...cpp/DirectShowHelper/source/debugallocs.h → ...ers/DirectShowHelper/source/debugallocs.h
@@ -26,4 +26,4 @@
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
-#endif
+#endif
View
0 ....cpp/DirectShowHelper/source/dllmodul.cpp → ...ters/DirectShowHelper/source/dllmodul.cpp
File renamed without changes.
View
2,652 ...p/DirectShowHelper/source/dshowhelper.cpp → ...s/DirectShowHelper/source/dshowhelper.cpp
@@ -1,1326 +1,1326 @@
-// Copyright (C) 2005-2010 Team MediaPortal
-// http://www.team-mediaportal.com
-//
-// MediaPortal is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 2 of the License, or
-// (at your option) any later version.
-//
-// MediaPortal is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
-
-#pragma warning(disable: 4995 4996)
-
-#include "StdAfx.h"
-#include <streams.h>
-#include <atlbase.h>
-#include <shlobj.h>
-#include <d3dx9.h>
-#include <vmr9.h>
-#include <evr.h>
-#include <sbe.h>
-#include <dvdmedia.h>
-#include <map>
-
-#include "dshowhelper.h"
-#include "evrcustomPresenter.h"
-#include "dx9allocatorpresenter.h"
-
-// For more details for memory leak detection see the alloctracing.h header
-#include "..\..\alloctracing.h"
-
-using namespace std;
-
-HMODULE m_hModuleDXVA2 = NULL;
-HMODULE m_hModuleEVR = NULL;
-HMODULE m_hModuleMFPLAT = NULL;
-HMODULE m_hModuleDWMAPI = NULL;
-HMODULE m_hModuleAVRT = NULL;
-HMODULE m_hModuleW7Helper = NULL;
-
-TDXVA2CreateDirect3DDeviceManager9* m_pDXVA2CreateDirect3DDeviceManager9 = NULL;
-TMFCreateVideoSampleFromSurface* m_pMFCreateVideoSampleFromSurface = NULL;
-TMFCreateVideoMediaType* m_pMFCreateVideoMediaType = NULL;
-TMFCreateMediaType* m_pMFCreateMediaType = NULL;
-
-// Vista / Windows 7 only
-TDwmEnableMMCSS* m_pDwmEnableMMCSS = NULL;
-TW7GetRefreshRate* m_pW7GetRefreshRate = NULL;
-
-TAvSetMmThreadCharacteristicsW* m_pAvSetMmThreadCharacteristicsW = NULL;
-TAvSetMmThreadPriority* m_pAvSetMmThreadPriority = NULL;
-TAvRevertMmThreadCharacteristics* m_pAvRevertMmThreadCharacteristics = NULL;
-
-
-
-BOOL m_bEVRLoaded = false;
-TCHAR* m_RenderPrefix = _T("vmr9");
-
-LPDIRECT3DDEVICE9 m_pDevice = NULL;
-CVMR9AllocatorPresenter* m_vmr9Presenter = NULL;
-MPEVRCustomPresenter* m_evrPresenter = NULL;
-IBaseFilter* m_pVMR9Filter = NULL;
-IVMRSurfaceAllocator9* m_allocator = NULL;
-LONG m_iRecordingId = 0;
-
-map<int,IStreamBufferRecordControl*> m_mapRecordControl;
-typedef map<int,IStreamBufferRecordControl*>::iterator imapRecordControl;
-
-#define MY_USER_ID 0x6ABE51
-#define MY_USER_ID2 0x6ABE52
-
-#define IsInterlaced(x) ((x) & AMINTERLACE_IsInterlaced)
-#define IsSingleField(x) ((x) & AMINTERLACE_1FieldPerSample)
-#define IsField1First(x) ((x) & AMINTERLACE_Field1First)
-
-#define INIT_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
- const GUID name \
- = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
-
-//#define DEFAULT_PRESENTER
-
-INIT_GUID(bobDxvaGuid, 0x335aa36e, 0x7884, 0x43a4, 0x9c, 0x91, 0x7f, 0x87, 0xfa, 0xf3, 0xe3, 0x7e);
-INIT_GUID(clsidTeeSink, 0x0A4252A0, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00);
-
-
-HRESULT __fastcall UnicodeToAnsi(LPCOLESTR pszW, LPSTR* ppszA)
-{
- ULONG cbAnsi;
- ULONG cCharacters;
- DWORD dwError;
-
- // If input is null then just return the same.
- if (pszW == NULL)
- {
- *ppszA = NULL;
- return NOERROR;
- }
-
- cCharacters = (ULONG)wcslen(pszW)+1;
- // Determine number of bytes to be allocated for ANSI string. An
- // ANSI string can have at most 2 bytes per character (for Double
- // Byte Character Strings.)
- cbAnsi = cCharacters*2;
-
- // Use of the OLE allocator is not required because the resultant
- // ANSI string will never be passed to another COM component. You
- // can use your own allocator.
- *ppszA = (LPSTR) CoTaskMemAlloc(cbAnsi);
- if (NULL == *ppszA)
- return E_OUTOFMEMORY;
-
- // Convert to ANSI.
- if (0 == WideCharToMultiByte(CP_ACP, 0, pszW, cCharacters, *ppszA,
- cbAnsi, NULL, NULL))
- {
- dwError = GetLastError();
- CoTaskMemFree(*ppszA);
- *ppszA = NULL;
- return HRESULT_FROM_WIN32(dwError);
- }
- return NOERROR;
-}
-
-
-void LogPath(TCHAR* dest, TCHAR* name)
-{
- TCHAR folder[MAX_PATH];
- SHGetSpecialFolderPath(NULL,folder,CSIDL_COMMON_APPDATA,FALSE);
- _stprintf(dest, _T("%s\\Team Mediaportal\\MediaPortal\\log\\%s.%s"), folder, m_RenderPrefix, name);
-}
-
-
-void LogRotate()
-{
- TCHAR fileName[MAX_PATH];
- LogPath(fileName, _T("log"));
- TCHAR bakFileName[MAX_PATH];
- LogPath(bakFileName, _T("bak"));
- _tremove(bakFileName);
- _trename(fileName, bakFileName);
-}
-
-
-CCritSec m_qLock;
-std::queue<std::string> m_logQueue;
-BOOL m_bLoggerRunning;
-HANDLE m_hLogger = NULL;
-
-string GetLogLine()
-{
- CAutoLock lock(&m_qLock);
- if ( m_logQueue.size() == 0 )
- {
- return "";
- }
- string ret = m_logQueue.front();
- m_logQueue.pop();
- return ret;
-}
-
-
-UINT CALLBACK LogThread(void* param)
-{
- TCHAR fileName[MAX_PATH];
- LogPath(fileName, _T("log"));
- while ( m_bLoggerRunning ) {
- if ( m_logQueue.size() > 0 ) {
- FILE* fp = _tfopen(fileName, _T("a+"));
- if (fp!=NULL)
- {
- SYSTEMTIME systemTime;
- GetLocalTime(&systemTime);
- string line = GetLogLine();
- while (!line.empty())
- {
- fprintf(fp, "%s", line.c_str());
- line = GetLogLine();
- }
- fclose(fp);
- }
- }
- Sleep(1000);
- }
- return 0;
-}
-
-
-void StartLogger()
-{
- UINT id;
- m_hLogger = (HANDLE)_beginthreadex(NULL, 0, LogThread, 0, 0, &id);
- SetThreadPriority(m_hLogger, THREAD_PRIORITY_BELOW_NORMAL);
-}
-
-
-void StopLogger()
-{
- if (m_hLogger)
- {
- m_bLoggerRunning = FALSE;
- WaitForSingleObject(m_hLogger, INFINITE);
- m_hLogger = NULL;
- }
-}
-
-
-void Log(const char *fmt, ...)
-{
- static CCritSec lock;
- va_list ap;
- va_start(ap,fmt);
-
- CAutoLock logLock(&lock);
- if (!m_hLogger) {
- m_bLoggerRunning = true;
- StartLogger();
- }
- char buffer[1000];
- int tmp;
- va_start(ap,fmt);
- tmp = vsprintf(buffer, fmt, ap);
- va_end(ap);
-
- SYSTEMTIME systemTime;
- GetLocalTime(&systemTime);
- char msg[5000];
- sprintf_s(msg, 5000,"%02.2d-%02.2d-%04.4d %02.2d:%02.2d:%02.2d.%03.3d [%x]%s\n",
- systemTime.wDay, systemTime.wMonth, systemTime.wYear,
- systemTime.wHour,systemTime.wMinute,systemTime.wSecond,
- systemTime.wMilliseconds,
- GetCurrentThreadId(),
- buffer);
- CAutoLock l(&m_qLock);
- m_logQueue.push((string)msg);
-};
-
-
-VMR9_SampleFormat ConvertInterlaceFlags(DWORD dwInterlaceFlags)
-{
- if (IsInterlaced(dwInterlaceFlags)) {
- if (IsSingleField(dwInterlaceFlags)) {
- if (IsField1First(dwInterlaceFlags)) {
- return VMR9_SampleFieldSingleEven;
- }
- else {
- return VMR9_SampleFieldSingleOdd;
- }
- }
- else {
- if (IsField1First(dwInterlaceFlags)) {
- return VMR9_SampleFieldInterleavedEvenFirst;
- }
- else {
- return VMR9_SampleFieldInterleavedOddFirst;
- }
- }
- }
- else {
- return VMR9_SampleProgressiveFrame; // Not interlaced.
- }
-}
-
-
-BOOL Vmr9Init(IVMR9Callback* callback, DWORD dwD3DDevice, IBaseFilter* vmr9Filter,DWORD monitor)
-{
- HRESULT hr;
- m_pDevice = (LPDIRECT3DDEVICE9)(dwD3DDevice);
- m_pVMR9Filter=vmr9Filter;
-
- Log("Vmr9Init");
-
- CComQIPtr<IVMRFilterConfig9> pConfig = m_pVMR9Filter;
- if(!pConfig)
- {
- return FALSE;
- }
-