| 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 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 bool VideoCodecInitializer::SetupCodec( | 35 bool VideoCodecInitializer::SetupCodec( |
| 36 const VideoEncoderConfig& config, | 36 const VideoEncoderConfig& config, |
| 37 const VideoSendStream::Config::EncoderSettings settings, | 37 const VideoSendStream::Config::EncoderSettings settings, |
| 38 const std::vector<VideoStream>& streams, | 38 const std::vector<VideoStream>& streams, |
| 39 bool nack_enabled, | 39 bool nack_enabled, |
| 40 VideoCodec* codec, | 40 VideoCodec* codec, |
| 41 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) { | 41 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) { |
| 42 *codec = | 42 *codec = VideoEncoderConfigToVideoCodec( |
| 43 VideoEncoderConfigToVideoCodec(config, streams, settings.payload_name, | 43 config, streams, settings.payload_name, settings.payload_type, |
| 44 settings.payload_type, nack_enabled); | 44 settings.stereo_associated_payload_name, nack_enabled); |
| 45 | 45 |
| 46 std::unique_ptr<TemporalLayersFactory> tl_factory; | 46 std::unique_ptr<TemporalLayersFactory> tl_factory; |
| 47 switch (codec->codecType) { | 47 switch (codec->codecType) { |
| 48 case kVideoCodecVP8: { | 48 case kVideoCodecVP8: { |
| 49 if (!codec->VP8()->tl_factory) { | 49 if (!codec->VP8()->tl_factory) { |
| 50 if (codec->mode == kScreensharing && | 50 if (codec->mode == kScreensharing && |
| 51 (codec->numberOfSimulcastStreams > 1 || | 51 (codec->numberOfSimulcastStreams > 1 || |
| 52 (codec->numberOfSimulcastStreams == 1 && | 52 (codec->numberOfSimulcastStreams == 1 && |
| 53 codec->VP8()->numberOfTemporalLayers == 2))) { | 53 codec->VP8()->numberOfTemporalLayers == 2))) { |
| 54 // Conference mode temporal layering for screen content. | 54 // Conference mode temporal layering for screen content. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 return rate_allocator; | 91 return rate_allocator; |
| 92 } | 92 } |
| 93 | 93 |
| 94 // TODO(sprang): Split this up and separate the codec specific parts. | 94 // TODO(sprang): Split this up and separate the codec specific parts. |
| 95 VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec( | 95 VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec( |
| 96 const VideoEncoderConfig& config, | 96 const VideoEncoderConfig& config, |
| 97 const std::vector<VideoStream>& streams, | 97 const std::vector<VideoStream>& streams, |
| 98 const std::string& payload_name, | 98 const std::string& payload_name, |
| 99 int payload_type, | 99 int payload_type, |
| 100 const std::string& stereo_associated_payload_name, |
| 100 bool nack_enabled) { | 101 bool nack_enabled) { |
| 101 static const int kEncoderMinBitrateKbps = 30; | 102 static const int kEncoderMinBitrateKbps = 30; |
| 102 RTC_DCHECK(!streams.empty()); | 103 RTC_DCHECK(!streams.empty()); |
| 103 RTC_DCHECK_GE(config.min_transmit_bitrate_bps, 0); | 104 RTC_DCHECK_GE(config.min_transmit_bitrate_bps, 0); |
| 104 | 105 |
| 105 VideoCodec video_codec; | 106 VideoCodec video_codec; |
| 106 memset(&video_codec, 0, sizeof(video_codec)); | 107 memset(&video_codec, 0, sizeof(video_codec)); |
| 107 video_codec.codecType = PayloadStringToCodecType(payload_name); | 108 video_codec.codecType = PayloadStringToCodecType(payload_name); |
| 108 | 109 |
| 110 const bool is_stereo_codec = video_codec.codecType == kVideoCodecStereo; |
| 111 if (is_stereo_codec) { |
| 112 video_codec.codecType = |
| 113 PayloadStringToCodecType(stereo_associated_payload_name); |
| 114 } |
| 115 |
| 109 switch (config.content_type) { | 116 switch (config.content_type) { |
| 110 case VideoEncoderConfig::ContentType::kRealtimeVideo: | 117 case VideoEncoderConfig::ContentType::kRealtimeVideo: |
| 111 video_codec.mode = kRealtimeVideo; | 118 video_codec.mode = kRealtimeVideo; |
| 112 break; | 119 break; |
| 113 case VideoEncoderConfig::ContentType::kScreen: | 120 case VideoEncoderConfig::ContentType::kScreen: |
| 114 video_codec.mode = kScreensharing; | 121 video_codec.mode = kScreensharing; |
| 115 if (!streams.empty() && | 122 if (!streams.empty() && |
| 116 streams[0].temporal_layer_thresholds_bps.size() == 1) { | 123 streams[0].temporal_layer_thresholds_bps.size() == 1) { |
| 117 video_codec.targetBitrate = | 124 video_codec.targetBitrate = |
| 118 streams[0].temporal_layer_thresholds_bps[0] / 1000; | 125 streams[0].temporal_layer_thresholds_bps[0] / 1000; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // Unset max bitrate -> cap to one bit per pixel. | 238 // Unset max bitrate -> cap to one bit per pixel. |
| 232 video_codec.maxBitrate = | 239 video_codec.maxBitrate = |
| 233 (video_codec.width * video_codec.height * video_codec.maxFramerate) / | 240 (video_codec.width * video_codec.height * video_codec.maxFramerate) / |
| 234 1000; | 241 1000; |
| 235 } | 242 } |
| 236 if (video_codec.maxBitrate < kEncoderMinBitrateKbps) | 243 if (video_codec.maxBitrate < kEncoderMinBitrateKbps) |
| 237 video_codec.maxBitrate = kEncoderMinBitrateKbps; | 244 video_codec.maxBitrate = kEncoderMinBitrateKbps; |
| 238 | 245 |
| 239 RTC_DCHECK_GT(streams[0].max_framerate, 0); | 246 RTC_DCHECK_GT(streams[0].max_framerate, 0); |
| 240 video_codec.maxFramerate = streams[0].max_framerate; | 247 video_codec.maxFramerate = streams[0].max_framerate; |
| 248 |
| 249 if (is_stereo_codec) |
| 250 video_codec.codecType = kVideoCodecStereo; |
| 251 |
| 241 return video_codec; | 252 return video_codec; |
| 242 } | 253 } |
| 243 | 254 |
| 244 } // namespace webrtc | 255 } // namespace webrtc |
| OLD | NEW |