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

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

Issue 1993113003: Refactor how padding is calculated. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed review comments. Created 4 years, 6 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_tests.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
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 public EncodedImageCallback, 53 public EncodedImageCallback,
54 public VCMSendStatisticsCallback { 54 public VCMSendStatisticsCallback {
55 public: 55 public:
56 friend class ViEBitrateObserver; 56 friend class ViEBitrateObserver;
57 57
58 ViEEncoder(uint32_t number_of_cores, 58 ViEEncoder(uint32_t number_of_cores,
59 ProcessThread* module_process_thread, 59 ProcessThread* module_process_thread,
60 SendStatisticsProxy* stats_proxy, 60 SendStatisticsProxy* stats_proxy,
61 OveruseFrameDetector* overuse_detector, 61 OveruseFrameDetector* overuse_detector,
62 EncodedImageCallback* sink); 62 EncodedImageCallback* sink);
63
64 ~ViEEncoder(); 63 ~ViEEncoder();
65 64
66 vcm::VideoSender* video_sender(); 65 vcm::VideoSender* video_sender();
67 66
68 // Returns the id of the owning channel. 67 // Returns the id of the owning channel.
69 int Owner() const; 68 int Owner() const;
70 69
71 void Start(); 70 void Start();
72 // Drops incoming packets before they get to the encoder. 71 // Drops incoming packets before they get to the encoder.
73 void Pause(); 72 void Pause();
74 73
75 // Codec settings. 74 // Codec settings.
76 int32_t RegisterExternalEncoder(VideoEncoder* encoder, 75 int32_t RegisterExternalEncoder(VideoEncoder* encoder,
77 uint8_t pl_type, 76 uint8_t pl_type,
78 bool internal_source); 77 bool internal_source);
79 int32_t DeRegisterExternalEncoder(uint8_t pl_type); 78 int32_t DeRegisterExternalEncoder(uint8_t pl_type);
80 void SetEncoder(const VideoCodec& video_codec, 79 void SetEncoder(const VideoCodec& video_codec,
81 int min_transmit_bitrate_bps,
82 size_t max_data_payload_length); 80 size_t max_data_payload_length);
83 81
84 void EncodeVideoFrame(const VideoFrame& video_frame); 82 void EncodeVideoFrame(const VideoFrame& video_frame);
85 void SendKeyFrame(); 83 void SendKeyFrame();
86 84
85 // Returns the time when the encoder last received an input frame or produced
86 // an encoded frame.
87 int64_t time_of_last_frame_activity_ms();
88
87 // Implements VideoEncoderRateObserver. 89 // Implements VideoEncoderRateObserver.
88 // TODO(perkj): Refactor VideoEncoderRateObserver. This is only used for 90 // TODO(perkj): Refactor VideoEncoderRateObserver. This is only used for
89 // stats. The stats should be set in VideoSendStream instead. 91 // stats. The stats should be set in VideoSendStream instead.
90 // |bitrate_bps| is the target bitrate and |framerate| is the input frame 92 // |bitrate_bps| is the target bitrate and |framerate| is the input frame
91 // rate so it has nothing to do with the actual encoder. 93 // rate so it has nothing to do with the actual encoder.
92 void OnSetRates(uint32_t bitrate_bps, int framerate) override; 94 void OnSetRates(uint32_t bitrate_bps, int framerate) override;
93 95
94 // Implements EncodedImageCallback. 96 // Implements EncodedImageCallback.
95 int32_t Encoded(const EncodedImage& encoded_image, 97 int32_t Encoded(const EncodedImage& encoded_image,
96 const CodecSpecificInfo* codec_specific_info, 98 const CodecSpecificInfo* codec_specific_info,
97 const RTPFragmentationHeader* fragmentation) override; 99 const RTPFragmentationHeader* fragmentation) override;
98 100
99 // Implements VideoSendStatisticsCallback. 101 // Implements VideoSendStatisticsCallback.
100 void SendStatistics(uint32_t bit_rate, 102 void SendStatistics(uint32_t bit_rate,
101 uint32_t frame_rate, 103 uint32_t frame_rate,
102 const std::string& encoder_name) override; 104 const std::string& encoder_name) override;
103 105
104 // virtual to test EncoderStateFeedback with mocks. 106 // virtual to test EncoderStateFeedback with mocks.
105 virtual void OnReceivedIntraFrameRequest(size_t stream_index); 107 virtual void OnReceivedIntraFrameRequest(size_t stream_index);
106 virtual void OnReceivedSLI(uint8_t picture_id); 108 virtual void OnReceivedSLI(uint8_t picture_id);
107 virtual void OnReceivedRPSI(uint64_t picture_id); 109 virtual void OnReceivedRPSI(uint64_t picture_id);
108 110
109 // Note that this method might return a value higher than the current BWE and
110 // it's up to the caller to possibly limit the value.
111 int GetPaddingNeededBps() const;
112
113 void OnBitrateUpdated(uint32_t bitrate_bps, 111 void OnBitrateUpdated(uint32_t bitrate_bps,
114 uint8_t fraction_lost, 112 uint8_t fraction_lost,
115 int64_t round_trip_time_ms); 113 int64_t round_trip_time_ms);
116 114
117 private: 115 private:
118 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); 116 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_);
119 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); 117 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_);
120 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); 118 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_);
121 119
122 const uint32_t number_of_cores_; 120 const uint32_t number_of_cores_;
123 EncodedImageCallback* const sink_; 121 EncodedImageCallback* const sink_;
124 122
125 const std::unique_ptr<VideoProcessing> vp_; 123 const std::unique_ptr<VideoProcessing> vp_;
126 vcm::VideoSender video_sender_; 124 vcm::VideoSender video_sender_;
127 125
128 rtc::CriticalSection data_cs_; 126 rtc::CriticalSection data_cs_;
129 127
130 SendStatisticsProxy* const stats_proxy_; 128 SendStatisticsProxy* const stats_proxy_;
131 OveruseFrameDetector* const overuse_detector_; 129 OveruseFrameDetector* const overuse_detector_;
132 130
133 // The time we last received an input frame or encoded frame. This is used to 131 // The time we last received an input frame or encoded frame. This is used to
134 // track when video is stopped long enough that we also want to stop sending 132 // track when video is stopped long enough that we also want to stop sending
135 // padding. 133 // padding.
136 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); 134 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_);
137 VideoCodec encoder_config_ GUARDED_BY(data_cs_); 135 VideoCodec encoder_config_ GUARDED_BY(data_cs_);
138 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_);
139 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); 136 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_);
140 bool encoder_paused_ GUARDED_BY(data_cs_); 137 bool encoder_paused_ GUARDED_BY(data_cs_);
141 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); 138 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_);
142 139
143 ProcessThread* module_process_thread_; 140 ProcessThread* module_process_thread_;
144 141
145 bool has_received_sli_ GUARDED_BY(data_cs_); 142 bool has_received_sli_ GUARDED_BY(data_cs_);
146 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); 143 uint8_t picture_id_sli_ GUARDED_BY(data_cs_);
147 bool has_received_rpsi_ GUARDED_BY(data_cs_); 144 bool has_received_rpsi_ GUARDED_BY(data_cs_);
148 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); 145 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_);
149 146
150 bool video_suspended_ GUARDED_BY(data_cs_); 147 bool video_suspended_ GUARDED_BY(data_cs_);
151 }; 148 };
152 149
153 } // namespace webrtc 150 } // namespace webrtc
154 151
155 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ 152 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/video/video_send_stream_tests.cc ('k') | webrtc/video/vie_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698