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 |
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/common_types.h" | 20 #include "webrtc/common_types.h" |
21 #include "webrtc/video_encoder.h" | 21 #include "webrtc/video_encoder.h" |
22 #include "webrtc/media/base/videosinkinterface.h" | 22 #include "webrtc/media/base/videosinkinterface.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
24 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 24 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
25 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" | |
26 #include "webrtc/modules/video_coding/video_coding_impl.h" | 25 #include "webrtc/modules/video_coding/video_coding_impl.h" |
27 #include "webrtc/modules/video_processing/include/video_processing.h" | 26 #include "webrtc/modules/video_processing/include/video_processing.h" |
28 #include "webrtc/typedefs.h" | 27 #include "webrtc/typedefs.h" |
29 | 28 |
30 namespace webrtc { | 29 namespace webrtc { |
31 | 30 |
32 class Config; | 31 class Config; |
33 class EncodedImageCallback; | 32 class EncodedImageCallback; |
34 class OveruseFrameDetector; | 33 class OveruseFrameDetector; |
35 class PacedSender; | 34 class PacedSender; |
(...skipping 15 matching lines...) Expand all Loading... | |
51 // 5. Call Start. | 50 // 5. Call Start. |
52 // 6. For each available raw video frame call EncodeVideoFrame. | 51 // 6. For each available raw video frame call EncodeVideoFrame. |
53 class ViEEncoder : public VideoEncoderRateObserver, | 52 class ViEEncoder : public VideoEncoderRateObserver, |
54 public EncodedImageCallback, | 53 public EncodedImageCallback, |
55 public VCMPacketizationCallback, | 54 public VCMPacketizationCallback, |
56 public VCMSendStatisticsCallback { | 55 public VCMSendStatisticsCallback { |
57 public: | 56 public: |
58 friend class ViEBitrateObserver; | 57 friend class ViEBitrateObserver; |
59 | 58 |
60 ViEEncoder(uint32_t number_of_cores, | 59 ViEEncoder(uint32_t number_of_cores, |
61 const std::vector<uint32_t>& ssrcs, | |
62 ProcessThread* module_process_thread, | 60 ProcessThread* module_process_thread, |
63 SendStatisticsProxy* stats_proxy, | 61 SendStatisticsProxy* stats_proxy, |
64 // TODO(nisse): Used only for tests, delete? | 62 // TODO(nisse): Used only for tests, delete? |
65 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, | 63 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, |
66 OveruseFrameDetector* overuse_detector, | 64 OveruseFrameDetector* overuse_detector, |
67 PacedSender* pacer); | 65 PacedSender* pacer); |
68 ~ViEEncoder(); | 66 ~ViEEncoder(); |
69 | 67 |
70 bool Init(); | 68 bool Init(); |
71 | 69 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 // Implements EncodedImageCallback. | 106 // Implements EncodedImageCallback. |
109 int32_t Encoded(const EncodedImage& encoded_image, | 107 int32_t Encoded(const EncodedImage& encoded_image, |
110 const CodecSpecificInfo* codec_specific_info, | 108 const CodecSpecificInfo* codec_specific_info, |
111 const RTPFragmentationHeader* fragmentation) override; | 109 const RTPFragmentationHeader* fragmentation) override; |
112 | 110 |
113 // Implements VideoSendStatisticsCallback. | 111 // Implements VideoSendStatisticsCallback. |
114 int32_t SendStatistics(const uint32_t bit_rate, | 112 int32_t SendStatistics(const uint32_t bit_rate, |
115 const uint32_t frame_rate) override; | 113 const uint32_t frame_rate) override; |
116 | 114 |
117 // virtual to test EncoderStateFeedback with mocks. | 115 // virtual to test EncoderStateFeedback with mocks. |
118 virtual void OnReceivedIntraFrameRequest(uint32_t ssrc); | 116 virtual void OnReceivedIntraFrameRequest(int stream_index); |
pbos-webrtc
2016/05/02 01:05:27
size_t
| |
119 virtual void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id); | 117 virtual void OnReceivedSLI(uint8_t picture_id); |
120 virtual void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id); | 118 virtual void OnReceivedRPSI(uint64_t picture_id); |
121 | 119 |
122 int GetPaddingNeededBps() const; | 120 int GetPaddingNeededBps() const; |
123 | 121 |
124 void OnBitrateUpdated(uint32_t bitrate_bps, | 122 void OnBitrateUpdated(uint32_t bitrate_bps, |
125 uint8_t fraction_lost, | 123 uint8_t fraction_lost, |
126 int64_t round_trip_time_ms); | 124 int64_t round_trip_time_ms); |
127 | 125 |
128 private: | 126 private: |
129 static const bool kEnableFrameRecording = false; | |
130 static const int kMaxLayers = 3; | |
131 | |
132 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 127 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
133 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 128 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
134 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 129 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
135 | 130 |
136 const uint32_t number_of_cores_; | 131 const uint32_t number_of_cores_; |
137 const std::vector<uint32_t> ssrcs_; | |
138 | 132 |
139 const std::unique_ptr<VideoProcessing> vp_; | 133 const std::unique_ptr<VideoProcessing> vp_; |
140 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; | 134 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; |
141 vcm::VideoSender video_sender_; | 135 vcm::VideoSender video_sender_; |
142 | 136 |
143 rtc::CriticalSection data_cs_; | 137 rtc::CriticalSection data_cs_; |
144 | 138 |
145 SendStatisticsProxy* const stats_proxy_; | 139 SendStatisticsProxy* const stats_proxy_; |
146 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; | 140 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; |
147 OveruseFrameDetector* const overuse_detector_; | 141 OveruseFrameDetector* const overuse_detector_; |
148 PacedSender* const pacer_; | 142 PacedSender* const pacer_; |
149 | 143 |
150 // The time we last received an input frame or encoded frame. This is used to | 144 // The time we last received an input frame or encoded frame. This is used to |
151 // track when video is stopped long enough that we also want to stop sending | 145 // track when video is stopped long enough that we also want to stop sending |
152 // padding. | 146 // padding. |
153 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); | 147 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); |
154 VideoCodec encoder_config_ GUARDED_BY(data_cs_); | 148 VideoCodec encoder_config_ GUARDED_BY(data_cs_); |
155 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); | 149 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); |
156 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); | 150 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); |
157 bool network_is_transmitting_ GUARDED_BY(data_cs_); | 151 bool network_is_transmitting_ GUARDED_BY(data_cs_); |
158 bool encoder_paused_ GUARDED_BY(data_cs_); | 152 bool encoder_paused_ GUARDED_BY(data_cs_); |
159 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); | 153 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); |
160 std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(data_cs_); | |
161 | 154 |
162 rtc::CriticalSection sink_cs_; | 155 rtc::CriticalSection sink_cs_; |
163 EncodedImageCallback* sink_ GUARDED_BY(sink_cs_); | 156 EncodedImageCallback* sink_ GUARDED_BY(sink_cs_); |
164 | 157 |
165 ProcessThread* module_process_thread_; | 158 ProcessThread* module_process_thread_; |
166 | 159 |
167 bool has_received_sli_ GUARDED_BY(data_cs_); | 160 bool has_received_sli_ GUARDED_BY(data_cs_); |
168 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); | 161 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); |
169 bool has_received_rpsi_ GUARDED_BY(data_cs_); | 162 bool has_received_rpsi_ GUARDED_BY(data_cs_); |
170 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); | 163 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); |
171 | 164 |
172 bool video_suspended_ GUARDED_BY(data_cs_); | 165 bool video_suspended_ GUARDED_BY(data_cs_); |
173 | |
174 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_); | |
175 }; | 166 }; |
176 | 167 |
177 } // namespace webrtc | 168 } // namespace webrtc |
178 | 169 |
179 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 170 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
OLD | NEW |