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

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

Issue 1505253004: Support for remote audio into tracks (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add thread check, Remove bits_per_sample and use int16_t. Created 5 years 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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1241 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1242 RTC_DCHECK(stream_); 1242 RTC_DCHECK(stream_);
1243 return stream_->GetStats(); 1243 return stream_->GetStats();
1244 } 1244 }
1245 1245
1246 int channel() const { 1246 int channel() const {
1247 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1247 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1248 return config_.voe_channel_id; 1248 return config_.voe_channel_id;
1249 } 1249 }
1250 1250
1251 void SetRawAudioSink(rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) {
1252 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1253 stream_->SetSink(std::move(sink));
1254 }
1255
1251 private: 1256 private:
1252 void RecreateAudioReceiveStream(bool use_combined_bwe, 1257 void RecreateAudioReceiveStream(bool use_combined_bwe,
1253 const std::vector<webrtc::RtpExtension>& extensions) { 1258 const std::vector<webrtc::RtpExtension>& extensions) {
1254 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1259 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1255 if (stream_) { 1260 if (stream_) {
1256 call_->DestroyAudioReceiveStream(stream_); 1261 call_->DestroyAudioReceiveStream(stream_);
1257 stream_ = nullptr; 1262 stream_ = nullptr;
1258 } 1263 }
1259 config_.rtp.extensions = extensions; 1264 config_.rtp.extensions = extensions;
1260 config_.combined_audio_video_bwe = use_combined_bwe; 1265 config_.combined_audio_video_bwe = use_combined_bwe;
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 // Deregister default channel, if that's the one being destroyed. 2030 // Deregister default channel, if that's the one being destroyed.
2026 if (IsDefaultRecvStream(ssrc)) { 2031 if (IsDefaultRecvStream(ssrc)) {
2027 default_recv_ssrc_ = -1; 2032 default_recv_ssrc_ = -1;
2028 } 2033 }
2029 2034
2030 const int channel = it->second->channel(); 2035 const int channel = it->second->channel();
2031 2036
2032 // Clean up and delete the receive stream+channel. 2037 // Clean up and delete the receive stream+channel.
2033 LOG(LS_INFO) << "Removing audio receive stream " << ssrc 2038 LOG(LS_INFO) << "Removing audio receive stream " << ssrc
2034 << " with VoiceEngine channel #" << channel << "."; 2039 << " with VoiceEngine channel #" << channel << ".";
2040 it->second->SetRawAudioSink(nullptr);
2035 delete it->second; 2041 delete it->second;
2036 recv_streams_.erase(it); 2042 recv_streams_.erase(it);
2037 return DeleteVoEChannel(channel); 2043 return DeleteVoEChannel(channel);
2038 } 2044 }
2039 2045
2040 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, 2046 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc,
2041 AudioRenderer* renderer) { 2047 AudioRenderer* renderer) {
2042 auto it = send_streams_.find(ssrc); 2048 auto it = send_streams_.find(ssrc);
2043 if (it == send_streams_.end()) { 2049 if (it == send_streams_.end()) {
2044 if (renderer) { 2050 if (renderer) {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 rinfo.decoding_plc = stats.decoding_plc; 2407 rinfo.decoding_plc = stats.decoding_plc;
2402 rinfo.decoding_cng = stats.decoding_cng; 2408 rinfo.decoding_cng = stats.decoding_cng;
2403 rinfo.decoding_plc_cng = stats.decoding_plc_cng; 2409 rinfo.decoding_plc_cng = stats.decoding_plc_cng;
2404 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms; 2410 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms;
2405 info->receivers.push_back(rinfo); 2411 info->receivers.push_back(rinfo);
2406 } 2412 }
2407 2413
2408 return true; 2414 return true;
2409 } 2415 }
2410 2416
2417 void WebRtcVoiceMediaChannel::SetRawAudioSink(
2418 uint32_t ssrc,
2419 rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) {
2420 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
the sun 2015/12/11 16:32:05 Nit: add LOG(LS_VERBOSE) << "WebRtcVoiceMediaChann
tommi (sloooow) - chröme 2015/12/11 17:51:18 Done.
2421 const auto it = recv_streams_.find(ssrc);
2422 if (it == recv_streams_.end()) {
2423 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc;
2424 return;
2425 }
2426 it->second->SetRawAudioSink(std::move(sink));
2427 }
2428
2411 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { 2429 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) {
2412 unsigned int ulevel = 0; 2430 unsigned int ulevel = 0;
2413 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); 2431 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel);
2414 return (ret == 0) ? static_cast<int>(ulevel) : -1; 2432 return (ret == 0) ? static_cast<int>(ulevel) : -1;
2415 } 2433 }
2416 2434
2417 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { 2435 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const {
2418 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2436 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2419 const auto it = recv_streams_.find(ssrc); 2437 const auto it = recv_streams_.find(ssrc);
2420 if (it != recv_streams_.end()) { 2438 if (it != recv_streams_.end()) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 } 2503 }
2486 } else { 2504 } else {
2487 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2505 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2488 engine()->voe()->base()->StopPlayout(channel); 2506 engine()->voe()->base()->StopPlayout(channel);
2489 } 2507 }
2490 return true; 2508 return true;
2491 } 2509 }
2492 } // namespace cricket 2510 } // namespace cricket
2493 2511
2494 #endif // HAVE_WEBRTC_VOICE 2512 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698