From 20d9283e3d3d695f6861260a02f24c466ed6f1b2 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 7 Oct 2020 05:05:25 +0900 Subject: [PATCH] mfvideosrc: Use only the first video stream per device Non-first video stream might not be working with current implementation. It could be non-video (e.g., photo source) and then ReadSample() might be blocked forever. Part-of: --- sys/mediafoundation/gstmfsourcereader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/mediafoundation/gstmfsourcereader.cpp b/sys/mediafoundation/gstmfsourcereader.cpp index a93d3960e7..3d6dd63c4e 100644 --- a/sys/mediafoundation/gstmfsourcereader.cpp +++ b/sys/mediafoundation/gstmfsourcereader.cpp @@ -180,7 +180,14 @@ gst_mf_enum_media_type_from_source_reader (IMFSourceReader * source_reader, g_return_val_if_fail (source_reader != NULL, FALSE); g_return_val_if_fail (media_types != NULL, FALSE); - for (i = 0;; i++) { + { + /* Retrive only the first video stream. non-first video stream might be + * photo stream which doesn't seem to be working propertly in this implementation. + * + * Note: Chromium seems to be using the first video stream + * https://github.com/chromium/chromium/blob/ccd149af47315e4c6f2fc45d55be1b271f39062c/media/capture/video/win/video_capture_device_factory_win.cc + */ + i = MF_SOURCE_READER_FIRST_VIDEO_STREAM; for (j = 0;; j++) { ComPtr media_type;