Skip to content

Commit

Permalink
Merge pull request microsoft#254 from JoelCorley/rs4-update
Browse files Browse the repository at this point in the history
Update AVStream / Camera samples for RS4.
  • Loading branch information
NeoAdonis authored Jul 19, 2018
2 parents 84a856e + 021af44 commit 501519d
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 212 deletions.
189 changes: 0 additions & 189 deletions avstream/avscamera/sys/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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...
Expand Down
6 changes: 4 additions & 2 deletions avstream/avscamera/sys/Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion avstream/avscamera/sys/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ class CSensor
}

void
SetSynthesizerAttribute( CSynthesizer::Attribute Attrib, LONGLONG Info );
SetSynthesizerAttribute( CSynthesizer::Attribute Attrib, LONGLONG Info, LONG PinId );

protected:
LONG
Expand Down
2 changes: 1 addition & 1 deletion avstream/avscamera/sys/SensorSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion avstream/avscamera/sys/Synthesizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ class CSynthesizer :
LONGLONG m_Attrib[MAX_Attribute];

// This value is used to fudge a rotated image.
enum
AcpiPldRotation
m_Rotation;

Expand Down
12 changes: 6 additions & 6 deletions avstream/avscamera/sys/hwsim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions avstream/sampledevicemft/multipinmft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ STDMETHODIMP CMultipinMft::QueryInterface(
--*/

// This Sample will create a grayscale for known media types. Please remove MF_DEVICEMFT_ADD_GRAYSCALER_ to remove the grayscaler
// 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
// Please search for the @@@@ README tag for critical sections in code and it's documentation
//
Expand Down Expand Up @@ -778,15 +778,15 @@ output pins and populate the corresponding MFT_OUTPUT_DATA_BUFFER with the sampl
pdwStatus ) ) )
{
gotOne = true;
// Do photo confirmation if enabled off the preview stream only
// Do photo confirmation if enabled from the preview stream only
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
BOOL pIsPreviewPin = FALSE;
if (pOutputSamples[i].pSample &&
IsPhotoConfirmationEnabled() &&
((SUCCEEDED(CheckPreviewPin(static_cast<IMFAttributes*>(spOpin.Get()), &pIsPreviewPin)) && pIsPreviewPin) &&
InterlockedCompareExchange(reinterpret_cast<PLONG>(&m_firePhotoConfirmation),FALSE,TRUE)))
InterlockedCompareExchange(reinterpret_cast<PLONG>(&m_firePhotoConfirmation), FALSE, TRUE)))
{
// Please note photo confirmation should always be fired off the preview stream.
// Please note photo confirmation should always be fired from the preview stream.
ComPtr<IMFMediaType> spMediaType;
if (SUCCEEDED(spOpin->getMediaType(spMediaType.GetAddressOf())))
{
Expand Down
8 changes: 4 additions & 4 deletions avstream/samplemft0/Package/package.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
8 changes: 4 additions & 4 deletions avstream/samplemft0/SampleMft0.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down

0 comments on commit 501519d

Please sign in to comment.