| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 uint32_t target_bitrate_kbps = | 100 uint32_t target_bitrate_kbps = |
| 101 allocated_bitrates_bps.GetBitrate(simulcast_id, 0) / 1000; | 101 allocated_bitrates_bps.GetBitrate(simulcast_id, 0) / 1000; |
| 102 const uint32_t expected_allocated_bitrate_kbps = target_bitrate_kbps; | 102 const uint32_t expected_allocated_bitrate_kbps = target_bitrate_kbps; |
| 103 RTC_DCHECK_EQ( | 103 RTC_DCHECK_EQ( |
| 104 target_bitrate_kbps, | 104 target_bitrate_kbps, |
| 105 allocated_bitrates_bps.GetSpatialLayerSum(simulcast_id) / 1000); | 105 allocated_bitrates_bps.GetSpatialLayerSum(simulcast_id) / 1000); |
| 106 const int num_temporal_streams = std::max<uint8_t>( | 106 const int num_temporal_streams = std::max<uint8_t>( |
| 107 1, codec_.numberOfSimulcastStreams == 0 | 107 1, codec_.numberOfSimulcastStreams == 0 |
| 108 ? codec_.VP8().numberOfTemporalLayers | 108 ? codec_.VP8().numberOfTemporalLayers |
| 109 : codec_.simulcastStream[0].numberOfTemporalLayers); | 109 : codec_.simulcastStream[simulcast_id].numberOfTemporalLayers); |
| 110 | 110 |
| 111 uint32_t max_bitrate_kbps; | 111 uint32_t max_bitrate_kbps; |
| 112 if (num_spatial_streams == 1) { | 112 // Legacy temporal-layered only screenshare, or simulcast screenshare |
| 113 max_bitrate_kbps = codec_.maxBitrate; | 113 // with legacy mode for simulcast stream 0. |
| 114 | 114 if (codec_.mode == kScreensharing && codec_.targetBitrate > 0 && |
| 115 // TODO(holmer): This is a temporary hack for screensharing, where we | 115 ((num_spatial_streams == 1 && num_temporal_streams == 2) || // Legacy. |
| 116 (num_spatial_streams > 1 && simulcast_id == 0))) { // Simulcast. |
| 117 // TODO(holmer): This is a "temporary" hack for screensharing, where we |
| 116 // interpret the startBitrate as the encoder target bitrate. This is | 118 // interpret the startBitrate as the encoder target bitrate. This is |
| 117 // to allow for a different max bitrate, so if the codec can't meet | 119 // to allow for a different max bitrate, so if the codec can't meet |
| 118 // the target we still allow it to overshoot up to the max before dropping | 120 // the target we still allow it to overshoot up to the max before dropping |
| 119 // frames. This hack should be improved. | 121 // frames. This hack should be improved. |
| 120 if (codec_.mode == kScreensharing && codec_.targetBitrate > 0 && | 122 int tl0_bitrate = std::min(codec_.targetBitrate, target_bitrate_kbps); |
| 121 num_temporal_streams == 2) { | 123 max_bitrate_kbps = std::min(codec_.maxBitrate, target_bitrate_kbps); |
| 122 int tl0_bitrate = std::min(codec_.targetBitrate, target_bitrate_kbps); | 124 target_bitrate_kbps = tl0_bitrate; |
| 123 max_bitrate_kbps = std::min(codec_.maxBitrate, target_bitrate_kbps); | 125 } else if (num_spatial_streams == 1) { |
| 124 target_bitrate_kbps = tl0_bitrate; | 126 max_bitrate_kbps = codec_.maxBitrate; |
| 125 } | |
| 126 } else { | 127 } else { |
| 127 max_bitrate_kbps = codec_.simulcastStream[simulcast_id].maxBitrate; | 128 max_bitrate_kbps = codec_.simulcastStream[simulcast_id].maxBitrate; |
| 128 } | 129 } |
| 129 | 130 |
| 130 std::vector<uint32_t> tl_allocation = tl_it->second->OnRatesUpdated( | 131 std::vector<uint32_t> tl_allocation = tl_it->second->OnRatesUpdated( |
| 131 target_bitrate_kbps, max_bitrate_kbps, framerate); | 132 target_bitrate_kbps, max_bitrate_kbps, framerate); |
| 132 RTC_DCHECK_GT(tl_allocation.size(), 0); | 133 RTC_DCHECK_GT(tl_allocation.size(), 0); |
| 133 RTC_DCHECK_LE(tl_allocation.size(), num_temporal_streams); | 134 RTC_DCHECK_LE(tl_allocation.size(), num_temporal_streams); |
| 134 | 135 |
| 135 uint64_t tl_allocation_sum_kbps = 0; | 136 uint64_t tl_allocation_sum_kbps = 0; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 152 BitrateAllocation allocation = | 153 BitrateAllocation allocation = |
| 153 temp_allocator.GetAllocation(codec_.maxBitrate * 1000, framerate); | 154 temp_allocator.GetAllocation(codec_.maxBitrate * 1000, framerate); |
| 154 return allocation.get_sum_bps(); | 155 return allocation.get_sum_bps(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 const VideoCodec& webrtc::SimulcastRateAllocator::GetCodec() const { | 158 const VideoCodec& webrtc::SimulcastRateAllocator::GetCodec() const { |
| 158 return codec_; | 159 return codec_; |
| 159 } | 160 } |
| 160 | 161 |
| 161 } // namespace webrtc | 162 } // namespace webrtc |
| OLD | NEW |