Skip to content

Commit a3d9f54

Browse files
committed
Terminate (end) VideoTrackDesktopSource if source cannot be selected
1 parent 38beae8 commit a3d9f54

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace jni
3737

3838
void start();
3939
void stop();
40+
void terminate();
4041

4142
// AdaptedVideoTrackSource implementation.
4243
virtual bool is_screencast() const override;

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

+9-4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ namespace jni
8888
}
8989
}
9090

91+
void VideoTrackDesktopSource::terminate()
92+
{
93+
// Notify the track that we are permanently done.
94+
sourceState = kEnded;
95+
FireOnChanged();
96+
}
97+
9198
bool VideoTrackDesktopSource::is_screencast() const {
9299
return true;
93100
}
@@ -110,10 +117,7 @@ namespace jni
110117
if (result == webrtc::DesktopCapturer::Result::ERROR_PERMANENT) {
111118
RTC_LOG(LS_ERROR) << "Permanent error capturing desktop frame. Stopping track.";
112119

113-
// Notify the track that we are permanently done.
114-
sourceState = kEnded;
115-
FireOnChanged();
116-
120+
terminate();
117121
stop();
118122
}
119123

@@ -254,6 +258,7 @@ namespace jni
254258
}
255259

256260
if (!capturer->SelectSource(sourceId)) {
261+
terminate();
257262
return;
258263
}
259264

0 commit comments

Comments
 (0)