Skip to content

Commit 4dc36ef

Browse files
check participant shared_ptr before reference
1 parent 06f05bf commit 4dc36ef

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

bridge/src/bridge_audio_track.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void BridgeAudioTrack::release() {
110110
released_ = true;
111111

112112
// Unpublish the track from the room
113-
if (participant_ && track_) {
113+
if (participant_ && track_ && track_->publication()) {
114114
try {
115115
participant_->unpublishTrack(track_->publication()->sid());
116116
} catch (...) {

bridge/src/bridge_video_track.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void BridgeVideoTrack::release() {
109109
released_ = true;
110110

111111
// Unpublish the track from the room
112-
if (participant_ && track_) {
112+
if (participant_ && track_ && track_->publication()) {
113113
try {
114114
participant_->unpublishTrack(track_->publication()->sid());
115115
} catch (...) {

examples/simple_room/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ int main(int argc, char *argv[]) {
359359
videoOpts.dtx = false;
360360
videoOpts.simulcast = true;
361361
try {
362+
// publishTrack takes std::shared_ptr<Track>, LocalAudioTrack derives from
363+
// Track
362364
room->localParticipant()->publishTrack(videoTrack, videoOpts);
365+
363366
const auto videoPub = videoTrack->publication();
364367

365368
std::cout << "Published track:\n"

0 commit comments

Comments
 (0)