OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 302 } |
303 output->red_rtx_payload_type = other.red_rtx_payload_type; | 303 output->red_rtx_payload_type = other.red_rtx_payload_type; |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 // Returns true if the given codec is disallowed from doing simulcast. | 307 // Returns true if the given codec is disallowed from doing simulcast. |
308 bool IsCodecBlacklistedForSimulcast(const std::string& codec_name) { | 308 bool IsCodecBlacklistedForSimulcast(const std::string& codec_name) { |
309 return CodecNamesEq(codec_name, kH264CodecName); | 309 return CodecNamesEq(codec_name, kH264CodecName); |
310 } | 310 } |
311 | 311 |
| 312 // The selected thresholds for QVGA and VGA corresponded to a QP around 10. |
| 313 // The change in QP declined above the selected bitrates. |
| 314 static int GetMaxDefaultVideoBitrateKbps(int width, int height) { |
| 315 if (width * height <= 320 * 240) { |
| 316 return 600; |
| 317 } else if (width * height <= 640 * 480) { |
| 318 return 1700; |
| 319 } else if (width * height <= 960 * 540) { |
| 320 return 2000; |
| 321 } else { |
| 322 return 2500; |
| 323 } |
| 324 } |
312 } // namespace | 325 } // namespace |
313 | 326 |
314 // Constants defined in talk/media/webrtc/constants.h | 327 // Constants defined in talk/media/webrtc/constants.h |
315 // TODO(pbos): Move these to a separate constants.cc file. | 328 // TODO(pbos): Move these to a separate constants.cc file. |
316 const int kMinVideoBitrate = 30; | 329 const int kMinVideoBitrate = 30; |
317 const int kStartVideoBitrate = 300; | 330 const int kStartVideoBitrate = 300; |
318 const int kMaxVideoBitrate = 2000; | |
319 | 331 |
320 const int kVideoMtu = 1200; | 332 const int kVideoMtu = 1200; |
321 const int kVideoRtpBufferSize = 65536; | 333 const int kVideoRtpBufferSize = 65536; |
322 | 334 |
323 // This constant is really an on/off, lower-level configurable NACK history | 335 // This constant is really an on/off, lower-level configurable NACK history |
324 // duration hasn't been implemented. | 336 // duration hasn't been implemented. |
325 static const int kNackHistoryMs = 1000; | 337 static const int kNackHistoryMs = 1000; |
326 | 338 |
327 static const int kDefaultQpMax = 56; | 339 static const int kDefaultQpMax = 56; |
328 | 340 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 int codec_max_bitrate_kbps; | 454 int codec_max_bitrate_kbps; |
443 if (codec.GetParam(kCodecParamMaxBitrate, &codec_max_bitrate_kbps)) { | 455 if (codec.GetParam(kCodecParamMaxBitrate, &codec_max_bitrate_kbps)) { |
444 max_bitrate_bps = codec_max_bitrate_kbps * 1000; | 456 max_bitrate_bps = codec_max_bitrate_kbps * 1000; |
445 } | 457 } |
446 if (num_streams != 1) { | 458 if (num_streams != 1) { |
447 return CreateSimulcastVideoStreams(codec, options, max_bitrate_bps, | 459 return CreateSimulcastVideoStreams(codec, options, max_bitrate_bps, |
448 num_streams); | 460 num_streams); |
449 } | 461 } |
450 | 462 |
451 // For unset max bitrates set default bitrate for non-simulcast. | 463 // For unset max bitrates set default bitrate for non-simulcast. |
452 if (max_bitrate_bps <= 0) | 464 if (max_bitrate_bps <= 0) { |
453 max_bitrate_bps = kMaxVideoBitrate * 1000; | 465 max_bitrate_bps = |
| 466 GetMaxDefaultVideoBitrateKbps(codec.width, codec.height) * 1000; |
| 467 } |
454 | 468 |
455 webrtc::VideoStream stream; | 469 webrtc::VideoStream stream; |
456 stream.width = codec.width; | 470 stream.width = codec.width; |
457 stream.height = codec.height; | 471 stream.height = codec.height; |
458 stream.max_framerate = | 472 stream.max_framerate = |
459 codec.framerate != 0 ? codec.framerate : kDefaultVideoMaxFramerate; | 473 codec.framerate != 0 ? codec.framerate : kDefaultVideoMaxFramerate; |
460 | 474 |
461 stream.min_bitrate_bps = kMinVideoBitrate * 1000; | 475 stream.min_bitrate_bps = kMinVideoBitrate * 1000; |
462 stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps; | 476 stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps; |
463 | 477 |
(...skipping 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2744 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2758 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2745 } | 2759 } |
2746 } | 2760 } |
2747 | 2761 |
2748 return video_codecs; | 2762 return video_codecs; |
2749 } | 2763 } |
2750 | 2764 |
2751 } // namespace cricket | 2765 } // namespace cricket |
2752 | 2766 |
2753 #endif // HAVE_WEBRTC_VIDEO | 2767 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |