Chromium Code Reviews| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 for (size_t i = 0; i < vals.size(); ++i) { | 88 for (size_t i = 0; i < vals.size(); ++i) { |
| 89 if (i > 0) { | 89 if (i > 0) { |
| 90 ost << ", "; | 90 ost << ", "; |
| 91 } | 91 } |
| 92 ost << vals[i].ToString(); | 92 ost << vals[i].ToString(); |
| 93 } | 93 } |
| 94 ost << "]"; | 94 ost << "]"; |
| 95 return ost.str(); | 95 return ost.str(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Construction-time settings, passed to | |
| 99 // MediaControllerInterface::Create, and passed on when creating | |
| 100 // MediaChannels. | |
| 101 struct MediaConfig { | |
| 102 // Set DSCP value on packets. This flag comes from the | |
| 103 // PeerConnection constraint 'googDscp'. | |
| 104 bool enable_dscp = false; | |
| 105 | |
| 106 // Video-specific config | |
| 107 | |
| 108 // Enable WebRTC CPU Overuse Detection. This flag comes from the | |
|
perkj_webrtc
2016/02/09 15:35:37
We normally descibe the purpose. Not the exact cal
nisse-webrtc
2016/02/10 08:53:00
I understand this comment is going to get less acc
| |
| 109 // PeerConnection constraint 'googCpuOveruseDetection' and is | |
| 110 // checked in WebRtcVideoChannel2::OnLoadUpdate, where it's passed | |
| 111 // to VideoCapturer::video_adapter()->OnCpuResolutionRequest. | |
| 112 bool enable_cpu_overuse_detection = true; | |
| 113 | |
| 114 // Set to true if the renderer has an algorithm of frame selection. | |
| 115 // If the value is true, then WebRTC will hand over a frame as soon as | |
| 116 // possible without delay, and rendering smoothness is completely the duty | |
| 117 // of the renderer; | |
| 118 // If the value is false, then WebRTC is responsible to delay frame release | |
| 119 // in order to increase rendering smoothness. | |
| 120 // | |
| 121 // This flag comes from PeerConnection's RtcConfiguration, but is | |
|
perkj_webrtc
2016/02/09 15:35:37
dito
| |
| 122 // currently only set by the command line flag | |
| 123 // 'disable-rtc-smoothness-algorithm'. | |
| 124 // WebRtcVideoChannel2::AddRecvStream copies it to the created | |
| 125 // WebRtcVideoReceiveStream, where it is returned by the | |
| 126 // SmoothsRenderedFrames method. This method is used by the | |
| 127 // VideoReceiveStream, where the value is passed on to the | |
| 128 // IncomingVideoStream constructor. | |
| 129 bool disable_prerenderer_smoothing = false; | |
| 130 }; | |
| 131 | |
| 98 // Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine. | 132 // Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine. |
| 99 // Used to be flags, but that makes it hard to selectively apply options. | 133 // Used to be flags, but that makes it hard to selectively apply options. |
| 100 // We are moving all of the setting of options to structs like this, | 134 // We are moving all of the setting of options to structs like this, |
| 101 // but some things currently still use flags. | 135 // but some things currently still use flags. |
| 102 struct AudioOptions { | 136 struct AudioOptions { |
| 103 void SetAll(const AudioOptions& change) { | 137 void SetAll(const AudioOptions& change) { |
| 104 SetFrom(&echo_cancellation, change.echo_cancellation); | 138 SetFrom(&echo_cancellation, change.echo_cancellation); |
| 105 SetFrom(&auto_gain_control, change.auto_gain_control); | 139 SetFrom(&auto_gain_control, change.auto_gain_control); |
| 106 SetFrom(&noise_suppression, change.noise_suppression); | 140 SetFrom(&noise_suppression, change.noise_suppression); |
| 107 SetFrom(&highpass_filter, change.highpass_filter); | 141 SetFrom(&highpass_filter, change.highpass_filter); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 118 SetFrom(&extended_filter_aec, change.extended_filter_aec); | 152 SetFrom(&extended_filter_aec, change.extended_filter_aec); |
| 119 SetFrom(&delay_agnostic_aec, change.delay_agnostic_aec); | 153 SetFrom(&delay_agnostic_aec, change.delay_agnostic_aec); |
| 120 SetFrom(&experimental_ns, change.experimental_ns); | 154 SetFrom(&experimental_ns, change.experimental_ns); |
| 121 SetFrom(&aec_dump, change.aec_dump); | 155 SetFrom(&aec_dump, change.aec_dump); |
| 122 SetFrom(&tx_agc_target_dbov, change.tx_agc_target_dbov); | 156 SetFrom(&tx_agc_target_dbov, change.tx_agc_target_dbov); |
| 123 SetFrom(&tx_agc_digital_compression_gain, | 157 SetFrom(&tx_agc_digital_compression_gain, |
| 124 change.tx_agc_digital_compression_gain); | 158 change.tx_agc_digital_compression_gain); |
| 125 SetFrom(&tx_agc_limiter, change.tx_agc_limiter); | 159 SetFrom(&tx_agc_limiter, change.tx_agc_limiter); |
| 126 SetFrom(&recording_sample_rate, change.recording_sample_rate); | 160 SetFrom(&recording_sample_rate, change.recording_sample_rate); |
| 127 SetFrom(&playout_sample_rate, change.playout_sample_rate); | 161 SetFrom(&playout_sample_rate, change.playout_sample_rate); |
| 128 SetFrom(&dscp, change.dscp); | |
| 129 SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe); | 162 SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe); |
| 130 } | 163 } |
| 131 | 164 |
| 132 bool operator==(const AudioOptions& o) const { | 165 bool operator==(const AudioOptions& o) const { |
| 133 return echo_cancellation == o.echo_cancellation && | 166 return echo_cancellation == o.echo_cancellation && |
| 134 auto_gain_control == o.auto_gain_control && | 167 auto_gain_control == o.auto_gain_control && |
| 135 noise_suppression == o.noise_suppression && | 168 noise_suppression == o.noise_suppression && |
| 136 highpass_filter == o.highpass_filter && | 169 highpass_filter == o.highpass_filter && |
| 137 stereo_swapping == o.stereo_swapping && | 170 stereo_swapping == o.stereo_swapping && |
| 138 audio_jitter_buffer_max_packets == o.audio_jitter_buffer_max_packets && | 171 audio_jitter_buffer_max_packets == o.audio_jitter_buffer_max_packets && |
| 139 audio_jitter_buffer_fast_accelerate == | 172 audio_jitter_buffer_fast_accelerate == |
| 140 o.audio_jitter_buffer_fast_accelerate && | 173 o.audio_jitter_buffer_fast_accelerate && |
| 141 typing_detection == o.typing_detection && | 174 typing_detection == o.typing_detection && |
| 142 aecm_generate_comfort_noise == o.aecm_generate_comfort_noise && | 175 aecm_generate_comfort_noise == o.aecm_generate_comfort_noise && |
| 143 conference_mode == o.conference_mode && | 176 conference_mode == o.conference_mode && |
| 144 experimental_agc == o.experimental_agc && | 177 experimental_agc == o.experimental_agc && |
| 145 extended_filter_aec == o.extended_filter_aec && | 178 extended_filter_aec == o.extended_filter_aec && |
| 146 delay_agnostic_aec == o.delay_agnostic_aec && | 179 delay_agnostic_aec == o.delay_agnostic_aec && |
| 147 experimental_ns == o.experimental_ns && | 180 experimental_ns == o.experimental_ns && |
| 148 adjust_agc_delta == o.adjust_agc_delta && | 181 adjust_agc_delta == o.adjust_agc_delta && |
| 149 aec_dump == o.aec_dump && | 182 aec_dump == o.aec_dump && |
| 150 tx_agc_target_dbov == o.tx_agc_target_dbov && | 183 tx_agc_target_dbov == o.tx_agc_target_dbov && |
| 151 tx_agc_digital_compression_gain == o.tx_agc_digital_compression_gain && | 184 tx_agc_digital_compression_gain == o.tx_agc_digital_compression_gain && |
| 152 tx_agc_limiter == o.tx_agc_limiter && | 185 tx_agc_limiter == o.tx_agc_limiter && |
| 153 recording_sample_rate == o.recording_sample_rate && | 186 recording_sample_rate == o.recording_sample_rate && |
| 154 playout_sample_rate == o.playout_sample_rate && | 187 playout_sample_rate == o.playout_sample_rate && |
| 155 dscp == o.dscp && | |
| 156 combined_audio_video_bwe == o.combined_audio_video_bwe; | 188 combined_audio_video_bwe == o.combined_audio_video_bwe; |
| 157 } | 189 } |
| 158 | 190 |
| 159 std::string ToString() const { | 191 std::string ToString() const { |
| 160 std::ostringstream ost; | 192 std::ostringstream ost; |
| 161 ost << "AudioOptions {"; | 193 ost << "AudioOptions {"; |
| 162 ost << ToStringIfSet("aec", echo_cancellation); | 194 ost << ToStringIfSet("aec", echo_cancellation); |
| 163 ost << ToStringIfSet("agc", auto_gain_control); | 195 ost << ToStringIfSet("agc", auto_gain_control); |
| 164 ost << ToStringIfSet("ns", noise_suppression); | 196 ost << ToStringIfSet("ns", noise_suppression); |
| 165 ost << ToStringIfSet("hf", highpass_filter); | 197 ost << ToStringIfSet("hf", highpass_filter); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 176 ost << ToStringIfSet("extended_filter_aec", extended_filter_aec); | 208 ost << ToStringIfSet("extended_filter_aec", extended_filter_aec); |
| 177 ost << ToStringIfSet("delay_agnostic_aec", delay_agnostic_aec); | 209 ost << ToStringIfSet("delay_agnostic_aec", delay_agnostic_aec); |
| 178 ost << ToStringIfSet("experimental_ns", experimental_ns); | 210 ost << ToStringIfSet("experimental_ns", experimental_ns); |
| 179 ost << ToStringIfSet("aec_dump", aec_dump); | 211 ost << ToStringIfSet("aec_dump", aec_dump); |
| 180 ost << ToStringIfSet("tx_agc_target_dbov", tx_agc_target_dbov); | 212 ost << ToStringIfSet("tx_agc_target_dbov", tx_agc_target_dbov); |
| 181 ost << ToStringIfSet("tx_agc_digital_compression_gain", | 213 ost << ToStringIfSet("tx_agc_digital_compression_gain", |
| 182 tx_agc_digital_compression_gain); | 214 tx_agc_digital_compression_gain); |
| 183 ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter); | 215 ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter); |
| 184 ost << ToStringIfSet("recording_sample_rate", recording_sample_rate); | 216 ost << ToStringIfSet("recording_sample_rate", recording_sample_rate); |
| 185 ost << ToStringIfSet("playout_sample_rate", playout_sample_rate); | 217 ost << ToStringIfSet("playout_sample_rate", playout_sample_rate); |
| 186 ost << ToStringIfSet("dscp", dscp); | |
| 187 ost << ToStringIfSet("combined_audio_video_bwe", combined_audio_video_bwe); | 218 ost << ToStringIfSet("combined_audio_video_bwe", combined_audio_video_bwe); |
| 188 ost << "}"; | 219 ost << "}"; |
| 189 return ost.str(); | 220 return ost.str(); |
| 190 } | 221 } |
| 191 | 222 |
| 192 // Audio processing that attempts to filter away the output signal from | 223 // Audio processing that attempts to filter away the output signal from |
| 193 // later inbound pickup. | 224 // later inbound pickup. |
| 194 rtc::Optional<bool> echo_cancellation; | 225 rtc::Optional<bool> echo_cancellation; |
| 195 // Audio processing to adjust the sensitivity of the local mic dynamically. | 226 // Audio processing to adjust the sensitivity of the local mic dynamically. |
| 196 rtc::Optional<bool> auto_gain_control; | 227 rtc::Optional<bool> auto_gain_control; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 213 rtc::Optional<bool> extended_filter_aec; | 244 rtc::Optional<bool> extended_filter_aec; |
| 214 rtc::Optional<bool> delay_agnostic_aec; | 245 rtc::Optional<bool> delay_agnostic_aec; |
| 215 rtc::Optional<bool> experimental_ns; | 246 rtc::Optional<bool> experimental_ns; |
| 216 rtc::Optional<bool> aec_dump; | 247 rtc::Optional<bool> aec_dump; |
| 217 // Note that tx_agc_* only applies to non-experimental AGC. | 248 // Note that tx_agc_* only applies to non-experimental AGC. |
| 218 rtc::Optional<uint16_t> tx_agc_target_dbov; | 249 rtc::Optional<uint16_t> tx_agc_target_dbov; |
| 219 rtc::Optional<uint16_t> tx_agc_digital_compression_gain; | 250 rtc::Optional<uint16_t> tx_agc_digital_compression_gain; |
| 220 rtc::Optional<bool> tx_agc_limiter; | 251 rtc::Optional<bool> tx_agc_limiter; |
| 221 rtc::Optional<uint32_t> recording_sample_rate; | 252 rtc::Optional<uint32_t> recording_sample_rate; |
| 222 rtc::Optional<uint32_t> playout_sample_rate; | 253 rtc::Optional<uint32_t> playout_sample_rate; |
| 223 // Set DSCP value for packet sent from audio channel. | |
| 224 rtc::Optional<bool> dscp; | |
| 225 // Enable combined audio+bandwidth BWE. | 254 // Enable combined audio+bandwidth BWE. |
| 255 // TODO(pthatcher): This flag is set from the | |
| 256 // "googCombinedAudioVideoBwe", but not used anywhere. So delete it, | |
| 257 // and check if any other AudioOptions members are unused. | |
| 226 rtc::Optional<bool> combined_audio_video_bwe; | 258 rtc::Optional<bool> combined_audio_video_bwe; |
| 227 | 259 |
| 228 private: | 260 private: |
| 229 template <typename T> | 261 template <typename T> |
| 230 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { | 262 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { |
| 231 if (o) { | 263 if (o) { |
| 232 *s = o; | 264 *s = o; |
| 233 } | 265 } |
| 234 } | 266 } |
| 235 }; | 267 }; |
| 236 | 268 |
| 237 // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. | 269 // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. |
| 238 // Used to be flags, but that makes it hard to selectively apply options. | 270 // Used to be flags, but that makes it hard to selectively apply options. |
| 239 // We are moving all of the setting of options to structs like this, | 271 // We are moving all of the setting of options to structs like this, |
| 240 // but some things currently still use flags. | 272 // but some things currently still use flags. |
| 241 struct VideoOptions { | 273 struct VideoOptions { |
| 242 void SetAll(const VideoOptions& change) { | 274 void SetAll(const VideoOptions& change) { |
| 243 SetFrom(&video_noise_reduction, change.video_noise_reduction); | 275 SetFrom(&video_noise_reduction, change.video_noise_reduction); |
| 244 SetFrom(&cpu_overuse_detection, change.cpu_overuse_detection); | |
| 245 SetFrom(&conference_mode, change.conference_mode); | 276 SetFrom(&conference_mode, change.conference_mode); |
| 246 SetFrom(&dscp, change.dscp); | |
| 247 SetFrom(&suspend_below_min_bitrate, change.suspend_below_min_bitrate); | 277 SetFrom(&suspend_below_min_bitrate, change.suspend_below_min_bitrate); |
| 248 SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps); | 278 SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps); |
| 249 SetFrom(&disable_prerenderer_smoothing, | |
| 250 change.disable_prerenderer_smoothing); | |
| 251 } | 279 } |
| 252 | 280 |
| 253 bool operator==(const VideoOptions& o) const { | 281 bool operator==(const VideoOptions& o) const { |
| 254 return video_noise_reduction == o.video_noise_reduction && | 282 return video_noise_reduction == o.video_noise_reduction && |
| 255 cpu_overuse_detection == o.cpu_overuse_detection && | |
| 256 conference_mode == o.conference_mode && | 283 conference_mode == o.conference_mode && |
| 257 dscp == o.dscp && | |
| 258 suspend_below_min_bitrate == o.suspend_below_min_bitrate && | 284 suspend_below_min_bitrate == o.suspend_below_min_bitrate && |
| 259 screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps && | 285 screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps; |
| 260 disable_prerenderer_smoothing == o.disable_prerenderer_smoothing; | |
| 261 } | 286 } |
| 262 | 287 |
| 263 std::string ToString() const { | 288 std::string ToString() const { |
| 264 std::ostringstream ost; | 289 std::ostringstream ost; |
| 265 ost << "VideoOptions {"; | 290 ost << "VideoOptions {"; |
| 266 ost << ToStringIfSet("noise reduction", video_noise_reduction); | 291 ost << ToStringIfSet("noise reduction", video_noise_reduction); |
| 267 ost << ToStringIfSet("cpu overuse detection", cpu_overuse_detection); | |
| 268 ost << ToStringIfSet("conference mode", conference_mode); | 292 ost << ToStringIfSet("conference mode", conference_mode); |
| 269 ost << ToStringIfSet("dscp", dscp); | |
| 270 ost << ToStringIfSet("suspend below min bitrate", | 293 ost << ToStringIfSet("suspend below min bitrate", |
| 271 suspend_below_min_bitrate); | 294 suspend_below_min_bitrate); |
| 272 ost << ToStringIfSet("screencast min bitrate kbps", | 295 ost << ToStringIfSet("screencast min bitrate kbps", |
| 273 screencast_min_bitrate_kbps); | 296 screencast_min_bitrate_kbps); |
| 274 ost << "}"; | 297 ost << "}"; |
| 275 return ost.str(); | 298 return ost.str(); |
| 276 } | 299 } |
| 277 | 300 |
| 278 // Enable denoising? This flag comes from the getUserMedia | 301 // Enable denoising? This flag comes from the getUserMedia |
| 279 // constraint 'googNoiseReduction', and WebRtcVideoEngine2 passes it | 302 // constraint 'googNoiseReduction', and WebRtcVideoEngine2 passes it |
| 280 // on to the codec options. Disabled by default. | 303 // on to the codec options. Disabled by default. |
| 281 rtc::Optional<bool> video_noise_reduction; | 304 rtc::Optional<bool> video_noise_reduction; |
| 282 // Enable WebRTC Cpu Overuse Detection. This flag comes from the | |
| 283 // PeerConnection constraint 'googCpuOveruseDetection' and is | |
| 284 // checked in WebRtcVideoChannel2::OnLoadUpdate, where it's passed | |
| 285 // to VideoCapturer::video_adapter()->OnCpuResolutionRequest. | |
| 286 rtc::Optional<bool> cpu_overuse_detection; | |
| 287 // Use conference mode? This flag comes from the remote | 305 // Use conference mode? This flag comes from the remote |
| 288 // description's SDP line 'a=x-google-flag:conference', copied over | 306 // description's SDP line 'a=x-google-flag:conference', copied over |
| 289 // by VideoChannel::SetRemoteContent_w, and ultimately used by | 307 // by VideoChannel::SetRemoteContent_w, and ultimately used by |
| 290 // conference mode screencast logic in | 308 // conference mode screencast logic in |
| 291 // WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig. | 309 // WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig. |
| 292 // The special screencast behaviour is disabled by default. | 310 // The special screencast behaviour is disabled by default. |
| 293 rtc::Optional<bool> conference_mode; | 311 rtc::Optional<bool> conference_mode; |
| 294 // Set DSCP value for packet sent from video channel. This flag | |
| 295 // comes from the PeerConnection constraint 'googDscp' and, | |
| 296 // WebRtcVideoChannel2::SetOptions checks it before calling | |
| 297 // MediaChannel::SetDscp. If enabled, rtc::DSCP_AF41 is used. If | |
| 298 // disabled, which is the default, rtc::DSCP_DEFAULT is used. | |
| 299 rtc::Optional<bool> dscp; | |
| 300 // Enable WebRTC suspension of video. No video frames will be sent | 312 // Enable WebRTC suspension of video. No video frames will be sent |
| 301 // when the bitrate is below the configured minimum bitrate. This | 313 // when the bitrate is below the configured minimum bitrate. This |
| 302 // flag comes from the PeerConnection constraint | 314 // flag comes from the PeerConnection constraint |
| 303 // 'googSuspendBelowMinBitrate', and WebRtcVideoChannel2 copies it | 315 // 'googSuspendBelowMinBitrate', and WebRtcVideoChannel2 copies it |
| 304 // to VideoSendStream::Config::suspend_below_min_bitrate. | 316 // to VideoSendStream::Config::suspend_below_min_bitrate. |
| 305 rtc::Optional<bool> suspend_below_min_bitrate; | 317 rtc::Optional<bool> suspend_below_min_bitrate; |
| 306 // Force screencast to use a minimum bitrate. This flag comes from | 318 // Force screencast to use a minimum bitrate. This flag comes from |
| 307 // the PeerConnection constraint 'googScreencastMinBitrate'. It is | 319 // the PeerConnection constraint 'googScreencastMinBitrate'. It is |
| 308 // copied to the encoder config by WebRtcVideoChannel2. | 320 // copied to the encoder config by WebRtcVideoChannel2. |
| 309 rtc::Optional<int> screencast_min_bitrate_kbps; | 321 rtc::Optional<int> screencast_min_bitrate_kbps; |
| 310 // Set to true if the renderer has an algorithm of frame selection. | |
| 311 // If the value is true, then WebRTC will hand over a frame as soon as | |
| 312 // possible without delay, and rendering smoothness is completely the duty | |
| 313 // of the renderer; | |
| 314 // If the value is false, then WebRTC is responsible to delay frame release | |
| 315 // in order to increase rendering smoothness. | |
| 316 // | |
| 317 // This flag comes from PeerConnection's RtcConfiguration, but is | |
| 318 // currently only set by the command line flag | |
| 319 // 'disable-rtc-smoothness-algorithm'. | |
| 320 // WebRtcVideoChannel2::AddRecvStream copies it to the created | |
| 321 // WebRtcVideoReceiveStream, where it is returned by the | |
| 322 // SmoothsRenderedFrames method. This method is used by the | |
| 323 // VideoReceiveStream, where the value is passed on to the | |
| 324 // IncomingVideoStream constructor. | |
| 325 rtc::Optional<bool> disable_prerenderer_smoothing; | |
| 326 | 322 |
| 327 private: | 323 private: |
| 328 template <typename T> | 324 template <typename T> |
| 329 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { | 325 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { |
| 330 if (o) { | 326 if (o) { |
| 331 *s = o; | 327 *s = o; |
| 332 } | 328 } |
| 333 } | 329 } |
| 334 }; | 330 }; |
| 335 | 331 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 enum SocketType { ST_RTP, ST_RTCP }; | 374 enum SocketType { ST_RTP, ST_RTCP }; |
| 379 virtual bool SendPacket(rtc::Buffer* packet, | 375 virtual bool SendPacket(rtc::Buffer* packet, |
| 380 const rtc::PacketOptions& options) = 0; | 376 const rtc::PacketOptions& options) = 0; |
| 381 virtual bool SendRtcp(rtc::Buffer* packet, | 377 virtual bool SendRtcp(rtc::Buffer* packet, |
| 382 const rtc::PacketOptions& options) = 0; | 378 const rtc::PacketOptions& options) = 0; |
| 383 virtual int SetOption(SocketType type, rtc::Socket::Option opt, | 379 virtual int SetOption(SocketType type, rtc::Socket::Option opt, |
| 384 int option) = 0; | 380 int option) = 0; |
| 385 virtual ~NetworkInterface() {} | 381 virtual ~NetworkInterface() {} |
| 386 }; | 382 }; |
| 387 | 383 |
| 388 MediaChannel() : network_interface_(NULL) {} | 384 MediaChannel(const MediaConfig& config) |
| 385 : network_interface_(NULL) { | |
| 386 enable_dscp_ = config.enable_dscp; | |
| 387 } | |
| 388 MediaChannel() : enable_dscp_(false), network_interface_(NULL) {} | |
| 389 virtual ~MediaChannel() {} | 389 virtual ~MediaChannel() {} |
| 390 | 390 |
| 391 // Sets the abstract interface class for sending RTP/RTCP data. | 391 // Sets the abstract interface class for sending RTP/RTCP data. |
| 392 virtual void SetInterface(NetworkInterface *iface) { | 392 virtual void SetInterface(NetworkInterface *iface) { |
| 393 rtc::CritScope cs(&network_interface_crit_); | 393 rtc::CritScope cs(&network_interface_crit_); |
| 394 network_interface_ = iface; | 394 network_interface_ = iface; |
| 395 SetDscp(enable_dscp_ ? PreferredDscp() : rtc::DSCP_DEFAULT); | |
| 395 } | 396 } |
| 396 | 397 virtual rtc::DiffServCodePoint PreferredDscp() const { |
| 398 return rtc::DSCP_DEFAULT; | |
| 399 } | |
| 397 // Called when a RTP packet is received. | 400 // Called when a RTP packet is received. |
| 398 virtual void OnPacketReceived(rtc::Buffer* packet, | 401 virtual void OnPacketReceived(rtc::Buffer* packet, |
| 399 const rtc::PacketTime& packet_time) = 0; | 402 const rtc::PacketTime& packet_time) = 0; |
| 400 // Called when a RTCP packet is received. | 403 // Called when a RTCP packet is received. |
| 401 virtual void OnRtcpReceived(rtc::Buffer* packet, | 404 virtual void OnRtcpReceived(rtc::Buffer* packet, |
| 402 const rtc::PacketTime& packet_time) = 0; | 405 const rtc::PacketTime& packet_time) = 0; |
| 403 // Called when the socket's ability to send has changed. | 406 // Called when the socket's ability to send has changed. |
| 404 virtual void OnReadyToSend(bool ready) = 0; | 407 virtual void OnReadyToSend(bool ready) = 0; |
| 405 // Creates a new outgoing media stream with SSRCs and CNAME as described | 408 // Creates a new outgoing media stream with SSRCs and CNAME as described |
| 406 // by sp. | 409 // by sp. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 434 int SetOption(NetworkInterface::SocketType type, | 437 int SetOption(NetworkInterface::SocketType type, |
| 435 rtc::Socket::Option opt, | 438 rtc::Socket::Option opt, |
| 436 int option) { | 439 int option) { |
| 437 rtc::CritScope cs(&network_interface_crit_); | 440 rtc::CritScope cs(&network_interface_crit_); |
| 438 if (!network_interface_) | 441 if (!network_interface_) |
| 439 return -1; | 442 return -1; |
| 440 | 443 |
| 441 return network_interface_->SetOption(type, opt, option); | 444 return network_interface_->SetOption(type, opt, option); |
| 442 } | 445 } |
| 443 | 446 |
| 444 protected: | 447 private: |
| 445 // This method sets DSCP |value| on both RTP and RTCP channels. | 448 // This method sets DSCP |value| on both RTP and RTCP channels. |
| 446 int SetDscp(rtc::DiffServCodePoint value) { | 449 int SetDscp(rtc::DiffServCodePoint value) { |
| 447 int ret; | 450 int ret; |
| 448 ret = SetOption(NetworkInterface::ST_RTP, | 451 ret = SetOption(NetworkInterface::ST_RTP, |
| 449 rtc::Socket::OPT_DSCP, | 452 rtc::Socket::OPT_DSCP, |
| 450 value); | 453 value); |
| 451 if (ret == 0) { | 454 if (ret == 0) { |
| 452 ret = SetOption(NetworkInterface::ST_RTCP, | 455 ret = SetOption(NetworkInterface::ST_RTCP, |
| 453 rtc::Socket::OPT_DSCP, | 456 rtc::Socket::OPT_DSCP, |
| 454 value); | 457 value); |
| 455 } | 458 } |
| 456 return ret; | 459 return ret; |
| 457 } | 460 } |
| 458 | 461 |
| 459 private: | 462 private: |
|
perkj_webrtc
2016/02/09 15:35:37
remove private:
nisse-webrtc
2016/02/10 08:53:00
Done.
| |
| 460 bool DoSendPacket(rtc::Buffer* packet, | 463 bool DoSendPacket(rtc::Buffer* packet, |
| 461 bool rtcp, | 464 bool rtcp, |
| 462 const rtc::PacketOptions& options) { | 465 const rtc::PacketOptions& options) { |
| 463 rtc::CritScope cs(&network_interface_crit_); | 466 rtc::CritScope cs(&network_interface_crit_); |
| 464 if (!network_interface_) | 467 if (!network_interface_) |
| 465 return false; | 468 return false; |
| 466 | 469 |
| 467 return (!rtcp) ? network_interface_->SendPacket(packet, options) | 470 return (!rtcp) ? network_interface_->SendPacket(packet, options) |
| 468 : network_interface_->SendRtcp(packet, options); | 471 : network_interface_->SendRtcp(packet, options); |
| 469 } | 472 } |
| 470 | 473 |
| 474 bool enable_dscp_; | |
| 471 // |network_interface_| can be accessed from the worker_thread and | 475 // |network_interface_| can be accessed from the worker_thread and |
| 472 // from any MediaEngine threads. This critical section is to protect accessing | 476 // from any MediaEngine threads. This critical section is to protect accessing |
| 473 // of network_interface_ object. | 477 // of network_interface_ object. |
| 474 rtc::CriticalSection network_interface_crit_; | 478 rtc::CriticalSection network_interface_crit_; |
| 475 NetworkInterface* network_interface_; | 479 NetworkInterface* network_interface_; |
| 476 }; | 480 }; |
| 477 | 481 |
| 478 enum SendFlags { | 482 enum SendFlags { |
| 479 SEND_NOTHING, | 483 SEND_NOTHING, |
| 480 SEND_MICROPHONE | 484 SEND_MICROPHONE |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout. | 918 ERROR_PLAY_DEVICE_OPEN_FAILED = 200, // Could not open playout. |
| 915 ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS. | 919 ERROR_PLAY_DEVICE_MUTED, // Playout muted by OS. |
| 916 ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active. | 920 ERROR_PLAY_DEVICE_REMOVED, // Playout removed while active. |
| 917 ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing. | 921 ERROR_PLAY_RUNTIME_ERROR, // Errors in voice processing. |
| 918 ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure. | 922 ERROR_PLAY_SRTP_ERROR, // Generic SRTP failure. |
| 919 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. | 923 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 920 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. | 924 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
| 921 }; | 925 }; |
| 922 | 926 |
| 923 VoiceMediaChannel() {} | 927 VoiceMediaChannel() {} |
| 928 VoiceMediaChannel(const MediaConfig& config) : MediaChannel(config) {} | |
| 924 virtual ~VoiceMediaChannel() {} | 929 virtual ~VoiceMediaChannel() {} |
| 925 virtual bool SetSendParameters(const AudioSendParameters& params) = 0; | 930 virtual bool SetSendParameters(const AudioSendParameters& params) = 0; |
| 926 virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0; | 931 virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0; |
| 927 // Starts or stops playout of received audio. | 932 // Starts or stops playout of received audio. |
| 928 virtual bool SetPlayout(bool playout) = 0; | 933 virtual bool SetPlayout(bool playout) = 0; |
| 929 // Starts or stops sending (and potentially capture) of local audio. | 934 // Starts or stops sending (and potentially capture) of local audio. |
| 930 virtual bool SetSend(SendFlags flag) = 0; | 935 virtual bool SetSend(SendFlags flag) = 0; |
| 931 // Configure stream for sending. | 936 // Configure stream for sending. |
| 932 virtual bool SetAudioSend(uint32_t ssrc, | 937 virtual bool SetAudioSend(uint32_t ssrc, |
| 933 bool enable, | 938 bool enable, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 977 ERROR_REC_DEVICE_REMOVED, // Device is removed. | 982 ERROR_REC_DEVICE_REMOVED, // Device is removed. |
| 978 ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure. | 983 ERROR_REC_SRTP_ERROR, // Generic sender SRTP failure. |
| 979 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. | 984 ERROR_REC_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 980 ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore. | 985 ERROR_REC_CPU_MAX_CANT_DOWNGRADE, // Can't downgrade capture anymore. |
| 981 ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure. | 986 ERROR_PLAY_SRTP_ERROR = 200, // Generic receiver SRTP failure. |
| 982 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. | 987 ERROR_PLAY_SRTP_AUTH_FAILED, // Failed to authenticate packets. |
| 983 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. | 988 ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
| 984 }; | 989 }; |
| 985 | 990 |
| 986 VideoMediaChannel() {} | 991 VideoMediaChannel() {} |
| 992 VideoMediaChannel(const MediaConfig& config) : MediaChannel(config) {} | |
| 987 virtual ~VideoMediaChannel() {} | 993 virtual ~VideoMediaChannel() {} |
| 988 | 994 |
| 989 virtual bool SetSendParameters(const VideoSendParameters& params) = 0; | 995 virtual bool SetSendParameters(const VideoSendParameters& params) = 0; |
| 990 virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0; | 996 virtual bool SetRecvParameters(const VideoRecvParameters& params) = 0; |
| 991 // Gets the currently set codecs/payload types to be used for outgoing media. | 997 // Gets the currently set codecs/payload types to be used for outgoing media. |
| 992 virtual bool GetSendCodec(VideoCodec* send_codec) = 0; | 998 virtual bool GetSendCodec(VideoCodec* send_codec) = 0; |
| 993 // Starts or stops transmission (and potentially capture) of local video. | 999 // Starts or stops transmission (and potentially capture) of local video. |
| 994 virtual bool SetSend(bool send) = 0; | 1000 virtual bool SetSend(bool send) = 0; |
| 995 // Configure stream for sending. | 1001 // Configure stream for sending. |
| 996 virtual bool SetVideoSend(uint32_t ssrc, | 1002 virtual bool SetVideoSend(uint32_t ssrc, |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1128 // Signal when the media channel is ready to send the stream. Arguments are: | 1134 // Signal when the media channel is ready to send the stream. Arguments are: |
| 1129 // writable(bool) | 1135 // writable(bool) |
| 1130 sigslot::signal1<bool> SignalReadyToSend; | 1136 sigslot::signal1<bool> SignalReadyToSend; |
| 1131 // Signal for notifying that the remote side has closed the DataChannel. | 1137 // Signal for notifying that the remote side has closed the DataChannel. |
| 1132 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; | 1138 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; |
| 1133 }; | 1139 }; |
| 1134 | 1140 |
| 1135 } // namespace cricket | 1141 } // namespace cricket |
| 1136 | 1142 |
| 1137 #endif // WEBRTC_MEDIA_BASE_MEDIACHANNEL_H_ | 1143 #endif // WEBRTC_MEDIA_BASE_MEDIACHANNEL_H_ |
| OLD | NEW |