OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 23 matching lines...) Expand all Loading... | |
34 virtual ~EncodedImageCallback() {} | 34 virtual ~EncodedImageCallback() {} |
35 | 35 |
36 struct Result { | 36 struct Result { |
37 enum Error { | 37 enum Error { |
38 OK, | 38 OK, |
39 | 39 |
40 // Failed to send the packet. | 40 // Failed to send the packet. |
41 ERROR_SEND_FAILED, | 41 ERROR_SEND_FAILED, |
42 }; | 42 }; |
43 | 43 |
44 Result(Error error) : error(error) {} | 44 explicit Result(Error error) : error(error) {} |
45 Result(Error error, uint32_t frame_id) : error(error), frame_id(frame_id) {} | 45 Result(Error error, uint32_t frame_id) : error(error), frame_id(frame_id) {} |
46 | 46 |
47 Error error; | 47 Error error; |
48 | 48 |
49 // Frame ID assigned to the frame. The frame ID should be the same as the ID | 49 // Frame ID assigned to the frame. The frame ID should be the same as the ID |
50 // seen by the receiver for this frame. RTP timestamp of the frame is used | 50 // seen by the receiver for this frame. RTP timestamp of the frame is used |
51 // as frame ID when RTP is used to send video. Must be used only when | 51 // as frame ID when RTP is used to send video. Must be used only when |
52 // error=OK. | 52 // error=OK. |
53 uint32_t frame_id = 0; | 53 uint32_t frame_id = 0; |
54 | 54 |
(...skipping 12 matching lines...) Expand all Loading... | |
67 | 67 |
68 class VideoEncoder { | 68 class VideoEncoder { |
69 public: | 69 public: |
70 struct QpThresholds { | 70 struct QpThresholds { |
71 QpThresholds(int l, int h) : low(l), high(h) {} | 71 QpThresholds(int l, int h) : low(l), high(h) {} |
72 QpThresholds() : low(-1), high(-1) {} | 72 QpThresholds() : low(-1), high(-1) {} |
73 int low; | 73 int low; |
74 int high; | 74 int high; |
75 }; | 75 }; |
76 struct ScalingSettings { | 76 struct ScalingSettings { |
77 ScalingSettings(bool on, int low, int high) | 77 ScalingSettings(bool on, int low, int high); |
78 : enabled(on), | 78 explicit ScalingSettings(bool on); |
79 thresholds(rtc::Optional<QpThresholds>(QpThresholds(low, high))) {} | 79 ScalingSettings(const ScalingSettings&); |
80 explicit ScalingSettings(bool on) : enabled(on) {} | 80 ~ScalingSettings(); |
81 | |
81 const bool enabled; | 82 const bool enabled; |
82 const rtc::Optional<QpThresholds> thresholds; | 83 const rtc::Optional<QpThresholds> thresholds; |
83 }; | 84 }; |
84 | 85 |
85 static VideoCodecVP8 GetDefaultVp8Settings(); | 86 static VideoCodecVP8 GetDefaultVp8Settings(); |
86 static VideoCodecVP9 GetDefaultVp9Settings(); | 87 static VideoCodecVP9 GetDefaultVp9Settings(); |
87 static VideoCodecH264 GetDefaultH264Settings(); | 88 static VideoCodecH264 GetDefaultH264Settings(); |
88 | 89 |
89 virtual ~VideoEncoder() {} | 90 virtual ~VideoEncoder() {} |
90 | 91 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 // <0 - Errors: WEBRTC_VIDEO_CODEC_ERROR | 149 // <0 - Errors: WEBRTC_VIDEO_CODEC_ERROR |
149 virtual int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) = 0; | 150 virtual int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) = 0; |
150 | 151 |
151 // Inform the encoder about the new target bit rate. | 152 // Inform the encoder about the new target bit rate. |
152 // | 153 // |
153 // Input: | 154 // Input: |
154 // - bitrate : New target bit rate | 155 // - bitrate : New target bit rate |
155 // - framerate : The target frame rate | 156 // - framerate : The target frame rate |
156 // | 157 // |
157 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. | 158 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. |
158 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) { | 159 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate); |
brandtr
2017/08/10 08:05:35
Does it make sense to make it RTC_DEPRECATED?
mflodman
2017/08/10 08:23:56
Yes, done.
| |
159 RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated."; | |
160 return -1; | |
161 } | |
162 | 160 |
163 // Default fallback: Just use the sum of bitrates as the single target rate. | 161 // Default fallback: Just use the sum of bitrates as the single target rate. |
164 // TODO(sprang): Remove this default implementation when we remove SetRates(). | 162 // TODO(sprang): Remove this default implementation when we remove SetRates(). |
165 virtual int32_t SetRateAllocation(const BitrateAllocation& allocation, | 163 virtual int32_t SetRateAllocation(const BitrateAllocation& allocation, |
166 uint32_t framerate) { | 164 uint32_t framerate); |
167 return SetRates(allocation.get_sum_kbps(), framerate); | |
168 } | |
169 | 165 |
170 // Any encoder implementation wishing to use the WebRTC provided | 166 // Any encoder implementation wishing to use the WebRTC provided |
171 // quality scaler must implement this method. | 167 // quality scaler must implement this method. |
172 virtual ScalingSettings GetScalingSettings() const { | 168 virtual ScalingSettings GetScalingSettings() const; |
173 return ScalingSettings(false); | |
174 } | |
175 | 169 |
176 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } | 170 virtual int32_t SetPeriodicKeyFrames(bool enable); |
177 virtual bool SupportsNativeHandle() const { return false; } | 171 virtual bool SupportsNativeHandle() const; |
178 virtual const char* ImplementationName() const { return "unknown"; } | 172 virtual const char* ImplementationName() const; |
179 }; | 173 }; |
180 | |
181 } // namespace webrtc | 174 } // namespace webrtc |
182 #endif // WEBRTC_API_VIDEO_CODECS_VIDEO_ENCODER_H_ | 175 #endif // WEBRTC_API_VIDEO_CODECS_VIDEO_ENCODER_H_ |
OLD | NEW |