-
Notifications
You must be signed in to change notification settings - Fork 5k
Handling KSPROPERTY_CAMERACONTROL_EXTENDED_PROFILE on avscamera DMFT #1325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ng behavior on camera DMFT.
| } | ||
| done: | ||
| return hr; | ||
| return S_OK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If source device return failed on the following, hr won't hold S_OK here. I would assume if source device returned failed, but the DMFT itself supports the KsEvent, it should reply OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is with style there is multiple exit points in this new function while the rest of the code has single exit point I would keep the styling the same as the rest of the code
| && (pEvent->Id == KSPROPERTY_CAMERACONTROL_EXTENDED_PROFILE)) | ||
| { | ||
|
|
||
| m_hSelectedProfileKSEvent = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| FALSE, | ||
| DUPLICATE_SAME_ACCESS) == false) | ||
| { | ||
| return E_INVALIDARG; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (pProperty->Id == KSPROPERTY_CAMERACONTROL_EXTENDED_PROFILE) | ||
| { | ||
| DMFTCHECKHR_GOTO(ProfilePropertyHandler(pProperty, ulPropertyLength, pvPropertyData, ulDataLength, pulBytesReturned), done); | ||
| goto done; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: only use goto for error case
| } | ||
| if (m_isProfileDDISupportedInBaseDriver.value_or(true)) | ||
| { | ||
| m_hSelectedProfileKSEventSentToDriver = CreateEventExW( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| UNREFERENCED_PARAMETER(ulPropertyLength); | ||
| HRESULT hr = S_OK; | ||
|
|
||
| if (pProperty->Flags & KSPROPERTY_TYPE_SET) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check size
| // Deref on the connected outpins to break reference loop | ||
| (VOID)pInPin->ShutdownPin(); | ||
| } | ||
| return ShutdownEventGenerator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to handle canceling event and outstanding controls in shutdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referring to the doc. above, extended profile is not cancelable.
| <ClCompile> | ||
| <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;MF_WPP;SECURITY_WIN32;MFT_UNIQUE_METHOD_NAMES;MF_DEVICEMFT_ALLOW_MFT0_LOAD</PreprocessorDefinitions> | ||
| <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories);..\..\common;..\common</AdditionalIncludeDirectories> | ||
| <LanguageStandard>stdcpp17</LanguageStandard> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
| SetEvent(m_hSelectedProfileKSEvent); | ||
| m_hSelectedProfileKSEvent = nullptr; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait should not block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using MFPutWaitingWorkItem to signal the m_hSelectedProfileKSEvent (using m_hSelectedProfileKSEventSentToDriver as the event handle to the API in question). This doesn't afford you the ability to use a timeout, but the spec requires drivers to signal the event both in the case of success or if the operation can't complete.
|
|
||
| /// PDMFT only cares about ExtendedCameraControls, all others | ||
| /// are just blindly forwarded to the upstream DMFTs. | ||
| if (!IsEqualCLSID(pProperty->Set, KSPROPERTYSETID_ExtendedCameraControl)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| PWCHAR m_SymbolicLink; | ||
| HANDLE m_hSelectedProfileKSEvent; | ||
| HANDLE m_hSelectedProfileKSEventSentToDriver; | ||
| std::optional<bool> m_isProfileDDISupportedInBaseDriver; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want drivers querying static info if they are shipped with specific HW if this changes dynamically it is probably a bug
|
|
||
| interface IDirect3DDeviceManager9; | ||
|
|
||
| constexpr int kMAX_WAIT_TIME_DRIVER_PROFILE_KSEVENT = 3000;// ms, amount of time to wait for the profile DDI KsEvent sent to the driver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant is removed due to migrate to MFPutWaitingWorkItem instead of blocking wait.
| // TODO: required to avoid bug OS bug 36971659 in extended property handling that introduces a 16 bytes cookie | ||
| typedef struct | ||
| { | ||
| //byte cookieBuffer[16]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented out code
| DMFTCHECKHR_GOTO(pAttributes->SetUINT32( MF_SA_D3D_AWARE, TRUE ), done); | ||
| DMFTCHECKHR_GOTO(pAttributes->SetString( MFT_ENUM_HARDWARE_URL_Attribute, L"SampleMultiPinMft" ),done); | ||
| m_spAttributes = pAttributes; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: remove
| pvPropertyData, | ||
| ulDataLength, | ||
| pulBytesReturned),done); | ||
| if (pProperty->Id == KSPROPERTY_CAMERACONTROL_EXTENDED_PROFILE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (pProperty->Id == KSPROPERTY_CAMERACONTROL_EXTENDED_PROFILE)
This is incorrect. You're only checking against the Id. The combination should always be Set + Id to determine the control.
In this particular case, you're going to intercept any control whose Id is 34 regardless of whether that Id belongs to the KSPROPERTYSETID_ExtendedCameraControl or not. I think what you meant to do here is to intercept and call ProfilePropertyHandler only if the Set == KSPROPERTYSETID_ExtendedCameraControl && Id == KSPROPERTY_CAMERACONTROL_EXTENDED_PROFILE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent poinnt!!
|
|
||
| m_selectedProfileId.Type = pProfile->ProfileId; | ||
| m_selectedProfileId.Index = pProfile->Index; | ||
| m_selectedProfileId.Unused = pProfile->Reserved; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This information is never forwarded to the driver so the SentToDriver event will never signal.
2. On event handling, removed blocking wait, use MFPutWaitingWorkItem instead.
| KSCAMERA_EXTENDEDPROP_HEADER header; | ||
| } KSCAMERA_EXTENDEDPROP_HEADER_BUFFERED, * PKSCAMERA_EXTENDEDPROP_HEADER_BUFFERED; | ||
|
|
||
| // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove it is defined in ksmedia.h which should be already included
| } | ||
|
|
||
| HRESULT CMultipinMft::ProfileAsyncResultCallback(_In_ IMFAsyncResult* pResult) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No lock?
| wil::unique_event_nothrow m_hSelectedProfileKSEventSentToDriver; | ||
| std::optional<bool> m_isProfileDDISupportedInBaseDriver; | ||
| SENSORPROFILEID m_selectedProfileId; | ||
| MFAsyncCallback<CMultipinMft>m_profileCallback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is going to break if parent class goes away
| ulDataLength, | ||
| pBytesReturned), done); | ||
| // handle the event if it is to set profile | ||
| if (pEvent != nullptr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if this gets called twice before the first completes?
| hr = m_spIkscontrol->KsEvent(pEvent, | ||
| ulEventLength, | ||
| pEventData, | ||
| ulDataLength, | ||
| pBytesReturned); | ||
| DMFTCHECKHR_GOTO(hr, done); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| hr = m_spIkscontrol->KsEvent(pEvent, | |
| ulEventLength, | |
| pEventData, | |
| ulDataLength, | |
| pBytesReturned); | |
| DMFTCHECKHR_GOTO(hr, done); | |
| DMFTCHECKHR_GOTO(m_spIkscontrol->KsEvent(pEvent, ulEventLength, pEventData, ulDataLength, pBytesReturned), done); |
| hr = m_hSelectedProfileKSEventSentToDriver.create(); | ||
| DMFTCHECKHR_GOTO(hr, done); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DMFTCHECKHR_GOTO(m_hSelectedProfileKSEventSentToDriver.create(), done);
| driverEventData.EventHandle.Event = m_hSelectedProfileKSEventSentToDriver.get(); | ||
| DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "Handling profile set KsEvent, created profile KsEvent handle for driver: %p", m_hSelectedProfileKSEventSentToDriver.get()); | ||
| // defer to source device | ||
| HRESULT hr2 = m_spIkscontrol->KsEvent(pEvent, ulEventLength, (void*)(&driverEventData), ulDataLength, pBytesReturned); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code will show success while actually failing
| { | ||
| hr = m_hSelectedProfileKSEventSentToDriver.create(); | ||
| DMFTCHECKHR_GOTO(hr, done); | ||
| KSEVENTDATA driverEventData = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing size and data from original call
| /*++ | ||
| Description: | ||
| Implements IKSProperty::KsEvent function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to handle the event? It complicates the sample, I would just grab the control set it would make the change a lot smaller.
| done: | ||
| DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr); | ||
| return hr; | ||
| } CATCH_RETURN() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catch returns are only needed on the external com interfaces since the caller cannot not handle exceptions from external module.
| pEventData, | ||
| ulDataLength, | ||
| pBytesReturned); | ||
| DMFTCHECKHR_GOTO(hr, done); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[](http://example.com/codeflow?start=0&length=2)
remove tabs

In avscamera DMFT, its KsEvent and KsProperty functions handle KSPROPERTY_CAMERACONTROL_EXTENDED_PROFILE property to allow DMFT to behave appropriately in response of various camera streaming profile selected.