Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine.cc

Issue 1551813002: Storing raw audio sink for default audio track. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Minor cleanup. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 #else 125 #else
126 const char kAecDumpByAudioOptionFilename[] = "audio.aecdump"; 126 const char kAecDumpByAudioOptionFilename[] = "audio.aecdump";
127 #endif 127 #endif
128 128
129 // Constants from voice_engine_defines.h. 129 // Constants from voice_engine_defines.h.
130 const int kMinTelephoneEventCode = 0; // RFC4733 (Section 2.3.1) 130 const int kMinTelephoneEventCode = 0; // RFC4733 (Section 2.3.1)
131 const int kMaxTelephoneEventCode = 255; 131 const int kMaxTelephoneEventCode = 255;
132 const int kMinTelephoneEventDuration = 100; 132 const int kMinTelephoneEventDuration = 100;
133 const int kMaxTelephoneEventDuration = 60000; // Actual limit is 2^16 133 const int kMaxTelephoneEventDuration = 60000; // Actual limit is 2^16
134 134
135 class ProxySink : public webrtc::AudioSinkInterface {
136 public:
137 ProxySink(AudioSinkInterface* sink) : sink_(sink) {}
138
139 void OnData(const Data& audio) override { sink_->OnData(audio); }
140
141 private:
142 webrtc::AudioSinkInterface* sink_;
143 };
144
135 bool ValidateStreamParams(const StreamParams& sp) { 145 bool ValidateStreamParams(const StreamParams& sp) {
136 if (sp.ssrcs.empty()) { 146 if (sp.ssrcs.empty()) {
137 LOG(LS_ERROR) << "No SSRCs in stream parameters: " << sp.ToString(); 147 LOG(LS_ERROR) << "No SSRCs in stream parameters: " << sp.ToString();
138 return false; 148 return false;
139 } 149 }
140 if (sp.ssrcs.size() > 1) { 150 if (sp.ssrcs.size() > 1) {
141 LOG(LS_ERROR) << "Multiple SSRCs in stream parameters: " << sp.ToString(); 151 LOG(LS_ERROR) << "Multiple SSRCs in stream parameters: " << sp.ToString();
142 return false; 152 return false;
143 } 153 }
144 return true; 154 return true;
(...skipping 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 if (default_recv_ssrc_ == -1 && GetReceiveChannelId(ssrc) == -1) { 2189 if (default_recv_ssrc_ == -1 && GetReceiveChannelId(ssrc) == -1) {
2180 StreamParams sp; 2190 StreamParams sp;
2181 sp.ssrcs.push_back(ssrc); 2191 sp.ssrcs.push_back(ssrc);
2182 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; 2192 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << ".";
2183 if (!AddRecvStream(sp)) { 2193 if (!AddRecvStream(sp)) {
2184 LOG(LS_WARNING) << "Could not create default receive stream."; 2194 LOG(LS_WARNING) << "Could not create default receive stream.";
2185 return; 2195 return;
2186 } 2196 }
2187 default_recv_ssrc_ = ssrc; 2197 default_recv_ssrc_ = ssrc;
2188 SetOutputVolume(default_recv_ssrc_, default_recv_volume_); 2198 SetOutputVolume(default_recv_ssrc_, default_recv_volume_);
2199 rtc::scoped_ptr<webrtc::AudioSinkInterface> proxy_sink(
2200 default_sink_ ? new ProxySink(default_sink_.get()) : nullptr);
2201 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
2189 } 2202 }
2190 2203
2191 // Forward packet to Call. If the SSRC is unknown we'll return after this. 2204 // Forward packet to Call. If the SSRC is unknown we'll return after this.
2192 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, 2205 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
2193 packet_time.not_before); 2206 packet_time.not_before);
2194 webrtc::PacketReceiver::DeliveryStatus delivery_result = 2207 webrtc::PacketReceiver::DeliveryStatus delivery_result =
2195 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, 2208 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO,
2196 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), 2209 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(),
2197 webrtc_packet_time); 2210 webrtc_packet_time);
2198 if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) { 2211 if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 info->receivers.push_back(rinfo); 2420 info->receivers.push_back(rinfo);
2408 } 2421 }
2409 2422
2410 return true; 2423 return true;
2411 } 2424 }
2412 2425
2413 void WebRtcVoiceMediaChannel::SetRawAudioSink( 2426 void WebRtcVoiceMediaChannel::SetRawAudioSink(
2414 uint32_t ssrc, 2427 uint32_t ssrc,
2415 rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { 2428 rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) {
2416 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2429 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2417 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink"; 2430 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink: ssrc:" << ssrc
2431 << " " << (sink ? "(ptr)" : "NULL");
2432 if (ssrc == 0) {
2433 if (default_recv_ssrc_ != -1) {
2434 rtc::scoped_ptr<webrtc::AudioSinkInterface> proxy_sink(
2435 sink ? new ProxySink(sink.get()) : nullptr);
2436 SetRawAudioSink(default_recv_ssrc_, std::move(proxy_sink));
2437 }
2438 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.
2439 return;
2440 }
2418 const auto it = recv_streams_.find(ssrc); 2441 const auto it = recv_streams_.find(ssrc);
2419 if (it == recv_streams_.end()) { 2442 if (it == recv_streams_.end()) {
2420 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc; 2443 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc;
2421 return; 2444 return;
2422 } 2445 }
2423 it->second->SetRawAudioSink(std::move(sink)); 2446 it->second->SetRawAudioSink(std::move(sink));
2424 } 2447 }
2425 2448
2426 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { 2449 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) {
2427 unsigned int ulevel = 0; 2450 unsigned int ulevel = 0;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 } 2523 }
2501 } else { 2524 } else {
2502 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2525 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2503 engine()->voe()->base()->StopPlayout(channel); 2526 engine()->voe()->base()->StopPlayout(channel);
2504 } 2527 }
2505 return true; 2528 return true;
2506 } 2529 }
2507 } // namespace cricket 2530 } // namespace cricket
2508 2531
2509 #endif // HAVE_WEBRTC_VOICE 2532 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698