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

Side by Side Diff: webrtc/video_encoder.h

Issue 2474993002: Pass selected cricket::VideoCodec down to internal H264 encoder (Closed)
Patch Set: Fix. Created 4 years, 1 month 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
OLDNEW
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 <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/common_types.h" 18 #include "webrtc/common_types.h"
19 #include "webrtc/media/base/codec.h"
19 #include "webrtc/typedefs.h" 20 #include "webrtc/typedefs.h"
20 #include "webrtc/video_frame.h" 21 #include "webrtc/video_frame.h"
21 22
22 namespace webrtc { 23 namespace webrtc {
23 24
24 class RTPFragmentationHeader; 25 class RTPFragmentationHeader;
25 // TODO(pbos): Expose these through a public (root) header or change these APIs. 26 // TODO(pbos): Expose these through a public (root) header or change these APIs.
26 struct CodecSpecificInfo; 27 struct CodecSpecificInfo;
27 class VideoCodec; 28 class VideoCodec;
28 29
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 const CodecSpecificInfo* codec_specific_info, 69 const CodecSpecificInfo* codec_specific_info,
69 const RTPFragmentationHeader* fragmentation) { 70 const RTPFragmentationHeader* fragmentation) {
70 Result result = 71 Result result =
71 OnEncodedImage(encoded_image, codec_specific_info, fragmentation); 72 OnEncodedImage(encoded_image, codec_specific_info, fragmentation);
72 return (result.error != Result::OK) ? -1 : (result.drop_next_frame ? 1 : 0); 73 return (result.error != Result::OK) ? -1 : (result.drop_next_frame ? 1 : 0);
73 } 74 }
74 }; 75 };
75 76
76 class VideoEncoder { 77 class VideoEncoder {
77 public: 78 public:
78 enum EncoderType { 79 static VideoEncoder* Create(const cricket::VideoCodec& codec);
79 kH264,
80 kVp8,
81 kVp9,
82 kUnsupportedCodec,
83 };
84
85 static VideoEncoder* Create(EncoderType codec_type);
86 // Returns true if this type of encoder can be created using 80 // Returns true if this type of encoder can be created using
87 // VideoEncoder::Create. 81 // VideoEncoder::Create.
88 static bool IsSupportedSoftware(EncoderType codec_type); 82 static bool IsSupportedSoftware(const cricket::VideoCodec& codec);
89 static EncoderType CodecToEncoderType(VideoCodecType codec_type);
90 83
91 static VideoCodecVP8 GetDefaultVp8Settings(); 84 static VideoCodecVP8 GetDefaultVp8Settings();
92 static VideoCodecVP9 GetDefaultVp9Settings(); 85 static VideoCodecVP9 GetDefaultVp9Settings();
93 static VideoCodecH264 GetDefaultH264Settings(); 86 static VideoCodecH264 GetDefaultH264Settings();
94 87
95 virtual ~VideoEncoder() {} 88 virtual ~VideoEncoder() {}
96 89
97 // Initialize the encoder with the information from the codecSettings 90 // Initialize the encoder with the information from the codecSettings
98 // 91 //
99 // Input: 92 // Input:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 virtual void OnDroppedFrame() {} 160 virtual void OnDroppedFrame() {}
168 virtual bool SupportsNativeHandle() const { return false; } 161 virtual bool SupportsNativeHandle() const { return false; }
169 virtual const char* ImplementationName() const { return "unknown"; } 162 virtual const char* ImplementationName() const { return "unknown"; }
170 }; 163 };
171 164
172 // Class used to wrap external VideoEncoders to provide a fallback option on 165 // Class used to wrap external VideoEncoders to provide a fallback option on
173 // software encoding when a hardware encoder fails to encode a stream due to 166 // software encoding when a hardware encoder fails to encode a stream due to
174 // hardware restrictions, such as max resolution. 167 // hardware restrictions, such as max resolution.
175 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder { 168 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder {
176 public: 169 public:
177 VideoEncoderSoftwareFallbackWrapper(VideoCodecType codec_type, 170 VideoEncoderSoftwareFallbackWrapper(const cricket::VideoCodec& codec,
178 webrtc::VideoEncoder* encoder); 171 webrtc::VideoEncoder* encoder);
179 172
180 int32_t InitEncode(const VideoCodec* codec_settings, 173 int32_t InitEncode(const VideoCodec* codec_settings,
181 int32_t number_of_cores, 174 int32_t number_of_cores,
182 size_t max_payload_size) override; 175 size_t max_payload_size) override;
183 176
184 int32_t RegisterEncodeCompleteCallback( 177 int32_t RegisterEncodeCompleteCallback(
185 EncodedImageCallback* callback) override; 178 EncodedImageCallback* callback) override;
186 179
187 int32_t Release() override; 180 int32_t Release() override;
(...skipping 18 matching lines...) Expand all
206 // The last bitrate/framerate set, and a flag for noting they are set. 199 // The last bitrate/framerate set, and a flag for noting they are set.
207 bool rates_set_; 200 bool rates_set_;
208 uint32_t bitrate_; 201 uint32_t bitrate_;
209 uint32_t framerate_; 202 uint32_t framerate_;
210 203
211 // The last channel parameters set, and a flag for noting they are set. 204 // The last channel parameters set, and a flag for noting they are set.
212 bool channel_parameters_set_; 205 bool channel_parameters_set_;
213 uint32_t packet_loss_; 206 uint32_t packet_loss_;
214 int64_t rtt_; 207 int64_t rtt_;
215 208
216 const EncoderType encoder_type_; 209 const cricket::VideoCodec codec_;
217 webrtc::VideoEncoder* const encoder_; 210 webrtc::VideoEncoder* const encoder_;
218 211
219 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; 212 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_;
220 std::string fallback_implementation_name_; 213 std::string fallback_implementation_name_;
221 EncodedImageCallback* callback_; 214 EncodedImageCallback* callback_;
222 }; 215 };
223 } // namespace webrtc 216 } // namespace webrtc
224 #endif // WEBRTC_VIDEO_ENCODER_H_ 217 #endif // WEBRTC_VIDEO_ENCODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698