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

Side by Side Diff: webrtc/media/base/mediachannel.h

Issue 1670153003: Introduce struct MediaConfig, with construction-time settings. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed test nit; use reference. Created 4 years, 10 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
« no previous file with comments | « webrtc/media/base/fakemediaengine.h ('k') | webrtc/media/base/mediaengine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 for (size_t i = 0; i < vals.size(); ++i) { 71 for (size_t i = 0; i < vals.size(); ++i) {
72 if (i > 0) { 72 if (i > 0) {
73 ost << ", "; 73 ost << ", ";
74 } 74 }
75 ost << vals[i].ToString(); 75 ost << vals[i].ToString();
76 } 76 }
77 ost << "]"; 77 ost << "]";
78 return ost.str(); 78 return ost.str();
79 } 79 }
80 80
81 // Construction-time settings, passed to
82 // MediaControllerInterface::Create, and passed on when creating
83 // MediaChannels.
84 struct MediaConfig {
85 // Set DSCP value on packets. This flag comes from the
86 // PeerConnection constraint 'googDscp'.
87 bool enable_dscp = false;
88
89 // Video-specific config
90
91 // Enable WebRTC CPU Overuse Detection. This flag comes from the
92 // PeerConnection constraint 'googCpuOveruseDetection' and is
93 // checked in WebRtcVideoChannel2::OnLoadUpdate, where it's passed
94 // to VideoCapturer::video_adapter()->OnCpuResolutionRequest.
95 bool enable_cpu_overuse_detection = true;
96
97 // Set to true if the renderer has an algorithm of frame selection.
98 // If the value is true, then WebRTC will hand over a frame as soon as
99 // possible without delay, and rendering smoothness is completely the duty
100 // of the renderer;
101 // If the value is false, then WebRTC is responsible to delay frame release
102 // in order to increase rendering smoothness.
103 //
104 // This flag comes from PeerConnection's RtcConfiguration, but is
105 // currently only set by the command line flag
106 // 'disable-rtc-smoothness-algorithm'.
107 // WebRtcVideoChannel2::AddRecvStream copies it to the created
108 // WebRtcVideoReceiveStream, where it is returned by the
109 // SmoothsRenderedFrames method. This method is used by the
110 // VideoReceiveStream, where the value is passed on to the
111 // IncomingVideoStream constructor.
112 bool disable_prerenderer_smoothing = false;
113 };
114
81 // Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine. 115 // Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine.
82 // Used to be flags, but that makes it hard to selectively apply options. 116 // Used to be flags, but that makes it hard to selectively apply options.
83 // We are moving all of the setting of options to structs like this, 117 // We are moving all of the setting of options to structs like this,
84 // but some things currently still use flags. 118 // but some things currently still use flags.
85 struct AudioOptions { 119 struct AudioOptions {
86 void SetAll(const AudioOptions& change) { 120 void SetAll(const AudioOptions& change) {
87 SetFrom(&echo_cancellation, change.echo_cancellation); 121 SetFrom(&echo_cancellation, change.echo_cancellation);
88 SetFrom(&auto_gain_control, change.auto_gain_control); 122 SetFrom(&auto_gain_control, change.auto_gain_control);
89 SetFrom(&noise_suppression, change.noise_suppression); 123 SetFrom(&noise_suppression, change.noise_suppression);
90 SetFrom(&highpass_filter, change.highpass_filter); 124 SetFrom(&highpass_filter, change.highpass_filter);
(...skipping 10 matching lines...) Expand all
101 SetFrom(&extended_filter_aec, change.extended_filter_aec); 135 SetFrom(&extended_filter_aec, change.extended_filter_aec);
102 SetFrom(&delay_agnostic_aec, change.delay_agnostic_aec); 136 SetFrom(&delay_agnostic_aec, change.delay_agnostic_aec);
103 SetFrom(&experimental_ns, change.experimental_ns); 137 SetFrom(&experimental_ns, change.experimental_ns);
104 SetFrom(&aec_dump, change.aec_dump); 138 SetFrom(&aec_dump, change.aec_dump);
105 SetFrom(&tx_agc_target_dbov, change.tx_agc_target_dbov); 139 SetFrom(&tx_agc_target_dbov, change.tx_agc_target_dbov);
106 SetFrom(&tx_agc_digital_compression_gain, 140 SetFrom(&tx_agc_digital_compression_gain,
107 change.tx_agc_digital_compression_gain); 141 change.tx_agc_digital_compression_gain);
108 SetFrom(&tx_agc_limiter, change.tx_agc_limiter); 142 SetFrom(&tx_agc_limiter, change.tx_agc_limiter);
109 SetFrom(&recording_sample_rate, change.recording_sample_rate); 143 SetFrom(&recording_sample_rate, change.recording_sample_rate);
110 SetFrom(&playout_sample_rate, change.playout_sample_rate); 144 SetFrom(&playout_sample_rate, change.playout_sample_rate);
111 SetFrom(&dscp, change.dscp);
112 SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe); 145 SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe);
113 } 146 }
114 147
115 bool operator==(const AudioOptions& o) const { 148 bool operator==(const AudioOptions& o) const {
116 return echo_cancellation == o.echo_cancellation && 149 return echo_cancellation == o.echo_cancellation &&
117 auto_gain_control == o.auto_gain_control && 150 auto_gain_control == o.auto_gain_control &&
118 noise_suppression == o.noise_suppression && 151 noise_suppression == o.noise_suppression &&
119 highpass_filter == o.highpass_filter && 152 highpass_filter == o.highpass_filter &&
120 stereo_swapping == o.stereo_swapping && 153 stereo_swapping == o.stereo_swapping &&
121 audio_jitter_buffer_max_packets == o.audio_jitter_buffer_max_packets && 154 audio_jitter_buffer_max_packets == o.audio_jitter_buffer_max_packets &&
122 audio_jitter_buffer_fast_accelerate == 155 audio_jitter_buffer_fast_accelerate ==
123 o.audio_jitter_buffer_fast_accelerate && 156 o.audio_jitter_buffer_fast_accelerate &&
124 typing_detection == o.typing_detection && 157 typing_detection == o.typing_detection &&
125 aecm_generate_comfort_noise == o.aecm_generate_comfort_noise && 158 aecm_generate_comfort_noise == o.aecm_generate_comfort_noise &&
126 conference_mode == o.conference_mode && 159 conference_mode == o.conference_mode &&
127 experimental_agc == o.experimental_agc && 160 experimental_agc == o.experimental_agc &&
128 extended_filter_aec == o.extended_filter_aec && 161 extended_filter_aec == o.extended_filter_aec &&
129 delay_agnostic_aec == o.delay_agnostic_aec && 162 delay_agnostic_aec == o.delay_agnostic_aec &&
130 experimental_ns == o.experimental_ns && 163 experimental_ns == o.experimental_ns &&
131 adjust_agc_delta == o.adjust_agc_delta && 164 adjust_agc_delta == o.adjust_agc_delta &&
132 aec_dump == o.aec_dump && 165 aec_dump == o.aec_dump &&
133 tx_agc_target_dbov == o.tx_agc_target_dbov && 166 tx_agc_target_dbov == o.tx_agc_target_dbov &&
134 tx_agc_digital_compression_gain == o.tx_agc_digital_compression_gain && 167 tx_agc_digital_compression_gain == o.tx_agc_digital_compression_gain &&
135 tx_agc_limiter == o.tx_agc_limiter && 168 tx_agc_limiter == o.tx_agc_limiter &&
136 recording_sample_rate == o.recording_sample_rate && 169 recording_sample_rate == o.recording_sample_rate &&
137 playout_sample_rate == o.playout_sample_rate && 170 playout_sample_rate == o.playout_sample_rate &&
138 dscp == o.dscp &&
139 combined_audio_video_bwe == o.combined_audio_video_bwe; 171 combined_audio_video_bwe == o.combined_audio_video_bwe;
140 } 172 }
141 173
142 std::string ToString() const { 174 std::string ToString() const {
143 std::ostringstream ost; 175 std::ostringstream ost;
144 ost << "AudioOptions {"; 176 ost << "AudioOptions {";
145 ost << ToStringIfSet("aec", echo_cancellation); 177 ost << ToStringIfSet("aec", echo_cancellation);
146 ost << ToStringIfSet("agc", auto_gain_control); 178 ost << ToStringIfSet("agc", auto_gain_control);
147 ost << ToStringIfSet("ns", noise_suppression); 179 ost << ToStringIfSet("ns", noise_suppression);
148 ost << ToStringIfSet("hf", highpass_filter); 180 ost << ToStringIfSet("hf", highpass_filter);
(...skipping 10 matching lines...) Expand all
159 ost << ToStringIfSet("extended_filter_aec", extended_filter_aec); 191 ost << ToStringIfSet("extended_filter_aec", extended_filter_aec);
160 ost << ToStringIfSet("delay_agnostic_aec", delay_agnostic_aec); 192 ost << ToStringIfSet("delay_agnostic_aec", delay_agnostic_aec);
161 ost << ToStringIfSet("experimental_ns", experimental_ns); 193 ost << ToStringIfSet("experimental_ns", experimental_ns);
162 ost << ToStringIfSet("aec_dump", aec_dump); 194 ost << ToStringIfSet("aec_dump", aec_dump);
163 ost << ToStringIfSet("tx_agc_target_dbov", tx_agc_target_dbov); 195 ost << ToStringIfSet("tx_agc_target_dbov", tx_agc_target_dbov);
164 ost << ToStringIfSet("tx_agc_digital_compression_gain", 196 ost << ToStringIfSet("tx_agc_digital_compression_gain",
165 tx_agc_digital_compression_gain); 197 tx_agc_digital_compression_gain);
166 ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter); 198 ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter);
167 ost << ToStringIfSet("recording_sample_rate", recording_sample_rate); 199 ost << ToStringIfSet("recording_sample_rate", recording_sample_rate);
168 ost << ToStringIfSet("playout_sample_rate", playout_sample_rate); 200 ost << ToStringIfSet("playout_sample_rate", playout_sample_rate);
169 ost << ToStringIfSet("dscp", dscp);
170 ost << ToStringIfSet("combined_audio_video_bwe", combined_audio_video_bwe); 201 ost << ToStringIfSet("combined_audio_video_bwe", combined_audio_video_bwe);
171 ost << "}"; 202 ost << "}";
172 return ost.str(); 203 return ost.str();
173 } 204 }
174 205
175 // Audio processing that attempts to filter away the output signal from 206 // Audio processing that attempts to filter away the output signal from
176 // later inbound pickup. 207 // later inbound pickup.
177 rtc::Optional<bool> echo_cancellation; 208 rtc::Optional<bool> echo_cancellation;
178 // Audio processing to adjust the sensitivity of the local mic dynamically. 209 // Audio processing to adjust the sensitivity of the local mic dynamically.
179 rtc::Optional<bool> auto_gain_control; 210 rtc::Optional<bool> auto_gain_control;
(...skipping 16 matching lines...) Expand all
196 rtc::Optional<bool> extended_filter_aec; 227 rtc::Optional<bool> extended_filter_aec;
197 rtc::Optional<bool> delay_agnostic_aec; 228 rtc::Optional<bool> delay_agnostic_aec;
198 rtc::Optional<bool> experimental_ns; 229 rtc::Optional<bool> experimental_ns;
199 rtc::Optional<bool> aec_dump; 230 rtc::Optional<bool> aec_dump;
200 // Note that tx_agc_* only applies to non-experimental AGC. 231 // Note that tx_agc_* only applies to non-experimental AGC.
201 rtc::Optional<uint16_t> tx_agc_target_dbov; 232 rtc::Optional<uint16_t> tx_agc_target_dbov;
202 rtc::Optional<uint16_t> tx_agc_digital_compression_gain; 233 rtc::Optional<uint16_t> tx_agc_digital_compression_gain;
203 rtc::Optional<bool> tx_agc_limiter; 234 rtc::Optional<bool> tx_agc_limiter;
204 rtc::Optional<uint32_t> recording_sample_rate; 235 rtc::Optional<uint32_t> recording_sample_rate;
205 rtc::Optional<uint32_t> playout_sample_rate; 236 rtc::Optional<uint32_t> playout_sample_rate;
206 // Set DSCP value for packet sent from audio channel.
207 rtc::Optional<bool> dscp;
208 // Enable combined audio+bandwidth BWE. 237 // Enable combined audio+bandwidth BWE.
238 // TODO(pthatcher): This flag is set from the
239 // "googCombinedAudioVideoBwe", but not used anywhere. So delete it,
240 // and check if any other AudioOptions members are unused.
209 rtc::Optional<bool> combined_audio_video_bwe; 241 rtc::Optional<bool> combined_audio_video_bwe;
210 242
211 private: 243 private:
212 template <typename T> 244 template <typename T>
213 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { 245 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) {
214 if (o) { 246 if (o) {
215 *s = o; 247 *s = o;
216 } 248 }
217 } 249 }
218 }; 250 };
219 251
220 // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. 252 // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine.
221 // Used to be flags, but that makes it hard to selectively apply options. 253 // Used to be flags, but that makes it hard to selectively apply options.
222 // We are moving all of the setting of options to structs like this, 254 // We are moving all of the setting of options to structs like this,
223 // but some things currently still use flags. 255 // but some things currently still use flags.
224 struct VideoOptions { 256 struct VideoOptions {
225 void SetAll(const VideoOptions& change) { 257 void SetAll(const VideoOptions& change) {
226 SetFrom(&video_noise_reduction, change.video_noise_reduction); 258 SetFrom(&video_noise_reduction, change.video_noise_reduction);
227 SetFrom(&cpu_overuse_detection, change.cpu_overuse_detection);
228 SetFrom(&conference_mode, change.conference_mode); 259 SetFrom(&conference_mode, change.conference_mode);
229 SetFrom(&dscp, change.dscp);
230 SetFrom(&suspend_below_min_bitrate, change.suspend_below_min_bitrate); 260 SetFrom(&suspend_below_min_bitrate, change.suspend_below_min_bitrate);
231 SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps); 261 SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps);
232 SetFrom(&disable_prerenderer_smoothing,
233 change.disable_prerenderer_smoothing);
234 } 262 }
235 263
236 bool operator==(const VideoOptions& o) const { 264 bool operator==(const VideoOptions& o) const {
237 return video_noise_reduction == o.video_noise_reduction && 265 return video_noise_reduction == o.video_noise_reduction &&
238 cpu_overuse_detection == o.cpu_overuse_detection &&
239 conference_mode == o.conference_mode && 266 conference_mode == o.conference_mode &&
240 dscp == o.dscp &&
241 suspend_below_min_bitrate == o.suspend_below_min_bitrate && 267 suspend_below_min_bitrate == o.suspend_below_min_bitrate &&
242 screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps && 268 screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps;
243 disable_prerenderer_smoothing == o.disable_prerenderer_smoothing;
244 } 269 }
245 270
246 std::string ToString() const { 271 std::string ToString() const {
247 std::ostringstream ost; 272 std::ostringstream ost;
248 ost << "VideoOptions {"; 273 ost << "VideoOptions {";
249 ost << ToStringIfSet("noise reduction", video_noise_reduction); 274 ost << ToStringIfSet("noise reduction", video_noise_reduction);
250 ost << ToStringIfSet("cpu overuse detection", cpu_overuse_detection);
251 ost << ToStringIfSet("conference mode", conference_mode); 275 ost << ToStringIfSet("conference mode", conference_mode);
252 ost << ToStringIfSet("dscp", dscp);
253 ost << ToStringIfSet("suspend below min bitrate", 276 ost << ToStringIfSet("suspend below min bitrate",
254 suspend_below_min_bitrate); 277 suspend_below_min_bitrate);
255 ost << ToStringIfSet("screencast min bitrate kbps", 278 ost << ToStringIfSet("screencast min bitrate kbps",
256 screencast_min_bitrate_kbps); 279 screencast_min_bitrate_kbps);
257 ost << "}"; 280 ost << "}";
258 return ost.str(); 281 return ost.str();
259 } 282 }
260 283
261 // Enable denoising? This flag comes from the getUserMedia 284 // Enable denoising? This flag comes from the getUserMedia
262 // constraint 'googNoiseReduction', and WebRtcVideoEngine2 passes it 285 // constraint 'googNoiseReduction', and WebRtcVideoEngine2 passes it
263 // on to the codec options. Disabled by default. 286 // on to the codec options. Disabled by default.
264 rtc::Optional<bool> video_noise_reduction; 287 rtc::Optional<bool> video_noise_reduction;
265 // Enable WebRTC Cpu Overuse Detection. This flag comes from the
266 // PeerConnection constraint 'googCpuOveruseDetection' and is
267 // checked in WebRtcVideoChannel2::OnLoadUpdate, where it's passed
268 // to VideoCapturer::video_adapter()->OnCpuResolutionRequest.
269 rtc::Optional<bool> cpu_overuse_detection;
270 // Use conference mode? This flag comes from the remote 288 // Use conference mode? This flag comes from the remote
271 // description's SDP line 'a=x-google-flag:conference', copied over 289 // description's SDP line 'a=x-google-flag:conference', copied over
272 // by VideoChannel::SetRemoteContent_w, and ultimately used by 290 // by VideoChannel::SetRemoteContent_w, and ultimately used by
273 // conference mode screencast logic in 291 // conference mode screencast logic in
274 // WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig. 292 // WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig.
275 // The special screencast behaviour is disabled by default. 293 // The special screencast behaviour is disabled by default.
276 rtc::Optional<bool> conference_mode; 294 rtc::Optional<bool> conference_mode;
277 // Set DSCP value for packet sent from video channel. This flag
278 // comes from the PeerConnection constraint 'googDscp' and,
279 // WebRtcVideoChannel2::SetOptions checks it before calling
280 // MediaChannel::SetDscp. If enabled, rtc::DSCP_AF41 is used. If
281 // disabled, which is the default, rtc::DSCP_DEFAULT is used.
282 rtc::Optional<bool> dscp;
283 // Enable WebRTC suspension of video. No video frames will be sent 295 // Enable WebRTC suspension of video. No video frames will be sent
284 // when the bitrate is below the configured minimum bitrate. This 296 // when the bitrate is below the configured minimum bitrate. This
285 // flag comes from the PeerConnection constraint 297 // flag comes from the PeerConnection constraint
286 // 'googSuspendBelowMinBitrate', and WebRtcVideoChannel2 copies it 298 // 'googSuspendBelowMinBitrate', and WebRtcVideoChannel2 copies it
287 // to VideoSendStream::Config::suspend_below_min_bitrate. 299 // to VideoSendStream::Config::suspend_below_min_bitrate.
288 rtc::Optional<bool> suspend_below_min_bitrate; 300 rtc::Optional<bool> suspend_below_min_bitrate;
289 // Force screencast to use a minimum bitrate. This flag comes from 301 // Force screencast to use a minimum bitrate. This flag comes from
290 // the PeerConnection constraint 'googScreencastMinBitrate'. It is 302 // the PeerConnection constraint 'googScreencastMinBitrate'. It is
291 // copied to the encoder config by WebRtcVideoChannel2. 303 // copied to the encoder config by WebRtcVideoChannel2.
292 rtc::Optional<int> screencast_min_bitrate_kbps; 304 rtc::Optional<int> screencast_min_bitrate_kbps;
293 // Set to true if the renderer has an algorithm of frame selection.
294 // If the value is true, then WebRTC will hand over a frame as soon as
295 // possible without delay, and rendering smoothness is completely the duty
296 // of the renderer;
297 // If the value is false, then WebRTC is responsible to delay frame release
298 // in order to increase rendering smoothness.
299 //
300 // This flag comes from PeerConnection's RtcConfiguration, but is
301 // currently only set by the command line flag
302 // 'disable-rtc-smoothness-algorithm'.
303 // WebRtcVideoChannel2::AddRecvStream copies it to the created
304 // WebRtcVideoReceiveStream, where it is returned by the
305 // SmoothsRenderedFrames method. This method is used by the
306 // VideoReceiveStream, where the value is passed on to the
307 // IncomingVideoStream constructor.
308 rtc::Optional<bool> disable_prerenderer_smoothing;
309 305
310 private: 306 private:
311 template <typename T> 307 template <typename T>
312 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { 308 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) {
313 if (o) { 309 if (o) {
314 *s = o; 310 *s = o;
315 } 311 }
316 } 312 }
317 }; 313 };
318 314
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 enum SocketType { ST_RTP, ST_RTCP }; 357 enum SocketType { ST_RTP, ST_RTCP };
362 virtual bool SendPacket(rtc::Buffer* packet, 358 virtual bool SendPacket(rtc::Buffer* packet,
363 const rtc::PacketOptions& options) = 0; 359 const rtc::PacketOptions& options) = 0;
364 virtual bool SendRtcp(rtc::Buffer* packet, 360 virtual bool SendRtcp(rtc::Buffer* packet,
365 const rtc::PacketOptions& options) = 0; 361 const rtc::PacketOptions& options) = 0;
366 virtual int SetOption(SocketType type, rtc::Socket::Option opt, 362 virtual int SetOption(SocketType type, rtc::Socket::Option opt,
367 int option) = 0; 363 int option) = 0;
368 virtual ~NetworkInterface() {} 364 virtual ~NetworkInterface() {}
369 }; 365 };
370 366
371 MediaChannel() : network_interface_(NULL) {} 367 MediaChannel(const MediaConfig& config)
368 : enable_dscp_(config.enable_dscp), network_interface_(NULL) {}
369 MediaChannel() : enable_dscp_(false), network_interface_(NULL) {}
372 virtual ~MediaChannel() {} 370 virtual ~MediaChannel() {}
373 371
374 // Sets the abstract interface class for sending RTP/RTCP data. 372 // Sets the abstract interface class for sending RTP/RTCP data.
375 virtual void SetInterface(NetworkInterface *iface) { 373 virtual void SetInterface(NetworkInterface *iface) {
376 rtc::CritScope cs(&network_interface_crit_); 374 rtc::CritScope cs(&network_interface_crit_);
377 network_interface_ = iface; 375 network_interface_ = iface;
376 SetDscp(enable_dscp_ ? PreferredDscp() : rtc::DSCP_DEFAULT);
378 } 377 }
379 378 virtual rtc::DiffServCodePoint PreferredDscp() const {
379 return rtc::DSCP_DEFAULT;
380 }
380 // Called when a RTP packet is received. 381 // Called when a RTP packet is received.
381 virtual void OnPacketReceived(rtc::Buffer* packet, 382 virtual void OnPacketReceived(rtc::Buffer* packet,
382 const rtc::PacketTime& packet_time) = 0; 383 const rtc::PacketTime& packet_time) = 0;
383 // Called when a RTCP packet is received. 384 // Called when a RTCP packet is received.
384 virtual void OnRtcpReceived(rtc::Buffer* packet, 385 virtual void OnRtcpReceived(rtc::Buffer* packet,
385 const rtc::PacketTime& packet_time) = 0; 386 const rtc::PacketTime& packet_time) = 0;
386 // Called when the socket's ability to send has changed. 387 // Called when the socket's ability to send has changed.
387 virtual void OnReadyToSend(bool ready) = 0; 388 virtual void OnReadyToSend(bool ready) = 0;
388 // Creates a new outgoing media stream with SSRCs and CNAME as described 389 // Creates a new outgoing media stream with SSRCs and CNAME as described
389 // by sp. 390 // by sp.
(...skipping 27 matching lines...) Expand all
417 int SetOption(NetworkInterface::SocketType type, 418 int SetOption(NetworkInterface::SocketType type,
418 rtc::Socket::Option opt, 419 rtc::Socket::Option opt,
419 int option) { 420 int option) {
420 rtc::CritScope cs(&network_interface_crit_); 421 rtc::CritScope cs(&network_interface_crit_);
421 if (!network_interface_) 422 if (!network_interface_)
422 return -1; 423 return -1;
423 424
424 return network_interface_->SetOption(type, opt, option); 425 return network_interface_->SetOption(type, opt, option);
425 } 426 }
426 427
427 protected: 428 private:
428 // This method sets DSCP |value| on both RTP and RTCP channels. 429 // This method sets DSCP |value| on both RTP and RTCP channels.
429 int SetDscp(rtc::DiffServCodePoint value) { 430 int SetDscp(rtc::DiffServCodePoint value) {
430 int ret; 431 int ret;
431 ret = SetOption(NetworkInterface::ST_RTP, 432 ret = SetOption(NetworkInterface::ST_RTP,
432 rtc::Socket::OPT_DSCP, 433 rtc::Socket::OPT_DSCP,
433 value); 434 value);
434 if (ret == 0) { 435 if (ret == 0) {
435 ret = SetOption(NetworkInterface::ST_RTCP, 436 ret = SetOption(NetworkInterface::ST_RTCP,
436 rtc::Socket::OPT_DSCP, 437 rtc::Socket::OPT_DSCP,
437 value); 438 value);
438 } 439 }
439 return ret; 440 return ret;
440 } 441 }
441 442
442 private:
443 bool DoSendPacket(rtc::Buffer* packet, 443 bool DoSendPacket(rtc::Buffer* packet,
444 bool rtcp, 444 bool rtcp,
445 const rtc::PacketOptions& options) { 445 const rtc::PacketOptions& options) {
446 rtc::CritScope cs(&network_interface_crit_); 446 rtc::CritScope cs(&network_interface_crit_);
447 if (!network_interface_) 447 if (!network_interface_)
448 return false; 448 return false;
449 449
450 return (!rtcp) ? network_interface_->SendPacket(packet, options) 450 return (!rtcp) ? network_interface_->SendPacket(packet, options)
451 : network_interface_->SendRtcp(packet, options); 451 : network_interface_->SendRtcp(packet, options);
452 } 452 }
453 453
454 const bool enable_dscp_;
454 // |network_interface_| can be accessed from the worker_thread and 455 // |network_interface_| can be accessed from the worker_thread and
455 // from any MediaEngine threads. This critical section is to protect accessing 456 // from any MediaEngine threads. This critical section is to protect accessing
456 // of network_interface_ object. 457 // of network_interface_ object.
457 rtc::CriticalSection network_interface_crit_; 458 rtc::CriticalSection network_interface_crit_;
458 NetworkInterface* network_interface_; 459 NetworkInterface* network_interface_;
459 }; 460 };
460 461
461 enum SendFlags { 462 enum SendFlags {
462 SEND_NOTHING, 463 SEND_NOTHING,
463 SEND_MICROPHONE 464 SEND_MICROPHONE
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout. 898 ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout.
898 ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS. 899 ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS.
899 ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active. 900 ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active.
900 ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing. 901 ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing.
901 ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure. 902 ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure.
902 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. 903 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets.
903 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. 904 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected.
904 }; 905 };
905 906
906 VoiceMediaChannel() {} 907 VoiceMediaChannel() {}
908 VoiceMediaChannel(const MediaConfig& config) : MediaChannel(config) {}
907 virtual ~VoiceMediaChannel() {} 909 virtual ~VoiceMediaChannel() {}
908 virtual bool SetSendParameters(const AudioSendParameters& params) = 0; 910 virtual bool SetSendParameters(const AudioSendParameters& params) = 0;
909 virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0; 911 virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0;
910 // Starts or stops playout of received audio. 912 // Starts or stops playout of received audio.
911 virtual bool SetPlayout(bool playout) = 0; 913 virtual bool SetPlayout(bool playout) = 0;
912 // Starts or stops sending (and potentially capture) of local audio. 914 // Starts or stops sending (and potentially capture) of local audio.
913 virtual bool SetSend(SendFlags flag) = 0; 915 virtual bool SetSend(SendFlags flag) = 0;
914 // Configure stream for sending. 916 // Configure stream for sending.
915 virtual bool SetAudioSend(uint32_t ssrc, 917 virtual bool SetAudioSend(uint32_t ssrc,
916 bool enable, 918 bool enable,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 ERROR_REC_DEVICE_REMOVED, // Device is removed. 962 ERROR_REC_DEVICE_REMOVED, // Device is removed.
961 ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure. 963 ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure.
962 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. 964 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets.
963 ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore. 965 ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore.
964 ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure. 966 ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure.
965 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. 967 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets.
966 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. 968 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected.
967 }; 969 };
968 970
969 VideoMediaChannel() {} 971 VideoMediaChannel() {}
972 VideoMediaChannel(const MediaConfig& config) : MediaChannel(config) {}
970 virtual ~VideoMediaChannel() {} 973 virtual ~VideoMediaChannel() {}
971 974
972 virtual bool SetSendParameters(const VideoSendParameters& params) = 0; 975 virtual bool SetSendParameters(const VideoSendParameters& params) = 0;
973 virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0; 976 virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0;
974 // Gets the currently set codecs/payload types to be used for outgoing media. 977 // Gets the currently set codecs/payload types to be used for outgoing media.
975 virtual bool GetSendCodec(VideoCodec* send_codec) = 0; 978 virtual bool GetSendCodec(VideoCodec* send_codec) = 0;
976 // Starts or stops transmission (and potentially capture) of local video. 979 // Starts or stops transmission (and potentially capture) of local video.
977 virtual bool SetSend(bool send) = 0; 980 virtual bool SetSend(bool send) = 0;
978 // Configure stream for sending. 981 // Configure stream for sending.
979 virtual bool SetVideoSend(uint32_t ssrc, 982 virtual bool SetVideoSend(uint32_t ssrc,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 // Signal when the media channel is ready to send the stream. Arguments are: 1114 // Signal when the media channel is ready to send the stream. Arguments are:
1112 // writable(bool) 1115 // writable(bool)
1113 sigslot::signal1<bool> SignalReadyToSend; 1116 sigslot::signal1<bool> SignalReadyToSend;
1114 // Signal for notifying that the remote side has closed the DataChannel. 1117 // Signal for notifying that the remote side has closed the DataChannel.
1115 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; 1118 sigslot::signal1<uint32_t> SignalStreamClosedRemotely;
1116 }; 1119 };
1117 1120
1118 } // namespace cricket 1121 } // namespace cricket
1119 1122
1120 #endif // WEBRTC_MEDIA_BASE_MEDIACHANNEL_H_ 1123 #endif // WEBRTC_MEDIA_BASE_MEDIACHANNEL_H_
OLDNEW
« no previous file with comments | « webrtc/media/base/fakemediaengine.h ('k') | webrtc/media/base/mediaengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698