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

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: Addressing solenberg@'s comments. 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 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1237 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1238 RTC_DCHECK(stream_); 1238 RTC_DCHECK(stream_);
1239 return stream_->GetStats(); 1239 return stream_->GetStats();
1240 } 1240 }
1241 1241
1242 int channel() const { 1242 int channel() const {
1243 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1243 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1244 return config_.voe_channel_id; 1244 return config_.voe_channel_id;
1245 } 1245 }
1246 1246
1247 void SetRawAudioSink(rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { 1247 void SetRawAudioSink(
1248 const rtc::scoped_refptr<webrtc::AudioSinkInterface>& sink) {
1248 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1249 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1249 stream_->SetSink(std::move(sink)); 1250 stream_->SetSink(sink);
1250 } 1251 }
1251 1252
1252 private: 1253 private:
1253 void RecreateAudioReceiveStream(bool use_combined_bwe, 1254 void RecreateAudioReceiveStream(bool use_combined_bwe,
1254 const std::vector<webrtc::RtpExtension>& extensions) { 1255 const std::vector<webrtc::RtpExtension>& extensions) {
1255 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1256 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1256 if (stream_) { 1257 if (stream_) {
1257 call_->DestroyAudioReceiveStream(stream_); 1258 call_->DestroyAudioReceiveStream(stream_);
1258 stream_ = nullptr; 1259 stream_ = nullptr;
1259 } 1260 }
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 if (default_recv_ssrc_ == -1 && GetReceiveChannelId(ssrc) == -1) { 2180 if (default_recv_ssrc_ == -1 && GetReceiveChannelId(ssrc) == -1) {
2180 StreamParams sp; 2181 StreamParams sp;
2181 sp.ssrcs.push_back(ssrc); 2182 sp.ssrcs.push_back(ssrc);
2182 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; 2183 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << ".";
2183 if (!AddRecvStream(sp)) { 2184 if (!AddRecvStream(sp)) {
2184 LOG(LS_WARNING) << "Could not create default receive stream."; 2185 LOG(LS_WARNING) << "Could not create default receive stream.";
2185 return; 2186 return;
2186 } 2187 }
2187 default_recv_ssrc_ = ssrc; 2188 default_recv_ssrc_ = ssrc;
2188 SetOutputVolume(default_recv_ssrc_, default_recv_volume_); 2189 SetOutputVolume(default_recv_ssrc_, default_recv_volume_);
2190 SetRawAudioSink(default_recv_ssrc_, default_sink_);
2189 } 2191 }
2190 2192
2191 // Forward packet to Call. If the SSRC is unknown we'll return after this. 2193 // Forward packet to Call. If the SSRC is unknown we'll return after this.
2192 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, 2194 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
2193 packet_time.not_before); 2195 packet_time.not_before);
2194 webrtc::PacketReceiver::DeliveryStatus delivery_result = 2196 webrtc::PacketReceiver::DeliveryStatus delivery_result =
2195 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, 2197 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO,
2196 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), 2198 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(),
2197 webrtc_packet_time); 2199 webrtc_packet_time);
2198 if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) { 2200 if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 rinfo.decoding_plc_cng = stats.decoding_plc_cng; 2407 rinfo.decoding_plc_cng = stats.decoding_plc_cng;
2406 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms; 2408 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms;
2407 info->receivers.push_back(rinfo); 2409 info->receivers.push_back(rinfo);
2408 } 2410 }
2409 2411
2410 return true; 2412 return true;
2411 } 2413 }
2412 2414
2413 void WebRtcVoiceMediaChannel::SetRawAudioSink( 2415 void WebRtcVoiceMediaChannel::SetRawAudioSink(
2414 uint32_t ssrc, 2416 uint32_t ssrc,
2415 rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { 2417 const rtc::scoped_refptr<webrtc::AudioSinkInterface>& sink) {
2416 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2418 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2417 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink"; 2419 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink";
2420 if (ssrc == 0) {
2421 default_sink_ = sink;
2422 if (default_recv_ssrc_ == -1) {
2423 return;
2424 }
2425 ssrc = static_cast<uint32_t>(default_recv_ssrc_);
2426 }
2418 const auto it = recv_streams_.find(ssrc); 2427 const auto it = recv_streams_.find(ssrc);
2419 if (it == recv_streams_.end()) { 2428 if (it == recv_streams_.end()) {
2420 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc; 2429 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc;
2421 return; 2430 return;
2422 } 2431 }
2423 it->second->SetRawAudioSink(std::move(sink)); 2432 it->second->SetRawAudioSink(sink);
2424 } 2433 }
2425 2434
2426 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { 2435 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) {
2427 unsigned int ulevel = 0; 2436 unsigned int ulevel = 0;
2428 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); 2437 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel);
2429 return (ret == 0) ? static_cast<int>(ulevel) : -1; 2438 return (ret == 0) ? static_cast<int>(ulevel) : -1;
2430 } 2439 }
2431 2440
2432 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { 2441 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const {
2433 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2442 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 } 2509 }
2501 } else { 2510 } else {
2502 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2511 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2503 engine()->voe()->base()->StopPlayout(channel); 2512 engine()->voe()->base()->StopPlayout(channel);
2504 } 2513 }
2505 return true; 2514 return true;
2506 } 2515 }
2507 } // namespace cricket 2516 } // namespace cricket
2508 2517
2509 #endif // HAVE_WEBRTC_VOICE 2518 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698