Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: webrtc/config.h

Issue 2347843002: Add proper lifetime of encoder-specific settings (Closed)
Patch Set: nitpicks Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 // TODO(pbos): Move Config from common.h to here. 11 // TODO(pbos): Move Config from common.h to here.
12 12
13 #ifndef WEBRTC_CONFIG_H_ 13 #ifndef WEBRTC_CONFIG_H_
14 #define WEBRTC_CONFIG_H_ 14 #define WEBRTC_CONFIG_H_
15 15
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/optional.h" 19 #include "webrtc/base/optional.h"
20 #include "webrtc/base/refcount.h"
21 #include "webrtc/base/scoped_ref_ptr.h"
20 #include "webrtc/common_types.h" 22 #include "webrtc/common_types.h"
21 #include "webrtc/typedefs.h" 23 #include "webrtc/typedefs.h"
22 24
23 namespace webrtc { 25 namespace webrtc {
24 26
25 // Settings for NACK, see RFC 4585 for details. 27 // Settings for NACK, see RFC 4585 for details.
26 struct NackConfig { 28 struct NackConfig {
27 NackConfig() : rtp_history_ms(0) {} 29 NackConfig() : rtp_history_ms(0) {}
28 std::string ToString() const; 30 std::string ToString() const;
29 // Send side: the time RTP packets are stored for retransmissions. 31 // Send side: the time RTP packets are stored for retransmissions.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 int max_qp; 113 int max_qp;
112 114
113 // Bitrate thresholds for enabling additional temporal layers. Since these are 115 // Bitrate thresholds for enabling additional temporal layers. Since these are
114 // thresholds in between layers, we have one additional layer. One threshold 116 // thresholds in between layers, we have one additional layer. One threshold
115 // gives two temporal layers, one below the threshold and one above, two give 117 // gives two temporal layers, one below the threshold and one above, two give
116 // three, and so on. 118 // three, and so on.
117 // The VideoEncoder may redistribute bitrates over the temporal layers so a 119 // The VideoEncoder may redistribute bitrates over the temporal layers so a
118 // 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
119 // 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
120 // in the first temporal layer should not exceed 100k. 122 // in the first temporal layer should not exceed 100k.
121 // TODO(pbos): Apart from a special case for two-layer screencast these 123 // TODO(kthelgason): Apart from a special case for two-layer screencast these
122 // thresholds are not propagated to the VideoEncoder. To be implemented. 124 // thresholds are not propagated to the VideoEncoder. To be implemented.
123 std::vector<int> temporal_layer_thresholds_bps; 125 std::vector<int> temporal_layer_thresholds_bps;
124 }; 126 };
125 127
126 struct VideoEncoderConfig { 128 struct VideoEncoderConfig {
127 public: 129 public:
130 // These are reference counted to permit copying VideoEncoderConfig and be
131 // kept alive until all encoder_specific_settings go out of scope.
132 // TODO(kthelgason): Consider removing the need for copying VideoEncoderConfig
133 // and use rtc::Optional for encoder_specific_settings instead.
134 class EncoderSpecificSettings : public rtc::RefCountInterface {
135 public:
136 // TODO(pbos): Remove FillEncoderSpecificSettings as soon as VideoCodec is
137 // not in use and encoder implementations ask for codec-specific structs
138 // directly.
139 void FillEncoderSpecificSettings(VideoCodec* codec_struct) const;
140
141 virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const;
142 virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const;
143 virtual void FillVideoCodecH264(VideoCodecH264* h264_settings) const;
144 private:
145 virtual ~EncoderSpecificSettings() {}
146 friend struct VideoEncoderConfig;
147 };
148
149 class H264EncoderSpecificSettings : public EncoderSpecificSettings {
150 public:
151 explicit H264EncoderSpecificSettings(const VideoCodecH264& specifics);
152 virtual void FillVideoCodecH264(
153 VideoCodecH264* h264_settings) const override;
154
155 private:
156 VideoCodecH264 specifics_;
157 };
158
159 class Vp8EncoderSpecificSettings : public EncoderSpecificSettings {
160 public:
161 explicit Vp8EncoderSpecificSettings(const VideoCodecVP8& specifics);
162 virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const override;
163
164 private:
165 VideoCodecVP8 specifics_;
166 };
167
168 class Vp9EncoderSpecificSettings : public EncoderSpecificSettings {
169 public:
170 explicit Vp9EncoderSpecificSettings(const VideoCodecVP9& specifics);
171 virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const override;
172
173 private:
174 VideoCodecVP9 specifics_;
175 };
176
128 enum class ContentType { 177 enum class ContentType {
129 kRealtimeVideo, 178 kRealtimeVideo,
130 kScreen, 179 kScreen,
131 }; 180 };
132 181
133 VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default; 182 VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default;
134 VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete; 183 VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete;
135 184
136 // Mostly used by tests. Avoid creating copies if you can. 185 // Mostly used by tests. Avoid creating copies if you can.
137 VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); } 186 VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); }
138 187
139 VideoEncoderConfig(); 188 VideoEncoderConfig();
140 VideoEncoderConfig(VideoEncoderConfig&&) = default; 189 VideoEncoderConfig(VideoEncoderConfig&&) = default;
141 ~VideoEncoderConfig(); 190 ~VideoEncoderConfig();
142 std::string ToString() const; 191 std::string ToString() const;
143 192
144 std::vector<VideoStream> streams; 193 std::vector<VideoStream> streams;
145 std::vector<SpatialLayer> spatial_layers; 194 std::vector<SpatialLayer> spatial_layers;
146 ContentType content_type; 195 ContentType content_type;
147 void* encoder_specific_settings; 196 rtc::scoped_refptr<const EncoderSpecificSettings> encoder_specific_settings;
148 197
149 // Padding will be used up to this bitrate regardless of the bitrate produced 198 // Padding will be used up to this bitrate regardless of the bitrate produced
150 // by the encoder. Padding above what's actually produced by the encoder helps 199 // by the encoder. Padding above what's actually produced by the encoder helps
151 // maintaining a higher bitrate estimate. Padding will however not be sent 200 // maintaining a higher bitrate estimate. Padding will however not be sent
152 // unless the estimated bandwidth indicates that the link can handle it. 201 // unless the estimated bandwidth indicates that the link can handle it.
153 int min_transmit_bitrate_bps; 202 int min_transmit_bitrate_bps;
154 bool expect_encode_from_texture; 203 bool expect_encode_from_texture;
155 204
156 private: 205 private:
157 // Access to the copy constructor is private to force use of the Copy() 206 // Access to the copy constructor is private to force use of the Copy()
158 // method for those exceptional cases where we do use it. 207 // method for those exceptional cases where we do use it.
159 VideoEncoderConfig(const VideoEncoderConfig&) = default; 208 VideoEncoderConfig(const VideoEncoderConfig&) = default;
160 }; 209 };
161 210
162 struct VideoDecoderH264Settings { 211 struct VideoDecoderH264Settings {
163 std::string sprop_parameter_sets; 212 std::string sprop_parameter_sets;
164 }; 213 };
165 214
166 class DecoderSpecificSettings { 215 class DecoderSpecificSettings {
167 public: 216 public:
168 virtual ~DecoderSpecificSettings() {} 217 virtual ~DecoderSpecificSettings() {}
169 rtc::Optional<VideoDecoderH264Settings> h264_extra_settings; 218 rtc::Optional<VideoDecoderH264Settings> h264_extra_settings;
170 }; 219 };
171 220
172 } // namespace webrtc 221 } // namespace webrtc
173 222
174 #endif // WEBRTC_CONFIG_H_ 223 #endif // WEBRTC_CONFIG_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698