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

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

Issue 1785283002: Move BitrateAllocator reference from ViEEncoder to VideoSendStream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comment changes. Created 4 years, 9 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/video_send_stream.cc ('k') | webrtc/video/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
11 #ifndef WEBRTC_VIDEO_VIE_ENCODER_H_ 11 #ifndef WEBRTC_VIDEO_VIE_ENCODER_H_
12 #define WEBRTC_VIDEO_VIE_ENCODER_H_ 12 #define WEBRTC_VIDEO_VIE_ENCODER_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/criticalsection.h" 17 #include "webrtc/base/criticalsection.h"
18 #include "webrtc/base/scoped_ref_ptr.h" 18 #include "webrtc/base/scoped_ref_ptr.h"
19 #include "webrtc/base/thread_annotations.h" 19 #include "webrtc/base/thread_annotations.h"
20 #include "webrtc/call/bitrate_allocator.h"
21 #include "webrtc/common_types.h" 20 #include "webrtc/common_types.h"
22 #include "webrtc/frame_callback.h" 21 #include "webrtc/frame_callback.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
24 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 23 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
25 #include "webrtc/modules/video_processing/include/video_processing.h" 24 #include "webrtc/modules/video_processing/include/video_processing.h"
26 #include "webrtc/typedefs.h" 25 #include "webrtc/typedefs.h"
27 26
28 namespace webrtc { 27 namespace webrtc {
29 28
30 class BitrateAllocator;
31 class BitrateObserver;
32 class Config; 29 class Config;
33 class EncodedImageCallback; 30 class EncodedImageCallback;
34 class OveruseFrameDetector; 31 class OveruseFrameDetector;
35 class PacedSender; 32 class PacedSender;
36 class PayloadRouter; 33 class PayloadRouter;
37 class ProcessThread; 34 class ProcessThread;
38 class QMVideoSettingsCallback; 35 class QMVideoSettingsCallback;
39 class SendStatisticsProxy; 36 class SendStatisticsProxy;
40 class ViEBitrateObserver; 37 class ViEBitrateObserver;
41 class ViEEffectFilter; 38 class ViEEffectFilter;
42 class VideoCodingModule; 39 class VideoCodingModule;
43 class VideoEncoder; 40 class VideoEncoder;
44 41
45 class ViEEncoder : public VideoEncoderRateObserver, 42 class ViEEncoder : public VideoEncoderRateObserver,
46 public VCMPacketizationCallback, 43 public VCMPacketizationCallback,
47 public VCMSendStatisticsCallback { 44 public VCMSendStatisticsCallback {
48 public: 45 public:
49 friend class ViEBitrateObserver; 46 friend class ViEBitrateObserver;
50 47
51 ViEEncoder(uint32_t number_of_cores, 48 ViEEncoder(uint32_t number_of_cores,
52 const std::vector<uint32_t>& ssrcs, 49 const std::vector<uint32_t>& ssrcs,
53 ProcessThread* module_process_thread, 50 ProcessThread* module_process_thread,
54 SendStatisticsProxy* stats_proxy, 51 SendStatisticsProxy* stats_proxy,
55 I420FrameCallback* pre_encode_callback, 52 I420FrameCallback* pre_encode_callback,
56 OveruseFrameDetector* overuse_detector, 53 OveruseFrameDetector* overuse_detector,
57 PacedSender* pacer, 54 PacedSender* pacer,
58 PayloadRouter* payload_router, 55 PayloadRouter* payload_router);
59 BitrateAllocator* bitrate_allocator);
60 ~ViEEncoder(); 56 ~ViEEncoder();
61 57
62 bool Init(); 58 bool Init();
63 59
64 VideoCodingModule* vcm() const; 60 VideoCodingModule* vcm() const;
65 61
66 void SetNetworkTransmissionState(bool is_transmitting); 62 void SetNetworkTransmissionState(bool is_transmitting);
67 63
68 // Returns the id of the owning channel. 64 // Returns the id of the owning channel.
69 int Owner() const; 65 int Owner() const;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 98
103 // Implements VideoSendStatisticsCallback. 99 // Implements VideoSendStatisticsCallback.
104 int32_t SendStatistics(const uint32_t bit_rate, 100 int32_t SendStatistics(const uint32_t bit_rate,
105 const uint32_t frame_rate) override; 101 const uint32_t frame_rate) override;
106 102
107 // virtual to test EncoderStateFeedback with mocks. 103 // virtual to test EncoderStateFeedback with mocks.
108 virtual void OnReceivedIntraFrameRequest(uint32_t ssrc); 104 virtual void OnReceivedIntraFrameRequest(uint32_t ssrc);
109 virtual void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id); 105 virtual void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id);
110 virtual void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id); 106 virtual void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id);
111 107
112 // Lets the sender suspend video when the rate drops below
113 // |threshold_bps|, and turns back on when the rate goes back up above
114 // |threshold_bps| + |window_bps|.
115 void SuspendBelowMinBitrate();
116
117 // New-style callbacks, used by VideoSendStream. 108 // New-style callbacks, used by VideoSendStream.
118 void RegisterPostEncodeImageCallback( 109 void RegisterPostEncodeImageCallback(
119 EncodedImageCallback* post_encode_callback); 110 EncodedImageCallback* post_encode_callback);
120 111
121 int GetPaddingNeededBps() const; 112 int GetPaddingNeededBps() const;
122 113
123 protected: 114 void OnBitrateUpdated(uint32_t bitrate_bps,
124 // Called by BitrateObserver.
125 void OnNetworkChanged(uint32_t bitrate_bps,
126 uint8_t fraction_lost, 115 uint8_t fraction_lost,
127 int64_t round_trip_time_ms); 116 int64_t round_trip_time_ms);
128 117
129 private: 118 private:
130 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); 119 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_);
131 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); 120 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_);
132 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); 121 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_);
133 122
134 const uint32_t number_of_cores_; 123 const uint32_t number_of_cores_;
135 const std::vector<uint32_t> ssrcs_; 124 const std::vector<uint32_t> ssrcs_;
136 125
137 const std::unique_ptr<VideoProcessing> vp_; 126 const std::unique_ptr<VideoProcessing> vp_;
138 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; 127 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_;
139 const std::unique_ptr<VideoCodingModule> vcm_; 128 const std::unique_ptr<VideoCodingModule> vcm_;
140 129
141 rtc::CriticalSection data_cs_; 130 rtc::CriticalSection data_cs_;
142 std::unique_ptr<BitrateObserver> bitrate_observer_;
143 131
144 SendStatisticsProxy* const stats_proxy_; 132 SendStatisticsProxy* const stats_proxy_;
145 I420FrameCallback* const pre_encode_callback_; 133 I420FrameCallback* const pre_encode_callback_;
146 OveruseFrameDetector* const overuse_detector_; 134 OveruseFrameDetector* const overuse_detector_;
147 PacedSender* const pacer_; 135 PacedSender* const pacer_;
148 PayloadRouter* const send_payload_router_; 136 PayloadRouter* const send_payload_router_;
149 BitrateAllocator* const bitrate_allocator_;
150 137
151 // The time we last received an input frame or encoded frame. This is used to 138 // The time we last received an input frame or encoded frame. This is used to
152 // track when video is stopped long enough that we also want to stop sending 139 // track when video is stopped long enough that we also want to stop sending
153 // padding. 140 // padding.
154 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); 141 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_);
155 VideoCodec encoder_config_ GUARDED_BY(data_cs_); 142 VideoCodec encoder_config_ GUARDED_BY(data_cs_);
156 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); 143 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_);
157 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); 144 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_);
158 bool network_is_transmitting_ GUARDED_BY(data_cs_); 145 bool network_is_transmitting_ GUARDED_BY(data_cs_);
159 bool encoder_paused_ GUARDED_BY(data_cs_); 146 bool encoder_paused_ GUARDED_BY(data_cs_);
160 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); 147 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_);
161 std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(data_cs_); 148 std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(data_cs_);
162 149
163 ProcessThread* module_process_thread_; 150 ProcessThread* module_process_thread_;
164 151
165 bool has_received_sli_ GUARDED_BY(data_cs_); 152 bool has_received_sli_ GUARDED_BY(data_cs_);
166 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); 153 uint8_t picture_id_sli_ GUARDED_BY(data_cs_);
167 bool has_received_rpsi_ GUARDED_BY(data_cs_); 154 bool has_received_rpsi_ GUARDED_BY(data_cs_);
168 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); 155 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_);
169 156
170 bool video_suspended_ GUARDED_BY(data_cs_); 157 bool video_suspended_ GUARDED_BY(data_cs_);
171 }; 158 };
172 159
173 } // namespace webrtc 160 } // namespace webrtc
174 161
175 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ 162 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/video/video_send_stream.cc ('k') | webrtc/video/vie_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698