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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ProcessThread* module_process_thread, | 68 ProcessThread* module_process_thread, |
69 vcm::VideoReceiver* video_receiver, | 69 vcm::VideoReceiver* video_receiver, |
70 RemoteBitrateEstimator* remote_bitrate_estimator, | 70 RemoteBitrateEstimator* remote_bitrate_estimator, |
71 RtcpRttStats* rtt_stats, | 71 RtcpRttStats* rtt_stats, |
72 PacedSender* paced_sender, | 72 PacedSender* paced_sender, |
73 PacketRouter* packet_router); | 73 PacketRouter* packet_router); |
74 ~ViEChannel(); | 74 ~ViEChannel(); |
75 | 75 |
76 int32_t Init(); | 76 int32_t Init(); |
77 | 77 |
| 78 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_; } |
| 79 |
78 void SetProtectionMode(bool enable_nack, | 80 void SetProtectionMode(bool enable_nack, |
79 bool enable_fec, | 81 bool enable_fec, |
80 int payload_type_red, | 82 int payload_type_red, |
81 int payload_type_fec); | 83 int payload_type_fec); |
82 | 84 |
83 RtpState GetRtpStateForSsrc(uint32_t ssrc) const; | 85 RtpState GetRtpStateForSsrc(uint32_t ssrc) const; |
84 | 86 |
85 // Implements RtpFeedback. | 87 // Implements RtpFeedback. |
86 int32_t OnInitializeDecoder(const int8_t payload_type, | 88 int32_t OnInitializeDecoder(const int8_t payload_type, |
87 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 89 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
88 const int frequency, | 90 const int frequency, |
89 const size_t channels, | 91 const size_t channels, |
90 const uint32_t rate) override; | 92 const uint32_t rate) override; |
91 void OnIncomingSSRCChanged(const uint32_t ssrc) override; | 93 void OnIncomingSSRCChanged(const uint32_t ssrc) override; |
92 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override; | 94 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override; |
93 | 95 |
94 // Gets the module used by the channel. | 96 // Gets the module used by the channel. |
95 RtpRtcp* rtp_rtcp() const; | |
96 ViEReceiver* vie_receiver(); | 97 ViEReceiver* vie_receiver(); |
97 | 98 |
98 CallStatsObserver* GetStatsObserver(); | 99 CallStatsObserver* GetStatsObserver(); |
99 | 100 |
100 // Implements VCMReceiveCallback. | 101 // Implements VCMReceiveCallback. |
101 virtual int32_t FrameToRender(VideoFrame& video_frame); // NOLINT | 102 virtual int32_t FrameToRender(VideoFrame& video_frame); // NOLINT |
102 | 103 |
103 // Implements VCMReceiveCallback. | 104 // Implements VCMReceiveCallback. |
104 virtual int32_t ReceivedDecodedReferenceFrame( | 105 virtual int32_t ReceivedDecodedReferenceFrame( |
105 const uint64_t picture_id); | 106 const uint64_t picture_id); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 147 |
147 private: | 148 private: |
148 // Assumed to be protected. | 149 // Assumed to be protected. |
149 void StartDecodeThread(); | 150 void StartDecodeThread(); |
150 void StopDecodeThread(); | 151 void StopDecodeThread(); |
151 | 152 |
152 void ProcessNACKRequest(const bool enable); | 153 void ProcessNACKRequest(const bool enable); |
153 // Compute NACK list parameters for the buffering mode. | 154 // Compute NACK list parameters for the buffering mode. |
154 int GetRequiredNackListSize(int target_delay_ms); | 155 int GetRequiredNackListSize(int target_delay_ms); |
155 | 156 |
156 // ViEChannel exposes methods that allow to modify observers and callbacks | |
157 // to be modified. Such an API-style is cumbersome to implement and maintain | |
158 // at all the levels when comparing to only setting them at construction. As | |
159 // so this class instantiates its children with a wrapper that can be modified | |
160 // at a later time. | |
161 template <class T> | |
162 class RegisterableCallback : public T { | |
163 public: | |
164 RegisterableCallback() : callback_(nullptr) {} | |
165 | |
166 void Set(T* callback) { | |
167 rtc::CritScope lock(&critsect_); | |
168 callback_ = callback; | |
169 } | |
170 | |
171 protected: | |
172 // Note: this should be implemented with a RW-lock to allow simultaneous | |
173 // calls into the callback. However that doesn't seem to be needed for the | |
174 // current type of callbacks covered by this class. | |
175 rtc::CriticalSection critsect_; | |
176 T* callback_ GUARDED_BY(critsect_); | |
177 | |
178 private: | |
179 RTC_DISALLOW_COPY_AND_ASSIGN(RegisterableCallback); | |
180 }; | |
181 | |
182 class RegisterableRtcpPacketTypeCounterObserver | |
183 : public RegisterableCallback<RtcpPacketTypeCounterObserver> { | |
184 public: | |
185 void RtcpPacketTypesCounterUpdated( | |
186 uint32_t ssrc, | |
187 const RtcpPacketTypeCounter& packet_counter) override { | |
188 rtc::CritScope lock(&critsect_); | |
189 if (callback_) | |
190 callback_->RtcpPacketTypesCounterUpdated(ssrc, packet_counter); | |
191 } | |
192 | |
193 private: | |
194 } rtcp_packet_type_counter_observer_; | |
195 | |
196 | |
197 ProcessThread* const module_process_thread_; | 157 ProcessThread* const module_process_thread_; |
198 | 158 |
199 // Used for all registered callbacks except rendering. | 159 // Used for all registered callbacks except rendering. |
200 rtc::CriticalSection crit_; | 160 rtc::CriticalSection crit_; |
201 | 161 |
202 vcm::VideoReceiver* const video_receiver_; | 162 vcm::VideoReceiver* const video_receiver_; |
203 ViEReceiver vie_receiver_; | 163 ViEReceiver vie_receiver_; |
| 164 RtpRtcp* const rtp_rtcp_; |
204 | 165 |
205 // Helper to report call statistics. | 166 // Helper to report call statistics. |
206 std::unique_ptr<ChannelStatsObserver> stats_observer_; | 167 std::unique_ptr<ChannelStatsObserver> stats_observer_; |
207 | 168 |
208 // Not owned. | 169 // Not owned. |
209 ReceiveStatisticsProxy* receive_stats_callback_ GUARDED_BY(crit_); | 170 ReceiveStatisticsProxy* receive_stats_callback_ GUARDED_BY(crit_); |
210 FrameCounts receive_frame_counts_ GUARDED_BY(crit_); | 171 FrameCounts receive_frame_counts_ GUARDED_BY(crit_); |
211 IncomingVideoStream* incoming_video_stream_ GUARDED_BY(crit_); | 172 IncomingVideoStream* incoming_video_stream_ GUARDED_BY(crit_); |
212 RtcpRttStats* const rtt_stats_; | |
213 PacedSender* const paced_sender_; | |
214 PacketRouter* const packet_router_; | |
215 | 173 |
216 int max_nack_reordering_threshold_; | 174 int max_nack_reordering_threshold_; |
217 I420FrameCallback* pre_render_callback_ GUARDED_BY(crit_); | 175 I420FrameCallback* pre_render_callback_ GUARDED_BY(crit_); |
218 | 176 |
219 int64_t last_rtt_ms_ GUARDED_BY(crit_); | 177 int64_t last_rtt_ms_ GUARDED_BY(crit_); |
220 | |
221 // RtpRtcp module, declared last as it use other members on construction. | |
222 const std::unique_ptr<RtpRtcp> rtp_rtcp_; | |
223 }; | 178 }; |
224 | 179 |
225 } // namespace webrtc | 180 } // namespace webrtc |
226 | 181 |
227 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ | 182 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ |
OLD | NEW |