From: Jinhyung Jo Date: Fri, 17 Feb 2012 04:04:52 +0000 (+0900) Subject: [Title] improved camera performance & add win32 dll source X-Git-Tag: TizenStudio_2.0_p2.3~1694^2~49^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7197ad1d3a6926af8018afa25eb13d4d5c11b4c9;p=sdk%2Femulator%2Fqemu.git [Title] improved camera performance & add win32 dll source [Type] Enhancement [Module] Emulator / Camera [Priority] // Importance : Critical / Major / Minor [CQ#] // CQ Issue Number [Redmine#] // Redmine Isuue Number [Problem] // Problem Description [Cause] // Cause Description [Solution] // Solution Description [TestCase] // Executed the test-target (How to) Change-Id: I5d164e473870790ed80650d34dbf4a8a5b36b76b --- diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter.sln b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter.sln new file mode 100644 index 0000000..94d45b1 --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hwcfilter", "hwcfilter\hwcfilter.vcxproj", "{DF0AE82C-5AB7-47F5-B3F2-8CE447A7C2FC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF0AE82C-5AB7-47F5-B3F2-8CE447A7C2FC}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF0AE82C-5AB7-47F5-B3F2-8CE447A7C2FC}.Debug|Win32.Build.0 = Debug|Win32 + {DF0AE82C-5AB7-47F5-B3F2-8CE447A7C2FC}.Release|Win32.ActiveCfg = Release|Win32 + {DF0AE82C-5AB7-47F5-B3F2-8CE447A7C2FC}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter.suo b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter.suo new file mode 100644 index 0000000..65f5ed6 Binary files /dev/null and b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter.suo differ diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/ReadMe.txt b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/ReadMe.txt new file mode 100644 index 0000000..216fb77 --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/ReadMe.txt @@ -0,0 +1,38 @@ +======================================================================== + 동적 연결 라이브러리 : hwcfilter 프로젝트 개요 +======================================================================== + +응용 프로그램 마법사에서 이 hwcfilter DLL을 만들었습니다. + +hwcfilter 응용 프로그램을 구성하는 각 파일에 대한 +요약 설명이 포함되어 있습니다. + + +hwcfilter.vcxproj + 응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다. + 파일을 생성한 Visual C++ 버전에 대한 정보와 응용 프로그램 마법사를 사용하여 선택한 플랫폼, + 구성 및 프로젝트 기능에 대한 정보가 포함되어 있습니다. + +hwcfilter.vcxproj.filters + 응용 프로그램 마법사를 사용하여 생성된 VC++ 프로젝트의 필터 파일입니다. + 이 파일에는 프로젝트의 파일과 필터 간의 연결 정보가 들어 있습니다. + 이러한 연결은 특정 노드에서 유사한 확장명으로 그룹화된 파일을 표시하기 위해 IDE에서 + 사용됩니다. 예를 들어 ".cpp" 파일은 "소스 파일" 필터와 연결되어 있습니다. + +hwcfilter.cpp + 기본 DLL 소스 파일입니다. + +///////////////////////////////////////////////////////////////////////////// +기타 표준 파일: + +StdAfx.h, StdAfx.cpp + 이 파일은 미리 컴파일된 헤더(PCH) 파일 hwcfilter.pch와 + 미리 컴파일된 형식(PCT) 파일 StdAfx.obj를 빌드하는 데 사용됩니다. + +///////////////////////////////////////////////////////////////////////////// +기타 참고: + +응용 프로그램 마법사에서 사용하는 "TODO:" 주석은 사용자가 추가하거나 사용자 지정해야 하는 +소스 코드 부분을 나타냅니다. + +///////////////////////////////////////////////////////////////////////////// diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/dllmain.cpp b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/dllmain.cpp new file mode 100644 index 0000000..2d02faf --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/dllmain.cpp @@ -0,0 +1,19 @@ +// dllmain.cpp : DLL ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ÁøÀÔÁ¡À» Á¤ÀÇÇÕ´Ï´Ù. +#include "stdafx.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwccallback_h.h b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwccallback_h.h new file mode 100644 index 0000000..4f4814e --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwccallback_h.h @@ -0,0 +1,155 @@ + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0555 */ +/* at Wed Nov 23 21:52:11 2011 + */ +/* Compiler settings for HWCCallBack.idl: + Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __HWCCallBack_h_h__ +#define __HWCCallBack_h_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __ICaptureCallBack_FWD_DEFINED__ +#define __ICaptureCallBack_FWD_DEFINED__ +typedef interface ICaptureCallBack ICaptureCallBack; +#endif /* __ICaptureCallBack_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "Unknwn.h" +#include +#include + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __ICaptureCallBack_INTERFACE_DEFINED__ +#define __ICaptureCallBack_INTERFACE_DEFINED__ + +/* interface ICaptureCallBack */ +/* [full][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_ICaptureCallBack; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("4C337035-C89E-4B42-9B0C-367444DD70DD") + ICaptureCallBack : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE CaptureCallback( + /* [in] */ ULONG dwSize, + /* [size_is][in] */ BYTE *pBuffer) = 0; + + }; + +#else /* C style interface */ + + typedef struct ICaptureCallBackVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ICaptureCallBack * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ICaptureCallBack * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ICaptureCallBack * This); + + HRESULT ( STDMETHODCALLTYPE *CaptureCallback )( + ICaptureCallBack * This, + /* [in] */ ULONG dwSize, + /* [size_is][in] */ BYTE *pBuffer); + + END_INTERFACE + } ICaptureCallBackVtbl; + + interface ICaptureCallBack + { + CONST_VTBL struct ICaptureCallBackVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ICaptureCallBack_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ICaptureCallBack_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ICaptureCallBack_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ICaptureCallBack_CaptureCallback(This,dwSize,pBuffer) \ + ( (This)->lpVtbl -> CaptureCallback(This,dwSize,pBuffer) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ICaptureCallBack_INTERFACE_DEFINED__ */ + + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.cpp b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.cpp new file mode 100644 index 0000000..e449118 --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.cpp @@ -0,0 +1,616 @@ +#include "stdafx.h" +#include "hwcfilter.h" +#include +#include + +static HMODULE g_hModule = NULL; +static long g_cServerLocks = 0; +static long g_cComponents = 0; + +CHWCPin::CHWCPin(CHWCFilter *pFilter) : + m_pCFilter(pFilter), m_pConnectedPin(NULL), + m_pCallback(NULL), m_bReadOnly(FALSE), m_cRef(1) +{ + InterlockedIncrement(&g_cComponents); +} + +CHWCPin::~CHWCPin(void) +{ + InterlockedDecrement(&g_cComponents); +} + +STDMETHODIMP CHWCPin::QueryInterface(REFIID riid, void **ppv) +{ + if (riid == IID_IUnknown) { + *ppv = (IUnknown*)((IHWCPin*)this); + } else if (riid == IID_IPin) { + *ppv = (IPin*)this; + } else if (riid == IID_IMemInputPin) { + *ppv = (IMemInputPin*)this; + } else if (riid == IID_IHWCPin) { + *ppv = (IHWCPin*)this; + } else { + LPWSTR str; + StringFromIID(riid, &str); + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(this)->AddRef(); + return S_OK; +} + +STDMETHODIMP_(ULONG) CHWCPin::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +STDMETHODIMP_(ULONG) CHWCPin::Release() +{ + if( InterlockedDecrement(&m_cRef) == 0) + { + delete this; + return 0; + } + return m_cRef; +} + +STDMETHODIMP CHWCPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) +{ + if ( !pmt ) + return S_OK; + return S_FALSE; +} + +STDMETHODIMP CHWCPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) +{ + if (pConnector == NULL || pmt == NULL) + return E_POINTER; + + if (m_pConnectedPin) { + return VFW_E_ALREADY_CONNECTED; + } + FILTER_STATE fs; + m_pCFilter->GetState(0, &fs); + if (fs != State_Stopped) { + return VFW_E_NOT_STOPPED; + } + PIN_DIRECTION pd; + pConnector->QueryDirection(&pd); + if (pd == PINDIR_INPUT) { + return VFW_E_INVALID_DIRECTION; + } + + m_pConnectedPin = pConnector; + m_pConnectedPin->AddRef(); + return S_OK; +} + +STDMETHODIMP CHWCPin::Disconnect(void) +{ + HRESULT hr; + if (m_pConnectedPin == NULL) { + hr = S_FALSE; + } else { + m_pConnectedPin->Release(); + m_pConnectedPin = NULL; + hr = S_OK; + } + return hr; +} + +STDMETHODIMP CHWCPin::ConnectedTo(IPin **pPin) +{ + if (pPin == NULL) + return E_POINTER; + + HRESULT hr; + if ( m_pConnectedPin == NULL ) { + hr = VFW_E_NOT_CONNECTED; + } else { + m_pConnectedPin->AddRef(); + *pPin = m_pConnectedPin; + hr = S_OK; + } + return hr; +} + +STDMETHODIMP CHWCPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) +{ + if (pmt == NULL) { + return E_POINTER; + } + return VFW_E_NOT_CONNECTED; +} + +STDMETHODIMP CHWCPin::QueryPinInfo(PIN_INFO *pInfo) +{ + if (pInfo == NULL) + return E_POINTER; + + pInfo->pFilter = (IBaseFilter*)m_pCFilter; + if (m_pCFilter) + m_pCFilter->AddRef(); + memcpy((void*)pInfo->achName, (void*)HWCPinName, sizeof(HWCPinName)); + pInfo->dir = PINDIR_INPUT; + return S_OK; +} + +STDMETHODIMP CHWCPin::QueryDirection(PIN_DIRECTION *pPinDir) +{ + if (pPinDir == NULL) + return E_POINTER; + *pPinDir = PINDIR_INPUT; + return S_OK; +} + +STDMETHODIMP CHWCPin::QueryId(LPWSTR *Id) +{ + if (Id == NULL) + return E_POINTER; + PVOID pId = CoTaskMemAlloc(sizeof(HWCPinName)); + memcpy((void*)pId, (void*)HWCPinName, sizeof(HWCPinName)); + *Id = (LPWSTR)pId; + return S_OK; +} + +STDMETHODIMP CHWCPin::QueryAccept(const AM_MEDIA_TYPE *pmt) +{ + if (pmt == NULL) + return E_POINTER; + return S_OK; +} + +STDMETHODIMP CHWCPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) +{ + if (ppEnum == NULL) + return E_POINTER; + return E_NOTIMPL; +} + +STDMETHODIMP CHWCPin::QueryInternalConnections(IPin **ppPin, ULONG *nPin) +{ + return E_NOTIMPL; +} + +STDMETHODIMP CHWCPin::EndOfStream(void) +{ + return S_OK; +} + +STDMETHODIMP CHWCPin::BeginFlush(void) +{ + return S_OK; +} + +STDMETHODIMP CHWCPin::EndFlush(void) +{ + return S_OK; +} + +STDMETHODIMP CHWCPin::NewSegment(REFERENCE_TIME tStart, + REFERENCE_TIME tStop, + double dRate) +{ + return S_OK; +} + +STDMETHODIMP CHWCPin::GetAllocator(IMemAllocator **ppAllocator) +{ + if (ppAllocator == NULL) + return E_POINTER; + return VFW_E_NO_ALLOCATOR; +} + +STDMETHODIMP CHWCPin::NotifyAllocator(IMemAllocator *pAllocator, + BOOL bReadOnly) +{ + if (pAllocator == NULL) + return E_POINTER; + + return NOERROR; +} + +STDMETHODIMP CHWCPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps) +{ + return E_NOTIMPL; +} + +STDMETHODIMP CHWCPin::Receive(IMediaSample *pSample) +{ + if (pSample == NULL) + return E_POINTER; + if (m_pCallback != NULL) { + HRESULT hr; + BYTE* pBuffer = NULL; + DWORD dwSize = 0; + dwSize = pSample->GetSize(); + hr = pSample->GetPointer(&pBuffer); + if (FAILED(hr)) + return hr; + m_pCallback->CaptureCallback(dwSize, pBuffer); + } + return S_OK; +} + +STDMETHODIMP CHWCPin::ReceiveMultiple(IMediaSample **pSamples, + long nSamples, long *nSamplesProcessed) +{ + if (pSamples == NULL) + return E_POINTER; + HRESULT hr = S_OK; + nSamplesProcessed = 0; + while (nSamples-- > 0) + { + hr = Receive(pSamples[*nSamplesProcessed]); + if (hr != S_OK) + break; + (*nSamplesProcessed)++; + } + return hr; +} + +STDMETHODIMP CHWCPin::ReceiveCanBlock(void) +{ + return S_FALSE; +} + +STDMETHODIMP CHWCPin::SetCallback(ICaptureCallBack *pCaptureCB) +{ + if (pCaptureCB == NULL) { + m_pCallback->Release(); + } else { + m_pCallback = pCaptureCB; + m_pCallback->AddRef(); + } + return S_OK; +} + +CHWCEnumPins::CHWCEnumPins(CHWCFilter *pCHWCFilter, int pos) : + m_pFilter(pCHWCFilter), m_pos(pos), m_cRef(1) +{ + m_pFilter->AddRef(); + InterlockedIncrement(&g_cComponents); +} + +CHWCEnumPins::~CHWCEnumPins(void) +{ + m_pFilter->Release(); + InterlockedDecrement(&g_cComponents); +} + +STDMETHODIMP CHWCEnumPins::QueryInterface(REFIID riid, void **ppv) +{ + if (ppv == NULL) + return E_POINTER; + + if (riid == IID_IUnknown) { + *ppv = (IUnknown*)this; + } else if (riid == IID_IEnumPins) { + *ppv = (IEnumPins*)this; + } else { + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(this)->AddRef(); + return S_OK; +} + +STDMETHODIMP_(ULONG) CHWCEnumPins::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +STDMETHODIMP_(ULONG) CHWCEnumPins::Release() +{ + if (InterlockedDecrement(&m_cRef) == 0) { + delete this; + return 0; + } + return m_cRef; +} + +STDMETHODIMP CHWCEnumPins::Next(ULONG cPins, IPin **ppPins, + ULONG *pcFetched) +{ + if (ppPins == NULL) + return E_POINTER; + + ULONG fetched; + if (m_pos < 1 && cPins > 0) { + IPin *pPin; + m_pFilter->FindPin(HWCPinName, &pPin); + *ppPins = pPin; + pPin->AddRef(); + fetched = 1; + m_pos++; + } else { + fetched = 0; + } + if (pcFetched != NULL ) { + *pcFetched = fetched; + } + + return ( fetched == cPins ) ? S_OK : S_FALSE; +} + +STDMETHODIMP CHWCEnumPins::Skip(ULONG cPins) +{ + m_pos += cPins; + return ( m_pos >= 1 ) ? S_FALSE : S_OK; +} + +STDMETHODIMP CHWCEnumPins::Reset(void) +{ + m_pos = 0; + return S_OK; +} + +STDMETHODIMP CHWCEnumPins::Clone(IEnumPins **ppEnum) +{ + if (ppEnum == NULL) + return E_POINTER; + *ppEnum = new CHWCEnumPins(m_pFilter, m_pos); + if (*ppEnum == NULL) { + return E_OUTOFMEMORY; + } + return NOERROR; +} + +CHWCFilter::CHWCFilter() : m_pFilterGraph(NULL), m_state(State_Stopped), m_cRef(1) +{ + m_pPin = new CHWCPin(this); + InterlockedIncrement(&g_cComponents); +} + +CHWCFilter::~CHWCFilter() +{ + InterlockedDecrement(&g_cComponents); + + if (m_pPin) { + m_pPin->Release(); + m_pPin = NULL; + } + if (m_pFilterGraph) { + m_pFilterGraph->Release(); + m_pFilterGraph = NULL; + } +} + +STDMETHODIMP CHWCFilter::QueryInterface(REFIID riid, void **ppv) +{ + if( riid == IID_IUnknown ) { + *ppv = (IUnknown*)this; + } else if( riid == IID_IPersist ) { + *ppv = (IPersist*)this; + } else if( riid == IID_IMediaFilter ) { + *ppv = (IMediaFilter*)this; + } else if( riid == IID_IBaseFilter ) { + *ppv = (IBaseFilter*)this; + } else { + LPWSTR str; + StringFromIID(riid, &str); + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(this)->AddRef(); + + return S_OK; +} + +STDMETHODIMP_(ULONG) CHWCFilter::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +STDMETHODIMP_(ULONG) CHWCFilter::Release() +{ + if( InterlockedDecrement(&m_cRef) == 0) { + delete this; + return 0; + } + return m_cRef; +} + +STDMETHODIMP CHWCFilter::GetClassID(CLSID *pClsID) +{ + if (pClsID == NULL) + return E_POINTER; + return E_NOTIMPL; +} + +STDMETHODIMP CHWCFilter::GetState(DWORD dwMSecs, FILTER_STATE *State) +{ + *State = m_state; + return S_OK; +} + +STDMETHODIMP CHWCFilter::SetSyncSource(IReferenceClock *pClock) +{ + return S_OK; +} + +STDMETHODIMP CHWCFilter::GetSyncSource(IReferenceClock **pClock) +{ + *pClock = NULL; + return NOERROR; +} + +STDMETHODIMP CHWCFilter::Stop() +{ + m_pPin->EndFlush(); + m_state = State_Stopped; + return S_OK; +} + +STDMETHODIMP CHWCFilter::Pause() +{ + m_state = State_Paused; + return S_OK; +} + +STDMETHODIMP CHWCFilter::Run(REFERENCE_TIME tStart) +{ + if (m_state == State_Stopped){ + HRESULT hr = Pause(); + if (FAILED(hr)) { + return hr; + } + } + m_state = State_Running; + return S_OK; +} + +STDMETHODIMP CHWCFilter::EnumPins(IEnumPins **ppEnum) +{ + if (ppEnum == NULL) + return E_POINTER; + *ppEnum = (IEnumPins*)(new CHWCEnumPins(this, 0)); + return *ppEnum == NULL ? E_OUTOFMEMORY : S_OK; +} + +STDMETHODIMP CHWCFilter::FindPin(LPCWSTR Id, IPin **ppPin) +{ + if (ppPin == NULL) + return E_POINTER; + + if (memcmp((void*)Id, (void*)HWCPinName, sizeof(HWCPinName))) { + return VFW_E_NOT_FOUND; + } + + if (!m_pPin) { + m_pPin = new CHWCPin(this); + } + *ppPin = (IPin*)m_pPin; + m_pPin->AddRef(); + return S_OK; +} + +STDMETHODIMP CHWCFilter::QueryFilterInfo(FILTER_INFO *pInfo) +{ + if (pInfo == NULL) + return E_POINTER; + + memcpy((void*)pInfo->achName, (void*)HWCFilterName, sizeof(HWCFilterName)); + pInfo->pGraph = m_pFilterGraph; + if(m_pFilterGraph) { + m_pFilterGraph->AddRef(); + } + return S_OK; +} + +STDMETHODIMP CHWCFilter::JoinFilterGraph(IFilterGraph *pGraph, + LPCWSTR pName) +{ + m_pFilterGraph = pGraph; + pGraph->AddRef(); + return S_OK; +} + +STDMETHODIMP CHWCFilter::QueryVendorInfo(LPWSTR* pVendorInfo) +{ + return E_NOTIMPL; +} + +HWCClassFactory::HWCClassFactory(void) : m_cRef(1) +{ +} + +HWCClassFactory::~HWCClassFactory(void) +{ +} + +STDMETHODIMP HWCClassFactory::QueryInterface(REFIID riid, LPVOID* ppv) +{ + if (riid == IID_IUnknown || riid == IID_IClassFactory) { + *ppv = (IClassFactory*)this; + } else { + *ppv = NULL; + return E_NOINTERFACE; + } + + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +STDMETHODIMP_(ULONG) HWCClassFactory::AddRef(void) +{ + return InterlockedIncrement(&m_cRef); +} + +STDMETHODIMP_(ULONG) HWCClassFactory::Release(void) +{ + if (InterlockedDecrement(&m_cRef) == 0) { + delete this; + return 0; + } + return m_cRef; +} + +STDMETHODIMP HWCClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID* ppv) +{ + HRESULT hr; + CHWCFilter* pFilter = NULL; + *ppv = NULL; + + if (pUnkOuter != NULL) { + hr = CLASS_E_NOAGGREGATION; + } else { + pFilter = new CHWCFilter; + if (pFilter != NULL) { + hr = pFilter->QueryInterface(riid, ppv); + pFilter->Release(); + } else { + return E_OUTOFMEMORY; + } + } + + return hr; +} + +STDMETHODIMP HWCClassFactory::LockServer(BOOL bLock) +{ + if (bLock) { + InterlockedIncrement(&g_cServerLocks); + } else { + InterlockedDecrement(&g_cServerLocks); + } + return S_OK; +} + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; + HWCClassFactory *pFactory = NULL; + + if (rclsid != CLSID_HWCFilterClass) { + return hr; + } + + pFactory = new HWCClassFactory; + if (pFactory == NULL) { + hr = E_OUTOFMEMORY; + } else { + hr = pFactory->QueryInterface(riid, ppv); + pFactory->Release(); + } + + return hr; +} + +STDAPI DllCanUnloadNow(void) +{ + if ((g_cComponents == 0) && (g_cServerLocks == 0)) { + return S_OK; + } + return S_FALSE; +} + +STDAPI DllRegisterServer(void) +{ + return S_OK; +} + +STDAPI DllUnregisterServer(void) +{ + return S_OK; +} diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.def b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.def new file mode 100644 index 0000000..7978707 --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.def @@ -0,0 +1,4 @@ +LIBRARY +EXPORTS +HWCCtrl PRIVATE +HWCSetCallback PRIVATE \ No newline at end of file diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.h b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.h new file mode 100644 index 0000000..dd45278 --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.h @@ -0,0 +1,120 @@ +#ifndef __HWCFILTER_H__ +#define __HWCFILTER_H__ + +#include "hwcfilter_h.h" + +const IID __declspec(selectany) IID_IHWCPin = {0x33AFDC07,0xC2AB,0x4FC4,{0xBA,0x54,0x65,0xFA,0xDF,0x4B,0x47,0x4D}}; +const IID __declspec(selectany) IID_ICaptureCallBack = {0x4C337035,0xC89E,0x4B42,{0x9B,0x0C,0x36,0x74,0x44,0xDD,0x70,0xDD}}; + +static const WCHAR HWCPinName[] = L"HWCInputPin\0"; +static const WCHAR HWCFilterName[] = L"HWCFilter\0"; + +class CHWCFilter; + +class CHWCPin: public IHWCPin, public IMemInputPin +{ +public: + CHWCPin(CHWCFilter *pFilter); + virtual ~CHWCPin(); + STDMETHODIMP QueryInterface(REFIID riid, void **ppv); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + STDMETHODIMP Connect(IPin * pReceivePin, const AM_MEDIA_TYPE *pmt); + STDMETHODIMP ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); + STDMETHODIMP Disconnect(); + STDMETHODIMP ConnectedTo(IPin **pPin); + STDMETHODIMP ConnectionMediaType(AM_MEDIA_TYPE *pmt); + STDMETHODIMP QueryPinInfo(PIN_INFO *pInfo); + STDMETHODIMP QueryDirection(PIN_DIRECTION *pPinDir); + STDMETHODIMP QueryId(LPWSTR * Id); + STDMETHODIMP QueryAccept(const AM_MEDIA_TYPE *pmt); + STDMETHODIMP EnumMediaTypes(IEnumMediaTypes **ppEnum); + STDMETHODIMP QueryInternalConnections(IPin **apPin, ULONG *nPin); + STDMETHODIMP EndOfStream(); + STDMETHODIMP BeginFlush(); + STDMETHODIMP EndFlush(); + STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate ); + STDMETHODIMP SetCallback(ICaptureCallBack *pCallback); + + STDMETHODIMP GetAllocator(IMemAllocator **ppAllocator); + STDMETHODIMP NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly); + STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps); + STDMETHODIMP Receive(IMediaSample *pSample); + STDMETHODIMP ReceiveMultiple(IMediaSample **pSamples, long nSamples, long *nSamplesProcessed); + STDMETHODIMP ReceiveCanBlock(); + +protected: + CHWCFilter *m_pCFilter; + IPin *m_pConnectedPin; + ICaptureCallBack *m_pCallback; + BOOL m_bReadOnly; + long m_cRef; +}; + +class CHWCEnumPins: public IEnumPins +{ +public: + CHWCEnumPins(CHWCFilter *pFilter, int pos); + virtual ~CHWCEnumPins(); + STDMETHODIMP QueryInterface(REFIID riid, void **ppv); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP Next(ULONG cPins, IPin **ppPins, ULONG *pcFetched); + STDMETHODIMP Skip(ULONG cPins); + STDMETHODIMP Reset(); + STDMETHODIMP Clone(IEnumPins **ppEnum); + +protected: + CHWCFilter *m_pFilter; + int m_pos; + long m_cRef; +}; + +class CHWCFilter: public IBaseFilter +{ +public: + CHWCFilter(); + virtual ~CHWCFilter(); + STDMETHODIMP QueryInterface(REFIID riid, void **ppv); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP GetClassID(CLSID *pClsID); + STDMETHODIMP Stop(); + STDMETHODIMP Pause(); + STDMETHODIMP Run(REFERENCE_TIME tStart); + STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State); + STDMETHODIMP SetSyncSource(IReferenceClock *pClock); + STDMETHODIMP GetSyncSource(IReferenceClock **pClock); + STDMETHODIMP EnumPins(IEnumPins **ppEnum); + STDMETHODIMP FindPin(LPCWSTR Id, IPin **ppPin); + STDMETHODIMP QueryFilterInfo(FILTER_INFO *pInfo); + STDMETHODIMP JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName); + STDMETHODIMP QueryVendorInfo(LPWSTR *pVendorInfo); + +protected: + CHWCPin *m_pPin; + IFilterGraph *m_pFilterGraph; + FILTER_STATE m_state; + long m_cRef; +}; + +class HWCClassFactory : public IClassFactory +{ +public: + HWCClassFactory(); + virtual ~HWCClassFactory(); + + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppv); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID* ppv); + STDMETHODIMP LockServer(BOOL bLock); + +private: + long m_cRef; +}; + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv); + +#endif // __HWCFILTER_H__ \ No newline at end of file diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.vcxproj b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.vcxproj new file mode 100644 index 0000000..5258bc8 --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.vcxproj @@ -0,0 +1,109 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {DF0AE82C-5AB7-47F5-B3F2-8CE447A7C2FC} + Win32Proj + hwcfilter + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + true + + + false + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;HWCFILTER_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;strmiids.lib;%(AdditionalDependencies) + hwcfilter.def + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;HWCFILTER_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;strmiids.lib;%(AdditionalDependencies) + hwcfilter.def + + + + + + + + + + + + + + + + + false + + + false + + + + + + + Create + Create + + + + + + \ No newline at end of file diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.vcxproj.filters b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.vcxproj.filters new file mode 100644 index 0000000..35d7194 --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.vcxproj.filters @@ -0,0 +1,57 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + 소스 파일 + + + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + + + 소스 파일 + + + 소스 파일 + + + 소스 파일 + + + 소스 파일 + + + \ No newline at end of file diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.vcxproj.user b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.vcxproj.user new file mode 100644 index 0000000..695b5c7 --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter.vcxproj.user @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter_h.h b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter_h.h new file mode 100644 index 0000000..921e29e --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcfilter_h.h @@ -0,0 +1,279 @@ + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0555 */ +/* at Thu Nov 24 00:56:10 2011 + */ +/* Compiler settings for HWCFilter.idl: + Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __HWCFILTER_H_H__ +#define __HWCFILTER_H_H__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __IHWCPin_FWD_DEFINED__ +#define __IHWCPin_FWD_DEFINED__ +typedef interface IHWCPin IHWCPin; +#endif /* __IHWCPin_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include +#include +#include "hwccallback_h.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +/* interface __MIDL_itf_HWCFilter_0000_0000 */ +/* [local] */ + +// {320D90F3-3150-4D22-8437-1E5C0507CC39} +DEFINE_GUID(CLSID_HWCFilterClass, 0x320d90f3, 0x3150, 0x4d22, 0x84, 0x37, 0x1e, 0x5c, 0x5, 0x7, 0xcc, 0x39); + + + +extern RPC_IF_HANDLE __MIDL_itf_HWCFilter_0000_0000_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_HWCFilter_0000_0000_v0_0_s_ifspec; + +#ifndef __IHWCPin_INTERFACE_DEFINED__ +#define __IHWCPin_INTERFACE_DEFINED__ + +/* interface IHWCPin */ +/* [full][helpstring][uuid][object] */ + + +EXTERN_C const IID IID_IHWCPin; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("33AFDC07-C2AB-4FC4-BA54-65FADF4B474D") + IHWCPin : public IPin + { + public: + virtual HRESULT STDMETHODCALLTYPE SetCallback( + ICaptureCallBack *pCaptureCB) = 0; + + }; + +#else /* C style interface */ + + typedef struct IHWCPinVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IHWCPin * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IHWCPin * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IHWCPin * This); + + HRESULT ( STDMETHODCALLTYPE *Connect )( + IHWCPin * This, + /* [in] */ IPin *pReceivePin, + /* [annotation][in] */ + __in_opt const AM_MEDIA_TYPE *pmt); + + HRESULT ( STDMETHODCALLTYPE *ReceiveConnection )( + IHWCPin * This, + /* [in] */ IPin *pConnector, + /* [in] */ const AM_MEDIA_TYPE *pmt); + + HRESULT ( STDMETHODCALLTYPE *Disconnect )( + IHWCPin * This); + + HRESULT ( STDMETHODCALLTYPE *ConnectedTo )( + IHWCPin * This, + /* [annotation][out] */ + __out IPin **pPin); + + HRESULT ( STDMETHODCALLTYPE *ConnectionMediaType )( + IHWCPin * This, + /* [annotation][out] */ + __out AM_MEDIA_TYPE *pmt); + + HRESULT ( STDMETHODCALLTYPE *QueryPinInfo )( + IHWCPin * This, + /* [annotation][out] */ + __out PIN_INFO *pInfo); + + HRESULT ( STDMETHODCALLTYPE *QueryDirection )( + IHWCPin * This, + /* [annotation][out] */ + __out PIN_DIRECTION *pPinDir); + + HRESULT ( STDMETHODCALLTYPE *QueryId )( + IHWCPin * This, + /* [annotation][out] */ + __out LPWSTR *Id); + + HRESULT ( STDMETHODCALLTYPE *QueryAccept )( + IHWCPin * This, + /* [in] */ const AM_MEDIA_TYPE *pmt); + + HRESULT ( STDMETHODCALLTYPE *EnumMediaTypes )( + IHWCPin * This, + /* [annotation][out] */ + __out IEnumMediaTypes **ppEnum); + + HRESULT ( STDMETHODCALLTYPE *QueryInternalConnections )( + IHWCPin * This, + /* [annotation][out] */ + __out_ecount_part_opt(*nPin, *nPin) IPin **apPin, + /* [out][in] */ ULONG *nPin); + + HRESULT ( STDMETHODCALLTYPE *EndOfStream )( + IHWCPin * This); + + HRESULT ( STDMETHODCALLTYPE *BeginFlush )( + IHWCPin * This); + + HRESULT ( STDMETHODCALLTYPE *EndFlush )( + IHWCPin * This); + + HRESULT ( STDMETHODCALLTYPE *NewSegment )( + IHWCPin * This, + /* [in] */ REFERENCE_TIME tStart, + /* [in] */ REFERENCE_TIME tStop, + /* [in] */ double dRate); + + HRESULT ( STDMETHODCALLTYPE *SetCallback )( + IHWCPin * This, + ICaptureCallBack *pCaptureCB); + + END_INTERFACE + } IHWCPinVtbl; + + interface IHWCPin + { + CONST_VTBL struct IHWCPinVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IHWCPin_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IHWCPin_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IHWCPin_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IHWCPin_Connect(This,pReceivePin,pmt) \ + ( (This)->lpVtbl -> Connect(This,pReceivePin,pmt) ) + +#define IHWCPin_ReceiveConnection(This,pConnector,pmt) \ + ( (This)->lpVtbl -> ReceiveConnection(This,pConnector,pmt) ) + +#define IHWCPin_Disconnect(This) \ + ( (This)->lpVtbl -> Disconnect(This) ) + +#define IHWCPin_ConnectedTo(This,pPin) \ + ( (This)->lpVtbl -> ConnectedTo(This,pPin) ) + +#define IHWCPin_ConnectionMediaType(This,pmt) \ + ( (This)->lpVtbl -> ConnectionMediaType(This,pmt) ) + +#define IHWCPin_QueryPinInfo(This,pInfo) \ + ( (This)->lpVtbl -> QueryPinInfo(This,pInfo) ) + +#define IHWCPin_QueryDirection(This,pPinDir) \ + ( (This)->lpVtbl -> QueryDirection(This,pPinDir) ) + +#define IHWCPin_QueryId(This,Id) \ + ( (This)->lpVtbl -> QueryId(This,Id) ) + +#define IHWCPin_QueryAccept(This,pmt) \ + ( (This)->lpVtbl -> QueryAccept(This,pmt) ) + +#define IHWCPin_EnumMediaTypes(This,ppEnum) \ + ( (This)->lpVtbl -> EnumMediaTypes(This,ppEnum) ) + +#define IHWCPin_QueryInternalConnections(This,apPin,nPin) \ + ( (This)->lpVtbl -> QueryInternalConnections(This,apPin,nPin) ) + +#define IHWCPin_EndOfStream(This) \ + ( (This)->lpVtbl -> EndOfStream(This) ) + +#define IHWCPin_BeginFlush(This) \ + ( (This)->lpVtbl -> BeginFlush(This) ) + +#define IHWCPin_EndFlush(This) \ + ( (This)->lpVtbl -> EndFlush(This) ) + +#define IHWCPin_NewSegment(This,tStart,tStop,dRate) \ + ( (This)->lpVtbl -> NewSegment(This,tStart,tStop,dRate) ) + + +#define IHWCPin_SetCallback(This,pCaptureCB) \ + ( (This)->lpVtbl -> SetCallback(This,pCaptureCB) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IHWCPin_INTERFACE_DEFINED__ */ + + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif // __HWCFILTER_H_H__ + + diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcsp.cpp b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcsp.cpp new file mode 100644 index 0000000..2b2742e --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcsp.cpp @@ -0,0 +1,882 @@ +#include "hwcsp.h" + +CCallback::CCallback() : m_pCallback(NULL), m_cRef(1) +{ +} + +CCallback::~CCallback() +{ + if (m_pCallback) { + m_pCallback = NULL; + } +} + +STDMETHODIMP CCallback::QueryInterface(REFIID riid, void **ppv) +{ + if (riid == IID_IUnknown) { + *ppv = static_cast(this); + } else if (riid == IID_ICaptureCallBack) { + *ppv = static_cast(this); + } else { + LPWSTR str; + StringFromIID(riid, &str); + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(this)->AddRef(); + return S_OK; +} + +STDMETHODIMP CCallback::CaptureCallback(ULONG dwSize, BYTE *pBuffer) +{ + if (m_pCallback(dwSize, pBuffer)) { + return S_OK; + } + return E_FAIL; +} + +STDMETHODIMP CCallback::SetCallback(CallbackFn pCallbackFn) +{ + m_pCallback = pCallbackFn; + return S_OK; +} + +STDMETHODIMP_(ULONG) CCallback::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +STDMETHODIMP_(ULONG) CCallback::Release() +{ + if( InterlockedDecrement(&m_cRef) == 0) + { + delete this; + return 0; + } + return m_cRef; +} + +HWCSP::HWCSP() +{ + CoInitialize(NULL); + m_pGB = NULL; + m_pCGB = NULL; + m_pMC = NULL; + m_pME = NULL; + m_pOutputPin = NULL; + m_pInputPin = NULL; + m_pDF = NULL; + m_pSF = NULL; + m_hDLL = NULL; + m_pCallback = NULL; + m_dwFourcc = MAKEFOURCC('Y','U','Y','2'); + m_dwWidth = 640; + m_dwHeight = 480; + m_dwAvgInterval = 333333; +} + +HWCSP::~HWCSP() +{ + CloseInterfaces(); + CoUninitialize(); +} + +STDMETHODIMP HWCSP::Init() +{ + HRESULT hr; + + hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void**)&m_pGB); + if (FAILED(hr)) + return hr; + + hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void**)&m_pCGB); + if (FAILED(hr)) + return hr; + + hr = m_pCGB->SetFiltergraph(m_pGB); + if (FAILED(hr)) + return hr; + + hr = m_pGB->QueryInterface(IID_IMediaControl, (void **)&m_pMC); + if (FAILED(hr)) + return hr; + + hr = m_pGB->QueryInterface(IID_IMediaEventEx, (void **)&m_pME); + if (FAILED(hr)) + return hr; + + m_pCallback = new CCallback; + if (m_pCallback == NULL) + hr = E_OUTOFMEMORY; + + return hr; +} + +STDMETHODIMP HWCSP::BindSourceFilter() +{ + HRESULT hr; + + ICreateDevEnum *pCreateDevEnum = NULL; + hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, IID_ICreateDevEnum, (void**)&pCreateDevEnum); + if (FAILED(hr)) + return hr; + + IEnumMoniker *pEnumMK = NULL; + hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumMK, 0); + if (FAILED(hr)) + { + pCreateDevEnum->Release(); + return hr; + } + + if (!pEnumMK) + { + pCreateDevEnum->Release(); + return E_FAIL; + } + pEnumMK->Reset(); + + IMoniker *pMoniKer; + hr = pEnumMK->Next(1, &pMoniKer, NULL); + if (hr == S_FALSE) + { + hr = E_FAIL; + } + if (SUCCEEDED(hr)) + { + IPropertyBag *pBag = NULL; + IBaseFilter *temp = NULL; + hr = pMoniKer->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag); + if(SUCCEEDED(hr)) + { + VARIANT var; + var.vt = VT_BSTR; + hr = pBag->Read(L"FriendlyName", &var, NULL); + if (hr == NOERROR) + { + hr = pMoniKer->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&m_pDF); + if (FAILED(hr)) + { + //Counldn't bind moniker to filter object!! + } + else + { + m_pDF->AddRef(); + } + SysFreeString(var.bstrVal); + } + pBag->Release(); + } + pMoniKer->Release(); + } + + if (SUCCEEDED(hr)) + { + hr = m_pGB->AddFilter(m_pDF, L"Video Capture"); + if (hr != S_OK && hr != S_FALSE) + { + //Counldn't add Video Capture filter to our graph! + } + } + + return hr; +} + +STDMETHODIMP HWCSP::BindTargetFilter() +{ + HRESULT hr; + IClassFactory *pClassFactory= NULL; + hr = DllGetClassObject(CLSID_HWCFilterClass, IID_IClassFactory, (void**)&pClassFactory); + if (FAILED(hr)) + return hr; + + IBaseFilter *pHWCFilter = NULL; + pClassFactory->CreateInstance(NULL, IID_IBaseFilter, (void**)&pHWCFilter); + if (FAILED(hr)) + { + SAFE_RELEASE(pClassFactory); + return hr; + } + m_pSF = pHWCFilter; + + if (SUCCEEDED(hr)) + { + hr = m_pGB->AddFilter(m_pSF, L"HWCFilter"); + if (FAILED(hr)) + { + //Counldn't add HWCFilterr to our graph! + } + } + SAFE_RELEASE(pClassFactory); + + return hr; +} + +STDMETHODIMP HWCSP::ConnectFilters() +{ + HRESULT hr; + + hr = GetPin(m_pDF, PINDIR_OUTPUT , &m_pOutputPin); + if (FAILED(hr)) + return hr; + + hr = GetPin(m_pSF, PINDIR_INPUT , &m_pInputPin); + if (FAILED(hr)) + return hr; + + hr = m_pGB->Connect(m_pOutputPin, m_pInputPin); + return hr; +} + +STDMETHODIMP_(void) HWCSP::CloseInterfaces() +{ + if (m_pMC) + m_pMC->Stop(); + + if (m_pOutputPin) + m_pOutputPin->Disconnect(); + + SAFE_RELEASE(m_pGB); + SAFE_RELEASE(m_pCGB); + SAFE_RELEASE(m_pMC); + SAFE_RELEASE(m_pME); + SAFE_RELEASE(m_pOutputPin); + SAFE_RELEASE(m_pInputPin); + SAFE_RELEASE(m_pDF); + SAFE_RELEASE(m_pSF); + SAFE_RELEASE(m_pCallback); + + if (m_hDLL) { + FreeLibrary(m_hDLL); + m_hDLL = NULL; + } +} + +STDMETHODIMP_(void) HWCSP::DeleteMediaType(AM_MEDIA_TYPE *pmt) +{ + if (pmt == NULL) { + return; + } + + if (pmt->cbFormat != 0) { + CoTaskMemFree((PVOID)pmt->pbFormat); + pmt->cbFormat = 0; + pmt->pbFormat = NULL; + } + if (pmt->pUnk != NULL) { + pmt->pUnk->Release(); + pmt->pUnk = NULL; + } + + CoTaskMemFree((PVOID)pmt); +} + +STDMETHODIMP HWCSP::GetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir, IPin **ppPin) +{ + HRESULT hr; + IEnumPins *pEnum = NULL; + IPin *pPin = NULL; + + if (ppPin == NULL) + { + return E_POINTER; + } + + hr = pFilter->EnumPins(&pEnum); + if (FAILED(hr)) + return hr; + + while(pEnum->Next(1, &pPin, 0) == S_OK) + { + PIN_DIRECTION PinDirThis; + hr = pPin->QueryDirection(&PinDirThis); + if (FAILED(hr)) + { + SAFE_RELEASE(pPin); + SAFE_RELEASE(pEnum); + return hr; + } + if (PinDir == PinDirThis) + { + *ppPin = pPin; + SAFE_RELEASE(pEnum); + return S_OK; + } + SAFE_RELEASE(pPin); + } + + SAFE_RELEASE(pEnum); + return S_FALSE; +} + +STDMETHODIMP HWCSP::QueryVideoProcAmp(long nProperty, long *pMin, long *pMax, long *pStep, long *pDefault) +{ + HRESULT hr; + + IAMVideoProcAmp *pProcAmp = NULL; + hr = m_pDF->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp); + if (FAILED(hr)) + { + return hr; + } + + long Flags; + hr = pProcAmp->GetRange(nProperty, pMin, pMax, pStep, pDefault, &Flags); + + SAFE_RELEASE(pProcAmp); + return hr; +} + +STDMETHODIMP HWCSP::GetVideoProcAmp(long nProperty, long *pValue) +{ + HRESULT hr; + + IAMVideoProcAmp *pProcAmp = NULL; + hr = m_pDF->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp); + if (FAILED(hr)) + return hr; + + long Flags; + hr = pProcAmp->Get(nProperty, pValue, &Flags); + if (FAILED(hr)) + { + } + SAFE_RELEASE(pProcAmp); + return hr; +} + +STDMETHODIMP HWCSP::SetVideoProcAmp(long nProperty, long value) +{ + HRESULT hr; + + IAMVideoProcAmp *pProcAmp = NULL; + hr = m_pDF->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp); + if (FAILED(hr)) + return hr; + + hr = pProcAmp->Set(nProperty, value, VideoProcAmp_Flags_Manual); + SAFE_RELEASE(pProcAmp); + return hr; +} + +STDMETHODIMP HWCSP::StartPreview() +{ + HRESULT hr; + + hr = ((IHWCPin*)m_pInputPin)->SetCallback((ICaptureCallBack*)m_pCallback); + if (FAILED(hr)) + return hr; + + hr = m_pMC->Run(); + return hr; +} + +STDMETHODIMP HWCSP::StopPreview() +{ + HRESULT hr; + hr = ((IHWCPin*)m_pInputPin)->SetCallback(NULL); + + if (SUCCEEDED(hr)) + hr = m_pMC->Stop(); + return hr; +} +STDMETHODIMP HWCSP::GetDeviceCaps(ULONG *fourcc, ULONG *width, ULONG *height, ULONG *fps) +{ + HRESULT hr; + IAMStreamConfig* vsc = NULL; + AM_MEDIA_TYPE* pmt = NULL; + hr = m_pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pDF, IID_IAMStreamConfig, (void**)&vsc); + if (FAILED(hr)) + return hr; + + hr = vsc->GetFormat(&pmt); + if (FAILED(hr)) + { + vsc->Release(); + return hr; + } + + if (pmt != NULL) + { + if (pmt->formattype == FORMAT_VideoInfo) + { + VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmt->pbFormat; + if (pvi->bmiHeader.biBitCount == 24 && pvi->bmiHeader.biCompression == BI_RGB) { + *fourcc = MAKEFOURCC('R', 'G', 'B', '3'); + } else { + *fourcc = (ULONG)pvi->bmiHeader.biCompression; + } + *width = (ULONG)pvi->bmiHeader.biWidth; + *height = (ULONG)pvi->bmiHeader.biHeight; + *fps = (ULONG)pvi->AvgTimePerFrame; + } + DeleteMediaType(pmt); + } + vsc->Release(); + + return hr; +} + +STDMETHODIMP HWCSP::SetFPS(REFERENCE_TIME inFps) +{ + HRESULT hr; + IAMStreamConfig* vsc = NULL; + AM_MEDIA_TYPE* pmt = NULL; + hr = m_pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pDF, IID_IAMStreamConfig, (void**)&vsc); + if (FAILED(hr)) + return hr; + + hr = vsc->GetFormat(&pmt); + if (FAILED(hr)) + { + vsc->Release(); + return hr; + } + + if (pmt != NULL) + { + if (pmt->formattype == FORMAT_VideoInfo) + { + VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmt->pbFormat; + pvi->AvgTimePerFrame = inFps; + hr = vsc->SetFormat(pmt); + } + DeleteMediaType(pmt); + } + vsc->Release(); + return hr; +} + +STDMETHODIMP HWCSP::GetFPS(REFERENCE_TIME *outFps) +{ + HRESULT hr; + IAMStreamConfig* vsc = NULL; + AM_MEDIA_TYPE* pmt = NULL; + hr = m_pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pDF, IID_IAMStreamConfig, (void**)&vsc); + if (FAILED(hr)) + return hr; + + hr = vsc->GetFormat(&pmt); + if (FAILED(hr)) + { + vsc->Release(); + return hr; + } + + if (pmt != NULL) + { + if (pmt->formattype == FORMAT_VideoInfo) + { + VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmt->pbFormat; + *outFps = pvi->AvgTimePerFrame; + } + DeleteMediaType(pmt); + } + vsc->Release(); + return hr; +} + + +STDMETHODIMP HWCSP::SetResolution(LONG width, LONG height) +{ + HRESULT hr; + IAMStreamConfig* vsc = NULL; + AM_MEDIA_TYPE* pmt = NULL; + hr = m_pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pDF, IID_IAMStreamConfig, (void**)&vsc); + if (FAILED(hr)) + return hr; + + hr = vsc->GetFormat(&pmt); + if (FAILED(hr)) + { + vsc->Release(); + return hr; + } + + if (pmt != NULL) + { + if (pmt->formattype == FORMAT_VideoInfo) + { + VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmt->pbFormat; + pvi->bmiHeader.biWidth = width; + pvi->bmiHeader.biHeight = height; + pvi->AvgTimePerFrame = 333333; + pvi->bmiHeader.biSizeImage = ((width * pvi->bmiHeader.biBitCount) >> 3 ) * height; + hr = vsc->SetFormat(pmt); + } + DeleteMediaType(pmt); + } + vsc->Release(); + return hr; +} + +STDMETHODIMP HWCSP::GetResolution(LONG *width, LONG *height) +{ + HRESULT hr; + IAMStreamConfig* vsc = NULL; + AM_MEDIA_TYPE* pmt = NULL; + hr = m_pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pDF, IID_IAMStreamConfig, (void**)&vsc); + if (FAILED(hr)) + return hr; + + hr = vsc->GetFormat(&pmt); + if (FAILED(hr)) + { + vsc->Release(); + return hr; + } + + if (pmt != NULL) + { + if (pmt->formattype == FORMAT_VideoInfo) + { + VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmt->pbFormat; + *width = pvi->bmiHeader.biWidth; + *height = pvi->bmiHeader.biHeight; + } + DeleteMediaType(pmt); + } + vsc->Release(); + return hr; +} + +STDMETHODIMP HWCSP::GetFormats(LPVOID pData) +{ + HRESULT hr; + IAMStreamConfig *pSC; + + if (pData == NULL) + return E_POINTER; + + HWCParam *param = (HWCParam*)pData; + + hr = m_pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, 0, m_pDF, IID_IAMStreamConfig, (void**)&pSC); + if (FAILED(hr)) + return hr; + + int iCount = 0, iSize = 0, nIndex = 0; + hr = pSC->GetNumberOfCapabilities(&iCount, &iSize); + if (FAILED(hr)) + { + pSC->Release(); + return hr; + } + + if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) + { + for (int iFormat = 0; iFormat < iCount; iFormat++) + { + VIDEO_STREAM_CONFIG_CAPS scc; + AM_MEDIA_TYPE *pmtConfig; + hr = pSC->GetStreamCaps(iFormat, &pmtConfig, (BYTE*)&scc); + if (SUCCEEDED(hr)) + { + if (pmtConfig != NULL && pmtConfig->formattype == FORMAT_VideoInfo) + { + VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmtConfig->pbFormat; + // processing!!!! + } + } + DeleteMediaType(pmtConfig); + } + } + pSC->Release(); + return hr; +} + +STDMETHODIMP HWCSP::GetFrameSizes(LPVOID pData) +{ + HRESULT hr; + IAMStreamConfig *pSC; + + if (pData == NULL) + return E_POINTER; + + HWCParam *param = (HWCParam*)pData; + hr = m_pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, 0, m_pDF, IID_IAMStreamConfig, (void**)&pSC); + if (FAILED(hr)) + return hr; + + int iCount = 0, iSize = 0, nIndex = 0; + hr = pSC->GetNumberOfCapabilities(&iCount, &iSize); + if (FAILED(hr)) + { + pSC->Release(); + return hr; + } + + if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) + { + for (int iFormat = 0; iFormat < iCount; iFormat++) + { + VIDEO_STREAM_CONFIG_CAPS scc; + AM_MEDIA_TYPE *pmtConfig; + hr = pSC->GetStreamCaps(iFormat, &pmtConfig, (BYTE*)&scc); + if (SUCCEEDED(hr)) + { + if (pmtConfig != NULL && pmtConfig->formattype == FORMAT_VideoInfo) + { + VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmtConfig->pbFormat; + // processing!!!! + } + } + DeleteMediaType(pmtConfig); + } + } + pSC->Release(); + return hr; +} + +STDMETHODIMP HWCSP::SetDefaultValues() +{ + HRESULT hr; + IAMStreamConfig *pSConfig; + + hr = m_pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, 0, m_pDF, IID_IAMStreamConfig, (void**)&pSConfig); + if (FAILED(hr)) + return hr; + + int iCount = 0, iSize = 0; + hr = pSConfig->GetNumberOfCapabilities(&iCount, &iSize); + if (FAILED(hr)) + { + pSConfig->Release(); + return hr; + } + + if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) + { + for (int iFormat = 0; iFormat < iCount; iFormat++) + { + VIDEO_STREAM_CONFIG_CAPS scc; + AM_MEDIA_TYPE *pmtConfig; + + hr = pSConfig->GetStreamCaps(iFormat, &pmtConfig, (BYTE*)&scc); + if (SUCCEEDED(hr)) + { + if (pmtConfig->formattype == FORMAT_VideoInfo) + { + VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmtConfig->pbFormat; + if ((pvi->bmiHeader.biWidth == m_dwWidth) && + (pvi->bmiHeader.biHeight == m_dwHeight) && + (pvi->bmiHeader.biCompression == m_dwFourcc)) + { + pvi->AvgTimePerFrame = (REFERENCE_TIME)m_dwAvgInterval; + pSConfig->SetFormat(pmtConfig); + } + } + } + DeleteMediaType(pmtConfig); + } + } + pSConfig->Release(); + return hr; +} + +STDMETHODIMP HWCSP::GetFrameIntervals(LPVOID pData) +{ +} + +STDMETHODIMP HWCSP::SetCallback(CallbackFn pCallback) +{ + if (m_pCallback == NULL) { + return E_FAIL; + } + return m_pCallback->SetCallback(pCallback); +} + +static HWCSP *g_pObject = NULL; + +STDMETHODIMP HWCOpen() +{ + HRESULT hr; + + g_pObject = new HWCSP(); + hr = g_pObject->Init(); + if (FAILED(hr)) + goto error_failed; + + hr = g_pObject->BindSourceFilter(); + if (hr != S_OK) + goto error_failed; + + hr = g_pObject->BindTargetFilter(); + if (FAILED(hr)) + goto error_failed; + + hr = g_pObject->ConnectFilters(); + if (FAILED(hr)) + goto error_failed; + + hr = g_pObject->SetDefaultValues(); + if (FAILED(hr)) + goto error_failed; + + return NOERROR; + +error_failed: + delete g_pObject; + return hr; +} + +STDMETHODIMP HWCClose() +{ + if (g_pObject) + delete g_pObject; + return NOERROR; +} + +STDMETHODIMP HWCStart() +{ + if (g_pObject) + return g_pObject->StartPreview(); + + return E_FAIL; +} + +STDMETHODIMP HWCStop() +{ + if (g_pObject) + return g_pObject->StopPreview(); + + return E_FAIL; +} + +STDMETHODIMP HWCSetFPS(long num, long denom) +{ + HRESULT hr; + REFERENCE_TIME inFps = (REFERENCE_TIME)(10000000 * num / denom); + hr = g_pObject->SetFPS(inFps); + return hr; +} + +STDMETHODIMP HWCGetFPS(long *num, long *denom) +{ + HRESULT hr; + REFERENCE_TIME outFps = 0; + hr = g_pObject->GetFPS(&outFps); + if (SUCCEEDED(hr)) { + *num = 1; + *denom = (long)(10000000 / outFps); + } else { + *num = 0; + *denom = 0; + } + return hr; +} + +STDMETHODIMP HWCSetFormat(long width, long height) +{ + HRESULT hr; + hr = g_pObject->SetResolution(width, height); + return hr; +} +STDMETHODIMP HWCGetFormat() +{ + return NOERROR; +} +STDMETHODIMP HWCTryFormat() +{ + return NOERROR; +} +STDMETHODIMP HWCEnumFormat() +{ + return NOERROR; +} + +STDMETHODIMP HWCQueryControl(long nProperty, long *pMin, long *pMax, long *pStep, long *pDefault) +{ + if (g_pObject) + return g_pObject->QueryVideoProcAmp(nProperty, pMin, pMax, pStep, pDefault); + + return E_FAIL; +} + +STDMETHODIMP HWCSetControlValue(long nProperty, long value) +{ + if (g_pObject) + return g_pObject->SetVideoProcAmp(nProperty, value); + + return E_FAIL; +} + +STDMETHODIMP HWCGetControlValue(long nProperty, long *pVal) +{ + if (g_pObject) + return g_pObject->GetVideoProcAmp(nProperty, pVal); + + return E_FAIL; +} + +STDMETHODIMP HWCEnumFrameSizes() +{ + return NOERROR; +} +STDMETHODIMP HWCEnumFrameIntervals() +{ + return NOERROR; +} + +HWCFILTER_API HWCSetCallback(CallbackFn pCallback) +{ + HRESULT hr = g_pObject->SetCallback(pCallback); + return hr; +} + +HWCFILTER_API HWCCtrl(UINT nCmd, UINT nSize, LPVOID pBuf) +{ + HRESULT hr; + HWCParam *param = NULL; + + if (nSize && pBuf) + param = (HWCParam *)pBuf; + + switch (nCmd) + { + case HWC_OPEN: + hr = HWCOpen(); + break; + case HWC_CLOSE: + hr = HWCClose(); + break; + case HWC_START: + hr = HWCStart(); + break; + case HWC_STOP: + hr = HWCStop(); + break; + case HWC_S_FPS: + hr = HWCSetFPS(param->val1, param->val2); + break; + case HWC_G_FPS: + hr = HWCGetFPS(¶m->val1, ¶m->val2); + break; + case HWC_S_FMT: + hr = HWCSetFormat(param->val1, param->val2); + break; + case HWC_G_FMT: + break; + case HWC_TRY_FMT: + break; + case HWC_ENUM_FMT: + break; + case HWC_QCTRL: + hr = HWCQueryControl(param->val1, ¶m->val2, ¶m->val3, + ¶m->val4, ¶m->val5); + break; + case HWC_S_CTRL: + hr = HWCSetControlValue(param->val1, param->val2); + break; + case HWC_G_CTRL: + hr = HWCGetControlValue(param->val1, ¶m->val2); + break; + case HWC_ENUM_FSIZES: + break; + case HWC_ENUM_INTERVALS: + break; + default: + hr = E_INVALIDARG; + break; + } + return hr; +} \ No newline at end of file diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcsp.h b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcsp.h new file mode 100644 index 0000000..bc096fc --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/hwcsp.h @@ -0,0 +1,141 @@ +#ifndef __HWCPS_H__ +#define __HWCPS_H__ + +#ifdef HWCFILTER_EXPORTS +#define HWCFILTER_API extern "C" __declspec(dllexport) HRESULT __stdcall +#else +#define HWCFILTER_API __declspec(dllimport) +#endif + +#include +#include "hwcfilter.h" + +#define SAFE_RELEASE(x) if (x) { (x)->Release(); (x) = NULL; } + +typedef int (STDAPICALLTYPE *CallbackFn)(ULONG dwSize, BYTE *pBuffer); + +class CCallback : ICaptureCallBack +{ +public: + CCallback(); + virtual ~CCallback(); + STDMETHODIMP QueryInterface(REFIID riid, void **ppv); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP CaptureCallback(ULONG dwSize, BYTE *pBuffer); + STDMETHODIMP SetCallback(CallbackFn pCallbackFn); + +private: + long m_cRef; + CallbackFn m_pCallback; +}; + +class HWCSP +{ +public: + HWCSP(); + ~HWCSP(); + + STDMETHODIMP Init(); + + STDMETHODIMP BindSourceFilter(); + STDMETHODIMP BindTargetFilter(); + STDMETHODIMP ConnectFilters(); + STDMETHODIMP GetDeviceCaps(ULONG *fourcc, ULONG *width, ULONG *height, ULONG *fps); + + STDMETHODIMP_(void) CloseInterfaces(); + STDMETHODIMP_(void) DeleteMediaType(AM_MEDIA_TYPE *pmt); + + STDMETHODIMP QueryVideoProcAmp(long nProperty, long *pMin, long *pMax, long *pStep, long *pDefault); + STDMETHODIMP GetVideoProcAmp(long nProperty, long *pValue); + STDMETHODIMP SetVideoProcAmp(long nProperty, long value); + + STDMETHODIMP StartPreview(); + STDMETHODIMP StopPreview(); + + STDMETHODIMP SetFPS(REFERENCE_TIME inFps); + STDMETHODIMP GetFPS(REFERENCE_TIME *outFps); + + STDMETHODIMP SetResolution(LONG width, LONG height); + STDMETHODIMP GetResolution(LONG *width, LONG *height); + + STDMETHODIMP GetFormats(LPVOID pData); + STDMETHODIMP GetFrameSizes(LPVOID pData); + STDMETHODIMP GetFrameIntervals(LPVOID pData); + STDMETHODIMP SetDefaultValues(); + + STDMETHODIMP SetCallback(CallbackFn pCallback); + +private: + STDMETHODIMP GetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir, IPin **ppPin); + + IGraphBuilder *m_pGB ; + ICaptureGraphBuilder2 *m_pCGB; + IMediaControl *m_pMC; + IMediaEventEx *m_pME; + + IPin *m_pOutputPin; + IPin *m_pInputPin; + IBaseFilter *m_pDF; + IBaseFilter *m_pSF; + + CCallback *m_pCallback; + + HINSTANCE m_hDLL; + DWORD m_dwFourcc; + DWORD m_dwWidth; + DWORD m_dwHeight; + DWORD m_dwAvgInterval; +}; + +enum { + HWC_OPEN, + HWC_CLOSE, + HWC_START, + HWC_STOP, + HWC_S_FPS, + HWC_G_FPS, + HWC_S_FMT, + HWC_G_FMT, + HWC_TRY_FMT, + HWC_ENUM_FMT, + HWC_QCTRL, + HWC_S_CTRL, + HWC_G_CTRL, + HWC_ENUM_FSIZES, + HWC_ENUM_INTERVALS +}; + +typedef struct tagHWCParam { + long val1; + long val2; + long val3; + long val4; + long val5; +} HWCParam; + +HWCFILTER_API HWCCtrl(UINT nCmd, UINT nSize, LPVOID pBuf); + +HWCFILTER_API HWCSetCallback(CallbackFn pCallback); + +STDMETHODIMP HWCOpen(); +STDMETHODIMP HWCClose(); +STDMETHODIMP HWCStart(); +STDMETHODIMP HWCStop(); + +STDMETHODIMP HWCSetFPS(long num, long denom); +STDMETHODIMP HWCGetFPS(long *num, long *denom); + +STDMETHODIMP HWCSetFormat(long width, long height); +STDMETHODIMP HWCGetFormat(); +STDMETHODIMP HWCTryFormat(); +STDMETHODIMP HWCEnumFormat(); + +STDMETHODIMP HWCQueryControl(long nProperty, long *pMin, long *pMax, long *pStep, long *pDefault); +STDMETHODIMP HWCSetControlValue(long nProperty, long value); +STDMETHODIMP HWCGetControlValue(long nProperty, long *pVal); + +STDMETHODIMP HWCEnumFrameSizes(); +STDMETHODIMP HWCEnumFrameIntervals(); + +#endif // __HWCPS_H__ \ No newline at end of file diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/stdafx.cpp b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/stdafx.cpp new file mode 100644 index 0000000..701e869 --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : Ç¥ÁØ Æ÷ÇÔ ÆÄÀϸ¸ µé¾î ÀÖ´Â ¼Ò½º ÆÄÀÏÀÔ´Ï´Ù. +// hwcfilter.pch´Â ¹Ì¸® ÄÄÆÄÀÏµÈ Çì´õ°¡ µË´Ï´Ù. +// stdafx.obj¿¡´Â ¹Ì¸® ÄÄÆÄÀÏµÈ Çü½Ä Á¤º¸°¡ Æ÷ÇԵ˴ϴÙ. + +#include "stdafx.h" + +// TODO: ÇÊ¿äÇÑ Ãß°¡ Çì´õ´Â +// ÀÌ ÆÄÀÏÀÌ ¾Æ´Ñ STDAFX.H¿¡¼­ ÂüÁ¶ÇÕ´Ï´Ù. diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/stdafx.h b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/stdafx.h new file mode 100644 index 0000000..69c69fc --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/stdafx.h @@ -0,0 +1,16 @@ +// stdafx.h : ÀÚÁÖ »ç¿ëÇÏÁö¸¸ ÀÚÁÖ º¯°æµÇÁö´Â ¾Ê´Â +// Ç¥ÁØ ½Ã½ºÅÛ Æ÷ÇÔ ÆÄÀÏ ¹× ÇÁ·ÎÁ§Æ® °ü·Ã Æ÷ÇÔ ÆÄÀÏÀÌ +// µé¾î ÀÖ´Â Æ÷ÇÔ ÆÄÀÏÀÔ´Ï´Ù. +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // °ÅÀÇ »ç¿ëµÇÁö ¾Ê´Â ³»¿ëÀº Windows Çì´õ¿¡¼­ Á¦¿ÜÇÕ´Ï´Ù. +// Windows Çì´õ ÆÄÀÏ: +#include + + + +// TODO: ÇÁ·Î±×·¥¿¡ ÇÊ¿äÇÑ Ãß°¡ Çì´õ´Â ¿©±â¿¡¼­ ÂüÁ¶ÇÕ´Ï´Ù. diff --git a/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/targetver.h b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/targetver.h new file mode 100644 index 0000000..d5eaaea --- /dev/null +++ b/tizen/src/hw/camera_win32_dll/hwcfilter/hwcfilter/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h¸¦ Æ÷ÇÔÇϸé ÃÖ°í ¼öÁØÀÇ °¡¿ë¼ºÀ» °¡Áø Windows Ç÷§ÆûÀÌ Á¤Àǵ˴ϴÙ. + +// ÀÌÀü Windows Ç÷§Æû¿¡ ´ëÇØ ÀÀ¿ë ÇÁ·Î±×·¥À» ºôµåÇÏ·Á´Â °æ¿ì¿¡´Â SDKDDKVer.h¸¦ Æ÷ÇÔÇϱâ Àü¿¡ +// WinSDKVer.h¸¦ Æ÷ÇÔÇÏ°í _WIN32_WINNT ¸ÅÅ©·Î¸¦ Áö¿øÇÏ·Á´Â Ç÷§ÆûÀ¸·Î ¼³Á¤ÇϽʽÿÀ. + +#include diff --git a/tizen/src/hw/svcamera_win32.c b/tizen/src/hw/svcamera_win32.c index 98b3dfa..faa9709 100644 --- a/tizen/src/hw/svcamera_win32.c +++ b/tizen/src/hw/svcamera_win32.c @@ -145,6 +145,7 @@ typedef HRESULT (STDAPICALLTYPE *SETCALLBACKFN)(CallbackFn); static HINSTANCE g_hInst = NULL; +static SVCamState *g_state = NULL; static CTRLFN SVCamCtrl; static SETCALLBACKFN SVCamSetCallbackFn; @@ -152,10 +153,6 @@ static SETCALLBACKFN SVCamSetCallbackFn; static uint32_t cur_fmt_idx = 0; static uint32_t cur_frame_idx = 0; - -static void *g_vaddr = NULL; -static qemu_irq *g_irq = NULL; - void v4lconvert_yuyv_to_yuv420(const unsigned char *src, unsigned char *dest, uint32_t width, uint32_t height, uint32_t yvu); @@ -197,22 +194,29 @@ static long value_convert_to_guest(long min, long max, long value) static int STDAPICALLTYPE svcam_device_callbackfn(ULONG dwSize, BYTE *pBuffer) { + static uint32_t index = 0; uint32_t width, height; width = supported_dst_frames[cur_frame_idx].width; height = supported_dst_frames[cur_frame_idx].height; + void *buf = g_state->vaddr + (g_state->buf_size * index); switch (supported_dst_pixfmts[cur_fmt_idx].fmt) { case V4L2_PIX_FMT_YUV420: - v4lconvert_yuyv_to_yuv420(pBuffer, g_vaddr, width, height, 0); + v4lconvert_yuyv_to_yuv420(pBuffer, buf, width, height, 0); break; case V4L2_PIX_FMT_YVU420: - v4lconvert_yuyv_to_yuv420(pBuffer, g_vaddr, width, height, 1); + v4lconvert_yuyv_to_yuv420(pBuffer, buf, width, height, 1); break; case V4L2_PIX_FMT_YUYV: - memcpy(g_vaddr, (void*)pBuffer, dwSize); + memcpy(buf, (void*)pBuffer, dwSize); break; } - qemu_irq_raise(g_irq[2]); + index = !index; + + if (g_state->req_frame) { + qemu_irq_raise(g_state->dev.irq[2]); + g_state->req_frame = 0; + } return 1; } @@ -224,8 +228,7 @@ void svcam_device_init(SVCamState* state) pthread_cond_init(&thread->thread_cond, NULL); pthread_mutex_init(&thread->mutex_lock, NULL); - g_vaddr = state->vaddr; - g_irq = state->dev.irq; + g_state = state; } // SVCAM_CMD_OPEN @@ -299,6 +302,7 @@ void svcam_device_close(SVCamState* state) void svcam_device_start_preview(SVCamState* state) { HRESULT hr; + uint32_t width, height; SVCamParam *param = state->thread->param; TRACE("svcam_device_start_preview\n"); param->top = 0; @@ -306,10 +310,15 @@ void svcam_device_start_preview(SVCamState* state) if (FAILED(hr)) { param->errCode = EINVAL; ERR("start preview failed!!!, [HRESULT : 0x%x]\n", hr); + return; } pthread_mutex_lock(&state->thread->mutex_lock); state->streamon = 1; pthread_mutex_unlock(&state->thread->mutex_lock); + + width = supported_dst_frames[cur_frame_idx].width; + height = supported_dst_frames[cur_frame_idx].height; + state->buf_size = height * ((width * supported_dst_pixfmts[cur_fmt_idx].bpp) >> 3); } // SVCAM_CMD_STOP_PREVIEW @@ -327,6 +336,7 @@ void svcam_device_stop_preview(SVCamState* state) pthread_mutex_lock(&state->thread->mutex_lock); state->streamon = 0; pthread_mutex_unlock(&state->thread->mutex_lock); + state->buf_size = 0; } // SVCAM_CMD_S_PARAM