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

Side by Side Diff: webrtc/audio/audio_send_stream.cc

Issue 1418503010: Move some send stream configuration into webrtc::AudioSendStream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month 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 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 16 matching lines...) Expand all
27 std::stringstream ss; 27 std::stringstream ss;
28 ss << "{ssrc: " << ssrc; 28 ss << "{ssrc: " << ssrc;
29 ss << ", extensions: ["; 29 ss << ", extensions: [";
30 for (size_t i = 0; i < extensions.size(); ++i) { 30 for (size_t i = 0; i < extensions.size(); ++i) {
31 ss << extensions[i].ToString(); 31 ss << extensions[i].ToString();
32 if (i != extensions.size() - 1) { 32 if (i != extensions.size() - 1) {
33 ss << ", "; 33 ss << ", ";
34 } 34 }
35 } 35 }
36 ss << ']'; 36 ss << ']';
37 ss << ", c_name: " << c_name;
37 ss << '}'; 38 ss << '}';
38 return ss.str(); 39 return ss.str();
39 } 40 }
40 41
41 std::string AudioSendStream::Config::ToString() const { 42 std::string AudioSendStream::Config::ToString() const {
42 std::stringstream ss; 43 std::stringstream ss;
43 ss << "{rtp: " << rtp.ToString(); 44 ss << "{rtp: " << rtp.ToString();
44 ss << ", voe_channel_id: " << voe_channel_id; 45 ss << ", voe_channel_id: " << voe_channel_id;
45 // TODO(solenberg): Encoder config. 46 // TODO(solenberg): Encoder config.
46 ss << ", cng_payload_type: " << cng_payload_type; 47 ss << ", cng_payload_type: " << cng_payload_type;
47 ss << ", red_payload_type: " << red_payload_type; 48 ss << ", red_payload_type: " << red_payload_type;
48 ss << '}'; 49 ss << '}';
49 return ss.str(); 50 return ss.str();
50 } 51 }
51 52
52 namespace internal { 53 namespace internal {
53 54
54 AudioSendStream::AudioSendStream( 55 AudioSendStream::AudioSendStream(
55 const webrtc::AudioSendStream::Config& config, 56 const webrtc::AudioSendStream::Config& config,
56 const rtc::scoped_refptr<webrtc::AudioState>& audio_state) 57 const rtc::scoped_refptr<webrtc::AudioState>& audio_state)
57 : config_(config), audio_state_(audio_state) { 58 : config_(config), audio_state_(audio_state) {
58 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); 59 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString();
59 RTC_DCHECK_NE(config_.voe_channel_id, -1); 60 RTC_DCHECK_NE(config_.voe_channel_id, -1);
60 RTC_DCHECK(audio_state_.get()); 61 RTC_DCHECK(audio_state_.get());
62
63 const int channel_id = config.voe_channel_id;
64 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine());
65 RTC_CHECK_EQ(0, rtp->SetRTCPStatus(channel_id, true));
66 RTC_CHECK_EQ(0, rtp->SetLocalSSRC(channel_id, config.rtp.ssrc));
67 RTC_CHECK_EQ(0, rtp->SetRTCP_CNAME(channel_id, config.rtp.c_name.c_str()));
tommi 2015/11/12 13:44:57 Are all these CHECKs reasonable? I think checks a
the sun 2015/11/12 15:16:44 DCHECK is stripped out in non-debug builds, right?
tommi 2015/11/12 16:36:18 Yes, DCHECK is stripped out. You don't have to pu
the sun 2015/11/16 13:49:51 You're right. There will be some code bloat becaus
68 for (const auto& extension : config.rtp.extensions) {
69 // One-byte-extension local identifiers are in the range 1-14 inclusive.
70 RTC_DCHECK_GE(extension.id, 1);
71 RTC_DCHECK_LE(extension.id, 14);
72 if (extension.name == RtpExtension::kAbsSendTime) {
73 RTC_CHECK_EQ(0, rtp->SetSendAbsoluteSenderTimeStatus(channel_id, true,
74 extension.id));
75 } else if (extension.name == RtpExtension::kAudioLevel) {
76 RTC_CHECK_EQ(0, rtp->SetSendAudioLevelIndicationStatus(channel_id, true,
77 extension.id));
78 } else {
79 RTC_NOTREACHED() << "Registering unsupported RTP extension.";
80 }
81 }
61 } 82 }
62 83
63 AudioSendStream::~AudioSendStream() { 84 AudioSendStream::~AudioSendStream() {
64 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 85 RTC_DCHECK(thread_checker_.CalledOnValidThread());
65 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); 86 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString();
66 } 87 }
67 88
89 void AudioSendStream::Start() {
90 RTC_DCHECK(thread_checker_.CalledOnValidThread());
91 }
92
93 void AudioSendStream::Stop() {
94 RTC_DCHECK(thread_checker_.CalledOnValidThread());
95 }
96
97 void AudioSendStream::SignalNetworkState(NetworkState state) {
98 RTC_DCHECK(thread_checker_.CalledOnValidThread());
99 }
100
101 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) {
102 // TODO(solenberg): Tests call this function on a network thread, libjingle
103 // calls on the worker thread. We should move towards always using a network
104 // thread. Then this check can be enabled.
105 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
106 return false;
107 }
108
68 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { 109 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const {
69 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 110 RTC_DCHECK(thread_checker_.CalledOnValidThread());
70 webrtc::AudioSendStream::Stats stats; 111 webrtc::AudioSendStream::Stats stats;
71 stats.local_ssrc = config_.rtp.ssrc; 112 stats.local_ssrc = config_.rtp.ssrc;
72 internal::AudioState* audio_state = 113 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine());
73 static_cast<internal::AudioState*>(audio_state_.get()); 114 ScopedVoEInterface<VoECodec> codec(voice_engine());
74 VoiceEngine* voice_engine = audio_state->voice_engine(); 115 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine());
75 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine); 116 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine());
76 ScopedVoEInterface<VoECodec> codec(voice_engine);
77 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine);
78 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine);
79 unsigned int ssrc = 0; 117 unsigned int ssrc = 0;
80 webrtc::CallStatistics call_stats = {0}; 118 webrtc::CallStatistics call_stats = {0};
119 // TODO(solenberg): Change error code checking to RTC_CHECK_EQ(..., -1), if
120 // possible...
81 if (rtp->GetLocalSSRC(config_.voe_channel_id, ssrc) == -1 || 121 if (rtp->GetLocalSSRC(config_.voe_channel_id, ssrc) == -1 ||
82 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1) { 122 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1) {
83 return stats; 123 return stats;
84 } 124 }
85 125
86 stats.bytes_sent = call_stats.bytesSent; 126 stats.bytes_sent = call_stats.bytesSent;
87 stats.packets_sent = call_stats.packetsSent; 127 stats.packets_sent = call_stats.packetsSent;
88 128
89 webrtc::CodecInst codec_inst = {0}; 129 webrtc::CodecInst codec_inst = {0};
90 if (codec->GetSendCodec(config_.voe_channel_id, codec_inst) != -1) { 130 if (codec->GetSendCodec(config_.voe_channel_id, codec_inst) != -1) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 int erl = -100; 186 int erl = -100;
147 int erle = -100; 187 int erle = -100;
148 int dummy1 = 0; 188 int dummy1 = 0;
149 int dummy2 = 0; 189 int dummy2 = 0;
150 if (processing->GetEchoMetrics(erl, erle, dummy1, dummy2) != -1) { 190 if (processing->GetEchoMetrics(erl, erle, dummy1, dummy2) != -1) {
151 stats.echo_return_loss = erl; 191 stats.echo_return_loss = erl;
152 stats.echo_return_loss_enhancement = erle; 192 stats.echo_return_loss_enhancement = erle;
153 } 193 }
154 } 194 }
155 195
196 internal::AudioState* audio_state =
197 static_cast<internal::AudioState*>(audio_state_.get());
156 stats.typing_noise_detected = audio_state->typing_noise_detected(); 198 stats.typing_noise_detected = audio_state->typing_noise_detected();
157 199
158 return stats; 200 return stats;
159 } 201 }
160 202
161 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { 203 const webrtc::AudioSendStream::Config& AudioSendStream::config() const {
162 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 204 RTC_DCHECK(thread_checker_.CalledOnValidThread());
163 return config_; 205 return config_;
164 } 206 }
165 207
166 void AudioSendStream::Start() { 208 VoiceEngine* AudioSendStream::voice_engine() const {
167 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 209 internal::AudioState* audio_state =
168 } 210 static_cast<internal::AudioState*>(audio_state_.get());
169 211 VoiceEngine* voice_engine = audio_state->voice_engine();
170 void AudioSendStream::Stop() { 212 RTC_DCHECK(voice_engine);
171 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 213 return voice_engine;
172 }
173
174 void AudioSendStream::SignalNetworkState(NetworkState state) {
175 RTC_DCHECK(thread_checker_.CalledOnValidThread());
176 }
177
178 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) {
179 // TODO(solenberg): Tests call this function on a network thread, libjingle
180 // calls on the worker thread. We should move towards always using a network
181 // thread. Then this check can be enabled.
182 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
183 return false;
184 } 214 }
185 } // namespace internal 215 } // namespace internal
186 } // namespace webrtc 216 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698