-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[camera_windows] Set device media type for video preview explicitly #7447
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
Changes from 5 commits
b79eea5
d887b8f
b01c17c
1f17a42
cdf4f5c
2445b24
923fc4d
74cbd43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -467,10 +467,14 @@ HRESULT CaptureControllerImpl::FindBaseMediaTypes() { | |
| return hr; | ||
| } | ||
|
|
||
| return FindBaseMediaTypes(source.Get()); | ||
| } | ||
|
|
||
| HRESULT CaptureControllerImpl::FindBaseMediaTypes(IMFCaptureSource* source) { | ||
| // Find base media type for previewing. | ||
| if (!FindBestMediaType( | ||
| (DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_STREAM_FOR_VIDEO_PREVIEW, | ||
| source.Get(), base_preview_media_type_.GetAddressOf(), | ||
| source, base_preview_media_type_.GetAddressOf(), | ||
| GetMaxPreviewHeight(), &preview_frame_width_, | ||
| &preview_frame_height_)) { | ||
| return E_FAIL; | ||
|
|
@@ -479,8 +483,8 @@ HRESULT CaptureControllerImpl::FindBaseMediaTypes() { | |
| // Find base media type for record and photo capture. | ||
| if (!FindBestMediaType( | ||
| (DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_STREAM_FOR_VIDEO_RECORD, | ||
| source.Get(), base_capture_media_type_.GetAddressOf(), 0xffffffff, | ||
| nullptr, nullptr)) { | ||
| source, base_capture_media_type_.GetAddressOf(), 0xffffffff, nullptr, | ||
| nullptr)) { | ||
| return E_FAIL; | ||
| } | ||
|
|
||
|
|
@@ -566,15 +570,30 @@ void CaptureControllerImpl::StartPreview() { | |
|
|
||
| HRESULT hr = S_OK; | ||
|
|
||
| ComPtr<IMFCaptureSource> source; | ||
| hr = capture_engine_->GetSource(&source); | ||
| if (FAILED(hr)) { | ||
| return OnPreviewStarted(GetCameraResult(hr), | ||
| "Failed to initialize video preview"); | ||
|
||
| } | ||
|
|
||
| if (!base_preview_media_type_) { | ||
| // Enumerates mediatypes and finds media type for video capture. | ||
| hr = FindBaseMediaTypes(); | ||
| hr = FindBaseMediaTypes(source.Get()); | ||
| if (FAILED(hr)) { | ||
| return OnPreviewStarted(GetCameraResult(hr), | ||
| "Failed to initialize video preview"); | ||
| } | ||
| } | ||
|
|
||
| hr = source->SetCurrentDeviceMediaType( | ||
| (DWORD)MF_CAPTURE_ENGINE_PREFERRED_SOURCE_STREAM_FOR_VIDEO_PREVIEW, | ||
| base_preview_media_type_.Get()); | ||
| if (FAILED(hr)) { | ||
| return OnPreviewStarted(GetCameraResult(hr), | ||
| "Failed to initialize video preview"); | ||
| } | ||
|
|
||
| texture_handler_->UpdateTextureSize(preview_frame_width_, | ||
| preview_frame_height_); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,6 +180,7 @@ class CaptureControllerImpl : public CaptureController, | |
| // Enumerates video_sources media types and finds out best resolution | ||
| // for preview and video capture. | ||
| HRESULT FindBaseMediaTypes(); | ||
| HRESULT FindBaseMediaTypes(IMFCaptureSource* source); | ||
|
||
|
|
||
| // Stops preview. Called internally on camera reset and dispose. | ||
| HRESULT StopPreview(); | ||
|
|
||
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.
For versions <1, Dart convention is to use the build number for bugfixes, so this should be
0.2.5+1.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.
I have fixed the versioning in 4ffbedd