Index: webrtc/video/rtp_video_stream_receiver.cc |
diff --git a/webrtc/video/rtp_video_stream_receiver.cc b/webrtc/video/rtp_video_stream_receiver.cc |
index 4204670c7eb5094278a093c3b3867d92c26d26ca..2b41065e8a5d443edb21e77943697b255886358f 100644 |
--- a/webrtc/video/rtp_video_stream_receiver.cc |
+++ b/webrtc/video/rtp_video_stream_receiver.cc |
@@ -10,6 +10,7 @@ |
#include "webrtc/video/rtp_video_stream_receiver.h" |
+#include <algorithm> |
#include <utility> |
#include <vector> |
@@ -191,6 +192,8 @@ RtpVideoStreamReceiver::RtpVideoStreamReceiver( |
} |
RtpVideoStreamReceiver::~RtpVideoStreamReceiver() { |
+ RTC_DCHECK(secondary_sinks_.empty()); |
+ |
if (nack_module_) { |
process_thread_->DeRegisterModule(nack_module_.get()); |
} |
@@ -361,6 +364,10 @@ void RtpVideoStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) { |
rtp_receive_statistics_->IncomingPacket( |
header, packet.size(), IsPacketRetransmitted(header, in_order)); |
} |
+ |
+ for (auto* secondary_sink : secondary_sinks_) { |
+ secondary_sink->OnRtpPacket(packet); |
+ } |
} |
int32_t RtpVideoStreamReceiver::RequestKeyFrame() { |
@@ -428,6 +435,25 @@ rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedKeyframePacketMs() |
return packet_buffer_->LastReceivedKeyframePacketMs(); |
} |
+void RtpVideoStreamReceiver::AddSecondarySink(RtpPacketSinkInterface* sink) { |
+ RTC_DCHECK(std::find(secondary_sinks_.cbegin(), secondary_sinks_.cend(), |
+ sink) == secondary_sinks_.cend()); |
+ secondary_sinks_.push_back(sink); |
+} |
+ |
+void RtpVideoStreamReceiver::RemoveSecondarySink( |
+ const RtpPacketSinkInterface* sink) { |
+ auto it = std::find(secondary_sinks_.begin(), secondary_sinks_.end(), sink); |
+ if (it == secondary_sinks_.end()) { |
+ // We might be rolling-back a call whose setup failed mid-way. In such a |
+ // case, it's simpler to remove "everything" rather than remember what |
+ // has already been added. |
+ LOG(LS_WARNING) << "Removal of unknown sink (" << sink << ")."; |
danilchap
2017/07/25 17:29:54
why stream to text log address of the sink pointer
eladalon
2017/07/26 08:20:29
I thought it might sometimes help, but I agree it'
|
+ return; |
+ } |
+ secondary_sinks_.erase(it); |
+} |
+ |
void RtpVideoStreamReceiver::ReceivePacket(const uint8_t* packet, |
size_t packet_length, |
const RTPHeader& header, |