| 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 <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
| 19 #include "webrtc/base/scoped_ref_ptr.h" | 19 #include "webrtc/base/scoped_ref_ptr.h" |
| 20 #include "webrtc/base/thread_annotations.h" | 20 #include "webrtc/base/thread_annotations.h" |
| 21 #include "webrtc/common_types.h" | 21 #include "webrtc/common_types.h" |
| 22 #include "webrtc/video_encoder.h" | 22 #include "webrtc/video_encoder.h" |
| 23 #include "webrtc/media/base/videosinkinterface.h" | 23 #include "webrtc/media/base/videosinkinterface.h" |
| 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 25 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 25 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
| 26 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" | |
| 27 #include "webrtc/modules/video_coding/video_coding_impl.h" | 26 #include "webrtc/modules/video_coding/video_coding_impl.h" |
| 28 #include "webrtc/modules/video_processing/include/video_processing.h" | 27 #include "webrtc/modules/video_processing/include/video_processing.h" |
| 29 #include "webrtc/typedefs.h" | 28 #include "webrtc/typedefs.h" |
| 30 | 29 |
| 31 namespace webrtc { | 30 namespace webrtc { |
| 32 | 31 |
| 33 class Config; | 32 class Config; |
| 34 class EncodedImageCallback; | 33 class EncodedImageCallback; |
| 35 class OveruseFrameDetector; | 34 class OveruseFrameDetector; |
| 36 class PacedSender; | 35 class PacedSender; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 51 // the encoded bit stream. | 50 // the encoded bit stream. |
| 52 // 5. Call Start. | 51 // 5. Call Start. |
| 53 // 6. For each available raw video frame call EncodeVideoFrame. | 52 // 6. For each available raw video frame call EncodeVideoFrame. |
| 54 class ViEEncoder : public VideoEncoderRateObserver, | 53 class ViEEncoder : public VideoEncoderRateObserver, |
| 55 public EncodedImageCallback, | 54 public EncodedImageCallback, |
| 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 OveruseFrameDetector* overuse_detector); | 62 OveruseFrameDetector* overuse_detector); |
| 65 ~ViEEncoder(); | 63 ~ViEEncoder(); |
| 66 | 64 |
| 67 vcm::VideoSender* video_sender(); | 65 vcm::VideoSender* video_sender(); |
| 68 | 66 |
| 69 void SetNetworkTransmissionState(bool is_transmitting); | 67 void SetNetworkTransmissionState(bool is_transmitting); |
| 70 | 68 |
| 71 // Returns the id of the owning channel. | 69 // Returns the id of the owning channel. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 int32_t Encoded(const EncodedImage& encoded_image, | 99 int32_t Encoded(const EncodedImage& encoded_image, |
| 102 const CodecSpecificInfo* codec_specific_info, | 100 const CodecSpecificInfo* codec_specific_info, |
| 103 const RTPFragmentationHeader* fragmentation) override; | 101 const RTPFragmentationHeader* fragmentation) override; |
| 104 | 102 |
| 105 // Implements VideoSendStatisticsCallback. | 103 // Implements VideoSendStatisticsCallback. |
| 106 void SendStatistics(uint32_t bit_rate, | 104 void SendStatistics(uint32_t bit_rate, |
| 107 uint32_t frame_rate, | 105 uint32_t frame_rate, |
| 108 const std::string& encoder_name) override; | 106 const std::string& encoder_name) override; |
| 109 | 107 |
| 110 // virtual to test EncoderStateFeedback with mocks. | 108 // virtual to test EncoderStateFeedback with mocks. |
| 111 virtual void OnReceivedIntraFrameRequest(uint32_t ssrc); | 109 virtual void OnReceivedIntraFrameRequest(size_t stream_index); |
| 112 virtual void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id); | 110 virtual void OnReceivedSLI(uint8_t picture_id); |
| 113 virtual void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id); | 111 virtual void OnReceivedRPSI(uint64_t picture_id); |
| 114 | 112 |
| 115 int GetPaddingNeededBps() const; | 113 int GetPaddingNeededBps() const; |
| 116 | 114 |
| 117 void OnBitrateUpdated(uint32_t bitrate_bps, | 115 void OnBitrateUpdated(uint32_t bitrate_bps, |
| 118 uint8_t fraction_lost, | 116 uint8_t fraction_lost, |
| 119 int64_t round_trip_time_ms); | 117 int64_t round_trip_time_ms); |
| 120 | 118 |
| 121 private: | 119 private: |
| 122 static const bool kEnableFrameRecording = false; | |
| 123 static const int kMaxLayers = 3; | |
| 124 | |
| 125 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 120 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
| 126 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 121 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
| 127 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 122 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
| 128 | 123 |
| 129 const uint32_t number_of_cores_; | 124 const uint32_t number_of_cores_; |
| 130 const std::vector<uint32_t> ssrcs_; | |
| 131 | 125 |
| 132 const std::unique_ptr<VideoProcessing> vp_; | 126 const std::unique_ptr<VideoProcessing> vp_; |
| 133 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; | 127 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; |
| 134 vcm::VideoSender video_sender_; | 128 vcm::VideoSender video_sender_; |
| 135 | 129 |
| 136 rtc::CriticalSection data_cs_; | 130 rtc::CriticalSection data_cs_; |
| 137 | 131 |
| 138 SendStatisticsProxy* const stats_proxy_; | 132 SendStatisticsProxy* const stats_proxy_; |
| 139 OveruseFrameDetector* const overuse_detector_; | 133 OveruseFrameDetector* const overuse_detector_; |
| 140 | 134 |
| 141 // The time we last received an input frame or encoded frame. This is used to | 135 // The time we last received an input frame or encoded frame. This is used to |
| 142 // track when video is stopped long enough that we also want to stop sending | 136 // track when video is stopped long enough that we also want to stop sending |
| 143 // padding. | 137 // padding. |
| 144 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); | 138 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); |
| 145 VideoCodec encoder_config_ GUARDED_BY(data_cs_); | 139 VideoCodec encoder_config_ GUARDED_BY(data_cs_); |
| 146 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); | 140 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); |
| 147 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); | 141 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); |
| 148 bool network_is_transmitting_ GUARDED_BY(data_cs_); | 142 bool network_is_transmitting_ GUARDED_BY(data_cs_); |
| 149 bool encoder_paused_ GUARDED_BY(data_cs_); | 143 bool encoder_paused_ GUARDED_BY(data_cs_); |
| 150 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); | 144 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); |
| 151 std::vector<int64_t> time_last_intra_request_ms_ GUARDED_BY(data_cs_); | |
| 152 | 145 |
| 153 rtc::CriticalSection sink_cs_; | 146 rtc::CriticalSection sink_cs_; |
| 154 EncodedImageCallback* sink_ GUARDED_BY(sink_cs_); | 147 EncodedImageCallback* sink_ GUARDED_BY(sink_cs_); |
| 155 | 148 |
| 156 ProcessThread* module_process_thread_; | 149 ProcessThread* module_process_thread_; |
| 157 | 150 |
| 158 bool has_received_sli_ GUARDED_BY(data_cs_); | 151 bool has_received_sli_ GUARDED_BY(data_cs_); |
| 159 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); | 152 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); |
| 160 bool has_received_rpsi_ GUARDED_BY(data_cs_); | 153 bool has_received_rpsi_ GUARDED_BY(data_cs_); |
| 161 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); | 154 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); |
| 162 | 155 |
| 163 bool video_suspended_ GUARDED_BY(data_cs_); | 156 bool video_suspended_ GUARDED_BY(data_cs_); |
| 164 | |
| 165 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_); | |
| 166 }; | 157 }; |
| 167 | 158 |
| 168 } // namespace webrtc | 159 } // namespace webrtc |
| 169 | 160 |
| 170 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 161 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
| OLD | NEW |