| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // three, and so on. | 118 // three, and so on. |
| 119 // The VideoEncoder may redistribute bitrates over the temporal layers so a | 119 // The VideoEncoder may redistribute bitrates over the temporal layers so a |
| 120 // bitrate threshold of 100k and an estimate of 105k does not imply that we | 120 // bitrate threshold of 100k and an estimate of 105k does not imply that we |
| 121 // get 100k in one temporal layer and 5k in the other, just that the bitrate | 121 // get 100k in one temporal layer and 5k in the other, just that the bitrate |
| 122 // in the first temporal layer should not exceed 100k. | 122 // in the first temporal layer should not exceed 100k. |
| 123 // TODO(kthelgason): Apart from a special case for two-layer screencast these | 123 // TODO(kthelgason): Apart from a special case for two-layer screencast these |
| 124 // thresholds are not propagated to the VideoEncoder. To be implemented. | 124 // thresholds are not propagated to the VideoEncoder. To be implemented. |
| 125 std::vector<int> temporal_layer_thresholds_bps; | 125 std::vector<int> temporal_layer_thresholds_bps; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 struct VideoEncoderConfig { | 128 class VideoEncoderConfig { |
| 129 public: | 129 public: |
| 130 // These are reference counted to permit copying VideoEncoderConfig and be | 130 // These are reference counted to permit copying VideoEncoderConfig and be |
| 131 // kept alive until all encoder_specific_settings go out of scope. | 131 // kept alive until all encoder_specific_settings go out of scope. |
| 132 // TODO(kthelgason): Consider removing the need for copying VideoEncoderConfig | 132 // TODO(kthelgason): Consider removing the need for copying VideoEncoderConfig |
| 133 // and use rtc::Optional for encoder_specific_settings instead. | 133 // and use rtc::Optional for encoder_specific_settings instead. |
| 134 class EncoderSpecificSettings : public rtc::RefCountInterface { | 134 class EncoderSpecificSettings : public rtc::RefCountInterface { |
| 135 public: | 135 public: |
| 136 // TODO(pbos): Remove FillEncoderSpecificSettings as soon as VideoCodec is | 136 // TODO(pbos): Remove FillEncoderSpecificSettings as soon as VideoCodec is |
| 137 // not in use and encoder implementations ask for codec-specific structs | 137 // not in use and encoder implementations ask for codec-specific structs |
| 138 // directly. | 138 // directly. |
| 139 void FillEncoderSpecificSettings(VideoCodec* codec_struct) const; | 139 void FillEncoderSpecificSettings(VideoCodec* codec_struct) const; |
| 140 | 140 |
| 141 virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const; | 141 virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const; |
| 142 virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const; | 142 virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const; |
| 143 virtual void FillVideoCodecH264(VideoCodecH264* h264_settings) const; | 143 virtual void FillVideoCodecH264(VideoCodecH264* h264_settings) const; |
| 144 private: | 144 private: |
| 145 virtual ~EncoderSpecificSettings() {} | 145 virtual ~EncoderSpecificSettings() {} |
| 146 friend struct VideoEncoderConfig; | 146 friend class VideoEncoderConfig; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 class H264EncoderSpecificSettings : public EncoderSpecificSettings { | 149 class H264EncoderSpecificSettings : public EncoderSpecificSettings { |
| 150 public: | 150 public: |
| 151 explicit H264EncoderSpecificSettings(const VideoCodecH264& specifics); | 151 explicit H264EncoderSpecificSettings(const VideoCodecH264& specifics); |
| 152 virtual void FillVideoCodecH264( | 152 void FillVideoCodecH264(VideoCodecH264* h264_settings) const override; |
| 153 VideoCodecH264* h264_settings) const override; | |
| 154 | 153 |
| 155 private: | 154 private: |
| 156 VideoCodecH264 specifics_; | 155 VideoCodecH264 specifics_; |
| 157 }; | 156 }; |
| 158 | 157 |
| 159 class Vp8EncoderSpecificSettings : public EncoderSpecificSettings { | 158 class Vp8EncoderSpecificSettings : public EncoderSpecificSettings { |
| 160 public: | 159 public: |
| 161 explicit Vp8EncoderSpecificSettings(const VideoCodecVP8& specifics); | 160 explicit Vp8EncoderSpecificSettings(const VideoCodecVP8& specifics); |
| 162 virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const override; | 161 void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const override; |
| 163 | 162 |
| 164 private: | 163 private: |
| 165 VideoCodecVP8 specifics_; | 164 VideoCodecVP8 specifics_; |
| 166 }; | 165 }; |
| 167 | 166 |
| 168 class Vp9EncoderSpecificSettings : public EncoderSpecificSettings { | 167 class Vp9EncoderSpecificSettings : public EncoderSpecificSettings { |
| 169 public: | 168 public: |
| 170 explicit Vp9EncoderSpecificSettings(const VideoCodecVP9& specifics); | 169 explicit Vp9EncoderSpecificSettings(const VideoCodecVP9& specifics); |
| 171 virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const override; | 170 void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const override; |
| 172 | 171 |
| 173 private: | 172 private: |
| 174 VideoCodecVP9 specifics_; | 173 VideoCodecVP9 specifics_; |
| 175 }; | 174 }; |
| 176 | 175 |
| 177 enum class ContentType { | 176 enum class ContentType { |
| 178 kRealtimeVideo, | 177 kRealtimeVideo, |
| 179 kScreen, | 178 kScreen, |
| 180 }; | 179 }; |
| 181 | 180 |
| 181 class VideoStreamFactoryInterface : public rtc::RefCountInterface { |
| 182 public: |
| 183 // An implementation should return a std::vector<VideoStream> with the |
| 184 // wanted VideoStream settings for the given video resolution. |
| 185 // The size of the vector may not be larger than |
| 186 // |encoder_config.number_of_streams|. |
| 187 virtual std::vector<VideoStream> CreateEncoderStreams( |
| 188 int width, |
| 189 int height, |
| 190 const VideoEncoderConfig& encoder_config) = 0; |
| 191 |
| 192 protected: |
| 193 virtual ~VideoStreamFactoryInterface() {} |
| 194 }; |
| 195 |
| 182 VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default; | 196 VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default; |
| 183 VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete; | 197 VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete; |
| 184 | 198 |
| 185 // Mostly used by tests. Avoid creating copies if you can. | 199 // Mostly used by tests. Avoid creating copies if you can. |
| 186 VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); } | 200 VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); } |
| 187 | 201 |
| 188 VideoEncoderConfig(); | 202 VideoEncoderConfig(); |
| 189 VideoEncoderConfig(VideoEncoderConfig&&) = default; | 203 VideoEncoderConfig(VideoEncoderConfig&&) = default; |
| 190 ~VideoEncoderConfig(); | 204 ~VideoEncoderConfig(); |
| 191 std::string ToString() const; | 205 std::string ToString() const; |
| 192 | 206 |
| 193 std::vector<VideoStream> streams; | 207 rtc::scoped_refptr<VideoStreamFactoryInterface> video_stream_factory; |
| 194 std::vector<SpatialLayer> spatial_layers; | 208 std::vector<SpatialLayer> spatial_layers; |
| 195 ContentType content_type; | 209 ContentType content_type; |
| 196 rtc::scoped_refptr<const EncoderSpecificSettings> encoder_specific_settings; | 210 rtc::scoped_refptr<const EncoderSpecificSettings> encoder_specific_settings; |
| 197 | 211 |
| 198 // Padding will be used up to this bitrate regardless of the bitrate produced | 212 // Padding will be used up to this bitrate regardless of the bitrate produced |
| 199 // by the encoder. Padding above what's actually produced by the encoder helps | 213 // by the encoder. Padding above what's actually produced by the encoder helps |
| 200 // maintaining a higher bitrate estimate. Padding will however not be sent | 214 // maintaining a higher bitrate estimate. Padding will however not be sent |
| 201 // unless the estimated bandwidth indicates that the link can handle it. | 215 // unless the estimated bandwidth indicates that the link can handle it. |
| 202 int min_transmit_bitrate_bps; | 216 int min_transmit_bitrate_bps; |
| 203 bool expect_encode_from_texture; | 217 int max_bitrate_bps; |
| 218 |
| 219 // Max number of encoded VideoStreams to produce. |
| 220 size_t number_of_streams; |
| 204 | 221 |
| 205 private: | 222 private: |
| 206 // Access to the copy constructor is private to force use of the Copy() | 223 // Access to the copy constructor is private to force use of the Copy() |
| 207 // method for those exceptional cases where we do use it. | 224 // method for those exceptional cases where we do use it. |
| 208 VideoEncoderConfig(const VideoEncoderConfig&) = default; | 225 VideoEncoderConfig(const VideoEncoderConfig&) = default; |
| 209 }; | 226 }; |
| 210 | 227 |
| 211 struct VideoDecoderH264Settings { | 228 struct VideoDecoderH264Settings { |
| 212 std::string sprop_parameter_sets; | 229 std::string sprop_parameter_sets; |
| 213 }; | 230 }; |
| 214 | 231 |
| 215 class DecoderSpecificSettings { | 232 class DecoderSpecificSettings { |
| 216 public: | 233 public: |
| 217 virtual ~DecoderSpecificSettings() {} | 234 virtual ~DecoderSpecificSettings() {} |
| 218 rtc::Optional<VideoDecoderH264Settings> h264_extra_settings; | 235 rtc::Optional<VideoDecoderH264Settings> h264_extra_settings; |
| 219 }; | 236 }; |
| 220 | 237 |
| 221 } // namespace webrtc | 238 } // namespace webrtc |
| 222 | 239 |
| 223 #endif // WEBRTC_CONFIG_H_ | 240 #endif // WEBRTC_CONFIG_H_ |
| OLD | NEW |