OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 #include <cstdio> | 37 #include <cstdio> |
38 #include <string> | 38 #include <string> |
39 #include <vector> | 39 #include <vector> |
40 | 40 |
41 #include "talk/media/base/audioframe.h" | 41 #include "talk/media/base/audioframe.h" |
42 #include "talk/media/base/audiorenderer.h" | 42 #include "talk/media/base/audiorenderer.h" |
43 #include "talk/media/base/constants.h" | 43 #include "talk/media/base/constants.h" |
44 #include "talk/media/base/streamparams.h" | 44 #include "talk/media/base/streamparams.h" |
45 #include "talk/media/webrtc/webrtcmediaengine.h" | 45 #include "talk/media/webrtc/webrtcmediaengine.h" |
46 #include "talk/media/webrtc/webrtcvoe.h" | 46 #include "talk/media/webrtc/webrtcvoe.h" |
| 47 #include "webrtc/audio/audio_sink.h" |
47 #include "webrtc/base/arraysize.h" | 48 #include "webrtc/base/arraysize.h" |
48 #include "webrtc/base/base64.h" | 49 #include "webrtc/base/base64.h" |
49 #include "webrtc/base/byteorder.h" | 50 #include "webrtc/base/byteorder.h" |
50 #include "webrtc/base/common.h" | 51 #include "webrtc/base/common.h" |
51 #include "webrtc/base/helpers.h" | 52 #include "webrtc/base/helpers.h" |
52 #include "webrtc/base/logging.h" | 53 #include "webrtc/base/logging.h" |
53 #include "webrtc/base/stringencode.h" | 54 #include "webrtc/base/stringencode.h" |
54 #include "webrtc/base/stringutils.h" | 55 #include "webrtc/base/stringutils.h" |
55 #include "webrtc/call/rtc_event_log.h" | 56 #include "webrtc/call/rtc_event_log.h" |
56 #include "webrtc/common.h" | 57 #include "webrtc/common.h" |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1242 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1242 RTC_DCHECK(stream_); | 1243 RTC_DCHECK(stream_); |
1243 return stream_->GetStats(); | 1244 return stream_->GetStats(); |
1244 } | 1245 } |
1245 | 1246 |
1246 int channel() const { | 1247 int channel() const { |
1247 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1248 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1248 return config_.voe_channel_id; | 1249 return config_.voe_channel_id; |
1249 } | 1250 } |
1250 | 1251 |
| 1252 void SetRawAudioSink(rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { |
| 1253 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1254 stream_->SetSink(std::move(sink)); |
| 1255 } |
| 1256 |
1251 private: | 1257 private: |
1252 void RecreateAudioReceiveStream(bool use_combined_bwe, | 1258 void RecreateAudioReceiveStream(bool use_combined_bwe, |
1253 const std::vector<webrtc::RtpExtension>& extensions) { | 1259 const std::vector<webrtc::RtpExtension>& extensions) { |
1254 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1260 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1255 if (stream_) { | 1261 if (stream_) { |
1256 call_->DestroyAudioReceiveStream(stream_); | 1262 call_->DestroyAudioReceiveStream(stream_); |
1257 stream_ = nullptr; | 1263 stream_ = nullptr; |
1258 } | 1264 } |
1259 config_.rtp.extensions = extensions; | 1265 config_.rtp.extensions = extensions; |
1260 config_.combined_audio_video_bwe = use_combined_bwe; | 1266 config_.combined_audio_video_bwe = use_combined_bwe; |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 // Deregister default channel, if that's the one being destroyed. | 2031 // Deregister default channel, if that's the one being destroyed. |
2026 if (IsDefaultRecvStream(ssrc)) { | 2032 if (IsDefaultRecvStream(ssrc)) { |
2027 default_recv_ssrc_ = -1; | 2033 default_recv_ssrc_ = -1; |
2028 } | 2034 } |
2029 | 2035 |
2030 const int channel = it->second->channel(); | 2036 const int channel = it->second->channel(); |
2031 | 2037 |
2032 // Clean up and delete the receive stream+channel. | 2038 // Clean up and delete the receive stream+channel. |
2033 LOG(LS_INFO) << "Removing audio receive stream " << ssrc | 2039 LOG(LS_INFO) << "Removing audio receive stream " << ssrc |
2034 << " with VoiceEngine channel #" << channel << "."; | 2040 << " with VoiceEngine channel #" << channel << "."; |
| 2041 it->second->SetRawAudioSink(nullptr); |
2035 delete it->second; | 2042 delete it->second; |
2036 recv_streams_.erase(it); | 2043 recv_streams_.erase(it); |
2037 return DeleteVoEChannel(channel); | 2044 return DeleteVoEChannel(channel); |
2038 } | 2045 } |
2039 | 2046 |
2040 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, | 2047 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, |
2041 AudioRenderer* renderer) { | 2048 AudioRenderer* renderer) { |
2042 auto it = send_streams_.find(ssrc); | 2049 auto it = send_streams_.find(ssrc); |
2043 if (it == send_streams_.end()) { | 2050 if (it == send_streams_.end()) { |
2044 if (renderer) { | 2051 if (renderer) { |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 rinfo.decoding_plc = stats.decoding_plc; | 2408 rinfo.decoding_plc = stats.decoding_plc; |
2402 rinfo.decoding_cng = stats.decoding_cng; | 2409 rinfo.decoding_cng = stats.decoding_cng; |
2403 rinfo.decoding_plc_cng = stats.decoding_plc_cng; | 2410 rinfo.decoding_plc_cng = stats.decoding_plc_cng; |
2404 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms; | 2411 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms; |
2405 info->receivers.push_back(rinfo); | 2412 info->receivers.push_back(rinfo); |
2406 } | 2413 } |
2407 | 2414 |
2408 return true; | 2415 return true; |
2409 } | 2416 } |
2410 | 2417 |
| 2418 void WebRtcVoiceMediaChannel::SetRawAudioSink( |
| 2419 uint32_t ssrc, |
| 2420 rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { |
| 2421 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 2422 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink"; |
| 2423 const auto it = recv_streams_.find(ssrc); |
| 2424 if (it == recv_streams_.end()) { |
| 2425 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc; |
| 2426 return; |
| 2427 } |
| 2428 it->second->SetRawAudioSink(std::move(sink)); |
| 2429 } |
| 2430 |
2411 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { | 2431 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { |
2412 unsigned int ulevel = 0; | 2432 unsigned int ulevel = 0; |
2413 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); | 2433 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); |
2414 return (ret == 0) ? static_cast<int>(ulevel) : -1; | 2434 return (ret == 0) ? static_cast<int>(ulevel) : -1; |
2415 } | 2435 } |
2416 | 2436 |
2417 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { | 2437 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { |
2418 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2438 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2419 const auto it = recv_streams_.find(ssrc); | 2439 const auto it = recv_streams_.find(ssrc); |
2420 if (it != recv_streams_.end()) { | 2440 if (it != recv_streams_.end()) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2485 } | 2505 } |
2486 } else { | 2506 } else { |
2487 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2507 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2488 engine()->voe()->base()->StopPlayout(channel); | 2508 engine()->voe()->base()->StopPlayout(channel); |
2489 } | 2509 } |
2490 return true; | 2510 return true; |
2491 } | 2511 } |
2492 } // namespace cricket | 2512 } // namespace cricket |
2493 | 2513 |
2494 #endif // HAVE_WEBRTC_VOICE | 2514 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |