| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
| 11 #include "webrtc/media/engine/webrtcvideoengine2.h" | 11 #include "webrtc/media/engine/webrtcvideoengine2.h" |
| 12 | 12 |
| 13 #include <stdio.h> |
| 13 #include <algorithm> | 14 #include <algorithm> |
| 14 #include <set> | 15 #include <set> |
| 15 #include <string> | 16 #include <string> |
| 16 | 17 |
| 17 #include "webrtc/base/buffer.h" | 18 #include "webrtc/base/buffer.h" |
| 18 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
| 19 #include "webrtc/base/stringutils.h" | 20 #include "webrtc/base/stringutils.h" |
| 20 #include "webrtc/base/timeutils.h" | 21 #include "webrtc/base/timeutils.h" |
| 21 #include "webrtc/base/trace_event.h" | 22 #include "webrtc/base/trace_event.h" |
| 22 #include "webrtc/call.h" | 23 #include "webrtc/call.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 return 600; | 309 return 600; |
| 309 } else if (width * height <= 640 * 480) { | 310 } else if (width * height <= 640 * 480) { |
| 310 return 1700; | 311 return 1700; |
| 311 } else if (width * height <= 960 * 540) { | 312 } else if (width * height <= 960 * 540) { |
| 312 return 2000; | 313 return 2000; |
| 313 } else { | 314 } else { |
| 314 return 2500; | 315 return 2500; |
| 315 } | 316 } |
| 316 } | 317 } |
| 317 | 318 |
| 319 bool GetVp9LayersFromFieldTrialGroup(int* num_spatial_layers, |
| 320 int* num_temporal_layers) { |
| 321 std::string group = webrtc::field_trial::FindFullName("WebRTC-SupportVP9SVC"); |
| 322 if (group.empty()) |
| 323 return false; |
| 324 |
| 325 if (sscanf(group.c_str(), "EnabledByFlag_%dSL%dTL", num_spatial_layers, |
| 326 num_temporal_layers) != 2) { |
| 327 return false; |
| 328 } |
| 329 const int kMaxSpatialLayers = 3; |
| 330 if (*num_spatial_layers > kMaxSpatialLayers || *num_spatial_layers < 1) |
| 331 return false; |
| 332 |
| 333 const int kMaxTemporalLayers = 3; |
| 334 if (*num_temporal_layers > kMaxTemporalLayers || *num_temporal_layers < 1) |
| 335 return false; |
| 336 |
| 337 return true; |
| 338 } |
| 339 |
| 340 int GetDefaultVp9SpatialLayers() { |
| 341 int num_sl; |
| 342 int num_tl; |
| 343 if (GetVp9LayersFromFieldTrialGroup(&num_sl, &num_tl)) { |
| 344 return num_sl; |
| 345 } |
| 346 return 1; |
| 347 } |
| 348 |
| 349 int GetDefaultVp9TemporalLayers() { |
| 350 int num_sl; |
| 351 int num_tl; |
| 352 if (GetVp9LayersFromFieldTrialGroup(&num_sl, &num_tl)) { |
| 353 return num_tl; |
| 354 } |
| 355 return 1; |
| 356 } |
| 318 } // namespace | 357 } // namespace |
| 319 | 358 |
| 320 // Constants defined in webrtc/media/engine/constants.h | 359 // Constants defined in webrtc/media/engine/constants.h |
| 321 // TODO(pbos): Move these to a separate constants.cc file. | 360 // TODO(pbos): Move these to a separate constants.cc file. |
| 322 const int kMinVideoBitrate = 30; | 361 const int kMinVideoBitrate = 30; |
| 323 const int kStartVideoBitrate = 300; | 362 const int kStartVideoBitrate = 300; |
| 324 | 363 |
| 325 const int kVideoMtu = 1200; | 364 const int kVideoMtu = 1200; |
| 326 const int kVideoRtpBufferSize = 65536; | 365 const int kVideoRtpBufferSize = 65536; |
| 327 | 366 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); | 475 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); |
| 437 encoder_settings_.vp8.automaticResizeOn = automatic_resize; | 476 encoder_settings_.vp8.automaticResizeOn = automatic_resize; |
| 438 // VP8 denoising is enabled by default. | 477 // VP8 denoising is enabled by default. |
| 439 encoder_settings_.vp8.denoisingOn = | 478 encoder_settings_.vp8.denoisingOn = |
| 440 codec_default_denoising ? true : denoising; | 479 codec_default_denoising ? true : denoising; |
| 441 encoder_settings_.vp8.frameDroppingOn = frame_dropping; | 480 encoder_settings_.vp8.frameDroppingOn = frame_dropping; |
| 442 return &encoder_settings_.vp8; | 481 return &encoder_settings_.vp8; |
| 443 } | 482 } |
| 444 if (CodecNamesEq(codec.name, kVp9CodecName)) { | 483 if (CodecNamesEq(codec.name, kVp9CodecName)) { |
| 445 encoder_settings_.vp9 = webrtc::VideoEncoder::GetDefaultVp9Settings(); | 484 encoder_settings_.vp9 = webrtc::VideoEncoder::GetDefaultVp9Settings(); |
| 485 if (is_screencast) { |
| 486 // TODO(asapersson): Set to 2 for now since there is a DCHECK in |
| 487 // VideoSendStream::ReconfigureVideoEncoder. |
| 488 encoder_settings_.vp9.numberOfSpatialLayers = 2; |
| 489 } else { |
| 490 encoder_settings_.vp9.numberOfSpatialLayers = |
| 491 GetDefaultVp9SpatialLayers(); |
| 492 } |
| 446 // VP9 denoising is disabled by default. | 493 // VP9 denoising is disabled by default. |
| 447 encoder_settings_.vp9.denoisingOn = | 494 encoder_settings_.vp9.denoisingOn = |
| 448 codec_default_denoising ? false : denoising; | 495 codec_default_denoising ? false : denoising; |
| 449 encoder_settings_.vp9.frameDroppingOn = frame_dropping; | 496 encoder_settings_.vp9.frameDroppingOn = frame_dropping; |
| 450 return &encoder_settings_.vp9; | 497 return &encoder_settings_.vp9; |
| 451 } | 498 } |
| 452 return NULL; | 499 return NULL; |
| 453 } | 500 } |
| 454 | 501 |
| 455 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() | 502 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() |
| (...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked | 1910 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked |
| 1864 // on the VideoCodec struct as target and max bitrates, respectively. | 1911 // on the VideoCodec struct as target and max bitrates, respectively. |
| 1865 // See eg. webrtc::VP8EncoderImpl::SetRates(). | 1912 // See eg. webrtc::VP8EncoderImpl::SetRates(). |
| 1866 encoder_config.streams[0].target_bitrate_bps = | 1913 encoder_config.streams[0].target_bitrate_bps = |
| 1867 config.tl0_bitrate_kbps * 1000; | 1914 config.tl0_bitrate_kbps * 1000; |
| 1868 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; | 1915 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; |
| 1869 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); | 1916 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); |
| 1870 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back( | 1917 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back( |
| 1871 config.tl0_bitrate_kbps * 1000); | 1918 config.tl0_bitrate_kbps * 1000); |
| 1872 } | 1919 } |
| 1920 if (CodecNamesEq(codec.name, kVp9CodecName) && !is_screencast && |
| 1921 encoder_config.streams.size() == 1) { |
| 1922 encoder_config.streams[0].temporal_layer_thresholds_bps.resize( |
| 1923 GetDefaultVp9TemporalLayers() - 1); |
| 1924 } |
| 1873 return encoder_config; | 1925 return encoder_config; |
| 1874 } | 1926 } |
| 1875 | 1927 |
| 1876 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( | 1928 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( |
| 1877 int width, | 1929 int width, |
| 1878 int height) { | 1930 int height) { |
| 1879 if (last_dimensions_.width == width && last_dimensions_.height == height && | 1931 if (last_dimensions_.width == width && last_dimensions_.height == height && |
| 1880 !pending_encoder_reconfiguration_) { | 1932 !pending_encoder_reconfiguration_) { |
| 1881 // Configured using the same parameters, do not reconfigure. | 1933 // Configured using the same parameters, do not reconfigure. |
| 1882 return; | 1934 return; |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2531 rtx_mapping[video_codecs[i].codec.id] != | 2583 rtx_mapping[video_codecs[i].codec.id] != |
| 2532 fec_settings.red_payload_type) { | 2584 fec_settings.red_payload_type) { |
| 2533 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2585 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2534 } | 2586 } |
| 2535 } | 2587 } |
| 2536 | 2588 |
| 2537 return video_codecs; | 2589 return video_codecs; |
| 2538 } | 2590 } |
| 2539 | 2591 |
| 2540 } // namespace cricket | 2592 } // namespace cricket |
| OLD | NEW |