summaryrefslogtreecommitdiff
path: root/AVStream/samplemft0
diff options
context:
space:
mode:
authorWei Mao <[email protected]>2017-03-17 19:47:04 -0700
committerWei Mao <[email protected]>2017-03-17 19:47:04 -0700
commit1a3e0d580380e58bf336a242d2affc8a1e2d1ddf (patch)
treebf5d9c5b0b4cba1b81726b9f78c4d5ff5c636fea /AVStream/samplemft0
parentda21c8784c83c5fd614f3030323e229d6a5fb10e (diff)
Fix cases
Diffstat (limited to 'AVStream/samplemft0')
-rw-r--r--AVStream/samplemft0/Mft0.cpp975
-rw-r--r--AVStream/samplemft0/Mft0.h224
-rw-r--r--AVStream/samplemft0/Mft0.rgs15
-rw-r--r--AVStream/samplemft0/README.md28
-rw-r--r--AVStream/samplemft0/SampleHelpers.h143
-rw-r--r--AVStream/samplemft0/SampleMft0.cpp83
-rw-r--r--AVStream/samplemft0/SampleMft0.def16
-rw-r--r--AVStream/samplemft0/SampleMft0.idl48
-rw-r--r--AVStream/samplemft0/SampleMft0.rcbin0 -> 6644 bytes
-rw-r--r--AVStream/samplemft0/SampleMft0.rgs3
-rw-r--r--AVStream/samplemft0/SampleMft0.sln41
-rw-r--r--AVStream/samplemft0/SampleMft0.vcxproj146
-rw-r--r--AVStream/samplemft0/SampleMft0.vcxproj.Filters99
-rw-r--r--AVStream/samplemft0/dllmain.cpp19
-rw-r--r--AVStream/samplemft0/dllmain.h10
-rw-r--r--AVStream/samplemft0/resource.hbin0 -> 1710 bytes
-rw-r--r--AVStream/samplemft0/stdafx.cpp13
-rw-r--r--AVStream/samplemft0/stdafx.h42
-rw-r--r--AVStream/samplemft0/stdafxsrc.cpp1
-rw-r--r--AVStream/samplemft0/targetver.h15
20 files changed, 1921 insertions, 0 deletions
diff --git a/AVStream/samplemft0/Mft0.cpp b/AVStream/samplemft0/Mft0.cpp
new file mode 100644
index 00000000..044a4e71
--- /dev/null
+++ b/AVStream/samplemft0/Mft0.cpp
@@ -0,0 +1,975 @@
+// Mft0.cpp : Implementation of CMft0
+
+#include "stdafx.h"
+#include "Mft0.h"
+#include "SampleHelpers.h"
+#include <WinString.h>
+
+// CMft0
+STDMETHODIMP CMft0::UpdateDsp(UINT32 uiPercentOfScreen)
+{
+ m_percentOfScreen = uiPercentOfScreen;
+ return S_OK;
+}
+
+STDMETHODIMP CMft0::Enable(void)
+{
+ m_bEnableEffects = TRUE;
+ return S_OK;
+}
+
+STDMETHODIMP CMft0::Disable(void)
+{
+ m_bEnableEffects = FALSE;
+ return S_OK;
+}
+
+STDMETHODIMP CMft0::GetDspSetting(UINT* puiPercentOfScreen, BOOL* pIsEnabled)
+{
+ HRESULT hr = S_OK;
+ do {
+ CHK_NULL_PTR_BRK(puiPercentOfScreen);
+ CHK_NULL_PTR_BRK(pIsEnabled);
+ *puiPercentOfScreen = m_percentOfScreen;
+ *pIsEnabled = m_bEnableEffects;
+ } while (FALSE);
+
+ return S_OK;
+}
+
+STDMETHODIMP CMft0::GetIids(
+ /* [out] */ _Out_ ULONG *iidCount,
+ /* [size_is][size_is][out] */ _Outptr_result_buffer_maybenull_(*iidCount) IID **iids)
+{
+ HRESULT hr = S_OK;
+ do {
+ CHK_NULL_PTR_BRK(iidCount);
+ CHK_NULL_PTR_BRK(iids);
+ *iids = NULL;
+ *iidCount = 0;
+ } while (FALSE);
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetRuntimeClassName(
+ /* [out] */ _Outptr_result_maybenull_ HSTRING *className)
+{
+ HRESULT hr = S_OK;
+ if(className != nullptr)
+ {
+ hr = WindowsCreateString(NULL, 0, className);
+ if(FAILED(hr)){
+ hr = E_OUTOFMEMORY;
+ }
+ }else {
+ hr = E_INVALIDARG;
+ }
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetTrustLevel(
+ /* [out] */ _Out_ TrustLevel *trustLevel)
+{
+ HRESULT hr = S_OK;
+ do {
+ CHK_NULL_PTR_BRK(trustLevel);
+ *trustLevel = TrustLevel::BaseTrust;
+ } while (FALSE);
+
+ return hr;
+}
+
+
+STDMETHODIMP CMft0::GetStreamLimits(
+ /* [out] */ _Out_ DWORD *pdwInputMinimum,
+ /* [out] */ _Out_ DWORD *pdwInputMaximum,
+ /* [out] */ _Out_ DWORD *pdwOutputMinimum,
+ /* [out] */ _Out_ DWORD *pdwOutputMaximum)
+{
+ HRESULT hr = S_OK;
+ do {
+ if ((pdwInputMinimum == NULL) ||
+ (pdwInputMaximum == NULL) ||
+ (pdwOutputMinimum == NULL) ||
+ (pdwOutputMaximum == NULL))
+ {
+ hr = E_POINTER;
+ break;
+ }
+
+ // This MFT has a fixed number of streams.
+ *pdwInputMinimum = 1;
+ *pdwInputMaximum = 1;
+ *pdwOutputMinimum = 1;
+ *pdwOutputMaximum = 1;
+ } while (FALSE);
+
+ return hr;
+}
+
+
+STDMETHODIMP CMft0::GetStreamCount(
+ /* [out] */ _Out_ DWORD *pcInputStreams,
+ /* [out] */ _Out_ DWORD *pcOutputStreams)
+{
+ HRESULT hr = S_OK;
+
+ do {
+ if ((pcInputStreams == NULL) || (pcOutputStreams == NULL))
+
+ {
+ hr = E_POINTER;
+ break;
+ }
+
+ // This MFT has a fixed number of streams.
+ *pcInputStreams = 1;
+ *pcOutputStreams = 1;
+ } while (FALSE);
+
+ return hr;
+}
+STDMETHODIMP CMft0::GetStreamIDs(
+ DWORD dwInputIDArraySize,
+ /* [size_is][out] */ _Out_writes_(dwInputIDArraySize) DWORD *pdwInputIDs,
+ DWORD dwOutputIDArraySize,
+ /* [size_is][out] */ _Out_writes_(dwOutputIDArraySize) DWORD *pdwOutputIDs)
+{
+ dwOutputIDArraySize = 0;
+ dwInputIDArraySize = 0;
+ pdwInputIDs = NULL;
+ pdwOutputIDs = NULL;
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CMft0::GetInputStreamInfo(
+ DWORD dwInputStreamID,
+ /* [out] */ _Out_ MFT_INPUT_STREAM_INFO *pStreamInfo)
+{
+ HRESULT hr = S_OK;
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_NULL_BRK(pStreamInfo);
+ if (!IsValidInputStream(dwInputStreamID))
+ {
+ CHK_LOG_BRK(MF_E_INVALIDSTREAMNUMBER);
+ }
+ if(m_pInputType) {
+ pStreamInfo->cbAlignment = 0;
+ pStreamInfo->cbSize = 0;
+ pStreamInfo->dwFlags = MFT_INPUT_STREAM_WHOLE_SAMPLES | MFT_INPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER ;
+ pStreamInfo->hnsMaxLatency = 0;
+ } else {
+ hr = MF_E_TRANSFORM_TYPE_NOT_SET;
+ }
+ } while (FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+
+STDMETHODIMP CMft0::GetOutputStreamInfo(
+ DWORD dwOutputStreamID,
+ /* [out] */ _Out_ MFT_OUTPUT_STREAM_INFO *pStreamInfo)
+{
+ HRESULT hr = S_OK;
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_NULL_BRK(pStreamInfo);
+ if (!IsValidInputStream(dwOutputStreamID))
+ {
+ CHK_LOG_BRK(MF_E_INVALIDSTREAMNUMBER);
+ }
+ if(m_pOutputType) {
+ pStreamInfo->cbAlignment = 0;
+ pStreamInfo->cbSize = 0;
+ pStreamInfo->dwFlags = MFT_OUTPUT_STREAM_WHOLE_SAMPLES | MFT_OUTPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER | MFT_OUTPUT_STREAM_PROVIDES_SAMPLES | MFT_OUTPUT_STREAM_FIXED_SAMPLE_SIZE;
+ } else {
+ hr = MF_E_TRANSFORM_TYPE_NOT_SET;
+ }
+
+ } while (FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetAttributes(
+ /* [out] */ _Outptr_result_maybenull_ IMFAttributes **ppAttributes)
+{
+ HRESULT hr = S_OK;
+
+ do {
+ CHK_NULL_PTR_BRK(ppAttributes);
+ if(!m_pGlobalAttributes) {
+ CHK_LOG_BRK(MFCreateAttributes(&m_pGlobalAttributes, 3));
+ CHK_LOG_BRK(m_pGlobalAttributes->SetUINT32(MF_TRANSFORM_ASYNC, FALSE));
+ CHK_LOG_BRK(m_pGlobalAttributes->SetString(MFT_ENUM_HARDWARE_URL_Attribute, L"Sample_CameraExtensionMft"));
+ CHK_LOG_BRK(m_pGlobalAttributes->SetUINT32(MFT_SUPPORT_DYNAMIC_FORMAT_CHANGE, TRUE));
+ }
+ *ppAttributes = m_pGlobalAttributes;
+ (*ppAttributes)->AddRef();
+ } while (FALSE);
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetInputStreamAttributes(
+ DWORD dwInputStreamID,
+ /* [out] */ _Outptr_result_maybenull_ IMFAttributes **ppAttributes)
+{
+ HRESULT hr = S_OK;
+
+ do {
+ if(dwInputStreamID > 0) {
+ hr = MF_E_INVALIDSTREAMNUMBER;
+ break;
+ }
+ CHK_NULL_PTR_BRK(ppAttributes);
+ if(!m_pInputAttributes){
+ CHK_LOG_BRK(MFCreateAttributes(&m_pInputAttributes, 2));
+ CHK_LOG_BRK(m_pInputAttributes->SetUINT32(MFT_SUPPORT_DYNAMIC_FORMAT_CHANGE, TRUE));
+ CHK_LOG_BRK(m_pInputAttributes->SetString(MFT_ENUM_HARDWARE_URL_Attribute, L"Sample_CameraExtensionMft"));
+ }
+ *ppAttributes = m_pInputAttributes;
+ (*ppAttributes)->AddRef();
+ } while (FALSE);
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetOutputStreamAttributes(
+ DWORD dwOutputStreamID,
+ /* [out] */ _Outptr_result_maybenull_ IMFAttributes **ppAttributes)
+{
+ HRESULT hr = S_OK;
+
+ do {
+ if(dwOutputStreamID > 0) {
+ hr = MF_E_INVALIDSTREAMNUMBER;
+ break;
+ }
+ CHK_NULL_PTR_BRK(ppAttributes);
+ CHK_NULL_PTR_BRK(m_pInputAttributes);
+
+ *ppAttributes = m_pInputAttributes;
+ (*ppAttributes)->AddRef();
+ } while (FALSE);
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::DeleteInputStream(
+ DWORD dwStreamID)
+{
+ HRESULT hr = S_OK;
+ if(dwStreamID > 0) {
+ hr = MF_E_INVALIDSTREAMNUMBER;
+ } else {
+ hr = E_NOTIMPL;
+ }
+ return hr;
+}
+
+STDMETHODIMP CMft0::AddInputStreams(
+ DWORD cStreams,
+ /* [in] */ _In_ DWORD *adwStreamIDs)
+{
+ HRESULT hr = S_OK;
+
+ if( !adwStreamIDs || cStreams > 0) {
+ hr = E_INVALIDARG;
+ } else {
+ hr = E_NOTIMPL;
+ }
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetInputAvailableType(
+ DWORD dwInputStreamID,
+ DWORD dwTypeIndex,
+ /* [out] */ _Outptr_result_maybenull_ IMFMediaType **ppType)
+{
+ HRESULT hr = S_OK;
+ IUnknown *pUnk = NULL;
+ IMFAttributes *pSourceAttributes = NULL;
+ UINT32 uiSourceStreamId = 0;
+ wchar_t *pszName;
+
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_BOOL_BRK(IsValidInputStream(dwInputStreamID));
+
+ if(!m_pSourceTransform && m_pInputAttributes) {
+ CHK_LOG_BRK(m_pInputAttributes->GetUnknown(MFT_CONNECTED_STREAM_ATTRIBUTE, IID_PPV_ARGS(&pSourceAttributes)));
+ CHK_LOG_BRK(pSourceAttributes->GetUnknown(MF_DEVICESTREAM_EXTENSION_PLUGIN_CONNECTION_POINT, IID_PPV_ARGS(&pUnk)));
+ CHK_LOG_BRK(pUnk->QueryInterface(__uuidof(IMFTransform), (void**)&m_pSourceTransform));
+ CHK_LOG_BRK(pSourceAttributes->GetGUID( MF_DEVICESTREAM_STREAM_CATEGORY, &m_stStreamType));
+ CHK_LOG_BRK(pSourceAttributes->GetUINT32( MF_DEVICESTREAM_STREAM_ID, &uiSourceStreamId));
+
+ if(m_stStreamType == PINNAME_VIDEO_CAPTURE) {
+ wprintf(L"Stream type: PINNAME_VIDEO_CAPTURE\n");
+ } else if(m_stStreamType == PINNAME_VIDEO_PREVIEW) {
+ wprintf(L"Stream type: PINNAME_VIDEO_PREVIEW\n");
+ } else if(m_stStreamType == PINNAME_VIDEO_STILL) {
+ wprintf(L"Stream type: PINNAME_VIDEO_STILL\n");
+ } else if(m_stStreamType == PINNAME_IMAGE) {
+ wprintf(L"Stream type: PINNAME_IMAGE\n");
+ } else {
+ StringFromCLSID(m_stStreamType, &pszName);
+ if(pszName){
+ wprintf(L"Stream type: %s\n", pszName);
+ CoTaskMemFree(pszName);
+ }
+ }
+ CHK_LOG_BRK((m_stStreamType == PINNAME_VIDEO_PREVIEW || m_stStreamType == PINNAME_VIDEO_CAPTURE) ? S_OK : E_UNEXPECTED);
+ CHK_LOG_BRK(GenerateMFMediaTypeListFromDevice(uiSourceStreamId));
+ }
+
+ CHK_LOG_BRK(GetMediaType(dwInputStreamID, dwTypeIndex, ppType));
+ } while (FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ SAFERELEASE(pUnk);
+ SAFERELEASE(pSourceAttributes);
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetOutputAvailableType(
+ DWORD dwOutputStreamID,
+ DWORD dwTypeIndex,
+ /* [out] */ _Outptr_result_maybenull_ IMFMediaType **ppType)
+{
+ HRESULT hr = S_OK;
+ IUnknown *pUnk = NULL;
+ IMFAttributes *pSourceAttributes = NULL;
+ UINT32 uiSourceStreamId = 0;
+ wchar_t *pszName;
+
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_BOOL_BRK(IsValidOutputStream(dwOutputStreamID));
+ if(!m_pSourceTransform && m_pInputAttributes) {
+ CHK_LOG_BRK(m_pInputAttributes->GetUnknown(MFT_CONNECTED_STREAM_ATTRIBUTE, IID_PPV_ARGS(&pSourceAttributes)));
+ CHK_LOG_BRK(pSourceAttributes->GetUnknown(MF_DEVICESTREAM_EXTENSION_PLUGIN_CONNECTION_POINT, IID_PPV_ARGS(&pUnk)));
+ CHK_LOG_BRK(pUnk->QueryInterface(__uuidof(IMFTransform), (void**)&m_pSourceTransform));
+ CHK_LOG_BRK(pSourceAttributes->GetGUID( MF_DEVICESTREAM_STREAM_CATEGORY, &m_stStreamType));
+ CHK_LOG_BRK(pSourceAttributes->GetUINT32( MF_DEVICESTREAM_STREAM_ID, &uiSourceStreamId));
+ if(m_stStreamType == PINNAME_VIDEO_CAPTURE) {
+ wprintf(L"Stream type: PINNAME_VIDEO_CAPTURE\n");
+ } else if(m_stStreamType == PINNAME_VIDEO_PREVIEW) {
+ wprintf(L"Stream type: PINNAME_VIDEO_PREVIEW\n");
+ } else if(m_stStreamType == PINNAME_VIDEO_STILL) {
+ wprintf(L"Stream type: PINNAME_VIDEO_STILL\n");
+ } else if(m_stStreamType == PINNAME_IMAGE) {
+ wprintf(L"Stream type: PINNAME_IMAGE\n");
+ } else {
+ StringFromCLSID(m_stStreamType, &pszName);
+ wprintf(L"Stream type: %s\n", pszName);
+ }
+ CHK_LOG_BRK((m_stStreamType == PINNAME_VIDEO_PREVIEW || m_stStreamType == PINNAME_VIDEO_CAPTURE) ? S_OK : E_UNEXPECTED);
+ CHK_LOG_BRK(GenerateMFMediaTypeListFromDevice(uiSourceStreamId));
+ }
+
+ CHK_LOG_BRK(GetMediaType(dwOutputStreamID, dwTypeIndex, ppType));
+ } while (FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ SAFERELEASE(pUnk);
+ SAFERELEASE(pSourceAttributes);
+ return hr;
+}
+
+STDMETHODIMP CMft0::SetInputType(
+ DWORD dwInputStreamID,
+ /* [in] */ _In_opt_ IMFMediaType *pType,
+ DWORD dwFlags)
+{
+ HRESULT hr = S_OK;
+
+ EnterCriticalSection(&m_critSec);
+
+ BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0);
+ // Validate flags.
+ do {
+ if(bReallySet) {
+ CComPtr<IMFMediaType> pFullType;
+ CHK_LOG_BRK(IsMediaTypeSupported(dwInputStreamID, pType, &pFullType));
+ SAFERELEASE(m_pInputType);
+ SAFERELEASE(m_pOutputType);
+ m_pOutputType = pFullType;
+ m_pOutputType->AddRef();
+ m_pInputType = pFullType;
+ m_pInputType->AddRef();
+ } else {
+ CHK_LOG_BRK(IsMediaTypeSupported(dwInputStreamID, pType));
+ }
+ } while(FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+STDMETHODIMP CMft0::SetOutputType(
+ DWORD dwOutputStreamID,
+ /* [in] */ _In_opt_ IMFMediaType *pType,
+ DWORD dwFlags)
+{
+ HRESULT hr = S_OK;
+
+ do {
+ CHK_LOG_BRK(SetInputType(dwOutputStreamID, pType, dwFlags));
+ } while (FALSE);
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetInputCurrentType(
+ DWORD dwInputStreamID,
+ /* [out] */ _Outptr_result_maybenull_ IMFMediaType **ppType)
+{
+ HRESULT hr = S_OK;
+
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_NULL_BRK(ppType);
+
+ if (!IsValidInputStream(dwInputStreamID))
+ {
+ CHK_LOG_BRK(MF_E_INVALIDSTREAMNUMBER);
+ }
+ else if(m_pInputType)
+ {
+ *ppType = m_pInputType;
+ (*ppType)->AddRef();
+ }
+ else
+ {
+ CHK_LOG_BRK(MF_E_TRANSFORM_TYPE_NOT_SET);
+ }
+ } while (FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetOutputCurrentType(
+ DWORD dwOutputStreamID,
+ /* [out] */ _Outptr_result_maybenull_ IMFMediaType **ppType)
+{
+ HRESULT hr = S_OK;
+
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_NULL_BRK(ppType);
+
+ if (!IsValidOutputStream(dwOutputStreamID))
+ {
+ CHK_LOG_BRK(MF_E_INVALIDSTREAMNUMBER);
+ }
+ else if(m_pOutputType)
+ {
+ *ppType = m_pOutputType;
+ (*ppType)->AddRef();
+ }
+ else
+ {
+ CHK_LOG_BRK(MF_E_TRANSFORM_TYPE_NOT_SET);
+ }
+ } while (FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetInputStatus(
+ DWORD dwInputStreamID,
+ /* [out] */ _Out_ DWORD *pdwFlags)
+{
+ HRESULT hr = S_OK;
+
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_BOOL_BRK(pdwFlags);
+
+ if (!IsValidInputStream(dwInputStreamID))
+ {
+ CHK_LOG_BRK(MF_E_INVALIDSTREAMNUMBER);
+ }
+
+ // If we already have an input sample, we don't accept
+ // another one until the client calls ProcessOutput or Flush.
+ if (m_pSample == NULL)
+ {
+ *pdwFlags = MFT_INPUT_STATUS_ACCEPT_DATA;
+ }
+ else
+ {
+ *pdwFlags = 0;
+ }
+ } while (FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetOutputStatus(
+ /* [out] */ _Out_ DWORD *pdwFlags)
+{
+ HRESULT hr = S_OK;
+
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_NULL_BRK(pdwFlags);
+ // We can produce an output sample if (and only if)
+ // we have an input sample.
+ if (m_pSample != NULL)
+ {
+ *pdwFlags = MFT_OUTPUT_STATUS_SAMPLE_READY;
+ }
+ else
+ {
+ *pdwFlags = 0;
+ }
+ } while (FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+STDMETHODIMP CMft0::SetOutputBounds(
+ LONGLONG hnsLowerBound,
+ LONGLONG hnsUpperBound)
+{
+ UNREFERENCED_PARAMETER(hnsLowerBound);
+ UNREFERENCED_PARAMETER(hnsUpperBound);
+ return S_OK;
+}
+
+STDMETHODIMP CMft0::ProcessEvent(
+ DWORD dwInputStreamID,
+ /* [in] */ _In_opt_ IMFMediaEvent *pEvent)
+{
+ UNREFERENCED_PARAMETER(dwInputStreamID);
+ UNREFERENCED_PARAMETER(pEvent);
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CMft0::ProcessMessage(
+ MFT_MESSAGE_TYPE eMessage,
+ ULONG_PTR ulParam)
+{
+ UNREFERENCED_PARAMETER(ulParam);
+ HRESULT hr = S_OK;
+
+ EnterCriticalSection(&m_critSec);
+
+ switch (eMessage)
+ {
+ case MFT_MESSAGE_COMMAND_FLUSH:
+ // Flush the MFT.
+ hr = OnFlush();
+ break;
+
+ case MFT_MESSAGE_COMMAND_DRAIN:
+ // Drain: Tells the MFT not to accept any more input until
+ // all of the pending output has been processed. That is our
+ // default behevior already, so there is nothing to do.
+ break;
+
+ case MFT_MESSAGE_SET_D3D_MANAGER:
+ // The pipeline should never send this message unless the MFT
+ // has the MF_SA_D3D_AWARE attribute set to TRUE. However, if we
+ // do get this message, it's invalid and we don't implement it.
+ hr = E_NOTIMPL;
+ break;
+
+ // The remaining messages do not require any action from this MFT.
+ case MFT_MESSAGE_NOTIFY_BEGIN_STREAMING:
+ case MFT_MESSAGE_NOTIFY_END_STREAMING:
+ case MFT_MESSAGE_NOTIFY_END_OF_STREAM:
+ case MFT_MESSAGE_NOTIFY_START_OF_STREAM:
+ break;
+ }
+
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+STDMETHODIMP CMft0::ProcessInput(
+ DWORD dwInputStreamID,
+ IMFSample *pSample,
+ DWORD dwFlags)
+{
+ HRESULT hr = S_OK;
+
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_NULL_BRK(pSample);
+
+ CHK_BOOL_BRK(dwFlags == 0)
+
+ DWORD dwBufferCount = 0;
+
+ if (!IsValidInputStream(dwInputStreamID))
+ {
+ CHK_LOG_BRK(hr = MF_E_INVALIDSTREAMNUMBER);
+ }
+
+ if (!m_pInputType || !m_pOutputType)
+ {
+ CHK_LOG_BRK(MF_E_NOTACCEPTING); // Client must set input and output types.
+ }
+
+ if (m_pSample != NULL)
+ {
+ CHK_LOG_BRK(MF_E_NOTACCEPTING); // We already have an input sample.
+ }
+
+ // Validate the number of buffers. There should only be a single buffer to hold the video frame.
+ CHK_LOG_BRK(pSample->GetBufferCount(&dwBufferCount));
+
+ if (dwBufferCount == 0)
+ {
+ CHK_LOG_BRK(E_FAIL);
+ }
+ if (dwBufferCount > 1)
+ {
+ CHK_LOG_BRK(MF_E_SAMPLE_HAS_TOO_MANY_BUFFERS);
+ }
+
+ // Cache the sample. We do the actual work in ProcessOutput.
+ m_pSample = pSample;
+ pSample->AddRef(); // Hold a reference count on the sample.
+ } while (FALSE);
+
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+STDMETHODIMP CMft0::ProcessOutput(
+ DWORD dwFlags,
+ DWORD cOutputBufferCount,
+ /* [size_is][out][in] */ MFT_OUTPUT_DATA_BUFFER *pOutputSamples,
+ /* [out] */ DWORD *pdwStatus)
+{
+ HRESULT hr = S_OK;
+
+ IMFMediaBuffer *pMediaBufInput = NULL,
+ *pMediaBufOutput = NULL;
+ IMFSample *pOutputIMFSample = NULL;
+ LONGLONG hnsDuration = 0,
+ hnsTime = 0;
+
+ EnterCriticalSection(&m_critSec);
+
+ do {
+ CHK_BOOL_BRK(dwFlags == 0);
+ CHK_NULL_BRK(pOutputSamples);
+ CHK_NULL_BRK(pdwStatus);
+
+ // Must be exactly one output buffer.
+ CHK_BOOL_BRK(cOutputBufferCount == 1);
+
+ // If we don't have an input sample, we need some input before
+ // we can generate any output.
+ if (m_pSample == NULL)
+ {
+ hr = MF_E_TRANSFORM_NEED_MORE_INPUT;
+ break;
+ }
+
+ CHK_LOG_BRK(m_pSample->ConvertToContiguousBuffer(&pMediaBufInput));
+
+ MFCreateSample(&pOutputIMFSample);
+
+ if(!pOutputSamples[0].pSample){
+ CHK_LOG_BRK(m_pSample->ConvertToContiguousBuffer(&pMediaBufOutput));
+
+ } else {
+ CHK_LOG_BRK(pOutputSamples[0].pSample->ConvertToContiguousBuffer(&pMediaBufOutput));
+ }
+
+ pOutputIMFSample->AddBuffer(pMediaBufOutput);
+
+ CHK_LOG_BRK(OnProcessOutput(pMediaBufInput, pMediaBufOutput));
+ pOutputSamples[0].pSample = pOutputIMFSample;
+ pOutputIMFSample->AddRef();
+
+ pOutputSamples[0].dwStatus = 0;
+ *pdwStatus = 0;
+ if (SUCCEEDED(m_pSample->GetSampleDuration(&hnsDuration)))
+ {
+ CHK_LOG_BRK(pOutputSamples[0].pSample->SetSampleDuration(hnsDuration));
+ }
+
+ if (SUCCEEDED(m_pSample->GetSampleTime(&hnsTime)))
+ {
+ CHK_LOG_BRK(pOutputSamples[0].pSample->SetSampleTime(hnsTime));
+ }
+ } while (FALSE);
+
+ SAFERELEASE(pOutputIMFSample);
+ SAFERELEASE(pMediaBufInput);
+ SAFERELEASE(pMediaBufOutput);
+ SAFERELEASE(m_pSample); // Release our input sample.
+ LeaveCriticalSection(&m_critSec);
+ return hr;
+}
+
+BOOL CMft0::IsValidInputStream(DWORD dwInputStreamID)
+{
+ return dwInputStreamID == 0;
+}
+
+// IsValidOutputStream: Returns TRUE if dwOutputStreamID is a valid output stream identifier.
+BOOL CMft0::IsValidOutputStream(DWORD dwOutputStreamID)
+{
+ //update
+ return dwOutputStreamID == 0;
+}
+
+
+STDMETHODIMP CMft0::OnProcessOutput(IMFMediaBuffer *pIn, IMFMediaBuffer *pOut)
+{
+ HRESULT hr = S_OK;
+ LONG lDefaultStride = 0,
+ lSrcStride = 0,
+ lDestStride = 0;
+ UINT uiWidth = 0,
+ uiHeight = 0;
+ BYTE *pDest = NULL,
+ *pSrc = NULL;
+ //BOOL bCompressed = TRUE;
+ GUID stSubType = {0};
+
+ do {
+ CHK_NULL_PTR_BRK(m_pSample);
+ CHK_NULL_PTR_BRK(m_pInputType);
+
+ CHK_LOG_BRK(m_pInputType->GetGUID(MF_MT_SUBTYPE, &stSubType));
+
+ if(((stSubType == MFVideoFormat_RGB8) || (stSubType == MFVideoFormat_RGB555) ||
+ (stSubType == MFVideoFormat_RGB565) || (stSubType == MFVideoFormat_RGB24) ||
+ (stSubType == MFVideoFormat_RGB32) || (stSubType == MFVideoFormat_ARGB32) ||
+ (stSubType == MFVideoFormat_AI44) || (stSubType == MFVideoFormat_AYUV) ||
+ (stSubType == MFVideoFormat_I420) || (stSubType == MFVideoFormat_IYUV) ||
+ (stSubType == MFVideoFormat_NV11) || (stSubType == MFVideoFormat_NV12) ||
+ (stSubType == MFVideoFormat_UYVY) || (stSubType == MFVideoFormat_Y41P) ||
+ (stSubType == MFVideoFormat_Y41T) || (stSubType == MFVideoFormat_Y42T) ||
+ (stSubType == MFVideoFormat_YUY2) || (stSubType == MFVideoFormat_YV12) ||
+ (stSubType == MFVideoFormat_P010) || (stSubType == MFVideoFormat_P016) ||
+ (stSubType == MFVideoFormat_P210) || (stSubType == MFVideoFormat_P216) ||
+ (stSubType == MFVideoFormat_v210) || (stSubType == MFVideoFormat_v216) ||
+ (stSubType == MFVideoFormat_v410) || (stSubType == MFVideoFormat_Y210) ||
+ (stSubType == MFVideoFormat_Y216) || (stSubType == MFVideoFormat_Y410) ||
+ (stSubType == MFVideoFormat_Y416)) && m_bEnableEffects)
+ {
+ CHK_LOG_BRK(GetDefaultStride(&lDefaultStride));
+ CHK_LOG_BRK(MFGetAttributeSize(m_pInputType, MF_MT_FRAME_SIZE, &uiWidth, &uiHeight));
+ VideoBufferLock inputLock(pIn);
+ VideoBufferLock outputLock(pOut);
+
+ // Lock the input buffer.
+ CHK_LOG_BRK(inputLock.LockBuffer(lDefaultStride, uiHeight, &pSrc, &lSrcStride));
+
+ // Lock the output buffer.
+ CHK_LOG_BRK(outputLock.LockBuffer(lDefaultStride, uiHeight, &pDest, &lDestStride));
+ long lines = uiHeight;
+ if(m_percentOfScreen != -1 && m_percentOfScreen != 0) {
+ lines = (UINT)(uiHeight * (1.0- m_percentOfScreen/100.00));
+ }
+ for(long i = 0; i < (long)uiHeight; i++) {
+ if(lDestStride < 0) {
+ if(i >= lines) {
+ memset(pDest+i*lDestStride, 0, abs(lDefaultStride));
+ } else {
+ memcpy(pDest+i*lDestStride, pSrc+i*lDefaultStride, abs(lDefaultStride));
+ }
+ } else {
+ if(i >= lines) {
+ memset(pDest+i*lDestStride, 0, lDestStride);
+ } else {
+ memcpy(pDest+i*lDestStride, pSrc+i*lDestStride, lDestStride);
+ }
+ }
+ }
+ }
+ } while (FALSE);
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetDefaultStride(LONG *plStride)
+{
+ LONG lStride = 0;
+
+ // Try to get the default stride from the media type.
+ HRESULT hr = m_pInputType->GetUINT32(MF_MT_DEFAULT_STRIDE, (UINT32*)&lStride);
+ if (FAILED(hr))
+ {
+ // Attribute not set. Try to calculate the default stride.
+ GUID subtype = GUID_NULL;
+ UINT32 width = 0;
+ UINT32 height = 0;
+
+ // Get the subtype and the image size.
+ hr = m_pInputType->GetGUID(MF_MT_SUBTYPE, &subtype);
+ if (SUCCEEDED(hr))
+ {
+ hr = MFGetAttributeSize(m_pInputType, MF_MT_FRAME_SIZE, &width, &height);
+ }
+ if (SUCCEEDED(hr))
+ {
+ hr = MFGetStrideForBitmapInfoHeader(subtype.Data1, width, &lStride);
+ }
+
+ // Set the attribute for later reference.
+ if (SUCCEEDED(hr))
+ {
+ (void)m_pInputType->SetUINT32(MF_MT_DEFAULT_STRIDE, UINT32(lStride));
+ }
+ }
+
+ if (SUCCEEDED(hr))
+ {
+ *plStride = lStride;
+ }
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::OnFlush()
+{
+ HRESULT hr = S_OK;
+
+ // For this MFT, flushing just means releasing the input sample.
+ SAFERELEASE(m_pSample);
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::GetMediaType( DWORD dwStreamId, DWORD dwTypeIndex, IMFMediaType **ppType)
+{
+ HRESULT hr = S_OK;
+
+ do {
+ CHK_NULL_PTR_BRK(ppType);
+ if(dwStreamId != 0)
+ CHK_LOG_BRK(MF_E_INVALIDSTREAMNUMBER);
+ if(dwTypeIndex >= m_listOfMediaTypes.GetCount())
+ CHK_LOG_BRK(MF_E_NO_MORE_TYPES);
+
+ *ppType = m_listOfMediaTypes[dwTypeIndex];
+ (*ppType)->AddRef();
+ } while (FALSE);
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::IsMediaTypeSupported(UINT uiStreamId, IMFMediaType *pIMFMediaType, IMFMediaType **ppIMFMediaTypeFull)
+{
+ HRESULT hr = S_OK;
+
+ do {
+ CHK_NULL_PTR_BRK(pIMFMediaType);
+
+ if(uiStreamId != 0)
+ {
+ CHK_LOG_BRK(MF_E_INVALIDINDEX);
+ }
+ BOOL bFound =FALSE;
+ for(UINT i = 0; i< m_listOfMediaTypes.GetCount(); i++)
+ {
+ DWORD dwResult = 0;
+ hr = m_listOfMediaTypes[i]->IsEqual(pIMFMediaType, &dwResult);
+ if(hr == S_FALSE)
+ {
+
+ if((dwResult & MF_MEDIATYPE_EQUAL_MAJOR_TYPES) &&
+ (dwResult& MF_MEDIATYPE_EQUAL_FORMAT_TYPES) &&
+ (dwResult& MF_MEDIATYPE_EQUAL_FORMAT_DATA))
+ {
+ hr = S_OK;
+ }
+ }
+ if(hr == S_OK)
+ {
+ bFound = TRUE;
+ if(ppIMFMediaTypeFull) {
+ *ppIMFMediaTypeFull = m_listOfMediaTypes[i];
+ (*ppIMFMediaTypeFull)->AddRef();
+ }
+ break;
+ }
+ else if(FAILED(hr))
+ {
+ CHK_LOG_BRK(hr);
+ }
+
+ }
+ if(bFound == FALSE)
+ {
+ CHK_LOG_BRK(MF_E_INVALIDMEDIATYPE);
+ }
+ } while (FALSE);
+
+ return hr;
+}
+
+STDMETHODIMP CMft0::GenerateMFMediaTypeListFromDevice(UINT uiStreamId)
+{
+ HRESULT hr = S_OK;
+ GUID stSubType = {0};
+
+ do {
+ CHK_NULL_PTR_BRK(m_pSourceTransform);
+
+ m_listOfMediaTypes.RemoveAll();
+ for(UINT iMediaType = 0; TRUE; iMediaType++)
+ {
+ CComPtr<IMFMediaType> pMediaType;
+ hr = m_pSourceTransform->GetOutputAvailableType(uiStreamId, iMediaType, &pMediaType);
+ if(hr != S_OK)
+ break;
+ CHK_LOG_BRK(pMediaType->GetGUID(MF_MT_SUBTYPE, &stSubType));
+
+ if(((stSubType == MFVideoFormat_RGB8) || (stSubType == MFVideoFormat_RGB555) ||
+ (stSubType == MFVideoFormat_RGB565) || (stSubType == MFVideoFormat_RGB24) ||
+ (stSubType == MFVideoFormat_RGB32) || (stSubType == MFVideoFormat_ARGB32) ||
+ (stSubType == MFVideoFormat_AI44) || (stSubType == MFVideoFormat_AYUV) ||
+ (stSubType == MFVideoFormat_I420) || (stSubType == MFVideoFormat_IYUV) ||
+ (stSubType == MFVideoFormat_NV11) || (stSubType == MFVideoFormat_NV12) ||
+ (stSubType == MFVideoFormat_UYVY) || (stSubType == MFVideoFormat_Y41P) ||
+ (stSubType == MFVideoFormat_Y41T) || (stSubType == MFVideoFormat_Y42T) ||
+ (stSubType == MFVideoFormat_YUY2) || (stSubType == MFVideoFormat_YV12) ||
+ (stSubType == MFVideoFormat_P010) || (stSubType == MFVideoFormat_P016) ||
+ (stSubType == MFVideoFormat_P210) || (stSubType == MFVideoFormat_P216) ||
+ (stSubType == MFVideoFormat_v210) || (stSubType == MFVideoFormat_v216) ||
+ (stSubType == MFVideoFormat_v410) || (stSubType == MFVideoFormat_Y210) ||
+ (stSubType == MFVideoFormat_Y216) || (stSubType == MFVideoFormat_Y410) ||
+ (stSubType == MFVideoFormat_Y416)) && m_bEnableEffects)
+ {
+ m_listOfMediaTypes[(ULONG)(m_listOfMediaTypes.GetCount())] = pMediaType;
+ }
+ }
+
+ } while (FALSE);
+
+ if(hr == MF_E_NO_MORE_TYPES) {
+ hr = S_OK;
+ }
+
+ return hr;
+} \ No newline at end of file
diff --git a/AVStream/samplemft0/Mft0.h b/AVStream/samplemft0/Mft0.h
new file mode 100644
index 00000000..0cc85733
--- /dev/null
+++ b/AVStream/samplemft0/Mft0.h
@@ -0,0 +1,224 @@
+// Mft0.h : Declaration of the CMft0
+
+#pragma once
+#include "resource.h" // main symbols
+#include "SampleMft0.h"
+#include "SampleHelpers.h"
+
+#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
+#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
+#endif
+
+using namespace ATL;
+
+// CMft0
+
+class ATL_NO_VTABLE CMft0 :
+ public CComObjectRootEx<CComMultiThreadModel>,
+ public CComCoClass<CMft0, &CLSID_Mft0>,
+ public IMft0,
+ public IMFTransform,
+ public IInspectable
+{
+public:
+ CMft0() : m_pSample(NULL),
+ m_pInputType(NULL),
+ m_pOutputType(NULL),
+ m_pInputAttributes(0),
+ m_pGlobalAttributes(0),
+ m_pSourceTransform(0),
+ m_bEnableEffects(TRUE),
+ m_uiStreamId(0),
+ m_percentOfScreen(50),
+ m_nRefCount(1)
+ {
+ InitializeCriticalSection(&m_critSec);
+ }
+
+ DECLARE_REGISTRY_RESOURCEID(IDR_MFT0)
+
+ DECLARE_NOT_AGGREGATABLE(CMft0)
+
+ BEGIN_COM_MAP(CMft0)
+ COM_INTERFACE_ENTRY(IMft0)
+ COM_INTERFACE_ENTRY(IMFTransform)
+ COM_INTERFACE_ENTRY(IInspectable)
+ END_COM_MAP()
+
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ HRESULT FinalConstruct()
+ {
+ return S_OK;
+ }
+
+ void FinalRelease()
+ {
+ }
+
+public:
+ STDMETHOD(UpdateDsp)(UINT32 uiPercentOfScreen);
+ STDMETHOD(Enable)(void);
+ STDMETHOD(Disable)(void);
+ STDMETHOD(GetDspSetting)(UINT* puiPercentOfScreen, BOOL* pIsEnabled);
+
+ STDMETHODIMP GetIids(
+ /* [out] */ _Out_ ULONG *iidCount,
+ /* [size_is][size_is][out] */ _Outptr_result_buffer_maybenull_(*iidCount) IID **iids);
+
+ STDMETHODIMP GetRuntimeClassName(
+ /* [out] */ _Outptr_result_maybenull_ HSTRING *className);
+
+ STDMETHODIMP GetTrustLevel(
+ /* [out] */ _Out_ TrustLevel *trustLevel);
+
+ STDMETHODIMP GetStreamLimits(
+ /* [out] */ _Out_ DWORD *pdwInputMinimum,
+ /* [out] */ _Out_ DWORD *pdwInputMaximum,
+ /* [out] */ _Out_ DWORD *pdwOutputMinimum,
+ /* [out] */ _Out_ DWORD *pdwOutputMaximum);
+
+ STDMETHODIMP GetStreamCount(
+ /* [out] */ _Out_ DWORD *pcInputStreams,
+ /* [out] */ _Out_ DWORD *pcOutputStreams);
+
+ STDMETHODIMP GetStreamIDs(
+ DWORD dwInputIDArraySize,
+ /* [size_is][out] */ _Out_writes_(dwInputIDArraySize) DWORD *pdwInputIDs,
+ DWORD dwOutputIDArraySize,
+ /* [size_is][out] */ _Out_writes_(dwOutputIDArraySize) DWORD *pdwOutputIDs);
+
+ STDMETHODIMP GetInputStreamInfo(
+ DWORD dwInputStreamID,
+ /* [out] */ _Out_ MFT_INPUT_STREAM_INFO *pStreamInfo);
+
+ STDMETHODIMP GetOutputStreamInfo(
+ DWORD dwOutputStreamID,
+ /* [out] */ _Out_ MFT_OUTPUT_STREAM_INFO *pStreamInfo);
+
+ STDMETHODIMP GetAttributes(
+ /* [out] */ _Outptr_result_maybenull_ IMFAttributes **pAttributes);
+
+ STDMETHODIMP GetInputStreamAttributes(
+ DWORD dwInputStreamID,
+ /* [out] */ _Outptr_result_maybenull_ IMFAttributes **pAttributes);
+
+ STDMETHODIMP GetOutputStreamAttributes(
+ DWORD dwOutputStreamID,
+ /* [out] */ _Outptr_result_maybenull_ IMFAttributes **pAttributes);
+
+ STDMETHODIMP DeleteInputStream(
+ DWORD dwStreamID);
+
+ STDMETHODIMP AddInputStreams(
+ DWORD cStreams,
+ /* [in] */ _In_ DWORD *adwStreamIDs);
+
+ STDMETHODIMP GetInputAvailableType(
+ DWORD dwInputStreamID,
+ DWORD dwTypeIndex,
+ /* [out] */ _Outptr_result_maybenull_ IMFMediaType **ppType);
+
+ STDMETHODIMP GetOutputAvailableType(
+ DWORD dwOutputStreamID,
+ DWORD dwTypeIndex,
+ /* [out] */ _Outptr_result_maybenull_ IMFMediaType **ppType);
+
+ STDMETHODIMP SetInputType(
+ DWORD dwInputStreamID,
+ /* [in] */ _In_opt_ IMFMediaType *pType,
+ DWORD dwFlags);
+
+ STDMETHODIMP SetOutputType(
+ DWORD dwOutputStreamID,
+ /* [in] */ _In_opt_ IMFMediaType *pType,
+ DWORD dwFlags);
+
+ STDMETHODIMP GetInputCurrentType(
+ DWORD dwInputStreamID,
+ /* [out] */ _Outptr_result_maybenull_ IMFMediaType **ppType);
+
+ STDMETHODIMP GetOutputCurrentType(
+ DWORD dwOutputStreamID,
+ /* [out] */ _Outptr_result_maybenull_ IMFMediaType **ppType);
+
+ STDMETHODIMP GetInputStatus(
+ DWORD dwInputStreamID,
+ /* [out] */ _Out_ DWORD *pdwFlags);
+
+ STDMETHODIMP GetOutputStatus(
+ /* [out] */ _Out_ DWORD *pdwFlags);
+
+ STDMETHODIMP SetOutputBounds(
+ LONGLONG hnsLowerBound,
+ LONGLONG hnsUpperBound);
+
+ STDMETHODIMP ProcessEvent(
+ DWORD dwInputStreamID,
+ /* [in] */ _In_opt_ IMFMediaEvent *pEvent);
+
+ STDMETHODIMP ProcessMessage(
+ MFT_MESSAGE_TYPE eMessage,
+ ULONG_PTR ulParam);
+
+ STDMETHODIMP ProcessInput(
+ DWORD dwInputStreamID,
+ IMFSample *pSample,
+ DWORD dwFlags);
+
+ STDMETHODIMP ProcessOutput(
+ DWORD dwFlags,
+ DWORD cOutputBufferCount,
+ /* [size_is][out][in] */ MFT_OUTPUT_DATA_BUFFER *pOutputSamples,
+ /* [out] */ DWORD *pdwStatus);
+
+protected:
+ virtual ~CMft0()
+ {
+ SAFERELEASE(m_pInputAttributes);
+ SAFERELEASE(m_pGlobalAttributes);
+ SAFERELEASE(m_pSourceTransform);
+ SAFERELEASE(m_pInputType);
+ SAFERELEASE(m_pOutputType);
+ SAFERELEASE(m_pSample);
+ DeleteCriticalSection(&m_critSec);
+ }
+
+ STDMETHODIMP GetMediaType(DWORD dwStreamID, DWORD dwTypeIndex, IMFMediaType **ppType);
+ STDMETHODIMP IsMediaTypeSupported(UINT uiStreamId, IMFMediaType *pIMFMediaType, IMFMediaType **ppIMFMediaTypeFull = NULL);
+ STDMETHODIMP GenerateMFMediaTypeListFromDevice(UINT uiStreamId);
+
+ // HasPendingOutput: Returns TRUE if the MFT is holding an input sample.
+ BOOL HasPendingOutput() const { return m_pSample != NULL; }
+
+ // IsValidInputStream: Returns TRUE if dwInputStreamID is a valid input stream identifier.
+ BOOL IsValidInputStream(DWORD dwInputStreamID);
+
+ // IsValidOutputStream: Returns TRUE if dwOutputStreamID is a valid output stream identifier.
+ BOOL IsValidOutputStream(DWORD dwOutputStreamID);
+
+ STDMETHODIMP GetDefaultStride(LONG *plStride);
+
+ STDMETHODIMP OnProcessOutput(IMFMediaBuffer *pIn, IMFMediaBuffer *pOut);
+
+ STDMETHODIMP OnFlush();
+
+ CRITICAL_SECTION m_critSec;
+
+ IMFSample *m_pSample; // Input sample.
+ IMFMediaType *m_pInputType; // Input media type.
+ IMFMediaType *m_pOutputType; // Output media type.
+
+ // Image transform function. (Changes based on the media type.)
+ IMFAttributes *m_pInputAttributes;
+ IMFAttributes *m_pGlobalAttributes;
+ GUID m_stStreamType;
+ IMFTransform *m_pSourceTransform;
+ volatile BOOL m_bEnableEffects;
+ UINT m_uiStreamId;
+ UINT m_percentOfScreen;
+ UINT m_nRefCount;
+ CAtlMap<DWORD, CComPtr<IMFMediaType>> m_listOfMediaTypes;
+};
+
+OBJECT_ENTRY_AUTO(__uuidof(Mft0), CMft0)
diff --git a/AVStream/samplemft0/Mft0.rgs b/AVStream/samplemft0/Mft0.rgs
new file mode 100644
index 00000000..9ff876f4
--- /dev/null
+++ b/AVStream/samplemft0/Mft0.rgs
@@ -0,0 +1,15 @@
+HKCR
+{
+ NoRemove CLSID
+ {
+ ForceRemove {7BB640D9-33A4-4759-B290-F41A31DCF848} = s 'Mft0 Class'
+ {
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Both'
+ }
+ TypeLib = s '{DE05674A-C564-4C0E-9B7C-E1519F7AA767}'
+ Version = s '1.0'
+ }
+ }
+}
diff --git a/AVStream/samplemft0/README.md b/AVStream/samplemft0/README.md
new file mode 100644
index 00000000..7f6e50f6
--- /dev/null
+++ b/AVStream/samplemft0/README.md
@@ -0,0 +1,28 @@
+Driver MFT Sample
+=================
+
+Provides a *driver MFT* for use with a camera's Windows Store device app.A *driver MFT* is a Media Foundation Transform that's used with a specific camera when capturing video. The driver MFT is also known as MFT0 because it is the first MFT applied to the video stream captured from the camera. This MFT can provide a video effect or other processing when capturing photos or video from the camera. It can be distributed along with the driver package for a camera.
+
+In this sample, the driver MFT, when enabled, replaces a portion of the captured video with a green box. To test this sample, download the [Windows Store device app for camera sample](http://go.microsoft.com/fwlink/p/?linkid=249442) and the [Camera Capture UI sample](http://go.microsoft.com/fwlink/p/?linkid=249441). The [Windows Store device app for camera sample](http://go.microsoft.com/fwlink/p/?linkid=249442) provides a *Windows Store device app* that controls the effect implemented by the driver MFT. The [Camera Capture UI sample](http://go.microsoft.com/fwlink/p/?linkid=249441) provides a way to invoke the *Windows Store device app*.
+
+This sample is designed to be used with a specific camera. To run the sample, you need the your camera's device ID and device metadata package.
+
+
+Related topics
+--------------
+
+**Concepts**
+
+[Windows Store device apps for cameras](http://go.microsoft.com/fwlink/p/?LinkId=306683)
+
+[Media Foundation Transforms](http://msdn.microsoft.com/en-us/library/windows/hardware/ms703138)
+
+[Roadmap for Developing Streaming Media Drivers](http://msdn.microsoft.com/en-us/library/windows/hardware/ff568130)
+
+[Universal camera driver design guide for Windows 10](https://msdn.microsoft.com/en-us/Library/Windows/Hardware/dn937080)
+
+**Samples**
+
+[Windows Store device app for camera sample](http://go.microsoft.com/fwlink/p/?linkid=249442)
+
+[Camera Capture UI sample](http://go.microsoft.com/fwlink/p/?linkid=249441%20)
diff --git a/AVStream/samplemft0/SampleHelpers.h b/AVStream/samplemft0/SampleHelpers.h
new file mode 100644
index 00000000..870e2cd3
--- /dev/null
+++ b/AVStream/samplemft0/SampleHelpers.h
@@ -0,0 +1,143 @@
+//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+//// PARTICULAR PURPOSE.
+////
+//// Copyright (c) Microsoft Corporation. All rights reserved
+
+
+#pragma once
+#include "stdafx.h"
+
+#define WIDEN2(x) L ## x
+#define WIDEN(x) WIDEN2(x)
+#define __WFILE__ WIDEN(__FILE__)
+
+
+#define WPP_CONTROL_GUIDS \
+ WPP_DEFINE_CONTROL_GUID(WPPCameraExtensionMFt_Sample, \
+ (31A88041,BBF0,4D2C,A752,16EB1E51859C), \
+ WPP_DEFINE_BIT(AllMessages) \
+ )
+
+#define SAFEFREE(x) \
+ if(x) { \
+ free(x); \
+ x = NULL; \
+ }
+#define SAFERELEASE(x) \
+ if(x) { \
+ x->Release(); \
+ x = NULL; \
+ }
+
+#define CHK_LOG_BRK(exp) \
+ if(FAILED(hr = (exp))) { \
+ wprintf(L"HR=%08x File: %S Ln: %d\n", hr, __FILE__, __LINE__); \
+ break; \
+ }
+
+#define CHK_NULL_BRK(exp) \
+ if((exp) == NULL) { \
+ hr = E_OUTOFMEMORY; \
+ wprintf(L"HR=%08x File: %S Ln: %d\n", hr, __FILE__, __LINE__); \
+ break; \
+ }
+#define CHK_NULL_PTR_BRK(exp) \
+ if((exp) == NULL) { \
+ hr = E_INVALIDARG; \
+ wprintf(L"HR=%08x File: %S Ln: %d\n", hr, __FILE__, __LINE__); \
+ break; \
+ }
+
+#define CHK_BOOL_BRK(exp) \
+ if(!exp) { \
+ hr = E_FAIL; \
+ wprintf(L"HR=%08x File: %S Ln: %d\n", hr, __FILE__, __LINE__); \
+ break; \
+ }
+
+
+class VideoBufferLock
+{
+public:
+ VideoBufferLock(IMFMediaBuffer *pBuffer) : m_p2DBuffer(NULL)
+ {
+ m_pBuffer = pBuffer;
+ m_pBuffer->AddRef();
+
+ // Query for the 2-D buffer interface. OK if this fails.
+ m_pBuffer->QueryInterface(IID_IMF2DBuffer, (void**)&m_p2DBuffer);
+ }
+
+ ~VideoBufferLock()
+ {
+ UnlockBuffer();
+ SAFERELEASE(m_pBuffer);
+ SAFERELEASE(m_p2DBuffer);
+ }
+
+ // LockBuffer:
+ // Locks the buffer. Returns a pointer to scan line 0 and returns the stride.
+
+ // The caller must provide the default stride as an input parameter, in case
+ // the buffer does not expose IMF2DBuffer. You can calculate the default stride
+ // from the media type.
+
+ HRESULT LockBuffer(
+ LONG lDefaultStride, // Minimum stride (with no padding).
+ DWORD dwHeightInPixels, // Height of the image, in pixels.
+ BYTE **ppbScanLine0, // Receives a pointer to the start of scan line 0.
+ LONG *plStride // Receives the actual stride.
+ )
+ {
+ HRESULT hr = S_OK;
+
+ // Use the 2-D version if available.
+ if (m_p2DBuffer)
+ {
+ hr = m_p2DBuffer->Lock2D(ppbScanLine0, plStride);
+ }
+ else
+ {
+ // Use non-2D version.
+ BYTE *pData = NULL;
+
+ hr = m_pBuffer->Lock(&pData, NULL, NULL);
+ if (SUCCEEDED(hr))
+ {
+ *plStride = lDefaultStride;
+ if (lDefaultStride < 0)
+ {
+ // Bottom-up orientation. Return a pointer to the start of the
+ // last row *in memory* which is the top row of the image.
+ *ppbScanLine0 = pData + abs(lDefaultStride) * (dwHeightInPixels - 1);
+ }
+ else
+ {
+ // Top-down orientation. Return a pointer to the start of the
+ // buffer.
+ *ppbScanLine0 = pData;
+ }
+ }
+ }
+ return hr;
+ }
+
+ HRESULT UnlockBuffer()
+ {
+ if (m_p2DBuffer)
+ {
+ return m_p2DBuffer->Unlock2D();
+ }
+ else
+ {
+ return m_pBuffer->Unlock();
+ }
+ }
+
+private:
+ IMFMediaBuffer *m_pBuffer;
+ IMF2DBuffer *m_p2DBuffer;
+};
+
diff --git a/AVStream/samplemft0/SampleMft0.cpp b/AVStream/samplemft0/SampleMft0.cpp
new file mode 100644
index 00000000..997f05af
--- /dev/null
+++ b/AVStream/samplemft0/SampleMft0.cpp
@@ -0,0 +1,83 @@
+// SampleMft0.cpp : Implementation of DLL Exports.
+
+
+#include "stdafx.h"
+#include "resource.h"
+#include "SampleMft0.h"
+#include "dllmain.h"
+
+
+// Used to determine whether the DLL can be unloaded by OLE.
+STDAPI DllCanUnloadNow(void)
+{
+#ifdef _MERGE_PROXYSTUB
+ HRESULT hr = PrxDllCanUnloadNow();
+ if (hr != S_OK)
+ return hr;
+#endif
+ return _AtlModule.DllCanUnloadNow();
+}
+
+// Returns a class factory to create an object of the requested type.
+STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv)
+{
+#ifdef _MERGE_PROXYSTUB
+ if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
+ return S_OK;
+#endif
+ return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
+}
+
+// DllRegisterServer - Adds entries to the system registry.
+STDAPI DllRegisterServer(void)
+{
+ // registers object, typelib and all interfaces in typelib
+ HRESULT hr = _AtlModule.DllRegisterServer();
+#ifdef _MERGE_PROXYSTUB
+ if (FAILED(hr))
+ return hr;
+ hr = PrxDllRegisterServer();
+#endif
+ return hr;
+}
+
+// DllUnregisterServer - Removes entries from the system registry.
+STDAPI DllUnregisterServer(void)
+{
+ HRESULT hr = _AtlModule.DllUnregisterServer();
+#ifdef _MERGE_PROXYSTUB
+ if (FAILED(hr))
+ return hr;
+ hr = PrxDllRegisterServer();
+ if (FAILED(hr))
+ return hr;
+ hr = PrxDllUnregisterServer();
+#endif
+ return hr;
+}
+
+// DllInstall - Adds/Removes entries to the system registry per user per machine.
+STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine)
+{
+ UNREFERENCED_PARAMETER(pszCmdLine);
+ HRESULT hr = E_FAIL;
+ static const wchar_t szUserSwitch[] = L"user";
+
+
+ if (bInstall)
+ {
+ hr = DllRegisterServer();
+ if (FAILED(hr))
+ {
+ DllUnregisterServer();
+ }
+ }
+ else
+ {
+ hr = DllUnregisterServer();
+ }
+
+ return hr;
+}
+
+
diff --git a/AVStream/samplemft0/SampleMft0.def b/AVStream/samplemft0/SampleMft0.def
new file mode 100644
index 00000000..f4c9fe1c
--- /dev/null
+++ b/AVStream/samplemft0/SampleMft0.def
@@ -0,0 +1,16 @@
+; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+; ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+; PARTICULAR PURPOSE.
+; Copyright (c) Microsoft Corporation. All rights reserved
+
+; SampleMft0.def : Declares the module parameters.
+
+LIBRARY
+
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
+ DllInstall PRIVATE
diff --git a/AVStream/samplemft0/SampleMft0.idl b/AVStream/samplemft0/SampleMft0.idl
new file mode 100644
index 00000000..3b59f79a
--- /dev/null
+++ b/AVStream/samplemft0/SampleMft0.idl
@@ -0,0 +1,48 @@
+//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+//// PARTICULAR PURPOSE.
+////
+//// Copyright (c) Microsoft Corporation. All rights reserved
+
+// SampleMft0.idl : IDL source for SampleMft0
+//
+
+// This file will be processed by the MIDL tool to
+// produce the type library (SampleMft0.tlb) and marshalling code.
+
+import "oaidl.idl";
+import "ocidl.idl";
+import "Inspectable.idl";
+import "mftransform.idl";
+[
+ object,
+ uuid(F5208B72-A37A-457E-A309-AE3060780E21),
+ oleautomation,
+ nonextensible,
+ pointer_default(unique)
+]
+interface IMft0 : IUnknown{
+ [id(1)] HRESULT UpdateDsp([in] UINT32 uiPercentOfScreen);
+ [id(2)] HRESULT Enable(void);
+ [id(3)] HRESULT Disable(void);
+ [id(4)] HRESULT GetDspSetting([out] UINT* puiPercentOfScreen, [out] BOOL* pIsEnabled);
+};
+[
+ uuid(DE05674A-C564-4C0E-9B7C-E1519F7AA767),
+ version(1.0),
+]
+library SampleMft0Lib
+{
+ importlib("stdole2.tlb");
+ [
+ uuid(7BB640D9-33A4-4759-B290-F41A31DCF848)
+ ]
+ coclass Mft0
+ {
+ [default] interface IMft0;
+ interface IInspectable;
+ interface IMFTransform;
+ };
+};
+
diff --git a/AVStream/samplemft0/SampleMft0.rc b/AVStream/samplemft0/SampleMft0.rc
new file mode 100644
index 00000000..60d75128
--- /dev/null
+++ b/AVStream/samplemft0/SampleMft0.rc
Binary files differ
diff --git a/AVStream/samplemft0/SampleMft0.rgs b/AVStream/samplemft0/SampleMft0.rgs
new file mode 100644
index 00000000..e7d37400
--- /dev/null
+++ b/AVStream/samplemft0/SampleMft0.rgs
@@ -0,0 +1,3 @@
+HKCR
+{
+}
diff --git a/AVStream/samplemft0/SampleMft0.sln b/AVStream/samplemft0/SampleMft0.sln
new file mode 100644
index 00000000..8084fbc7
--- /dev/null
+++ b/AVStream/samplemft0/SampleMft0.sln
@@ -0,0 +1,41 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 11
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{D5FD28DE-8407-4B27-8785-9839775E254A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "package", "Package\package.VcxProj", "{07664D04-E5E5-4249-8382-4D97E3E5557D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleMft0", "SampleMft0.vcxproj", "{DCF923F6-7164-4A0E-9486-B8A140234CCA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {07664D04-E5E5-4249-8382-4D97E3E5557D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {07664D04-E5E5-4249-8382-4D97E3E5557D}.Debug|Win32.Build.0 = Debug|Win32
+ {07664D04-E5E5-4249-8382-4D97E3E5557D}.Debug|x64.ActiveCfg = Debug|x64
+ {07664D04-E5E5-4249-8382-4D97E3E5557D}.Debug|x64.Build.0 = Debug|x64
+ {07664D04-E5E5-4249-8382-4D97E3E5557D}.Release|Win32.ActiveCfg = Release|Win32
+ {07664D04-E5E5-4249-8382-4D97E3E5557D}.Release|Win32.Build.0 = Release|Win32
+ {07664D04-E5E5-4249-8382-4D97E3E5557D}.Release|x64.ActiveCfg = Release|x64
+ {07664D04-E5E5-4249-8382-4D97E3E5557D}.Release|x64.Build.0 = Release|x64
+ {DCF923F6-7164-4A0E-9486-B8A140234CCA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DCF923F6-7164-4A0E-9486-B8A140234CCA}.Debug|Win32.Build.0 = Debug|Win32
+ {DCF923F6-7164-4A0E-9486-B8A140234CCA}.Debug|x64.ActiveCfg = Debug|x64
+ {DCF923F6-7164-4A0E-9486-B8A140234CCA}.Debug|x64.Build.0 = Debug|x64
+ {DCF923F6-7164-4A0E-9486-B8A140234CCA}.Release|Win32.ActiveCfg = Release|Win32
+ {DCF923F6-7164-4A0E-9486-B8A140234CCA}.Release|Win32.Build.0 = Release|Win32
+ {DCF923F6-7164-4A0E-9486-B8A140234CCA}.Release|x64.ActiveCfg = Release|x64
+ {DCF923F6-7164-4A0E-9486-B8A140234CCA}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {07664D04-E5E5-4249-8382-4D97E3E5557D} = {D5FD28DE-8407-4B27-8785-9839775E254A}
+ EndGlobalSection
+EndGlobal
diff --git a/AVStream/samplemft0/SampleMft0.vcxproj b/AVStream/samplemft0/SampleMft0.vcxproj
new file mode 100644
index 00000000..90c623ba
--- /dev/null
+++ b/AVStream/samplemft0/SampleMft0.vcxproj
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="PropertySheets">
+ <DriverType />
+ <PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset>
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Label="Globals">
+ <Configuration>Debug</Configuration>
+ <Platform Condition="'$(Platform)' == ''">Win32</Platform>
+ <DebuggerFlavor Condition="'$(PlatformToolset)' == 'WindowsKernelModeDriver8.0'">DbgengKernelDebugger</DebuggerFlavor>
+ <DebuggerFlavor Condition="'$(PlatformToolset)' == 'WindowsUserModeDriver8.0'">DbgengRemoteDebugger</DebuggerFlavor>
+ <SampleGuid>{0D23004B-9844-4510-ABA0-E60F720528B8}</SampleGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{DCF923F6-7164-4A0E-9486-B8A140234CCA}</ProjectGuid>
+ <RootNamespace>$(MSBuildProjectName)</RootNamespace>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <TargetVersion>Win8</TargetVersion>
+ <UseDebugLibraries>True</UseDebugLibraries>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <TargetVersion>Win8</TargetVersion>
+ <UseDebugLibraries>False</UseDebugLibraries>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <TargetVersion>Win8</TargetVersion>
+ <UseDebugLibraries>True</UseDebugLibraries>
+ </PropertyGroup>
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <TargetVersion>Win8</TargetVersion>
+ <UseDebugLibraries>False</UseDebugLibraries>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <PropertyGroup>
+ <OutDir>$(IntDir)</OutDir>
+ </PropertyGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
+ </ImportGroup>
+ <ItemGroup Label="WrappedTaskItems" />
+ <PropertyGroup>
+ <TargetName>SampleMft0</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
+ <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='true'">MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <PropertyGroup>
+ <UseOfAtl>Static</UseOfAtl>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(IntDir)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <ClCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(IntDir)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(IntDir)</AdditionalIncludeDirectories>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup>
+ <Link>
+ <AdditionalDependencies>%(AdditionalDependencies);kernel32.lib;gdi32.lib;ntdll.lib;user32.lib;advapi32.lib;ole32.lib;uuid.lib;version.lib;winmm.lib;comdlg32.lib;Oleaut32.lib;Shlwapi.lib;comctl32.lib;mfuuid.lib;mf.lib;mfplat.lib;runtimeobject.lib</AdditionalDependencies>
+ <ModuleDefinitionFile>SampleMft0.def</ModuleDefinitionFile>
+ </Link>
+ <ClCompile>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="$(IntDir)\SampleMft0_i.c" />
+ <ClCompile Include="dllmain.cpp">
+ <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreCompiledHeaderFile>stdafx.h</PreCompiledHeaderFile>
+ <PreCompiledHeader>Use</PreCompiledHeader>
+ <PreCompiledHeaderOutputFile>$(IntDir)\stdafx.h.pch</PreCompiledHeaderOutputFile>
+ </ClCompile>
+ <ClCompile Include="Mft0.cpp">
+ <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreCompiledHeaderFile>stdafx.h</PreCompiledHeaderFile>
+ <PreCompiledHeader>Use</PreCompiledHeader>
+ <PreCompiledHeaderOutputFile>$(IntDir)\stdafx.h.pch</PreCompiledHeaderOutputFile>
+ </ClCompile>
+ <ClCompile Include="SampleMft0.cpp">
+ <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreCompiledHeaderFile>stdafx.h</PreCompiledHeaderFile>
+ <PreCompiledHeader>Use</PreCompiledHeader>
+ <PreCompiledHeaderOutputFile>$(IntDir)\stdafx.h.pch</PreCompiledHeaderOutputFile>
+ </ClCompile>
+ <ClCompile Include="stdafxsrc.cpp">
+ <AdditionalIncludeDirectories>;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreCompiledHeaderFile>stdafx.h</PreCompiledHeaderFile>
+ <PreCompiledHeader>Create</PreCompiledHeader>
+ <PreCompiledHeaderOutputFile>$(IntDir)\stdafx.h.pch</PreCompiledHeaderOutputFile>
+ </ClCompile>
+ <Midl Include="SampleMft0.idl" />
+ <ResourceCompile Include="SampleMft0.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Inf Exclude="@(Inf)" Include="*.inf" />
+ <FilesToPackage Include="$(TargetPath)" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Exclude="@(None)" Include="*.txt;*.htm;*.html" />
+ <None Exclude="@(None)" Include="*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2" />
+ <None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+</Project> \ No newline at end of file
diff --git a/AVStream/samplemft0/SampleMft0.vcxproj.Filters b/AVStream/samplemft0/SampleMft0.vcxproj.Filters
new file mode 100644
index 00000000..945f6fa5
--- /dev/null
+++ b/AVStream/samplemft0/SampleMft0.vcxproj.Filters
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ <UniqueIdentifier>{0EBBD007-C6C8-40FA-9163-D9AE2629FA55}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Header Files">
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ <UniqueIdentifier>{63FE7C31-9F1C-4BA9-9D75-64A0A33E2CE7}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Resource Files">
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ <UniqueIdentifier>{18AC824E-5296-4263-BF1C-82692203056E}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="$(IntDir)\SampleMft0_i.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="dllmain.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Mft0.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="SampleMft0.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="stdafxsrc.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="dllmain.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Mft0.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="SampleHelpers.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ <ClInclude Include="dllmain.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Mft0.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="SampleHelpers.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ <ClInclude Include="dllmain.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Mft0.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="SampleHelpers.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ <ClInclude Include="dllmain.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Mft0.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="SampleHelpers.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ <ClInclude Include="dllmain.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Mft0.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="SampleHelpers.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ <ClInclude Include="dllmain.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Mft0.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="SampleHelpers.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="SampleMft0.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Midl Include="SampleMft0.idl">
+ <Filter>Source Files</Filter>
+ </Midl>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="*.def;*.bat;*.hpj;*.asmx">
+ <Filter>Source Files</Filter>
+ </None>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/AVStream/samplemft0/dllmain.cpp b/AVStream/samplemft0/dllmain.cpp
new file mode 100644
index 00000000..df86088a
--- /dev/null
+++ b/AVStream/samplemft0/dllmain.cpp
@@ -0,0 +1,19 @@
+// dllmain.cpp : Implementation of DllMain.
+
+#include "stdafx.h"
+#include "resource.h"
+#include "SampleMft0.h"
+#include "dllmain.h"
+
+CSampleMft0Module _AtlModule;
+
+// DLL Entry Point
+extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+{
+#ifdef _MERGE_PROXYSTUB
+ if (!PrxDllMain(hInstance, dwReason, lpReserved))
+ return FALSE;
+#endif
+ hInstance;
+ return _AtlModule.DllMain(dwReason, lpReserved);
+}
diff --git a/AVStream/samplemft0/dllmain.h b/AVStream/samplemft0/dllmain.h
new file mode 100644
index 00000000..04e95ab3
--- /dev/null
+++ b/AVStream/samplemft0/dllmain.h
@@ -0,0 +1,10 @@
+// dllmain.h : Declaration of module class.
+
+class CSampleMft0Module : public ATL::CAtlDllModuleT< CSampleMft0Module >
+{
+public :
+ DECLARE_LIBID(LIBID_SampleMft0Lib)
+ DECLARE_REGISTRY_APPID_RESOURCEID(IDR_SAMPLEMFT0, "{F9ED475B-DC47-458A-A138-55D7E8A57AF0}")
+};
+
+extern class CSampleMft0Module _AtlModule;
diff --git a/AVStream/samplemft0/resource.h b/AVStream/samplemft0/resource.h
new file mode 100644
index 00000000..d20cf5a1
--- /dev/null
+++ b/AVStream/samplemft0/resource.h
Binary files differ
diff --git a/AVStream/samplemft0/stdafx.cpp b/AVStream/samplemft0/stdafx.cpp
new file mode 100644
index 00000000..feacb859
--- /dev/null
+++ b/AVStream/samplemft0/stdafx.cpp
@@ -0,0 +1,13 @@
+//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+//// PARTICULAR PURPOSE.
+////
+//// Copyright (c) Microsoft Corporation. All rights reserved
+
+
+// stdafx.cpp : source file that includes just the standard includes
+// SampleMft0.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
diff --git a/AVStream/samplemft0/stdafx.h b/AVStream/samplemft0/stdafx.h
new file mode 100644
index 00000000..86d812ec
--- /dev/null
+++ b/AVStream/samplemft0/stdafx.h
@@ -0,0 +1,42 @@
+//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+//// PARTICULAR PURPOSE.
+////
+//// Copyright (c) Microsoft Corporation. All rights reserved
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#pragma once
+
+#ifndef STRICT
+#define STRICT
+#endif
+
+#include "targetver.h"
+
+#define _ATL_APARTMENT_THREADED
+
+#define _ATL_NO_AUTOMATIC_NAMESPACE
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+
+
+#define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW
+
+#include "resource.h"
+#include <atlbase.h>
+#include <atlcom.h>
+#include <atlctl.h>
+#include <atlcoll.h>
+#include <DbgHelp.h>
+
+#include <mfapi.h>
+#include <mfidl.h>
+#include <mferror.h>
+#include <ks.h>
+#include <ksmedia.h>
+
+#include <inspectable.h> \ No newline at end of file
diff --git a/AVStream/samplemft0/stdafxsrc.cpp b/AVStream/samplemft0/stdafxsrc.cpp
new file mode 100644
index 00000000..1577c4e3
--- /dev/null
+++ b/AVStream/samplemft0/stdafxsrc.cpp
@@ -0,0 +1 @@
+#include "stdafx.h" \ No newline at end of file
diff --git a/AVStream/samplemft0/targetver.h b/AVStream/samplemft0/targetver.h
new file mode 100644
index 00000000..fc349fa5
--- /dev/null
+++ b/AVStream/samplemft0/targetver.h
@@ -0,0 +1,15 @@
+//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+//// PARTICULAR PURPOSE.
+////
+//// Copyright (c) Microsoft Corporation. All rights reserved
+
+#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <SDKDDKVer.h>