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 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 vcm::VideoSender* video_sender(); | 72 vcm::VideoSender* video_sender(); |
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 // Loss protection. Must be called before SetEncoder() to have max packet size | 97 // Loss protection. Must be called before SetEncoder() to have max packet size |
88 // updated according to protection. | 98 // updated according to protection. |
89 // TODO(pbos): Set protection method on construction. | 99 // TODO(pbos): Set protection method on construction. |
90 void SetProtectionMethod(bool nack, bool fec); | 100 void SetProtectionMethod(bool nack, bool fec); |
91 | 101 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 const std::unique_ptr<VideoProcessing> vp_; | 139 const std::unique_ptr<VideoProcessing> vp_; |
130 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; | 140 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; |
131 vcm::VideoSender video_sender_; | 141 vcm::VideoSender video_sender_; |
132 | 142 |
133 rtc::CriticalSection data_cs_; | 143 rtc::CriticalSection data_cs_; |
134 | 144 |
135 SendStatisticsProxy* const stats_proxy_; | 145 SendStatisticsProxy* const stats_proxy_; |
136 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; | 146 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; |
137 OveruseFrameDetector* const overuse_detector_; | 147 OveruseFrameDetector* const overuse_detector_; |
138 PacedSender* const pacer_; | 148 PacedSender* const pacer_; |
139 PayloadRouter* const send_payload_router_; | |
140 EncodedImageCallback* const post_encode_callback_; | |
141 | 149 |
142 // The time we last received an input frame or encoded frame. This is used to | 150 // The time we last received an input frame or encoded frame. This is used to |
143 // track when video is stopped long enough that we also want to stop sending | 151 // track when video is stopped long enough that we also want to stop sending |
144 // padding. | 152 // padding. |
145 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); | 153 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); |
146 VideoCodec encoder_config_ GUARDED_BY(data_cs_); | 154 VideoCodec encoder_config_ GUARDED_BY(data_cs_); |
147 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); | 155 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); |
148 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); | 156 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); |
149 bool network_is_transmitting_ GUARDED_BY(data_cs_); | 157 bool network_is_transmitting_ GUARDED_BY(data_cs_); |
150 bool encoder_paused_ GUARDED_BY(data_cs_); | 158 bool encoder_paused_ GUARDED_BY(data_cs_); |
151 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); | 159 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); |
152 std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(data_cs_); | 160 std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(data_cs_); |
153 | 161 |
| 162 rtc::CriticalSection sink_cs_; |
| 163 EncodedImageCallback* sink_ GUARDED_BY(sink_cs_); |
| 164 |
154 ProcessThread* module_process_thread_; | 165 ProcessThread* module_process_thread_; |
155 | 166 |
156 bool has_received_sli_ GUARDED_BY(data_cs_); | 167 bool has_received_sli_ GUARDED_BY(data_cs_); |
157 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); | 168 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); |
158 bool has_received_rpsi_ GUARDED_BY(data_cs_); | 169 bool has_received_rpsi_ GUARDED_BY(data_cs_); |
159 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); | 170 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); |
160 | 171 |
161 bool video_suspended_ GUARDED_BY(data_cs_); | 172 bool video_suspended_ GUARDED_BY(data_cs_); |
162 | 173 |
163 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_); | 174 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_); |
164 }; | 175 }; |
165 | 176 |
166 } // namespace webrtc | 177 } // namespace webrtc |
167 | 178 |
168 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 179 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
OLD | NEW |