summaryrefslogtreecommitdiff
path: root/avstream
diff options
context:
space:
mode:
authorJoel Corley <[email protected]>2018-06-29 19:19:18 -0700
committerJoel Corley <[email protected]>2018-06-29 19:19:18 -0700
commit30ddbb997660fa4ae3608759b9d2d0789774ccdc (patch)
treed656c50cea303cb554460d529038fe5364634b01 /avstream
parent6c1981b8504329521343ad00f32daa847fa6083a (diff)
Update AVStream / Camera samples for RS4.
Diffstat (limited to 'avstream')
-rw-r--r--avstream/avscamera/sys/Device.cpp189
-rw-r--r--avstream/avscamera/sys/Sensor.cpp6
-rw-r--r--avstream/avscamera/sys/Sensor.h2
-rw-r--r--avstream/avscamera/sys/SensorSimulation.cpp2
-rw-r--r--avstream/avscamera/sys/Synthesizer.h1
-rw-r--r--avstream/avscamera/sys/hwsim.cpp12
-rw-r--r--avstream/sampledevicemft/basepin.cpp6
-rw-r--r--avstream/sampledevicemft/common.h2
-rw-r--r--avstream/sampledevicemft/multipinmft.cpp19
-rw-r--r--avstream/sampledevicemft/multipinmft.h2
-rw-r--r--avstream/sampledevicemft/multipinmfthelpers.cpp135
-rw-r--r--avstream/sampledevicemft/multipinmfthelpers.h7
-rw-r--r--avstream/samplemft0/Package/package.vcxproj8
-rw-r--r--avstream/samplemft0/SampleMft0.vcxproj8
14 files changed, 117 insertions, 282 deletions
diff --git a/avstream/avscamera/sys/Device.cpp b/avstream/avscamera/sys/Device.cpp
index ed46bdc8..943b2f2b 100644
--- a/avstream/avscamera/sys/Device.cpp
+++ b/avstream/avscamera/sys/Device.cpp
@@ -29,160 +29,6 @@
**************************************************************************/
-/////
-/// Structures...
-//// Profile 0
-static KSCAMERA_PROFILE_MEDIAINFO s_Profile0_PreviewMediaInfo[] =
-{
- //{ resolution }, { fps }, Flags, Data0, Data1, Data2, Data 3
- { { 1920, 1080 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 1280, 720 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 640, 360 }, { 30, 1 }, 0, 0, 0, 0, 0 },
-};
-
-static KSCAMERA_PROFILE_MEDIAINFO s_Profile0_RecordMediaInfo[] =
-{
- //{ resolution }, { fps }, Flags, Data0, Data1, Data2, Data 3
- { { 3840, 2160 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 1920, 1080 }, { 120, 1 }, 0, 0, 0, 0, 0 },
- { { 1920, 1080 }, { 90, 1 }, 0, 0, 0, 0, 0 },
- { { 1920, 1080 }, { 60, 1 }, 0, 0, 0, 0, 0 },
- { { 1920, 1080 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 1280, 720 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 640, 360 }, { 30, 1 }, 0, 0, 0, 0, 0 },
-};
-
-static KSCAMERA_PROFILE_MEDIAINFO s_Profile0_PhotoMediaInfo[] =
-{
- //{ resolution }, { fps }, Flags, Data0, Data1, Data2, Data 3
- { { 1920, 1080 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 1280, 720 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 640, 360 }, { 30, 1 }, 0, 0, 0, 0, 0 }
-};
-
-
-//// Profile 1
-static KSCAMERA_PROFILE_MEDIAINFO s_Profile1_PreviewMediaInfo[] =
-{
- //{ resolution }, { fps }, Flags, Data0, Data1, Data2, Data 3
- { { 1920, 1080 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 1280, 720 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 640, 360 }, { 30, 1 }, 0, 0, 0, 0, 0 }
-};
-
-static KSCAMERA_PROFILE_MEDIAINFO s_Profile1_PhotoMediaInfo[] =
-{
- //{ resolution }, { fps }, Flags, Data0, Data1, Data2, Data 3
- { { 7680, 4320 }, { 0, 1 }, 0, 0, 0, 0, 0 },
- { { 3840, 2160 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 1920, 1080 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 1280, 720 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 640, 360 }, { 30, 1 }, 0, 0, 0, 0, 0 }
-};
-
-//// Profile 2
-static KSCAMERA_PROFILE_MEDIAINFO s_Profile2_PreviewMediaInfo[] =
-{
- //{ resolution }, { fps }, Flags, Data0, Data1, Data2, Data 3
- { { 1920, 1080 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 1280, 720 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 640, 360 }, { 30, 1 }, 0, 0, 0, 0, 0 }
-};
-
-static KSCAMERA_PROFILE_MEDIAINFO s_Profile2_RecordMediaInfo[] =
-{
- //{ resolution }, { fps }, Flags, Data0, Data1, Data2, Data 3
- { { 1920, 1080 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 1280, 720 }, { 30, 1 }, 0, 0, 0, 0, 0 },
- { { 640, 360 }, { 30, 1 }, 0, 0, 0, 0, 0 }
-};
-
-static KSCAMERA_PROFILE_PININFO s_Profile0_PinInfo[] =
-{
- { {STATIC_PINNAME_VIDEO_PREVIEW}, 0,0, ARRAYSIZE(s_Profile0_PreviewMediaInfo), s_Profile0_PreviewMediaInfo },
- { {STATIC_PINNAME_VIDEO_CAPTURE}, 0,0, ARRAYSIZE(s_Profile0_RecordMediaInfo), s_Profile0_RecordMediaInfo },
- { {STATIC_PINNAME_IMAGE}, 0,0, ARRAYSIZE(s_Profile0_PhotoMediaInfo), s_Profile0_PhotoMediaInfo }
-};
-
-static KSCAMERA_PROFILE_PININFO s_Profile1_PinInfo[] =
-{
- { {STATIC_PINNAME_VIDEO_PREVIEW}, 0,0, ARRAYSIZE(s_Profile1_PreviewMediaInfo), s_Profile1_PreviewMediaInfo },
- { {STATIC_PINNAME_IMAGE}, 0,0, ARRAYSIZE(s_Profile1_PhotoMediaInfo), s_Profile1_PhotoMediaInfo }
-};
-
-static KSCAMERA_PROFILE_PININFO s_Profile2_PinInfo[] =
-{
- { {STATIC_PINNAME_VIDEO_PREVIEW}, 0,0, ARRAYSIZE(s_Profile2_PreviewMediaInfo), s_Profile2_PreviewMediaInfo },
- { {STATIC_PINNAME_VIDEO_CAPTURE}, 0,0, ARRAYSIZE(s_Profile2_RecordMediaInfo), s_Profile2_RecordMediaInfo }
-};
-
-static KSCAMERA_PROFILE_INFO s_Profiles[] =
-{
- { {STATIC_KSCAMERAPROFILE_BalancedVideoAndPhoto}, 0, ARRAYSIZE(s_Profile0_PinInfo), s_Profile0_PinInfo },
- { {STATIC_KSCAMERAPROFILE_HighQualityPhoto}, 0, ARRAYSIZE(s_Profile1_PinInfo), s_Profile1_PinInfo },
- { {STATIC_KSCAMERAPROFILE_VideoRecording}, 0, ARRAYSIZE(s_Profile2_PinInfo), s_Profile2_PinInfo }
-};
-
-// The front camera is concurrent with the rear camera, so the front camera concurrency
-// has the back camera's reference GUID and vice versa.
-static KSCAMERA_PROFILE_CONCURRENCYINFO s_Profile2_ConcurrencyInfoFront[] =
-{
- { {STATIC_RearCamera_Filter}, 0, 1, &s_Profiles[2] }
-};
-
-static KSCAMERA_PROFILE_CONCURRENCYINFO s_Profile2_ConcurrencyInfoBack[] =
-{
- { {STATIC_FrontCamera_Filter}, 0, 1, &s_Profiles[2] }
-};
-
-const UINT32 s_ProfileCount = 3;
-
-UINT32
-InitializeDeviceProfiles(
- _In_ BOOL fFrontCamera,
- _Outptr_result_maybenull_
- PKSDEVICE_PROFILE_INFO *ppDeviceProfiles
-)
-{
- UINT32 uiProfileCount = 0;
- PKSDEVICE_PROFILE_INFO pDeviceProfiles = NULL;
-
- pDeviceProfiles = (PKSDEVICE_PROFILE_INFO)ExAllocatePoolWithTag( PagedPool, sizeof(KSDEVICE_PROFILE_INFO) * ARRAYSIZE(s_Profiles) , 'fpSC');
- if( !pDeviceProfiles )
- {
- // Can't publish, we're out of memory, silently fail here.
- *ppDeviceProfiles = nullptr;
- goto Exit;
- }
-
- for (UINT32 i = 0; i < ARRAYSIZE(s_Profiles); i++)
- {
- pDeviceProfiles[i].Type = KSDEVICE_PROFILE_TYPE_CAMERA;
- pDeviceProfiles[i].Size = sizeof(KSDEVICE_PROFILE_INFO);
- pDeviceProfiles[i].Camera.Info = s_Profiles[i];
- pDeviceProfiles[i].Camera.Reserved = 0;
- pDeviceProfiles[i].Camera.ConcurrencyCount = 0;
- pDeviceProfiles[i].Camera.Concurrency = NULL;
- }
-
- pDeviceProfiles[2].Camera.ConcurrencyCount = 1;
- if (fFrontCamera)
- {
- pDeviceProfiles[2].Camera.Concurrency = (PKSCAMERA_PROFILE_CONCURRENCYINFO)&s_Profile2_ConcurrencyInfoFront;
- }
- else
- {
- pDeviceProfiles[2].Camera.Concurrency = (PKSCAMERA_PROFILE_CONCURRENCYINFO)&s_Profile2_ConcurrencyInfoBack;
- }
-
- uiProfileCount = ARRAYSIZE(s_Profiles);
- *ppDeviceProfiles = pDeviceProfiles;
- pDeviceProfiles = NULL;
-
-Exit:
- return uiProfileCount;
-}
-
#ifdef ALLOC_PRAGMA
#pragma code_seg("PAGE")
#endif // ALLOC_PRAGMA
@@ -673,7 +519,6 @@ Return Value:
PKSDEVICE_PROFILE_INFO pDeviceProfiles = nullptr;
UINT32 uiProfileCount = 0;
PUNICODE_STRING SymbolicLinkName = KsFilterFactoryGetSymbolicLink(FilterFactory);
- BOOL fFrontCamera = FALSE;
ACPI_PLD_V2_BUFFER pld = {0};
pld.Revision = 2;
pld.Panel = m_Context[i].AcpiPosition;
@@ -691,40 +536,6 @@ Return Value:
sizeof(pld),
(PVOID)&pld)
);
-
- if( m_Context[i].Descriptor->ReferenceGuid &&
- IsEqualGUID(*(m_Context[i].Descriptor->ReferenceGuid), FFC_Filter))
- {
- fFrontCamera = TRUE;
- }
-
- // Publish our profile here.
- uiProfileCount = InitializeDeviceProfiles(fFrontCamera, &pDeviceProfiles);
- if( uiProfileCount > 0 && pDeviceProfiles != nullptr)
- {
- if( NT_SUCCESS(KsInitializeDeviceProfile(FilterFactory)) )
- {
- for( UINT32 j=0; j<uiProfileCount; j++ )
- {
- if( !NT_SUCCESS(KsPublishDeviceProfile(FilterFactory, &pDeviceProfiles[j])) )
- {
- // Bail...
- break;
- }
- }
- if( !NT_SUCCESS(KsPersistDeviceProfile(FilterFactory)) )
- {
- // Trace here?
- }
- }
-
- ExFreePool(pDeviceProfiles);
- pDeviceProfiles = NULL;
- }
- else
- {
- IFFAILED_EXIT(STATUS_INSUFFICIENT_RESOURCES);
- }
}
// On a real device this object would be constructed whenever the sensor hardware is ready...
diff --git a/avstream/avscamera/sys/Sensor.cpp b/avstream/avscamera/sys/Sensor.cpp
index 97615250..9215f6b6 100644
--- a/avstream/avscamera/sys/Sensor.cpp
+++ b/avstream/avscamera/sys/Sensor.cpp
@@ -1090,14 +1090,16 @@ void
CSensor::
SetSynthesizerAttribute(
CSynthesizer::Attribute Attrib,
- LONGLONG Info
+ LONGLONG Info,
+ LONG PinId
)
{
PAGED_CODE();
for( ULONG Pin=0; IsValidIndex(Pin); Pin++ )
{
- if( m_Synthesizer[Pin] )
+ if( (Pin==(ULONG)PinId || IsStillIndex(Pin)) &&
+ m_Synthesizer[Pin] )
{
m_Synthesizer[Pin]->Set( Attrib, Info );
}
diff --git a/avstream/avscamera/sys/Sensor.h b/avstream/avscamera/sys/Sensor.h
index dac97630..34997908 100644
--- a/avstream/avscamera/sys/Sensor.h
+++ b/avstream/avscamera/sys/Sensor.h
@@ -517,7 +517,7 @@ public:
}
void
- SetSynthesizerAttribute( CSynthesizer::Attribute Attrib, LONGLONG Info );
+ SetSynthesizerAttribute( CSynthesizer::Attribute Attrib, LONGLONG Info, LONG PinId );
protected:
LONG
diff --git a/avstream/avscamera/sys/SensorSimulation.cpp b/avstream/avscamera/sys/SensorSimulation.cpp
index ce6a2c17..95824ca5 100644
--- a/avstream/avscamera/sys/SensorSimulation.cpp
+++ b/avstream/avscamera/sys/SensorSimulation.cpp
@@ -702,7 +702,7 @@ GetFaceDetection(
KSCAMERA_EXTENDEDPROP_FACEDETECTION_SMILE ;
pProperty->Max() = m_FaceDetectionMax;
- pProperty->Min() = 1;
+ pProperty->Min() = 0;
pProperty->Step() = 1;
*pProperty = m_FaceDetectionCurrentMax;
pProperty->Result = m_FaceDetectionResult;
diff --git a/avstream/avscamera/sys/Synthesizer.h b/avstream/avscamera/sys/Synthesizer.h
index 6612a3f6..7281ff80 100644
--- a/avstream/avscamera/sys/Synthesizer.h
+++ b/avstream/avscamera/sys/Synthesizer.h
@@ -132,7 +132,6 @@ protected:
LONGLONG m_Attrib[MAX_Attribute];
// This value is used to fudge a rotated image.
- enum
AcpiPldRotation
m_Rotation;
diff --git a/avstream/avscamera/sys/hwsim.cpp b/avstream/avscamera/sys/hwsim.cpp
index 4309befb..2db48d30 100644
--- a/avstream/avscamera/sys/hwsim.cpp
+++ b/avstream/avscamera/sys/hwsim.cpp
@@ -1195,16 +1195,16 @@ Return Value:
// Generate a "time stamp" just to overlay it onto the capture image.
// It makes it more exciting than bars that do nothing.
//
- // Only set these values if it's a preview simulation.
- // Note: This was simpler than overloading CHardwareSimulation...
- if( m_Sensor->IsPreviewIndex(m_PinID) )
+ // Note: Streaming pins have their own indexes; but still pins track
+ // the most recent streaming pin's index.
+ if (!m_Sensor->IsStillIndex(m_PinID))
{
DBG_TRACE("QPC=0x%016llX", Qpc);
// Broadcast the preview pin's info to all pin simulations.
- m_Sensor->SetSynthesizerAttribute(CSynthesizer::FrameNumber, m_InterruptTime);
- m_Sensor->SetSynthesizerAttribute(CSynthesizer::RelativePts, (m_InterruptTime + 1) * m_TimePerFrame );
- m_Sensor->SetSynthesizerAttribute(CSynthesizer::QpcTime, Qpc );
+ m_Sensor->SetSynthesizerAttribute(CSynthesizer::FrameNumber, m_InterruptTime, m_PinID);
+ m_Sensor->SetSynthesizerAttribute(CSynthesizer::RelativePts, (m_InterruptTime + 1) * m_TimePerFrame, m_PinID);
+ m_Sensor->SetSynthesizerAttribute(CSynthesizer::QpcTime, Qpc, m_PinID);
}
m_Synthesizer->DoSynthesize();
diff --git a/avstream/sampledevicemft/basepin.cpp b/avstream/sampledevicemft/basepin.cpp
index 80647f39..5e4ba038 100644
--- a/avstream/sampledevicemft/basepin.cpp
+++ b/avstream/sampledevicemft/basepin.cpp
@@ -644,9 +644,11 @@ STDMETHODIMP COutPin::ProcessOutput(_In_ DWORD dwFlags,
}
//
// Any processing before we pass the sample to further in the pipeline should be done here
- // PROCESSSAMPLE(pSample);
+ // PROCESSSAMPLE(pSample); There is a bug in the pipeline and to circumvent that we have to
+ // keep a reference on the sample. The pipeline is not releasing a reference when the sample
+ // is fed in ProcessInput. We are explicitly releasing it for the pipeline.
//
- pOutputSample->pSample = spSample.Get();
+ pOutputSample->pSample = spSample.Detach();
pOutputSample->dwStatus = S_OK;
done:
return hr;
diff --git a/avstream/sampledevicemft/common.h b/avstream/sampledevicemft/common.h
index 93f107c6..d32ec618 100644
--- a/avstream/sampledevicemft/common.h
+++ b/avstream/sampledevicemft/common.h
@@ -537,7 +537,7 @@ public:
// Query for the 2-D buffer interface. OK if this fails.
if (FAILED(m_pBuffer->QueryInterface(IID_PPV_ARGS(m_p2DBuffer2.GetAddressOf()))))
{
- m_p2DBuffer->QueryInterface(IID_PPV_ARGS(m_p2DBuffer.GetAddressOf()));
+ m_pBuffer->QueryInterface(IID_PPV_ARGS(m_p2DBuffer.GetAddressOf()));
}
}
~VideoBufferLock()
diff --git a/avstream/sampledevicemft/multipinmft.cpp b/avstream/sampledevicemft/multipinmft.cpp
index 4b9a10e2..5a3bb933 100644
--- a/avstream/sampledevicemft/multipinmft.cpp
+++ b/avstream/sampledevicemft/multipinmft.cpp
@@ -27,6 +27,7 @@ CMultipinMft::CMultipinMft()
m_filterInWarmStart(false)
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
, m_spPhotoConfirmationCallback(nullptr)
+ , m_firePhotoConfirmation(FALSE)
#endif
{
HRESULT hr = S_OK;
@@ -156,6 +157,9 @@ done:
--*/
+// This Sample will create a grayscale for known media types. Please remove MF_DEVICEMFT_ADD_GRAYSCALER_ to remove the grayscaler
+// This sample also has photo confirmation enabled remove DMF_DEVICEMFT_PHTOTOCONFIRMATION to remove photo confirmation
+
STDMETHODIMP CMultipinMft::InitializeTransform (
_In_ IMFAttributes *pAttributes
)
@@ -681,6 +685,8 @@ STDMETHODIMP CMultipinMft::ProcessInput(
DMFTCHECKHR_GOTO( inPin->SendSample( pSample ), done );
done:
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr );
+ // Workaround A Bug in the pipeline which is incorrectly not releasing the sample
+ SAFE_RELEASE(pSample);
return hr;
}
@@ -723,22 +729,24 @@ output pins and populate the corresponding MFT_OUTPUT_DATA_BUFFER with the sampl
pdwStatus ) ) )
{
gotOne = true;
- // Do photo confirmation if enabled
+ // Do photo confirmation if enabled off the preview stream only
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
- BOOL pIsImagePin = FALSE;
+ BOOL pIsPreviewPin = FALSE;
if (pOutputSamples[i].pSample &&
IsPhotoConfirmationEnabled() &&
- (SUCCEEDED(CheckImagePin(static_cast<IMFAttributes*>(poPin), &pIsImagePin)) && pIsImagePin))
+ ((SUCCEEDED(CheckPreviewPin(static_cast<IMFAttributes*>(poPin), &pIsPreviewPin)) && pIsPreviewPin) &&
+ InterlockedCompareExchange(reinterpret_cast<PLONG>(&m_firePhotoConfirmation),FALSE,TRUE)))
{
+ // Please note photo confirmation should always be fired off the preview stream.
ComPtr<IMFMediaType> spMediaType;
if (SUCCEEDED(poPin->getMediaType(spMediaType.GetAddressOf())))
{
// Do Photo confirmation
ProcessCapturePhotoConfirmationCallBack(spMediaType.Get(), pOutputSamples[i].pSample);
+ m_firePhotoConfirmation = FALSE;
}
}
#endif
-
}
}
if (gotOne)
@@ -1071,6 +1079,9 @@ STDMETHODIMP CMultipinMft::KsProperty(
else
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Take Single Photo Trigger");
+#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
+ InterlockedExchange(reinterpret_cast<PLONG>(&m_firePhotoConfirmation),TRUE);
+#endif
}
}
}
diff --git a/avstream/sampledevicemft/multipinmft.h b/avstream/sampledevicemft/multipinmft.h
index 5bdaaca9..b55a221a 100644
--- a/avstream/sampledevicemft/multipinmft.h
+++ b/avstream/sampledevicemft/multipinmft.h
@@ -7,7 +7,6 @@
//
#pragma once
-#define MF_DEVICEMFT_ADD_GRAYSCALER_ 1
#include "common.h"
#include "mftpeventgenerator.h"
#include "basepin.h"
@@ -402,6 +401,7 @@ private:
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
ComPtr<IMFAsyncCallback> m_spPhotoConfirmationCallback; //Photo Confirmation related definitions
GUID m_guidPhotoConfirmationSubtype;
+ BOOL m_firePhotoConfirmation;
#endif
};
diff --git a/avstream/sampledevicemft/multipinmfthelpers.cpp b/avstream/sampledevicemft/multipinmfthelpers.cpp
index 788b52ab..063fafca 100644
--- a/avstream/sampledevicemft/multipinmfthelpers.cpp
+++ b/avstream/sampledevicemft/multipinmfthelpers.cpp
@@ -44,6 +44,7 @@ STDMETHODIMP_(VOID) CPinQueue::InsertInternal( _In_ IMFSample *pSample )
if (FAILED(hr))
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
+ // There is a bug in the pipeline that doesn't release the sample fed from processinput. We have to explicitly release the sample here
SAFE_RELEASE(pSample);
}
}
@@ -108,9 +109,6 @@ STDMETHODIMP CPinQueue::RecreateTee( _In_ IMFMediaType *inMediatype,
HRESULT hr = S_OK;
MF_TRANSFORM_XVP_OPERATION operation = DeviceMftTransformXVPIllegal;
- DMFTCHECKNULL_GOTO(inMediatype, done, E_INVALIDARG);
- DMFTCHECKNULL_GOTO(outMediatype, done, E_INVALIDARG);
-
SAFE_DELETE(m_teer);
CNullTee *nulltee = new (std::nothrow) CNullTee();
@@ -158,7 +156,7 @@ STDMETHODIMP CPinQueueWithGrayScale::RecreateTee( _In_ IMFMediaType *inMediatyp
outMediatype,
punkManager),done);
DMFTCHECKNULL_GOTO(m_teer, done, E_UNEXPECTED);
- // Wrap the media type with Gray scale tee only if the input media type is a YUY2, UYVY or NV12
+ // Wrap the media type with Gray scale tee only if the input media type is a YUY2, UYVY, NV12 or RGB32
DMFTCHECKHR_GOTO(inMediatype->GetGUID(MF_MT_SUBTYPE, &gInputSubType), done);
if (IsEqualCLSID(gInputSubType, MFVideoFormat_NV12)
||IsEqualCLSID(gInputSubType, MFVideoFormat_YUY2)
@@ -359,10 +357,7 @@ STDMETHODIMP CXvptee::Do(_In_ IMFSample *pSample, _Outptr_ IMFSample** pOutSampl
}
*pOutSample = spXVPOutputSample.Detach();
- //
- //Release the Sample back to the pipeline
- //
- pSample->Release();
+
done:
hr = FAILED(pohr) ? pohr : hr;
@@ -535,6 +530,7 @@ CXvptee::~CXvptee()
m_spDeviceManagerUnk = nullptr;
}
+#ifdef MF_DEVICEMFT_ADD_GRAYSCALER_
CGrayTee::CGrayTee(_In_ Ctee *tee) : CWrapTee(tee),m_transformfn(nullptr)
{
}
@@ -542,68 +538,66 @@ STDMETHODIMP CGrayTee::Do(_In_ IMFSample *pSample, _Outptr_ IMFSample** ppOutSam
{
HRESULT hr = S_OK;
ComPtr<IMFSample> spOutputSample;
- ComPtr<IMFMediaType> spMediaType = getOutMediaType();
ComPtr <IMFMediaBuffer> spMediaBufInput, spMediaBufOutput;
LONG lDefaultStride = 0, lSrcStride = 0,lDestStride = 0;
-
GUID guidOutputSubType = GUID_NULL;
LONGLONG hnsDuration, hnsTime = 0;
DWORD dwTotalLength = 0;
- DMFTCHECKHR_GOTO(pSample->GetTotalLength(&dwTotalLength), done);
+ BYTE *pDest = NULL, *pSrc = NULL;
+ DWORD cbBuffer = 0;
+ ComPtr<IMFMediaType> spMediaType = getOutMediaType();
DMFTCHECKNULL_GOTO(ppOutSample, done, E_INVALIDARG);
DMFTCHECKNULL_GOTO(pSample, done, E_INVALIDARG);
+
+ DMFTCHECKHR_GOTO(pSample->GetTotalLength(&dwTotalLength), done);
*ppOutSample = nullptr;
DMFTCHECKHR_GOTO(pSample->ConvertToContiguousBuffer(spMediaBufInput.GetAddressOf()), done);
- DMFTCHECKHR_GOTO(getOutMediaType()->GetGUID(MF_MT_SUBTYPE, &guidOutputSubType), done);
- DMFTCHECKHR_GOTO(MFGetStrideForBitmapInfoHeader(guidOutputSubType.Data1, m_rect.right, &lDefaultStride), done);
-
- DMFTCHECKHR_GOTO(MFCreateSample(spOutputSample.GetAddressOf()), done);
- DMFTCHECKHR_GOTO(pSample->CopyAllItems(spOutputSample.Get()), done);
- // Create the MediaBuffer for the new sample
- hr = MFCreate2DMediaBuffer(
- m_rect.right,
- m_rect.bottom,
- guidOutputSubType.Data1,
- FALSE, // top-down buffer (DX compatible)
- &spMediaBufOutput);
- if (FAILED(hr))
- {
- spMediaBufOutput = nullptr;
- DMFTCHECKHR_GOTO(MFCreateAlignedMemoryBuffer(
- dwTotalLength,
- MF_1_BYTE_ALIGNMENT,
- &spMediaBufOutput), done);
- }
- // Add the media buffer to the output sample
- DMFTCHECKHR_GOTO(spOutputSample->AddBuffer(spMediaBufOutput.Get()), done);
+
{
- BYTE *pDest = NULL, *pSrc = NULL;
- DWORD cbBuffer = 0;
VideoBufferLock inputLock(spMediaBufInput.Get());
- VideoBufferLock outputLock(spMediaBufOutput.Get());
- DMFTCHECKHR_GOTO(inputLock.LockBuffer(lDefaultStride, m_rect.bottom, &pSrc, &lSrcStride,&cbBuffer), done);
- DMFTCHECKHR_GOTO(outputLock.LockBuffer(lDefaultStride, m_rect.bottom, &pDest, &lDestStride,&cbBuffer,FALSE), done);
- if (m_transformfn)
+
+ DMFTCHECKHR_GOTO(spMediaType->GetGUID(MF_MT_SUBTYPE, &guidOutputSubType), done);
+ DMFTCHECKHR_GOTO(MFGetStrideForBitmapInfoHeader(guidOutputSubType.Data1, m_rect.right, &lDefaultStride), done);
+ DMFTCHECKHR_GOTO(MFCreateSample(spOutputSample.GetAddressOf()), done);
+ DMFTCHECKHR_GOTO(pSample->CopyAllItems(spOutputSample.Get()), done);
+ DMFTCHECKHR_GOTO(inputLock.LockBuffer(lDefaultStride, m_rect.bottom, &pSrc, &lSrcStride, &cbBuffer), done);
+ dwTotalLength = max(dwTotalLength, (DWORD)(abs(lSrcStride*m_rect.bottom)));
+ // Create the MediaBuffer for the new sample
+ hr = MFCreate2DMediaBuffer(
+ m_rect.right,
+ m_rect.bottom,
+ guidOutputSubType.Data1,
+ (lSrcStride < 0), // top-down buffer (DX compatible)
+ &spMediaBufOutput);
+ if (FAILED(hr))
{
- m_transformfn(m_rect, pDest, lDestStride, pSrc, lSrcStride, m_rect.right, m_rect.bottom);
+ spMediaBufOutput = nullptr;
+ DMFTCHECKHR_GOTO(MFCreateAlignedMemoryBuffer(
+ dwTotalLength,
+ MF_1_BYTE_ALIGNMENT,
+ &spMediaBufOutput), done);
+ }
+ // Add the media buffer to the output sample
+ DMFTCHECKHR_GOTO(spOutputSample->AddBuffer(spMediaBufOutput.Get()), done);
+ {
+ VideoBufferLock outputLock(spMediaBufOutput.Get());
+ DMFTCHECKHR_GOTO(outputLock.LockBuffer(lDefaultStride, m_rect.bottom, &pDest, &lDestStride, &cbBuffer, FALSE), done);
+ if (m_transformfn)
+ {
+ m_transformfn(m_rect, pDest, lDestStride, pSrc, lSrcStride, m_rect.right, m_rect.bottom);
+ }
+ }
+ if (SUCCEEDED(pSample->GetSampleDuration(&hnsDuration)))
+ {
+ DMFTCHECKHR_GOTO(spOutputSample->SetSampleDuration(hnsDuration), done);
+ }
+ if (SUCCEEDED(pSample->GetSampleTime(&hnsTime)))
+ {
+ DMFTCHECKHR_GOTO(spOutputSample->SetSampleTime(hnsTime), done);
}
}
- if (SUCCEEDED(pSample->GetSampleDuration(&hnsDuration)))
- {
- DMFTCHECKHR_GOTO(spOutputSample->SetSampleDuration(hnsDuration),done);
- }
- if (SUCCEEDED(pSample->GetSampleTime(&hnsTime)))
- {
- DMFTCHECKHR_GOTO(spOutputSample->SetSampleTime(hnsTime),done);
- }
- if (SUCCEEDED(spMediaBufInput->GetCurrentLength(&dwTotalLength)))
- {
- DMFTCHECKHR_GOTO(spMediaBufOutput->SetCurrentLength(dwTotalLength),done);
- }
-
*ppOutSample = spOutputSample.Detach();
- pSample->Release();
done:
return hr;
}
@@ -643,6 +637,7 @@ HRESULT CGrayTee::Configure(
done:
return hr;
}
+#endif
/*++
Descrtiption:
@@ -1061,21 +1056,35 @@ done:
return hr;
}
-HRESULT CheckImagePin( _In_ IMFAttributes* pAttributes, _Out_ PBOOL pbIsImagePin )
+HRESULT CheckPinType(_In_ IMFAttributes* pAttributes, _In_ GUID pinType, _Out_ PBOOL pResult)
{
HRESULT hr = S_OK;
+ GUID pinClsid = GUID_NULL;
+
DMFTCHECKNULL_GOTO(pAttributes, done, E_INVALIDARG);
- DMFTCHECKNULL_GOTO(pbIsImagePin, done, E_INVALIDARG);
+ DMFTCHECKNULL_GOTO(pResult, done, E_INVALIDARG);
+ *pResult = FALSE;
+
+ if (SUCCEEDED(pAttributes->GetGUID(MF_DEVICESTREAM_STREAM_CATEGORY, &pinClsid))
+ && (IsEqualCLSID(pinClsid, pinType)))
{
- GUID pinClsid = GUID_NULL;
- *pbIsImagePin = FALSE;
- if (SUCCEEDED(pAttributes->GetGUID(MF_DEVICESTREAM_STREAM_CATEGORY, &pinClsid))
- && ((IsEqualCLSID(pinClsid, PINNAME_IMAGE)) || IsEqualCLSID(pinClsid, PINNAME_VIDEO_STILL)))
- {
- *pbIsImagePin = TRUE;
- }
+ *pResult = TRUE;
}
done:
return hr;
}
+HRESULT CheckImagePin( _In_ IMFAttributes* pAttributes, _Out_ PBOOL pbIsImagePin )
+{
+ if ((SUCCEEDED(CheckPinType(pAttributes, PINNAME_IMAGE, pbIsImagePin)) && pbIsImagePin) ||
+ (SUCCEEDED(CheckPinType(pAttributes, PINNAME_VIDEO_STILL, pbIsImagePin)) && pbIsImagePin))
+ {
+ return S_OK;
+ }
+ return E_FAIL;
+}
+
+HRESULT CheckPreviewPin( _In_ IMFAttributes* pAttributes, _Out_ PBOOL pbIsPreviewPin)
+{
+ return CheckPinType(pAttributes, PINNAME_PREVIEW, pbIsPreviewPin);
+}
diff --git a/avstream/sampledevicemft/multipinmfthelpers.h b/avstream/sampledevicemft/multipinmfthelpers.h
index 9376470e..41472c85 100644
--- a/avstream/sampledevicemft/multipinmfthelpers.h
+++ b/avstream/sampledevicemft/multipinmfthelpers.h
@@ -149,7 +149,7 @@ private:
UINT32 m_uHeight;
ComPtr<IUnknown> m_spDeviceManagerUnk;
};
-
+#ifdef MF_DEVICEMFT_ADD_GRAYSCALER_
class CGrayTee : public CWrapTee {
public:
CGrayTee(Ctee*);
@@ -163,7 +163,7 @@ private:
DMFT_IMAGE_TRANSFORM_FN m_transformfn;
RECT m_rect;
};
-
+#endif
/*
################## EVENT HANDLING #############################################
Events are usually divided into two categories by the Capture Pipeline
@@ -265,7 +265,8 @@ public:
CPinCreationFactory(_In_ CMultipinMft* pDeviceTransform):m_spDeviceTransform(pDeviceTransform){
}
};
-
+HRESULT CheckPinType(_In_ IMFAttributes* pAttributes, _In_ GUID pinType, _Out_ PBOOL pbIsImagePin);
HRESULT CheckImagePin(_In_ IMFAttributes* pAttributes, _Out_ PBOOL pbIsImagePin);
+HRESULT CheckPreviewPin(_In_ IMFAttributes* pAttributes, _Out_ PBOOL pbIsPreviewPin);
diff --git a/avstream/samplemft0/Package/package.vcxproj b/avstream/samplemft0/Package/package.vcxproj
index b1b4d0a1..c898c343 100644
--- a/avstream/samplemft0/Package/package.vcxproj
+++ b/avstream/samplemft0/Package/package.vcxproj
@@ -33,19 +33,19 @@
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <TargetVersion>Windows8</TargetVersion>
+ <TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <TargetVersion>Windows8</TargetVersion>
+ <TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <TargetVersion>Windows8</TargetVersion>
+ <TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <TargetVersion>Windows8</TargetVersion>
+ <TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
diff --git a/avstream/samplemft0/SampleMft0.vcxproj b/avstream/samplemft0/SampleMft0.vcxproj
index 90c623ba..c7a28b8e 100644
--- a/avstream/samplemft0/SampleMft0.vcxproj
+++ b/avstream/samplemft0/SampleMft0.vcxproj
@@ -36,19 +36,19 @@
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <TargetVersion>Win8</TargetVersion>
+ <TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <TargetVersion>Win8</TargetVersion>
+ <TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <TargetVersion>Win8</TargetVersion>
+ <TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <TargetVersion>Win8</TargetVersion>
+ <TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />