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

Side by Side Diff: webrtc/video_encoder.h

Issue 2398963003: Move usage of QualityScaler to ViEEncoder. (Closed)
Patch Set: rebase Created 4 years 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 | « webrtc/video/vie_encoder_unittest.cc ('k') | no next file » | 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) 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/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/common_types.h" 19 #include "webrtc/common_types.h"
20 #include "webrtc/typedefs.h" 20 #include "webrtc/typedefs.h"
21 #include "webrtc/video_frame.h" 21 #include "webrtc/video_frame.h"
22 #include "webrtc/base/optional.h"
22 23
23 namespace webrtc { 24 namespace webrtc {
24 25
25 class RTPFragmentationHeader; 26 class RTPFragmentationHeader;
26 // TODO(pbos): Expose these through a public (root) header or change these APIs. 27 // TODO(pbos): Expose these through a public (root) header or change these APIs.
27 struct CodecSpecificInfo; 28 struct CodecSpecificInfo;
28 class VideoCodec; 29 class VideoCodec;
29 30
30 class EncodedImageCallback { 31 class EncodedImageCallback {
31 public: 32 public:
(...skipping 20 matching lines...) Expand all
52 53
53 // Tells the encoder that the next frame is should be dropped. 54 // Tells the encoder that the next frame is should be dropped.
54 bool drop_next_frame = false; 55 bool drop_next_frame = false;
55 }; 56 };
56 57
57 // Callback function which is called when an image has been encoded. 58 // Callback function which is called when an image has been encoded.
58 virtual Result OnEncodedImage( 59 virtual Result OnEncodedImage(
59 const EncodedImage& encoded_image, 60 const EncodedImage& encoded_image,
60 const CodecSpecificInfo* codec_specific_info, 61 const CodecSpecificInfo* codec_specific_info,
61 const RTPFragmentationHeader* fragmentation) = 0; 62 const RTPFragmentationHeader* fragmentation) = 0;
63
64 virtual void OnDroppedFrame() {}
62 }; 65 };
63 66
64 class VideoEncoder { 67 class VideoEncoder {
65 public: 68 public:
69 enum EncoderType {
70 kH264,
71 kVp8,
72 kVp9,
73 kUnsupportedCodec,
74 };
75 struct QpThresholds {
76 QpThresholds(int l, int h) : low(l), high(h) {}
77 QpThresholds() : low(-1), high(-1) {}
78 int low;
79 int high;
80 };
81 struct ScalingSettings {
82 ScalingSettings(bool on, int low, int high)
83 : enabled(on),
84 thresholds(rtc::Optional<QpThresholds>(QpThresholds(low, high))) {}
85 explicit ScalingSettings(bool on) : enabled(on) {}
86 const bool enabled;
87 const rtc::Optional<QpThresholds> thresholds;
88 };
89 static VideoEncoder* Create(EncoderType codec_type);
90 // Returns true if this type of encoder can be created using
91 // VideoEncoder::Create.
92 static bool IsSupportedSoftware(EncoderType codec_type);
93 static EncoderType CodecToEncoderType(VideoCodecType codec_type);
94
66 static VideoCodecVP8 GetDefaultVp8Settings(); 95 static VideoCodecVP8 GetDefaultVp8Settings();
67 static VideoCodecVP9 GetDefaultVp9Settings(); 96 static VideoCodecVP9 GetDefaultVp9Settings();
68 static VideoCodecH264 GetDefaultH264Settings(); 97 static VideoCodecH264 GetDefaultH264Settings();
69 98
70 virtual ~VideoEncoder() {} 99 virtual ~VideoEncoder() {}
71 100
72 // Initialize the encoder with the information from the codecSettings 101 // Initialize the encoder with the information from the codecSettings
73 // 102 //
74 // Input: 103 // Input:
75 // - codec_settings : Codec settings 104 // - codec_settings : Codec settings
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return -1; 170 return -1;
142 } 171 }
143 172
144 // Default fallback: Just use the sum of bitrates as the single target rate. 173 // Default fallback: Just use the sum of bitrates as the single target rate.
145 // TODO(sprang): Remove this default implementation when we remove SetRates(). 174 // TODO(sprang): Remove this default implementation when we remove SetRates().
146 virtual int32_t SetRateAllocation(const BitrateAllocation& allocation, 175 virtual int32_t SetRateAllocation(const BitrateAllocation& allocation,
147 uint32_t framerate) { 176 uint32_t framerate) {
148 return SetRates(allocation.get_sum_kbps(), framerate); 177 return SetRates(allocation.get_sum_kbps(), framerate);
149 } 178 }
150 179
180 // Any encoder implementation wishing to use the WebRTC provided
181 // quality scaler must implement this method.
182 virtual ScalingSettings GetScalingSettings() const {
183 return ScalingSettings(false);
184 }
185
151 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } 186 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; }
152 virtual void OnDroppedFrame() {}
153 virtual bool SupportsNativeHandle() const { return false; } 187 virtual bool SupportsNativeHandle() const { return false; }
154 virtual const char* ImplementationName() const { return "unknown"; } 188 virtual const char* ImplementationName() const { return "unknown"; }
155 }; 189 };
156 190
157 } // namespace webrtc 191 } // namespace webrtc
158 #endif // WEBRTC_VIDEO_ENCODER_H_ 192 #endif // WEBRTC_VIDEO_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698