Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit e962f64

Browse files
committed
Fix issue #165: SDK crashes on failed local stream creation
1 parent c7e2aa4 commit e962f64

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

talk/owt/sdk/base/stream.cc

+12
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,21 @@ LocalStream::LocalStream(const LocalCameraStreamParameters& parameters,
392392
}
393393
scoped_refptr<VideoTrackSourceInterface> source = capturer_->source();
394394
#endif
395+
if (!source) {
396+
RTC_LOG(LS_ERROR)
397+
<< "Failed to create video source. Please check device availability.";
398+
error_code = static_cast<int>(ExceptionType::kLocalNotSupported);
399+
return;
400+
}
395401
std::string video_track_id("VideoTrack-" + rtc::CreateRandomUuid());
396402
scoped_refptr<VideoTrackInterface> video_track =
397403
pcd_factory->CreateLocalVideoTrack(video_track_id, source);
404+
if (!video_track) {
405+
RTC_LOG(LS_ERROR)
406+
<< "Failed to create video track. Please check device availability.";
407+
error_code = static_cast<int>(ExceptionType::kLocalNotSupported);
408+
return;
409+
}
398410
stream->AddTrack(video_track);
399411
}
400412
source_.video = VideoSourceInfo::kCamera;

0 commit comments

Comments
 (0)