Chromium Code Reviews| Index: talk/media/webrtc/webrtcvoiceengine.cc |
| diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc |
| index 9742564985bca6c0437865dafbe76803608e384a..79c807564a504e71939687582447e8fb749ded89 100644 |
| --- a/talk/media/webrtc/webrtcvoiceengine.cc |
| +++ b/talk/media/webrtc/webrtcvoiceengine.cc |
| @@ -132,6 +132,16 @@ const int kMaxTelephoneEventCode = 255; |
| const int kMinTelephoneEventDuration = 100; |
| const int kMaxTelephoneEventDuration = 60000; // Actual limit is 2^16 |
| +class ProxySink : public webrtc::AudioSinkInterface { |
| + public: |
| + ProxySink(AudioSinkInterface* sink) : sink_(sink) {} |
| + |
| + void OnData(const Data& audio) override { sink_->OnData(audio); } |
| + |
| + private: |
| + webrtc::AudioSinkInterface* sink_; |
| +}; |
| + |
| bool ValidateStreamParams(const StreamParams& sp) { |
| if (sp.ssrcs.empty()) { |
| LOG(LS_ERROR) << "No SSRCs in stream parameters: " << sp.ToString(); |
| @@ -2186,6 +2196,9 @@ void WebRtcVoiceMediaChannel::OnPacketReceived( |
| } |
| default_recv_ssrc_ = ssrc; |
| SetOutputVolume(default_recv_ssrc_, default_recv_volume_); |
| + rtc::scoped_ptr<webrtc::AudioSinkInterface> proxy_sink( |
| + default_sink_ ? new ProxySink(default_sink_.get()) : nullptr); |
| + SetRawAudioSink(default_recv_ssrc_, std::move(proxy_sink)); |
|
tommi
2016/01/13 23:14:24
Do we actually want to make this call if default_s
Taylor Brandstetter
2016/01/13 23:55:12
I had "if (default_sink_)" originally, but I was s
the sun
2016/01/14 09:24:39
Yes, now that we can avoid allocating an object it
|
| } |
| // Forward packet to Call. If the SSRC is unknown we'll return after this. |
| @@ -2414,7 +2427,17 @@ void WebRtcVoiceMediaChannel::SetRawAudioSink( |
| uint32_t ssrc, |
| rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { |
| RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| - LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink"; |
| + LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink: ssrc:" << ssrc |
| + << " " << (sink ? "(ptr)" : "NULL"); |
| + if (ssrc == 0) { |
| + if (default_recv_ssrc_ != -1) { |
| + rtc::scoped_ptr<webrtc::AudioSinkInterface> proxy_sink( |
| + sink ? new ProxySink(sink.get()) : nullptr); |
| + SetRawAudioSink(default_recv_ssrc_, std::move(proxy_sink)); |
| + } |
| + default_sink_ = std::move(sink); |
|
tommi
2016/01/13 23:14:24
nit: do you mind moving this above the check for -
Taylor Brandstetter
2016/01/13 23:55:12
Is the sink accessed on any other threads? If so I
the sun
2016/01/14 09:24:39
I'd still like you to avoid the duplicate log line
tommi (sloooow) - chröme
2016/01/14 12:34:13
ah of course
Taylor Brandstetter
2016/01/14 15:48:47
My reasoning is that SetRenderer does the same thi
the sun
2016/01/14 15:51:44
Acknowledged.
|
| + return; |
| + } |
| const auto it = recv_streams_.find(ssrc); |
| if (it == recv_streams_.end()) { |
| LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc; |