Skip to content

Commit eee466f

Browse files
committed
Notify the track to end on permanent error when capturing a desktop frame
1 parent ed66a87 commit eee466f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

webrtc-jni/src/main/cpp/src/media/video/VideoTrackDesktopSource.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "modules/desktop_capture/desktop_capture_options.h"
2424
#include "modules/video_capture/video_capture_factory.h"
2525
#include "third_party/libyuv/include/libyuv/video_common.h"
26+
#include "rtc_base/logging.h"
2627
#include "system_wrappers/include/sleep.h"
2728

2829
#include "modules/desktop_capture/desktop_capturer.h"
@@ -106,6 +107,16 @@ namespace jni
106107
void VideoTrackDesktopSource::OnCaptureResult(webrtc::DesktopCapturer::Result result, std::unique_ptr<webrtc::DesktopFrame> frame)
107108
{
108109
if (result != webrtc::DesktopCapturer::Result::SUCCESS) {
110+
if (result == webrtc::DesktopCapturer::Result::ERROR_PERMANENT) {
111+
RTC_LOG(LS_ERROR) << "Permanent error capturing desktop frame. Stopping track.";
112+
113+
// Notify the track that we are permanently done.
114+
sourceState = kEnded;
115+
FireOnChanged();
116+
117+
stop();
118+
}
119+
109120
return;
110121
}
111122

@@ -261,7 +272,5 @@ namespace jni
261272

262273
webrtc::SleepMs(msPerFrame);
263274
}
264-
265-
sourceState = kEnded;
266275
}
267276
}

0 commit comments

Comments
 (0)