OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 case VideoEncoderConfig::ContentType::kScreen: | 59 case VideoEncoderConfig::ContentType::kScreen: |
60 video_codec.mode = kScreensharing; | 60 video_codec.mode = kScreensharing; |
61 if (config.streams.size() == 1 && | 61 if (config.streams.size() == 1 && |
62 config.streams[0].temporal_layer_thresholds_bps.size() == 1) { | 62 config.streams[0].temporal_layer_thresholds_bps.size() == 1) { |
63 video_codec.targetBitrate = | 63 video_codec.targetBitrate = |
64 config.streams[0].temporal_layer_thresholds_bps[0] / 1000; | 64 config.streams[0].temporal_layer_thresholds_bps[0] / 1000; |
65 } | 65 } |
66 break; | 66 break; |
67 } | 67 } |
68 | 68 |
| 69 if (config.encoder_specific_settings) |
| 70 config.encoder_specific_settings->FillEncoderSpecificSettings(&video_codec); |
| 71 |
69 switch (video_codec.codecType) { | 72 switch (video_codec.codecType) { |
70 case kVideoCodecVP8: { | 73 case kVideoCodecVP8: { |
71 if (config.encoder_specific_settings) { | 74 if (!config.encoder_specific_settings) |
72 video_codec.codecSpecific.VP8 = *reinterpret_cast<const VideoCodecVP8*>( | |
73 config.encoder_specific_settings); | |
74 } else { | |
75 video_codec.codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings(); | 75 video_codec.codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings(); |
76 } | |
77 video_codec.codecSpecific.VP8.numberOfTemporalLayers = | 76 video_codec.codecSpecific.VP8.numberOfTemporalLayers = |
78 static_cast<unsigned char>( | 77 static_cast<unsigned char>( |
79 streams.back().temporal_layer_thresholds_bps.size() + 1); | 78 streams.back().temporal_layer_thresholds_bps.size() + 1); |
80 break; | 79 break; |
81 } | 80 } |
82 case kVideoCodecVP9: { | 81 case kVideoCodecVP9: { |
83 if (config.encoder_specific_settings) { | 82 if (!config.encoder_specific_settings) |
84 video_codec.codecSpecific.VP9 = *reinterpret_cast<const VideoCodecVP9*>( | |
85 config.encoder_specific_settings); | |
86 if (video_codec.mode == kScreensharing) { | |
87 video_codec.codecSpecific.VP9.flexibleMode = true; | |
88 // For now VP9 screensharing use 1 temporal and 2 spatial layers. | |
89 RTC_DCHECK_EQ(video_codec.codecSpecific.VP9.numberOfTemporalLayers, | |
90 1); | |
91 RTC_DCHECK_EQ(video_codec.codecSpecific.VP9.numberOfSpatialLayers, 2); | |
92 } | |
93 } else { | |
94 video_codec.codecSpecific.VP9 = VideoEncoder::GetDefaultVp9Settings(); | 83 video_codec.codecSpecific.VP9 = VideoEncoder::GetDefaultVp9Settings(); |
| 84 if (video_codec.mode == kScreensharing && |
| 85 config.encoder_specific_settings) { |
| 86 video_codec.codecSpecific.VP9.flexibleMode = true; |
| 87 // For now VP9 screensharing use 1 temporal and 2 spatial layers. |
| 88 RTC_DCHECK_EQ(1, video_codec.codecSpecific.VP9.numberOfTemporalLayers); |
| 89 RTC_DCHECK_EQ(2, video_codec.codecSpecific.VP9.numberOfSpatialLayers); |
95 } | 90 } |
96 video_codec.codecSpecific.VP9.numberOfTemporalLayers = | 91 video_codec.codecSpecific.VP9.numberOfTemporalLayers = |
97 static_cast<unsigned char>( | 92 static_cast<unsigned char>( |
98 streams.back().temporal_layer_thresholds_bps.size() + 1); | 93 streams.back().temporal_layer_thresholds_bps.size() + 1); |
99 break; | 94 break; |
100 } | 95 } |
101 case kVideoCodecH264: { | 96 case kVideoCodecH264: { |
102 if (config.encoder_specific_settings) { | 97 if (!config.encoder_specific_settings) |
103 video_codec.codecSpecific.H264 = | |
104 *reinterpret_cast<const VideoCodecH264*>( | |
105 config.encoder_specific_settings); | |
106 } else { | |
107 video_codec.codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings(); | 98 video_codec.codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings(); |
108 } | |
109 break; | 99 break; |
110 } | 100 } |
111 default: | 101 default: |
112 // TODO(pbos): Support encoder_settings codec-agnostically. | 102 // TODO(pbos): Support encoder_settings codec-agnostically. |
113 RTC_DCHECK(!config.encoder_specific_settings) | 103 RTC_DCHECK(!config.encoder_specific_settings) |
114 << "Encoder-specific settings for codec type not wired up."; | 104 << "Encoder-specific settings for codec type not wired up."; |
115 break; | 105 break; |
116 } | 106 } |
117 | 107 |
118 strncpy(video_codec.plName, payload_name.c_str(), kPayloadNameSize - 1); | 108 strncpy(video_codec.plName, payload_name.c_str(), kPayloadNameSize - 1); |
(...skipping 29 matching lines...) Expand all Loading... |
148 | 138 |
149 sim_stream->width = static_cast<uint16_t>(streams[i].width); | 139 sim_stream->width = static_cast<uint16_t>(streams[i].width); |
150 sim_stream->height = static_cast<uint16_t>(streams[i].height); | 140 sim_stream->height = static_cast<uint16_t>(streams[i].height); |
151 sim_stream->minBitrate = streams[i].min_bitrate_bps / 1000; | 141 sim_stream->minBitrate = streams[i].min_bitrate_bps / 1000; |
152 sim_stream->targetBitrate = streams[i].target_bitrate_bps / 1000; | 142 sim_stream->targetBitrate = streams[i].target_bitrate_bps / 1000; |
153 sim_stream->maxBitrate = streams[i].max_bitrate_bps / 1000; | 143 sim_stream->maxBitrate = streams[i].max_bitrate_bps / 1000; |
154 sim_stream->qpMax = streams[i].max_qp; | 144 sim_stream->qpMax = streams[i].max_qp; |
155 sim_stream->numberOfTemporalLayers = static_cast<unsigned char>( | 145 sim_stream->numberOfTemporalLayers = static_cast<unsigned char>( |
156 streams[i].temporal_layer_thresholds_bps.size() + 1); | 146 streams[i].temporal_layer_thresholds_bps.size() + 1); |
157 | 147 |
158 video_codec.width = | 148 video_codec.width = std::max(video_codec.width, |
159 std::max(video_codec.width, static_cast<uint16_t>(streams[i].width)); | 149 static_cast<uint16_t>(streams[i].width)); |
160 video_codec.height = | 150 video_codec.height = std::max( |
161 std::max(video_codec.height, static_cast<uint16_t>(streams[i].height)); | 151 video_codec.height, static_cast<uint16_t>(streams[i].height)); |
162 video_codec.minBitrate = | 152 video_codec.minBitrate = |
163 std::min(static_cast<uint16_t>(video_codec.minBitrate), | 153 std::min(static_cast<uint16_t>(video_codec.minBitrate), |
164 static_cast<uint16_t>(streams[i].min_bitrate_bps / 1000)); | 154 static_cast<uint16_t>(streams[i].min_bitrate_bps / 1000)); |
165 video_codec.maxBitrate += streams[i].max_bitrate_bps / 1000; | 155 video_codec.maxBitrate += streams[i].max_bitrate_bps / 1000; |
166 video_codec.qpMax = std::max(video_codec.qpMax, | 156 video_codec.qpMax = std::max(video_codec.qpMax, |
167 static_cast<unsigned int>(streams[i].max_qp)); | 157 static_cast<unsigned int>(streams[i].max_qp)); |
168 } | 158 } |
169 | 159 |
170 if (video_codec.maxBitrate == 0) { | 160 if (video_codec.maxBitrate == 0) { |
171 // Unset max bitrate -> cap to one bit per pixel. | 161 // Unset max bitrate -> cap to one bit per pixel. |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 load_observer_->OnLoadUpdate(LoadObserver::kOveruse); | 661 load_observer_->OnLoadUpdate(LoadObserver::kOveruse); |
672 } | 662 } |
673 | 663 |
674 void ViEEncoder::NormalUsage() { | 664 void ViEEncoder::NormalUsage() { |
675 RTC_DCHECK_RUN_ON(&encoder_queue_); | 665 RTC_DCHECK_RUN_ON(&encoder_queue_); |
676 if (load_observer_) | 666 if (load_observer_) |
677 load_observer_->OnLoadUpdate(LoadObserver::kUnderuse); | 667 load_observer_->OnLoadUpdate(LoadObserver::kUnderuse); |
678 } | 668 } |
679 | 669 |
680 } // namespace webrtc | 670 } // namespace webrtc |
OLD | NEW |