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

Side by Side Diff: webrtc/modules/video_coding/main/source/generic_encoder.h

Issue 1426953003: Remove redudant encoder rate calls. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_
12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ 12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_
13 13
14 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" 14 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
15 #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h" 15 #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
16 16
17 #include <stdio.h> 17 #include <stdio.h>
18 18
19 #include "webrtc/base/criticalsection.h" 19 #include "webrtc/base/criticalsection.h"
20 #include "webrtc/base/scoped_ptr.h" 20 #include "webrtc/base/scoped_ptr.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 class CriticalSectionWrapper; 23 class CriticalSectionWrapper;
24 24
25 namespace media_optimization { 25 namespace media_optimization {
26 class MediaOptimization; 26 class MediaOptimization;
27 } // namespace media_optimization 27 } // namespace media_optimization
28 28
29 struct EncoderParameters {
30 uint32_t target_bitrate;
31 uint8_t loss_rate;
32 int64_t rtt;
33 uint32_t input_frame_rate;
34 };
35
29 /*************************************/ 36 /*************************************/
30 /* VCMEncodeFrameCallback class */ 37 /* VCMEncodeFrameCallback class */
31 /***********************************/ 38 /***********************************/
32 class VCMEncodedFrameCallback : public EncodedImageCallback 39 class VCMEncodedFrameCallback : public EncodedImageCallback
33 { 40 {
34 public: 41 public:
35 VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback); 42 VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback);
36 virtual ~VCMEncodedFrameCallback(); 43 virtual ~VCMEncodedFrameCallback();
37 44
38 /* 45 /*
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 /** 102 /**
96 * Encode raw image 103 * Encode raw image
97 * inputFrame : Frame containing raw image 104 * inputFrame : Frame containing raw image
98 * codecSpecificInfo : Specific codec data 105 * codecSpecificInfo : Specific codec data
99 * cameraFrameRate : Request or information from the remote side 106 * cameraFrameRate : Request or information from the remote side
100 * frameType : The requested frame type to encode 107 * frameType : The requested frame type to encode
101 */ 108 */
102 int32_t Encode(const VideoFrame& inputFrame, 109 int32_t Encode(const VideoFrame& inputFrame,
103 const CodecSpecificInfo* codecSpecificInfo, 110 const CodecSpecificInfo* codecSpecificInfo,
104 const std::vector<FrameType>& frameTypes); 111 const std::vector<FrameType>& frameTypes);
105 /** 112
106 * Set new target bitrate (bits/s) and framerate. 113 void SetEncoderParameters(const EncoderParameters& params);
107 * Return Value: new bit rate if OK, otherwise <0s.
108 */
109 // TODO(tommi): We could replace BitRate and FrameRate below with a GetRates
110 // method that matches SetRates. For fetching current rates, we'd then only
111 // grab the lock once instead of twice.
112 int32_t SetRates(uint32_t target_bitrate, uint32_t frameRate);
113 /**
114 * Set a new packet loss rate and a new round-trip time in milliseconds.
115 */
116 int32_t SetChannelParameters(int32_t packetLoss, int64_t rtt);
117 int32_t CodecConfigParameters(uint8_t* buffer, int32_t size);
118 /** 114 /**
119 * Register a transport callback which will be called to deliver the encoded 115 * Register a transport callback which will be called to deliver the encoded
120 * buffers 116 * buffers
121 */ 117 */
122 int32_t RegisterEncodeCallback( 118 int32_t RegisterEncodeCallback(
123 VCMEncodedFrameCallback* VCMencodedFrameCallback); 119 VCMEncodedFrameCallback* VCMencodedFrameCallback);
120 // TODO(tommi): We could replace BitRate and FrameRate below with a GetRates
stefan-webrtc 2015/10/29 14:12:06 GetEncoderParameters would make more sense then, w
pbos-webrtc 2015/10/29 14:37:33 Yep, done. Note that there's no caller who does us
stefan-webrtc 2015/10/29 14:50:22 But don't you have two methods for this now? Line
pbos-webrtc 2015/10/29 15:26:01 Brain fart, thanks, done. :)
121 // method that matches SetEncoderParameters. For fetching current rates,
122 // we'd then only grab the lock once instead of twice.
124 /** 123 /**
125 * Get encoder bit rate 124 * Get encoder bit rate
126 */ 125 */
127 uint32_t BitRate() const; 126 uint32_t BitRate() const;
128 /** 127 /**
129 * Get encoder frame rate 128 * Get encoder frame rate
130 */ 129 */
131 uint32_t FrameRate() const; 130 uint32_t FrameRate() const;
132 131
132 EncoderParameters encoder_parameters() const;
133
133 int32_t SetPeriodicKeyFrames(bool enable); 134 int32_t SetPeriodicKeyFrames(bool enable);
134 135
135 int32_t RequestFrame(const std::vector<FrameType>& frame_types); 136 int32_t RequestFrame(const std::vector<FrameType>& frame_types);
136 137
137 bool InternalSource() const; 138 bool InternalSource() const;
138 139
139 void OnDroppedFrame(); 140 void OnDroppedFrame();
140 141
141 bool SupportsNativeHandle() const; 142 bool SupportsNativeHandle() const;
142 143
143 int GetTargetFramerate(); 144 int GetTargetFramerate();
144 145
145 private: 146 private:
146 VideoEncoder* const encoder_; 147 VideoEncoder* const encoder_;
147 VideoEncoderRateObserver* const rate_observer_; 148 VideoEncoderRateObserver* const rate_observer_;
148 VCMEncodedFrameCallback* vcm_encoded_frame_callback_; 149 VCMEncodedFrameCallback* vcm_encoded_frame_callback_;
149 uint32_t bit_rate_; 150 EncoderParameters encoder_params_ GUARDED_BY(params_lock_);
150 uint32_t frame_rate_;
151 const bool internal_source_; 151 const bool internal_source_;
152 mutable rtc::CriticalSection rates_lock_; 152 mutable rtc::CriticalSection params_lock_;
153 VideoRotation rotation_; 153 VideoRotation rotation_;
154 bool is_screenshare_; 154 bool is_screenshare_;
155 }; // end of VCMGenericEncoder class 155 }; // end of VCMGenericEncoder class
156 156
157 } // namespace webrtc 157 } // namespace webrtc
158 158
159 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ 159 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698