From 58c3475ca9aaf41d55e5c1c57ef6d558274535f4 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 27 May 2016 15:02:39 +0200 Subject: [PATCH] Allow (re)selecting newly (re)appeared tracks in RTMP output. --- src/output/output.cpp | 1 + src/output/output_rtmp.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/output/output.cpp b/src/output/output.cpp index c16cbd3a..20c5e90d 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -1038,6 +1038,7 @@ namespace Mist { break; } } + selectedTracks.erase(trackId); } ///Attempts to prepare a new packet for output. diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp index 5eff3cb1..54490e3d 100644 --- a/src/output/output_rtmp.cpp +++ b/src/output/output_rtmp.cpp @@ -277,6 +277,21 @@ namespace Mist { } void OutRTMP::sendNext() { + + //If there are now more selectable tracks, select the new track and do a seek to the current timestamp + //Set sentHeader to false to force it to send init data + if (selectedTracks.size() < 2 && myMeta.tracks.size() > 1){ + size_t prevTrackCount = selectedTracks.size(); + selectDefaultTracks(); + if (selectedTracks.size() > prevTrackCount){ + INFO_MSG("Picked up new track - selecting it and resetting state."); + sentHeader = false; + seek(thisPacket.getTime()); + } + return; + } + + char rtmpheader[] = {0, //byte 0 = cs_id | ch_type 0, 0, 0, //bytes 1-3 = timestamp 0, 0, 0, //bytes 4-6 = length