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 |
11 #ifndef WEBRTC_VIDEO_ENCODER_H_ | 11 #ifndef WEBRTC_VIDEO_ENCODER_H_ |
12 #define WEBRTC_VIDEO_ENCODER_H_ | 12 #define WEBRTC_VIDEO_ENCODER_H_ |
13 | 13 |
| 14 #include <string> |
14 #include <vector> | 15 #include <vector> |
15 | 16 |
16 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
17 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
18 #include "webrtc/video_frame.h" | 19 #include "webrtc/video_frame.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 class RTPFragmentationHeader; | 23 class RTPFragmentationHeader; |
23 // TODO(pbos): Expose these through a public (root) header or change these APIs. | 24 // TODO(pbos): Expose these through a public (root) header or change these APIs. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // - bitrate : New target bit rate | 118 // - bitrate : New target bit rate |
118 // - framerate : The target frame rate | 119 // - framerate : The target frame rate |
119 // | 120 // |
120 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. | 121 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. |
121 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0; | 122 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0; |
122 | 123 |
123 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } | 124 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } |
124 virtual void OnDroppedFrame() {} | 125 virtual void OnDroppedFrame() {} |
125 virtual int GetTargetFramerate() { return -1; } | 126 virtual int GetTargetFramerate() { return -1; } |
126 virtual bool SupportsNativeHandle() const { return false; } | 127 virtual bool SupportsNativeHandle() const { return false; } |
| 128 virtual const char* ImplementationName() const { return "unknown"; } |
127 }; | 129 }; |
128 | 130 |
129 // Class used to wrap external VideoEncoders to provide a fallback option on | 131 // Class used to wrap external VideoEncoders to provide a fallback option on |
130 // software encoding when a hardware encoder fails to encode a stream due to | 132 // software encoding when a hardware encoder fails to encode a stream due to |
131 // hardware restrictions, such as max resolution. | 133 // hardware restrictions, such as max resolution. |
132 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder { | 134 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder { |
133 public: | 135 public: |
134 VideoEncoderSoftwareFallbackWrapper(VideoCodecType codec_type, | 136 VideoEncoderSoftwareFallbackWrapper(VideoCodecType codec_type, |
135 webrtc::VideoEncoder* encoder); | 137 webrtc::VideoEncoder* encoder); |
136 | 138 |
137 int32_t InitEncode(const VideoCodec* codec_settings, | 139 int32_t InitEncode(const VideoCodec* codec_settings, |
138 int32_t number_of_cores, | 140 int32_t number_of_cores, |
139 size_t max_payload_size) override; | 141 size_t max_payload_size) override; |
140 | 142 |
141 int32_t RegisterEncodeCompleteCallback( | 143 int32_t RegisterEncodeCompleteCallback( |
142 EncodedImageCallback* callback) override; | 144 EncodedImageCallback* callback) override; |
143 | 145 |
144 int32_t Release() override; | 146 int32_t Release() override; |
145 int32_t Encode(const VideoFrame& frame, | 147 int32_t Encode(const VideoFrame& frame, |
146 const CodecSpecificInfo* codec_specific_info, | 148 const CodecSpecificInfo* codec_specific_info, |
147 const std::vector<FrameType>* frame_types) override; | 149 const std::vector<FrameType>* frame_types) override; |
148 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; | 150 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; |
149 | 151 |
150 int32_t SetRates(uint32_t bitrate, uint32_t framerate) override; | 152 int32_t SetRates(uint32_t bitrate, uint32_t framerate) override; |
151 void OnDroppedFrame() override; | 153 void OnDroppedFrame() override; |
152 int GetTargetFramerate() override; | 154 int GetTargetFramerate() override; |
153 bool SupportsNativeHandle() const override; | 155 bool SupportsNativeHandle() const override; |
| 156 const char* ImplementationName() const override; |
154 | 157 |
155 private: | 158 private: |
156 bool InitFallbackEncoder(); | 159 bool InitFallbackEncoder(); |
157 | 160 |
158 // Settings used in the last InitEncode call and used if a dynamic fallback to | 161 // Settings used in the last InitEncode call and used if a dynamic fallback to |
159 // software is required. | 162 // software is required. |
160 VideoCodec codec_settings_; | 163 VideoCodec codec_settings_; |
161 int32_t number_of_cores_; | 164 int32_t number_of_cores_; |
162 size_t max_payload_size_; | 165 size_t max_payload_size_; |
163 | 166 |
164 // The last bitrate/framerate set, and a flag for noting they are set. | 167 // The last bitrate/framerate set, and a flag for noting they are set. |
165 bool rates_set_; | 168 bool rates_set_; |
166 uint32_t bitrate_; | 169 uint32_t bitrate_; |
167 uint32_t framerate_; | 170 uint32_t framerate_; |
168 | 171 |
169 // The last channel parameters set, and a flag for noting they are set. | 172 // The last channel parameters set, and a flag for noting they are set. |
170 bool channel_parameters_set_; | 173 bool channel_parameters_set_; |
171 uint32_t packet_loss_; | 174 uint32_t packet_loss_; |
172 int64_t rtt_; | 175 int64_t rtt_; |
173 | 176 |
174 const EncoderType encoder_type_; | 177 const EncoderType encoder_type_; |
175 webrtc::VideoEncoder* const encoder_; | 178 webrtc::VideoEncoder* const encoder_; |
176 | 179 |
177 rtc::scoped_ptr<webrtc::VideoEncoder> fallback_encoder_; | 180 rtc::scoped_ptr<webrtc::VideoEncoder> fallback_encoder_; |
| 181 std::string fallback_implementation_name_; |
178 EncodedImageCallback* callback_; | 182 EncodedImageCallback* callback_; |
179 }; | 183 }; |
180 } // namespace webrtc | 184 } // namespace webrtc |
181 #endif // WEBRTC_VIDEO_ENCODER_H_ | 185 #endif // WEBRTC_VIDEO_ENCODER_H_ |
OLD | NEW |