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