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

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

Issue 1912653002: Remove PayloadRouter dependency from ViEEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
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 14 matching lines...) Expand all
25 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" 25 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h"
26 #include "webrtc/modules/video_processing/include/video_processing.h" 26 #include "webrtc/modules/video_processing/include/video_processing.h"
27 #include "webrtc/typedefs.h" 27 #include "webrtc/typedefs.h"
28 28
29 namespace webrtc { 29 namespace webrtc {
30 30
31 class Config; 31 class Config;
32 class EncodedImageCallback; 32 class EncodedImageCallback;
33 class OveruseFrameDetector; 33 class OveruseFrameDetector;
34 class PacedSender; 34 class PacedSender;
35 class PayloadRouter;
36 class ProcessThread; 35 class ProcessThread;
37 class QMVideoSettingsCallback; 36 class QMVideoSettingsCallback;
38 class SendStatisticsProxy; 37 class SendStatisticsProxy;
39 class ViEBitrateObserver; 38 class ViEBitrateObserver;
40 class ViEEffectFilter; 39 class ViEEffectFilter;
41 class VideoCodingModule; 40 class VideoCodingModule;
42 class VideoEncoder; 41 class VideoEncoder;
43 42
43 // VieEncoder represent a video encoder that accepts raw video frames as input
44 // and produces an encoded bit stream.
45 // Usage:
46 // 1. Instantiate
47 // 2. Call Init
48 // 3. Call RegisterExternalEncoder if available.
49 // 4. Call SetEncoder with the codec settings and the object that shall receive
50 // the encoded bit stream.
51 // 5. Call Start.
52 // 6. For each available raw video frame call EncodeVideoFrame.
44 class ViEEncoder : public VideoEncoderRateObserver, 53 class ViEEncoder : public VideoEncoderRateObserver,
45 public EncodedImageCallback, 54 public EncodedImageCallback,
46 public VCMPacketizationCallback, 55 public VCMPacketizationCallback,
47 public VCMSendStatisticsCallback { 56 public VCMSendStatisticsCallback {
48 public: 57 public:
49 friend class ViEBitrateObserver; 58 friend class ViEBitrateObserver;
50 59
51 ViEEncoder(uint32_t number_of_cores, 60 ViEEncoder(uint32_t number_of_cores,
52 const std::vector<uint32_t>& ssrcs, 61 const std::vector<uint32_t>& ssrcs,
53 ProcessThread* module_process_thread, 62 ProcessThread* module_process_thread,
54 SendStatisticsProxy* stats_proxy, 63 SendStatisticsProxy* stats_proxy,
55 // TODO(nisse): Used only for tests, delete? 64 // TODO(nisse): Used only for tests, delete?
56 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, 65 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
57 OveruseFrameDetector* overuse_detector, 66 OveruseFrameDetector* overuse_detector,
58 PacedSender* pacer, 67 PacedSender* pacer);
59 PayloadRouter* payload_router,
60 EncodedImageCallback* post_encode_callback);
61 ~ViEEncoder(); 68 ~ViEEncoder();
62 69
63 bool Init(); 70 bool Init();
64 71
65 VideoCodingModule* vcm() const; 72 VideoCodingModule* vcm() const;
66 73
67 void SetNetworkTransmissionState(bool is_transmitting); 74 void SetNetworkTransmissionState(bool is_transmitting);
68 75
69 // Returns the id of the owning channel. 76 // Returns the id of the owning channel.
70 int Owner() const; 77 int Owner() const;
71 78
79 void Start();
72 // Drops incoming packets before they get to the encoder. 80 // Drops incoming packets before they get to the encoder.
73 void Pause(); 81 void Pause();
74 void Restart();
75 82
76 // Codec settings. 83 // Codec settings.
77 int32_t RegisterExternalEncoder(VideoEncoder* encoder, 84 int32_t RegisterExternalEncoder(VideoEncoder* encoder,
78 uint8_t pl_type, 85 uint8_t pl_type,
79 bool internal_source); 86 bool internal_source);
80 int32_t DeRegisterExternalEncoder(uint8_t pl_type); 87 int32_t DeRegisterExternalEncoder(uint8_t pl_type);
81 void SetEncoder(const VideoCodec& video_codec, int min_transmit_bitrate_bps); 88 void SetEncoder(const VideoCodec& video_codec,
89 int min_transmit_bitrate_bps,
90 size_t max_data_payload_length,
91 EncodedImageCallback* sink);
82 92
83 void EncodeVideoFrame(const VideoFrame& video_frame); 93 void EncodeVideoFrame(const VideoFrame& video_frame);
84 void SendKeyFrame(); 94 void SendKeyFrame();
85 95
86 uint32_t LastObservedBitrateBps() const; 96 uint32_t LastObservedBitrateBps() const;
87 int CodecTargetBitrate(uint32_t* bitrate) const; 97 int CodecTargetBitrate(uint32_t* bitrate) const;
88 // Loss protection. Must be called before SetEncoder() to have max packet size 98 // Loss protection. Must be called before SetEncoder() to have max packet size
89 // updated according to protection. 99 // updated according to protection.
90 // TODO(pbos): Set protection method on construction or extract vcm_ outside 100 // TODO(pbos): Set protection method on construction or extract vcm_ outside
91 // this class and set it on construction there. 101 // this class and set it on construction there.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const std::unique_ptr<VideoProcessing> vp_; 141 const std::unique_ptr<VideoProcessing> vp_;
132 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; 142 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_;
133 const std::unique_ptr<VideoCodingModule> vcm_; 143 const std::unique_ptr<VideoCodingModule> vcm_;
134 144
135 rtc::CriticalSection data_cs_; 145 rtc::CriticalSection data_cs_;
136 146
137 SendStatisticsProxy* const stats_proxy_; 147 SendStatisticsProxy* const stats_proxy_;
138 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; 148 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_;
139 OveruseFrameDetector* const overuse_detector_; 149 OveruseFrameDetector* const overuse_detector_;
140 PacedSender* const pacer_; 150 PacedSender* const pacer_;
141 PayloadRouter* const send_payload_router_;
142 EncodedImageCallback* const post_encode_callback_;
143 151
144 // The time we last received an input frame or encoded frame. This is used to 152 // The time we last received an input frame or encoded frame. This is used to
145 // track when video is stopped long enough that we also want to stop sending 153 // track when video is stopped long enough that we also want to stop sending
146 // padding. 154 // padding.
147 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); 155 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_);
148 VideoCodec encoder_config_ GUARDED_BY(data_cs_); 156 VideoCodec encoder_config_ GUARDED_BY(data_cs_);
149 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); 157 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_);
150 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); 158 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_);
151 bool network_is_transmitting_ GUARDED_BY(data_cs_); 159 bool network_is_transmitting_ GUARDED_BY(data_cs_);
152 bool encoder_paused_ GUARDED_BY(data_cs_); 160 bool encoder_paused_ GUARDED_BY(data_cs_);
153 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); 161 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_);
154 std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(data_cs_); 162 std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(data_cs_);
155 163
164 rtc::CriticalSection sink_cs_;
165 EncodedImageCallback* sink_ GUARDED_BY(sink_cs_);
166
156 ProcessThread* module_process_thread_; 167 ProcessThread* module_process_thread_;
157 168
158 bool has_received_sli_ GUARDED_BY(data_cs_); 169 bool has_received_sli_ GUARDED_BY(data_cs_);
159 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); 170 uint8_t picture_id_sli_ GUARDED_BY(data_cs_);
160 bool has_received_rpsi_ GUARDED_BY(data_cs_); 171 bool has_received_rpsi_ GUARDED_BY(data_cs_);
161 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); 172 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_);
162 173
163 bool video_suspended_ GUARDED_BY(data_cs_); 174 bool video_suspended_ GUARDED_BY(data_cs_);
164 175
165 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_); 176 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_);
166 }; 177 };
167 178
168 } // namespace webrtc 179 } // namespace webrtc
169 180
170 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ 181 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698