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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // 6. For each available raw video frame call EncodeVideoFrame. | 51 // 6. For each available raw video frame call EncodeVideoFrame. |
52 class ViEEncoder : public VideoEncoderRateObserver, | 52 class ViEEncoder : public VideoEncoderRateObserver, |
53 public EncodedImageCallback, | 53 public EncodedImageCallback, |
54 public VCMSendStatisticsCallback { | 54 public VCMSendStatisticsCallback { |
55 public: | 55 public: |
56 friend class ViEBitrateObserver; | 56 friend class ViEBitrateObserver; |
57 | 57 |
58 ViEEncoder(uint32_t number_of_cores, | 58 ViEEncoder(uint32_t number_of_cores, |
59 ProcessThread* module_process_thread, | 59 ProcessThread* module_process_thread, |
60 SendStatisticsProxy* stats_proxy, | 60 SendStatisticsProxy* stats_proxy, |
61 OveruseFrameDetector* overuse_detector); | 61 OveruseFrameDetector* overuse_detector, |
| 62 EncodedImageCallback* sink); |
| 63 |
62 ~ViEEncoder(); | 64 ~ViEEncoder(); |
63 | 65 |
64 vcm::VideoSender* video_sender(); | 66 vcm::VideoSender* video_sender(); |
65 | 67 |
66 // Returns the id of the owning channel. | 68 // Returns the id of the owning channel. |
67 int Owner() const; | 69 int Owner() const; |
68 | 70 |
69 void Start(); | 71 void Start(); |
70 // Drops incoming packets before they get to the encoder. | 72 // Drops incoming packets before they get to the encoder. |
71 void Pause(); | 73 void Pause(); |
72 | 74 |
73 // Codec settings. | 75 // Codec settings. |
74 int32_t RegisterExternalEncoder(VideoEncoder* encoder, | 76 int32_t RegisterExternalEncoder(VideoEncoder* encoder, |
75 uint8_t pl_type, | 77 uint8_t pl_type, |
76 bool internal_source); | 78 bool internal_source); |
77 int32_t DeRegisterExternalEncoder(uint8_t pl_type); | 79 int32_t DeRegisterExternalEncoder(uint8_t pl_type); |
78 void SetEncoder(const VideoCodec& video_codec, | 80 void SetEncoder(const VideoCodec& video_codec, |
79 int min_transmit_bitrate_bps, | 81 int min_transmit_bitrate_bps, |
80 size_t max_data_payload_length, | 82 size_t max_data_payload_length); |
81 EncodedImageCallback* sink); | |
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 // 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 |
88 // updated according to protection. | 89 // updated according to protection. |
89 // TODO(pbos): Set protection method on construction. | 90 // TODO(pbos): Set protection method on construction. |
90 void SetProtectionMethod(bool nack, bool fec); | 91 void SetProtectionMethod(bool nack, bool fec); |
91 | 92 |
(...skipping 20 matching lines...) Expand all Loading... |
112 void OnBitrateUpdated(uint32_t bitrate_bps, | 113 void OnBitrateUpdated(uint32_t bitrate_bps, |
113 uint8_t fraction_lost, | 114 uint8_t fraction_lost, |
114 int64_t round_trip_time_ms); | 115 int64_t round_trip_time_ms); |
115 | 116 |
116 private: | 117 private: |
117 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 118 bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
118 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 119 void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
119 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); | 120 void TraceFrameDropEnd() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); |
120 | 121 |
121 const uint32_t number_of_cores_; | 122 const uint32_t number_of_cores_; |
| 123 EncodedImageCallback* const sink_; |
122 | 124 |
123 const std::unique_ptr<VideoProcessing> vp_; | 125 const std::unique_ptr<VideoProcessing> vp_; |
124 vcm::VideoSender video_sender_; | 126 vcm::VideoSender video_sender_; |
125 | 127 |
126 rtc::CriticalSection data_cs_; | 128 rtc::CriticalSection data_cs_; |
127 | 129 |
128 SendStatisticsProxy* const stats_proxy_; | 130 SendStatisticsProxy* const stats_proxy_; |
129 OveruseFrameDetector* const overuse_detector_; | 131 OveruseFrameDetector* const overuse_detector_; |
130 | 132 |
131 // The time we last received an input frame or encoded frame. This is used to | 133 // The time we last received an input frame or encoded frame. This is used to |
132 // track when video is stopped long enough that we also want to stop sending | 134 // track when video is stopped long enough that we also want to stop sending |
133 // padding. | 135 // padding. |
134 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); | 136 int64_t time_of_last_frame_activity_ms_ GUARDED_BY(data_cs_); |
135 VideoCodec encoder_config_ GUARDED_BY(data_cs_); | 137 VideoCodec encoder_config_ GUARDED_BY(data_cs_); |
136 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); | 138 int min_transmit_bitrate_bps_ GUARDED_BY(data_cs_); |
137 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); | 139 uint32_t last_observed_bitrate_bps_ GUARDED_BY(data_cs_); |
138 bool encoder_paused_ GUARDED_BY(data_cs_); | 140 bool encoder_paused_ GUARDED_BY(data_cs_); |
139 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); | 141 bool encoder_paused_and_dropped_frame_ GUARDED_BY(data_cs_); |
140 | 142 |
141 rtc::CriticalSection sink_cs_; | |
142 EncodedImageCallback* sink_ GUARDED_BY(sink_cs_); | |
143 | |
144 ProcessThread* module_process_thread_; | 143 ProcessThread* module_process_thread_; |
145 | 144 |
146 bool has_received_sli_ GUARDED_BY(data_cs_); | 145 bool has_received_sli_ GUARDED_BY(data_cs_); |
147 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); | 146 uint8_t picture_id_sli_ GUARDED_BY(data_cs_); |
148 bool has_received_rpsi_ GUARDED_BY(data_cs_); | 147 bool has_received_rpsi_ GUARDED_BY(data_cs_); |
149 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); | 148 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); |
150 | 149 |
151 bool video_suspended_ GUARDED_BY(data_cs_); | 150 bool video_suspended_ GUARDED_BY(data_cs_); |
152 }; | 151 }; |
153 | 152 |
154 } // namespace webrtc | 153 } // namespace webrtc |
155 | 154 |
156 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 155 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
OLD | NEW |