| 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" | 25 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" |
| 26 #include "webrtc/modules/video_coding/video_coding_impl.h" |
| 26 #include "webrtc/modules/video_processing/include/video_processing.h" | 27 #include "webrtc/modules/video_processing/include/video_processing.h" |
| 27 #include "webrtc/typedefs.h" | 28 #include "webrtc/typedefs.h" |
| 28 | 29 |
| 29 namespace webrtc { | 30 namespace webrtc { |
| 30 | 31 |
| 31 class Config; | 32 class Config; |
| 32 class EncodedImageCallback; | 33 class EncodedImageCallback; |
| 33 class OveruseFrameDetector; | 34 class OveruseFrameDetector; |
| 34 class PacedSender; | 35 class PacedSender; |
| 35 class PayloadRouter; | 36 class PayloadRouter; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 55 // TODO(nisse): Used only for tests, delete? | 56 // TODO(nisse): Used only for tests, delete? |
| 56 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, | 57 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, |
| 57 OveruseFrameDetector* overuse_detector, | 58 OveruseFrameDetector* overuse_detector, |
| 58 PacedSender* pacer, | 59 PacedSender* pacer, |
| 59 PayloadRouter* payload_router, | 60 PayloadRouter* payload_router, |
| 60 EncodedImageCallback* post_encode_callback); | 61 EncodedImageCallback* post_encode_callback); |
| 61 ~ViEEncoder(); | 62 ~ViEEncoder(); |
| 62 | 63 |
| 63 bool Init(); | 64 bool Init(); |
| 64 | 65 |
| 65 VideoCodingModule* vcm() const; | 66 vcm::VideoSender* video_sender(); |
| 66 | 67 |
| 67 void SetNetworkTransmissionState(bool is_transmitting); | 68 void SetNetworkTransmissionState(bool is_transmitting); |
| 68 | 69 |
| 69 // Returns the id of the owning channel. | 70 // Returns the id of the owning channel. |
| 70 int Owner() const; | 71 int Owner() const; |
| 71 | 72 |
| 72 // Drops incoming packets before they get to the encoder. | 73 // Drops incoming packets before they get to the encoder. |
| 73 void Pause(); | 74 void Pause(); |
| 74 void Restart(); | 75 void Restart(); |
| 75 | 76 |
| 76 // Codec settings. | 77 // Codec settings. |
| 77 int32_t RegisterExternalEncoder(VideoEncoder* encoder, | 78 int32_t RegisterExternalEncoder(VideoEncoder* encoder, |
| 78 uint8_t pl_type, | 79 uint8_t pl_type, |
| 79 bool internal_source); | 80 bool internal_source); |
| 80 int32_t DeRegisterExternalEncoder(uint8_t pl_type); | 81 int32_t DeRegisterExternalEncoder(uint8_t pl_type); |
| 81 void SetEncoder(const VideoCodec& video_codec, int min_transmit_bitrate_bps); | 82 void SetEncoder(const VideoCodec& video_codec, int min_transmit_bitrate_bps); |
| 82 | 83 |
| 83 void EncodeVideoFrame(const VideoFrame& video_frame); | 84 void EncodeVideoFrame(const VideoFrame& video_frame); |
| 84 void SendKeyFrame(); | 85 void SendKeyFrame(); |
| 85 | 86 |
| 86 uint32_t LastObservedBitrateBps() const; | 87 uint32_t LastObservedBitrateBps() const; |
| 87 int CodecTargetBitrate(uint32_t* bitrate) const; | |
| 88 // Loss protection. Must be called before SetEncoder() to have max packet size | 88 // Loss protection. Must be called before SetEncoder() to have max packet size |
| 89 // updated according to protection. | 89 // updated according to protection. |
| 90 // TODO(pbos): Set protection method on construction or extract vcm_ outside | 90 // TODO(pbos): Set protection method on construction. |
| 91 // this class and set it on construction there. | |
| 92 void SetProtectionMethod(bool nack, bool fec); | 91 void SetProtectionMethod(bool nack, bool fec); |
| 93 | 92 |
| 94 // Implements VideoEncoderRateObserver. | 93 // Implements VideoEncoderRateObserver. |
| 95 void OnSetRates(uint32_t bitrate_bps, int framerate) override; | 94 void OnSetRates(uint32_t bitrate_bps, int framerate) override; |
| 96 | 95 |
| 97 // Implements VCMPacketizationCallback. | 96 // Implements VCMPacketizationCallback. |
| 98 void OnEncoderImplementationName(const char* implementation_name) override; | 97 void OnEncoderImplementationName(const char* implementation_name) override; |
| 99 | 98 |
| 100 // Implements EncodedImageCallback. | 99 // Implements EncodedImageCallback. |
| 101 int32_t Encoded(const EncodedImage& encoded_image, | 100 int32_t Encoded(const EncodedImage& encoded_image, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 123 | 122 |
| 124 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 123 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
| 125 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 124 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
| 126 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 125 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
| 127 | 126 |
| 128 const uint32_t number_of_cores_; | 127 const uint32_t number_of_cores_; |
| 129 const std::vector<uint32_t> ssrcs_; | 128 const std::vector<uint32_t> ssrcs_; |
| 130 | 129 |
| 131 const std::unique_ptr<VideoProcessing> vp_; | 130 const std::unique_ptr<VideoProcessing> vp_; |
| 132 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; | 131 const std::unique_ptr<QMVideoSettingsCallback> qm_callback_; |
| 133 const std::unique_ptr<VideoCodingModule> vcm_; | 132 vcm::VideoSender video_sender_; |
| 134 | 133 |
| 135 rtc::CriticalSection data_cs_; | 134 rtc::CriticalSection data_cs_; |
| 136 | 135 |
| 137 SendStatisticsProxy* const stats_proxy_; | 136 SendStatisticsProxy* const stats_proxy_; |
| 138 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; | 137 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; |
| 139 OveruseFrameDetector* const overuse_detector_; | 138 OveruseFrameDetector* const overuse_detector_; |
| 140 PacedSender* const pacer_; | 139 PacedSender* const pacer_; |
| 141 PayloadRouter* const send_payload_router_; | 140 PayloadRouter* const send_payload_router_; |
| 142 EncodedImageCallback* const post_encode_callback_; | 141 EncodedImageCallback* const post_encode_callback_; |
| 143 | 142 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 161 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); | 160 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); |
| 162 | 161 |
| 163 bool video_suspended_ GUARDED_BY(data_cs_); | 162 bool video_suspended_ GUARDED_BY(data_cs_); |
| 164 | 163 |
| 165 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_); | 164 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_); |
| 166 }; | 165 }; |
| 167 | 166 |
| 168 } // namespace webrtc | 167 } // namespace webrtc |
| 169 | 168 |
| 170 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 169 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
| OLD | NEW |