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

Side by Side Diff: webrtc/video_engine/vie_encoder.h

Issue 1354143004: Remove callback_cs_ in ViEEncoder. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 months 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_engine/vie_channel_group.cc ('k') | webrtc/video_engine/vie_encoder.cc » ('j') | 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) 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
(...skipping 21 matching lines...) Expand all
32 class Config; 32 class Config;
33 class CriticalSectionWrapper; 33 class CriticalSectionWrapper;
34 class EncodedImageCallback; 34 class EncodedImageCallback;
35 class PacedSender; 35 class PacedSender;
36 class PayloadRouter; 36 class PayloadRouter;
37 class ProcessThread; 37 class ProcessThread;
38 class QMVideoSettingsCallback; 38 class QMVideoSettingsCallback;
39 class SendStatisticsProxy; 39 class SendStatisticsProxy;
40 class ViEBitrateObserver; 40 class ViEBitrateObserver;
41 class ViEEffectFilter; 41 class ViEEffectFilter;
42 class ViEEncoderObserver;
43 class VideoCodingModule; 42 class VideoCodingModule;
44 43
45 // This class declares an abstract interface for a user defined observer. It is
46 // up to the VideoEngine user to implement a derived class which implements the
47 // observer class. The observer is registered using RegisterEncoderObserver()
48 // and deregistered using DeregisterEncoderObserver().
49 class ViEEncoderObserver {
50 public:
51 // This method is called once per second with the current encoded frame rate
52 // and bit rate.
53 virtual void OutgoingRate(const int video_channel,
54 const unsigned int framerate,
55 const unsigned int bitrate) = 0;
56
57 // This method is called whenever the state of the SuspendBelowMinBitrate
58 // changes, i.e., when |is_suspended| toggles.
59 virtual void SuspendChange(int video_channel, bool is_suspended) = 0;
60
61 protected:
62 virtual ~ViEEncoderObserver() {}
63 };
64
65 class ViEEncoder : public RtcpIntraFrameObserver, 44 class ViEEncoder : public RtcpIntraFrameObserver,
66 public VideoEncoderRateObserver, 45 public VideoEncoderRateObserver,
67 public VCMPacketizationCallback, 46 public VCMPacketizationCallback,
68 public VCMSendStatisticsCallback, 47 public VCMSendStatisticsCallback,
69 public VideoCaptureCallback { 48 public VideoCaptureCallback {
70 public: 49 public:
71 friend class ViEBitrateObserver; 50 friend class ViEBitrateObserver;
72 51
73 ViEEncoder(int32_t channel_id, 52 ViEEncoder(int32_t channel_id,
74 uint32_t number_of_cores, 53 uint32_t number_of_cores,
75 ProcessThread& module_process_thread, 54 ProcessThread* module_process_thread,
55 SendStatisticsProxy* stats_proxy,
56 I420FrameCallback* pre_encode_callback,
76 PacedSender* pacer, 57 PacedSender* pacer,
77 BitrateAllocator* bitrate_allocator); 58 BitrateAllocator* bitrate_allocator);
78 ~ViEEncoder(); 59 ~ViEEncoder();
79 60
80 bool Init(); 61 bool Init();
81 62
82 // This function is assumed to be called before any frames are delivered and 63 // This function is assumed to be called before any frames are delivered and
83 // only once. 64 // only once.
84 // Ideally this would be done in Init, but the dependencies between ViEEncoder 65 // Ideally this would be done in Init, but the dependencies between ViEEncoder
85 // and ViEChannel makes it really hard to do in a good way. 66 // and ViEChannel makes it really hard to do in a good way.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // Implements VCMPacketizationCallback. 120 // Implements VCMPacketizationCallback.
140 int32_t SendData(uint8_t payload_type, 121 int32_t SendData(uint8_t payload_type,
141 const EncodedImage& encoded_image, 122 const EncodedImage& encoded_image,
142 const RTPFragmentationHeader& fragmentation_header, 123 const RTPFragmentationHeader& fragmentation_header,
143 const RTPVideoHeader* rtp_video_hdr) override; 124 const RTPVideoHeader* rtp_video_hdr) override;
144 125
145 // Implements VideoSendStatisticsCallback. 126 // Implements VideoSendStatisticsCallback.
146 int32_t SendStatistics(const uint32_t bit_rate, 127 int32_t SendStatistics(const uint32_t bit_rate,
147 const uint32_t frame_rate) override; 128 const uint32_t frame_rate) override;
148 129
149 int32_t RegisterCodecObserver(ViEEncoderObserver* observer);
150
151 // Implements RtcpIntraFrameObserver. 130 // Implements RtcpIntraFrameObserver.
152 void OnReceivedIntraFrameRequest(uint32_t ssrc) override; 131 void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
153 void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id) override; 132 void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id) override;
154 void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id) override; 133 void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id) override;
155 void OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) override; 134 void OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) override;
156 135
157 // Sets SSRCs for all streams. 136 // Sets SSRCs for all streams.
158 bool SetSsrcs(const std::vector<uint32_t>& ssrcs); 137 bool SetSsrcs(const std::vector<uint32_t>& ssrcs);
159 138
160 void SetMinTransmitBitrate(int min_transmit_bitrate_kbps); 139 void SetMinTransmitBitrate(int min_transmit_bitrate_kbps);
161 140
162 // Lets the sender suspend video when the rate drops below 141 // Lets the sender suspend video when the rate drops below
163 // |threshold_bps|, and turns back on when the rate goes back up above 142 // |threshold_bps|, and turns back on when the rate goes back up above
164 // |threshold_bps| + |window_bps|. 143 // |threshold_bps| + |window_bps|.
165 void SuspendBelowMinBitrate(); 144 void SuspendBelowMinBitrate();
166 145
167 // New-style callbacks, used by VideoSendStream. 146 // New-style callbacks, used by VideoSendStream.
168 void RegisterPreEncodeCallback(I420FrameCallback* pre_encode_callback);
169 void RegisterPostEncodeImageCallback( 147 void RegisterPostEncodeImageCallback(
170 EncodedImageCallback* post_encode_callback); 148 EncodedImageCallback* post_encode_callback);
171 149
172 void RegisterSendStatisticsProxy(SendStatisticsProxy* send_statistics_proxy);
173
174 int channel_id() const { return channel_id_; } 150 int channel_id() const { return channel_id_; }
175 151
176 int GetPaddingNeededBps() const; 152 int GetPaddingNeededBps() const;
177 153
178 protected: 154 protected:
179 // Called by BitrateObserver. 155 // Called by BitrateObserver.
180 void OnNetworkChanged(uint32_t bitrate_bps, 156 void OnNetworkChanged(uint32_t bitrate_bps,
181 uint8_t fraction_lost, 157 uint8_t fraction_lost,
182 int64_t round_trip_time_ms); 158 int64_t round_trip_time_ms);
183 159
184 private: 160 private:
185 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); 161 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_);
186 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); 162 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_);
187 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); 163 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_);
188 164
189 void UpdateHistograms(); 165 void UpdateHistograms();
190 166
191 const int channel_id_; 167 const int channel_id_;
192 const uint32_t number_of_cores_; 168 const uint32_t number_of_cores_;
193 169
194 const rtc::scoped_ptr<VideoProcessingModule> vpm_; 170 const rtc::scoped_ptr<VideoProcessingModule> vpm_;
195 const rtc::scoped_ptr<QMVideoSettingsCallback> qm_callback_; 171 const rtc::scoped_ptr<QMVideoSettingsCallback> qm_callback_;
196 const rtc::scoped_ptr<VideoCodingModule> vcm_; 172 const rtc::scoped_ptr<VideoCodingModule> vcm_;
197 rtc::scoped_refptr<PayloadRouter> send_payload_router_; 173 rtc::scoped_refptr<PayloadRouter> send_payload_router_;
198 174
199 rtc::scoped_ptr<CriticalSectionWrapper> callback_cs_;
200 rtc::scoped_ptr<CriticalSectionWrapper> data_cs_; 175 rtc::scoped_ptr<CriticalSectionWrapper> data_cs_;
201 rtc::scoped_ptr<BitrateObserver> bitrate_observer_; 176 rtc::scoped_ptr<BitrateObserver> bitrate_observer_;
202 177
178 SendStatisticsProxy* const stats_proxy_;
179 I420FrameCallback* const pre_encode_callback_;
203 PacedSender* const pacer_; 180 PacedSender* const pacer_;
204 BitrateAllocator* const bitrate_allocator_; 181 BitrateAllocator* const bitrate_allocator_;
205 182
206 // The time we last received an input frame or encoded frame. This is used to 183 // The time we last received an input frame or encoded frame. This is used to
207 // track when video is stopped long enough that we also want to stop sending 184 // track when video is stopped long enough that we also want to stop sending
208 // padding. 185 // padding.
209 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); 186 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_);
210 bool simulcast_enabled_ GUARDED_BY(data_cs_); 187 bool simulcast_enabled_ GUARDED_BY(data_cs_);
211 int min_transmit_bitrate_kbps_ GUARDED_BY(data_cs_); 188 int min_transmit_bitrate_kbps_ GUARDED_BY(data_cs_);
212 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); 189 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_);
213 int target_delay_ms_ GUARDED_BY(data_cs_); 190 int target_delay_ms_ GUARDED_BY(data_cs_);
214 bool network_is_transmitting_ GUARDED_BY(data_cs_); 191 bool network_is_transmitting_ GUARDED_BY(data_cs_);
215 bool encoder_paused_ GUARDED_BY(data_cs_); 192 bool encoder_paused_ GUARDED_BY(data_cs_);
216 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); 193 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_);
217 std::map<unsigned int, int64_t> time_last_intra_request_ms_ 194 std::map<unsigned int, int64_t> time_last_intra_request_ms_
218 GUARDED_BY(data_cs_); 195 GUARDED_BY(data_cs_);
219 196
220 bool fec_enabled_; 197 bool fec_enabled_;
221 bool nack_enabled_; 198 bool nack_enabled_;
222 199
223 ViEEncoderObserver* codec_observer_ GUARDED_BY(callback_cs_); 200 ProcessThread* module_process_thread_;
224 ProcessThread& module_process_thread_;
225 201
226 bool has_received_sli_ GUARDED_BY(data_cs_); 202 bool has_received_sli_ GUARDED_BY(data_cs_);
227 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); 203 uint8_t picture_id_sli_ GUARDED_BY(data_cs_);
228 bool has_received_rpsi_ GUARDED_BY(data_cs_); 204 bool has_received_rpsi_ GUARDED_BY(data_cs_);
229 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); 205 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_);
230 std::map<uint32_t, int> ssrc_streams_ GUARDED_BY(data_cs_); 206 std::map<uint32_t, int> ssrc_streams_ GUARDED_BY(data_cs_);
231 207
232 bool video_suspended_ GUARDED_BY(data_cs_); 208 bool video_suspended_ GUARDED_BY(data_cs_);
233 I420FrameCallback* pre_encode_callback_ GUARDED_BY(callback_cs_);
234 const int64_t start_ms_; 209 const int64_t start_ms_;
235
236 SendStatisticsProxy* send_statistics_proxy_ GUARDED_BY(callback_cs_);
237 }; 210 };
238 211
239 } // namespace webrtc 212 } // namespace webrtc
240 213
241 #endif // WEBRTC_VIDEO_ENGINE_VIE_ENCODER_H_ 214 #endif // WEBRTC_VIDEO_ENGINE_VIE_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/video_engine/vie_channel_group.cc ('k') | webrtc/video_engine/vie_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698