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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 *s = o; | 231 *s = o; |
232 } | 232 } |
233 } | 233 } |
234 }; | 234 }; |
235 | 235 |
236 // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. | 236 // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. |
237 // Used to be flags, but that makes it hard to selectively apply options. | 237 // Used to be flags, but that makes it hard to selectively apply options. |
238 // We are moving all of the setting of options to structs like this, | 238 // We are moving all of the setting of options to structs like this, |
239 // but some things currently still use flags. | 239 // but some things currently still use flags. |
240 struct VideoOptions { | 240 struct VideoOptions { |
241 VideoOptions() | |
242 : process_adaptation_threshhold(kProcessCpuThreshold), | |
243 system_low_adaptation_threshhold(kLowSystemCpuThreshold), | |
244 system_high_adaptation_threshhold(kHighSystemCpuThreshold), | |
245 unsignalled_recv_stream_limit(kNumDefaultUnsignalledVideoRecvStreams) {} | |
246 | |
247 void SetAll(const VideoOptions& change) { | 241 void SetAll(const VideoOptions& change) { |
248 SetFrom(&adapt_input_to_cpu_usage, change.adapt_input_to_cpu_usage); | |
249 SetFrom(&adapt_cpu_with_smoothing, change.adapt_cpu_with_smoothing); | |
250 SetFrom(&video_adapt_third, change.video_adapt_third); | |
251 SetFrom(&video_noise_reduction, change.video_noise_reduction); | 242 SetFrom(&video_noise_reduction, change.video_noise_reduction); |
252 SetFrom(&video_start_bitrate, change.video_start_bitrate); | |
253 SetFrom(&cpu_overuse_detection, change.cpu_overuse_detection); | 243 SetFrom(&cpu_overuse_detection, change.cpu_overuse_detection); |
254 SetFrom(&cpu_underuse_threshold, change.cpu_underuse_threshold); | |
255 SetFrom(&cpu_overuse_threshold, change.cpu_overuse_threshold); | |
256 SetFrom(&cpu_underuse_encode_rsd_threshold, | |
257 change.cpu_underuse_encode_rsd_threshold); | |
258 SetFrom(&cpu_overuse_encode_rsd_threshold, | |
259 change.cpu_overuse_encode_rsd_threshold); | |
260 SetFrom(&cpu_overuse_encode_usage, change.cpu_overuse_encode_usage); | |
261 SetFrom(&conference_mode, change.conference_mode); | 244 SetFrom(&conference_mode, change.conference_mode); |
262 SetFrom(&process_adaptation_threshhold, | |
263 change.process_adaptation_threshhold); | |
264 SetFrom(&system_low_adaptation_threshhold, | |
265 change.system_low_adaptation_threshhold); | |
266 SetFrom(&system_high_adaptation_threshhold, | |
267 change.system_high_adaptation_threshhold); | |
268 SetFrom(&dscp, change.dscp); | 245 SetFrom(&dscp, change.dscp); |
269 SetFrom(&suspend_below_min_bitrate, change.suspend_below_min_bitrate); | 246 SetFrom(&suspend_below_min_bitrate, change.suspend_below_min_bitrate); |
270 SetFrom(&unsignalled_recv_stream_limit, | 247 SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps); |
271 change.unsignalled_recv_stream_limit); | |
272 SetFrom(&use_simulcast_adapter, change.use_simulcast_adapter); | |
273 SetFrom(&screencast_min_bitrate, change.screencast_min_bitrate); | |
274 SetFrom(&disable_prerenderer_smoothing, | 248 SetFrom(&disable_prerenderer_smoothing, |
275 change.disable_prerenderer_smoothing); | 249 change.disable_prerenderer_smoothing); |
276 } | 250 } |
277 | 251 |
278 bool operator==(const VideoOptions& o) const { | 252 bool operator==(const VideoOptions& o) const { |
279 return adapt_input_to_cpu_usage == o.adapt_input_to_cpu_usage && | 253 return video_noise_reduction == o.video_noise_reduction && |
280 adapt_cpu_with_smoothing == o.adapt_cpu_with_smoothing && | |
281 video_adapt_third == o.video_adapt_third && | |
282 video_noise_reduction == o.video_noise_reduction && | |
283 video_start_bitrate == o.video_start_bitrate && | |
284 cpu_overuse_detection == o.cpu_overuse_detection && | 254 cpu_overuse_detection == o.cpu_overuse_detection && |
285 cpu_underuse_threshold == o.cpu_underuse_threshold && | |
286 cpu_overuse_threshold == o.cpu_overuse_threshold && | |
287 cpu_underuse_encode_rsd_threshold == | |
288 o.cpu_underuse_encode_rsd_threshold && | |
289 cpu_overuse_encode_rsd_threshold == | |
290 o.cpu_overuse_encode_rsd_threshold && | |
291 cpu_overuse_encode_usage == o.cpu_overuse_encode_usage && | |
292 conference_mode == o.conference_mode && | 255 conference_mode == o.conference_mode && |
293 process_adaptation_threshhold == o.process_adaptation_threshhold && | |
294 system_low_adaptation_threshhold == | |
295 o.system_low_adaptation_threshhold && | |
296 system_high_adaptation_threshhold == | |
297 o.system_high_adaptation_threshhold && | |
298 dscp == o.dscp && | 256 dscp == o.dscp && |
299 suspend_below_min_bitrate == o.suspend_below_min_bitrate && | 257 suspend_below_min_bitrate == o.suspend_below_min_bitrate && |
300 unsignalled_recv_stream_limit == o.unsignalled_recv_stream_limit && | 258 screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps && |
301 use_simulcast_adapter == o.use_simulcast_adapter && | |
302 screencast_min_bitrate == o.screencast_min_bitrate && | |
303 disable_prerenderer_smoothing == o.disable_prerenderer_smoothing; | 259 disable_prerenderer_smoothing == o.disable_prerenderer_smoothing; |
304 } | 260 } |
305 | 261 |
306 std::string ToString() const { | 262 std::string ToString() const { |
307 std::ostringstream ost; | 263 std::ostringstream ost; |
308 ost << "VideoOptions {"; | 264 ost << "VideoOptions {"; |
309 ost << ToStringIfSet("cpu adaption", adapt_input_to_cpu_usage); | |
310 ost << ToStringIfSet("cpu adaptation smoothing", adapt_cpu_with_smoothing); | |
311 ost << ToStringIfSet("video adapt third", video_adapt_third); | |
312 ost << ToStringIfSet("noise reduction", video_noise_reduction); | 265 ost << ToStringIfSet("noise reduction", video_noise_reduction); |
313 ost << ToStringIfSet("start bitrate", video_start_bitrate); | |
314 ost << ToStringIfSet("cpu overuse detection", cpu_overuse_detection); | 266 ost << ToStringIfSet("cpu overuse detection", cpu_overuse_detection); |
315 ost << ToStringIfSet("cpu underuse threshold", cpu_underuse_threshold); | |
316 ost << ToStringIfSet("cpu overuse threshold", cpu_overuse_threshold); | |
317 ost << ToStringIfSet("cpu underuse encode rsd threshold", | |
318 cpu_underuse_encode_rsd_threshold); | |
319 ost << ToStringIfSet("cpu overuse encode rsd threshold", | |
320 cpu_overuse_encode_rsd_threshold); | |
321 ost << ToStringIfSet("cpu overuse encode usage", | |
322 cpu_overuse_encode_usage); | |
323 ost << ToStringIfSet("conference mode", conference_mode); | 267 ost << ToStringIfSet("conference mode", conference_mode); |
324 ost << ToStringIfSet("process", process_adaptation_threshhold); | |
325 ost << ToStringIfSet("low", system_low_adaptation_threshhold); | |
326 ost << ToStringIfSet("high", system_high_adaptation_threshhold); | |
327 ost << ToStringIfSet("dscp", dscp); | 268 ost << ToStringIfSet("dscp", dscp); |
328 ost << ToStringIfSet("suspend below min bitrate", | 269 ost << ToStringIfSet("suspend below min bitrate", |
329 suspend_below_min_bitrate); | 270 suspend_below_min_bitrate); |
330 ost << ToStringIfSet("num channels for early receive", | 271 ost << ToStringIfSet("screencast min bitrate kbps", |
331 unsignalled_recv_stream_limit); | 272 screencast_min_bitrate_kbps); |
332 ost << ToStringIfSet("use simulcast adapter", use_simulcast_adapter); | |
333 ost << ToStringIfSet("screencast min bitrate", screencast_min_bitrate); | |
334 ost << "}"; | 273 ost << "}"; |
335 return ost.str(); | 274 return ost.str(); |
336 } | 275 } |
337 | 276 |
338 // Enable CPU adaptation? | 277 // Enable denoising? This flag comes from the getUserMedia |
339 rtc::Optional<bool> adapt_input_to_cpu_usage; | 278 // constraint 'googNoiseReduction', and WebRtcVideoEngine2 passes it |
340 // Enable CPU adaptation smoothing? | 279 // on to the codec options. Disabled by default. |
341 rtc::Optional<bool> adapt_cpu_with_smoothing; | |
342 // Enable video adapt third? | |
343 rtc::Optional<bool> video_adapt_third; | |
344 // Enable denoising? | |
345 rtc::Optional<bool> video_noise_reduction; | 280 rtc::Optional<bool> video_noise_reduction; |
346 // Experimental: Enable WebRtc higher start bitrate? | 281 // Enable WebRTC Cpu Overuse Detection. This flag comes from the |
347 rtc::Optional<int> video_start_bitrate; | 282 // PeerConnection constraint 'googCpuOveruseDetection' and is |
348 // Enable WebRTC Cpu Overuse Detection, which is a new version of the CPU | 283 // checked in WebRtcVideoChannel2::OnLoadUpdate, where it's passed |
349 // adaptation algorithm. So this option will override the | 284 // to VideoCapturer::video_adapter()->OnCpuResolutionRequest. |
350 // |adapt_input_to_cpu_usage|. | |
351 rtc::Optional<bool> cpu_overuse_detection; | 285 rtc::Optional<bool> cpu_overuse_detection; |
352 // Low threshold (t1) for cpu overuse adaptation. (Adapt up) | 286 // Use conference mode? This flag comes from the remote |
353 // Metric: encode usage (m1). m1 < t1 => underuse. | 287 // description's SDP line 'a=x-google-flag:conference', copied over |
354 rtc::Optional<int> cpu_underuse_threshold; | 288 // by VideoChannel::SetRemoteContent_w, and ultimately used by |
355 // High threshold (t1) for cpu overuse adaptation. (Adapt down) | 289 // conference mode screencast logic in |
356 // Metric: encode usage (m1). m1 > t1 => overuse. | 290 // WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig. |
357 rtc::Optional<int> cpu_overuse_threshold; | 291 // The special screencast behaviour is disabled by default. |
358 // Low threshold (t2) for cpu overuse adaptation. (Adapt up) | |
359 // Metric: relative standard deviation of encode time (m2). | |
360 // Optional threshold. If set, (m1 < t1 && m2 < t2) => underuse. | |
361 // Note: t2 will have no effect if t1 is not set. | |
362 rtc::Optional<int> cpu_underuse_encode_rsd_threshold; | |
363 // High threshold (t2) for cpu overuse adaptation. (Adapt down) | |
364 // Metric: relative standard deviation of encode time (m2). | |
365 // Optional threshold. If set, (m1 > t1 || m2 > t2) => overuse. | |
366 // Note: t2 will have no effect if t1 is not set. | |
367 rtc::Optional<int> cpu_overuse_encode_rsd_threshold; | |
368 // Use encode usage for cpu detection. | |
369 rtc::Optional<bool> cpu_overuse_encode_usage; | |
370 // Use conference mode? | |
371 rtc::Optional<bool> conference_mode; | 292 rtc::Optional<bool> conference_mode; |
372 // Threshhold for process cpu adaptation. (Process limit) | 293 // Set DSCP value for packet sent from video channel. This flag |
373 rtc::Optional<float> process_adaptation_threshhold; | 294 // comes from the PeerConnection constraint 'googDscp' and, |
374 // Low threshhold for cpu adaptation. (Adapt up) | 295 // WebRtcVideoChannel2::SetOptions checks it before calling |
375 rtc::Optional<float> system_low_adaptation_threshhold; | 296 // MediaChannel::SetDscp. If enabled, rtc::DSCP_AF41 is used. If |
376 // High threshhold for cpu adaptation. (Adapt down) | 297 // disabled, which is the default, rtc::DSCP_DEFAULT is used. |
377 rtc::Optional<float> system_high_adaptation_threshhold; | |
378 // Set DSCP value for packet sent from video channel. | |
379 rtc::Optional<bool> dscp; | 298 rtc::Optional<bool> dscp; |
380 // Enable WebRTC suspension of video. No video frames will be sent when the | 299 // Enable WebRTC suspension of video. No video frames will be sent |
381 // bitrate is below the configured minimum bitrate. | 300 // when the bitrate is below the configured minimum bitrate. This |
| 301 // flag comes from the PeerConnection constraint |
| 302 // 'googSuspendBelowMinBitrate', and WebRtcVideoChannel2 copies it |
| 303 // to VideoSendStream::Config::suspend_below_min_bitrate. |
382 rtc::Optional<bool> suspend_below_min_bitrate; | 304 rtc::Optional<bool> suspend_below_min_bitrate; |
383 // Limit on the number of early receive channels that can be created. | 305 // Force screencast to use a minimum bitrate. This flag comes from |
384 rtc::Optional<int> unsignalled_recv_stream_limit; | 306 // the PeerConnection constraint 'googScreencastMinBitrate'. It is |
385 // Enable use of simulcast adapter. | 307 // copied to the encoder config by WebRtcVideoChannel2. |
386 rtc::Optional<bool> use_simulcast_adapter; | 308 rtc::Optional<int> screencast_min_bitrate_kbps; |
387 // Force screencast to use a minimum bitrate | |
388 rtc::Optional<int> screencast_min_bitrate; | |
389 // Set to true if the renderer has an algorithm of frame selection. | 309 // Set to true if the renderer has an algorithm of frame selection. |
390 // If the value is true, then WebRTC will hand over a frame as soon as | 310 // If the value is true, then WebRTC will hand over a frame as soon as |
391 // possible without delay, and rendering smoothness is completely the duty | 311 // possible without delay, and rendering smoothness is completely the duty |
392 // of the renderer; | 312 // of the renderer; |
393 // If the value is false, then WebRTC is responsible to delay frame release | 313 // If the value is false, then WebRTC is responsible to delay frame release |
394 // in order to increase rendering smoothness. | 314 // in order to increase rendering smoothness. |
| 315 // |
| 316 // This flag comes from PeerConnection's RtcConfiguration, but is |
| 317 // currently only set by the command line flag |
| 318 // 'disable-rtc-smoothness-algorithm'. |
| 319 // WebRtcVideoChannel2::AddRecvStream copies it to the created |
| 320 // WebRtcVideoReceiveStream, where it is returned by the |
| 321 // SmoothsRenderedFrames method. This method is used by the |
| 322 // VideoReceiveStream, where the value is passed on to the |
| 323 // IncomingVideoStream constructor. |
395 rtc::Optional<bool> disable_prerenderer_smoothing; | 324 rtc::Optional<bool> disable_prerenderer_smoothing; |
396 | 325 |
397 private: | 326 private: |
398 template <typename T> | 327 template <typename T> |
399 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { | 328 static void SetFrom(rtc::Optional<T>* s, const rtc::Optional<T>& o) { |
400 if (o) { | 329 if (o) { |
401 *s = o; | 330 *s = o; |
402 } | 331 } |
403 } | 332 } |
404 }; | 333 }; |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 // Signal when the media channel is ready to send the stream. Arguments are: | 1137 // Signal when the media channel is ready to send the stream. Arguments are: |
1209 // writable(bool) | 1138 // writable(bool) |
1210 sigslot::signal1<bool> SignalReadyToSend; | 1139 sigslot::signal1<bool> SignalReadyToSend; |
1211 // Signal for notifying that the remote side has closed the DataChannel. | 1140 // Signal for notifying that the remote side has closed the DataChannel. |
1212 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; | 1141 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; |
1213 }; | 1142 }; |
1214 | 1143 |
1215 } // namespace cricket | 1144 } // namespace cricket |
1216 | 1145 |
1217 #endif // TALK_MEDIA_BASE_MEDIACHANNEL_H_ | 1146 #endif // TALK_MEDIA_BASE_MEDIACHANNEL_H_ |
OLD | NEW |