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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 class ViEChannel : public VCMFrameTypeCallback, | 58 class ViEChannel : public VCMFrameTypeCallback, |
59 public VCMReceiveCallback, | 59 public VCMReceiveCallback, |
60 public VCMReceiveStatisticsCallback, | 60 public VCMReceiveStatisticsCallback, |
61 public VCMDecoderTimingCallback, | 61 public VCMDecoderTimingCallback, |
62 public VCMPacketRequestCallback, | 62 public VCMPacketRequestCallback, |
63 public RtpFeedback { | 63 public RtpFeedback { |
64 public: | 64 public: |
65 friend class ChannelStatsObserver; | 65 friend class ChannelStatsObserver; |
66 friend class ViEChannelProtectionCallback; | 66 friend class ViEChannelProtectionCallback; |
67 | 67 |
68 ViEChannel(uint32_t number_of_cores, | 68 ViEChannel(Transport* transport, |
69 Transport* transport, | |
70 ProcessThread* module_process_thread, | 69 ProcessThread* module_process_thread, |
71 PayloadRouter* send_payload_router, | 70 PayloadRouter* send_payload_router, |
72 VideoCodingModule* vcm, | 71 VideoCodingModule* vcm, |
73 RtcpIntraFrameObserver* intra_frame_observer, | 72 RtcpIntraFrameObserver* intra_frame_observer, |
74 RtcpBandwidthObserver* bandwidth_observer, | 73 RtcpBandwidthObserver* bandwidth_observer, |
75 TransportFeedbackObserver* transport_feedback_observer, | 74 TransportFeedbackObserver* transport_feedback_observer, |
76 RemoteBitrateEstimator* remote_bitrate_estimator, | 75 RemoteBitrateEstimator* remote_bitrate_estimator, |
77 RtcpRttStats* rtt_stats, | 76 RtcpRttStats* rtt_stats, |
78 PacedSender* paced_sender, | 77 PacedSender* paced_sender, |
79 PacketRouter* packet_router, | 78 PacketRouter* packet_router, |
80 size_t max_rtp_streams, | 79 size_t max_rtp_streams, |
81 bool sender); | 80 bool sender); |
82 ~ViEChannel(); | 81 ~ViEChannel(); |
83 | 82 |
84 int32_t Init(); | 83 int32_t Init(); |
85 | 84 |
86 // Sets the encoder to use for the channel. |new_stream| indicates the encoder | 85 // Sets the encoder to use for the channel. |new_stream| indicates the encoder |
87 // type has changed and we should start a new RTP stream. | 86 // type has changed and we should start a new RTP stream. |
88 int32_t SetSendCodec(const VideoCodec& video_codec, bool new_stream = true); | 87 int32_t SetSendCodec(const VideoCodec& video_codec, bool new_stream = true); |
89 int32_t SetReceiveCodec(const VideoCodec& video_codec); | |
90 // Registers an external decoder. | |
91 void RegisterExternalDecoder(const uint8_t pl_type, VideoDecoder* decoder); | |
92 int32_t ReceiveCodecStatistics(uint32_t* num_key_frames, | |
93 uint32_t* num_delta_frames); | |
94 void SetExpectedRenderDelay(int delay_ms); | |
95 | 88 |
96 void SetRTCPMode(const RtcpMode rtcp_mode); | 89 void SetRTCPMode(const RtcpMode rtcp_mode); |
97 void SetProtectionMode(bool enable_nack, | 90 void SetProtectionMode(bool enable_nack, |
98 bool enable_fec, | 91 bool enable_fec, |
99 int payload_type_red, | 92 int payload_type_red, |
100 int payload_type_fec); | 93 int payload_type_fec); |
101 bool IsSendingFecEnabled(); | 94 bool IsSendingFecEnabled(); |
102 int SetSenderBufferingMode(int target_delay_ms); | 95 int SetSenderBufferingMode(int target_delay_ms); |
103 int SetSendTimestampOffsetStatus(bool enable, int id); | 96 int SetSendTimestampOffsetStatus(bool enable, int id); |
104 int SetReceiveTimestampOffsetStatus(bool enable, int id); | |
105 int SetSendAbsoluteSendTimeStatus(bool enable, int id); | 97 int SetSendAbsoluteSendTimeStatus(bool enable, int id); |
106 int SetReceiveAbsoluteSendTimeStatus(bool enable, int id); | |
107 int SetSendVideoRotationStatus(bool enable, int id); | 98 int SetSendVideoRotationStatus(bool enable, int id); |
108 int SetReceiveVideoRotationStatus(bool enable, int id); | |
109 int SetSendTransportSequenceNumber(bool enable, int id); | 99 int SetSendTransportSequenceNumber(bool enable, int id); |
110 int SetReceiveTransportSequenceNumber(bool enable, int id); | |
111 void SetRtcpXrRrtrStatus(bool enable); | |
112 void EnableTMMBR(bool enable); | |
113 | 100 |
114 // Sets SSRC for outgoing stream. | 101 // Sets SSRC for outgoing stream. |
115 int32_t SetSSRC(const uint32_t SSRC, | 102 int32_t SetSSRC(const uint32_t SSRC, |
116 const StreamType usage, | 103 const StreamType usage, |
117 const unsigned char simulcast_idx); | 104 const unsigned char simulcast_idx); |
118 | 105 |
119 // Gets SSRC for outgoing stream number |idx|. | 106 // Gets SSRC for outgoing stream number |idx|. |
120 int32_t GetLocalSSRC(uint8_t idx, unsigned int* ssrc); | 107 int32_t GetLocalSSRC(uint8_t idx, unsigned int* ssrc); |
121 | 108 |
122 // Gets SSRC for the incoming stream. | 109 // Gets SSRC for the incoming stream. |
123 uint32_t GetRemoteSSRC(); | 110 uint32_t GetRemoteSSRC(); |
124 | 111 |
125 int SetRtxSendPayloadType(int payload_type, int associated_payload_type); | 112 int SetRtxSendPayloadType(int payload_type, int associated_payload_type); |
126 void SetRtxReceivePayloadType(int payload_type, int associated_payload_type); | |
127 // If set to true, the RTX payload type mapping supplied in | |
128 // |SetRtxReceivePayloadType| will be used when restoring RTX packets. Without | |
129 // it, RTX packets will always be restored to the last non-RTX packet payload | |
130 // type received. | |
131 void SetUseRtxPayloadMappingOnRestore(bool val); | |
132 | 113 |
133 void SetRtpStateForSsrc(uint32_t ssrc, const RtpState& rtp_state); | 114 void SetRtpStateForSsrc(uint32_t ssrc, const RtpState& rtp_state); |
134 RtpState GetRtpStateForSsrc(uint32_t ssrc); | 115 RtpState GetRtpStateForSsrc(uint32_t ssrc); |
135 | 116 |
136 // Sets the CName for the outgoing stream on the channel. | 117 // Sets the CName for the outgoing stream on the channel. |
137 int32_t SetRTCPCName(const char* rtcp_cname); | 118 int32_t SetRTCPCName(const char* rtcp_cname); |
138 | 119 |
139 // Gets the CName of the incoming stream. | 120 // Gets the CName of the incoming stream. |
140 int32_t GetRemoteRTCPCName(char rtcp_cname[]); | 121 int32_t GetRemoteRTCPCName(char rtcp_cname[]); |
141 | 122 |
142 // Returns statistics reported by the remote client in an RTCP packet. | 123 // Returns statistics reported by the remote client in an RTCP packet. |
143 // TODO(pbos): Remove this along with VideoSendStream::GetRtt(). | 124 // TODO(pbos): Remove this along with VideoSendStream::GetRtt(). |
144 int32_t GetSendRtcpStatistics(uint16_t* fraction_lost, | 125 int32_t GetSendRtcpStatistics(uint16_t* fraction_lost, |
145 uint32_t* cumulative_lost, | 126 uint32_t* cumulative_lost, |
146 uint32_t* extended_max, | 127 uint32_t* extended_max, |
147 uint32_t* jitter_samples, | 128 uint32_t* jitter_samples, |
148 int64_t* rtt_ms); | 129 int64_t* rtt_ms); |
149 | 130 |
150 // Called on receipt of RTCP report block from remote side. | 131 // Called on receipt of RTCP report block from remote side. |
151 void RegisterSendChannelRtcpStatisticsCallback( | 132 void RegisterSendChannelRtcpStatisticsCallback( |
152 RtcpStatisticsCallback* callback); | 133 RtcpStatisticsCallback* callback); |
153 | 134 |
154 // Called on generation of RTCP stats | |
155 void RegisterReceiveChannelRtcpStatisticsCallback( | |
156 RtcpStatisticsCallback* callback); | |
157 | |
158 // Gets send statistics for the rtp and rtx stream. | 135 // Gets send statistics for the rtp and rtx stream. |
159 void GetSendStreamDataCounters(StreamDataCounters* rtp_counters, | 136 void GetSendStreamDataCounters(StreamDataCounters* rtp_counters, |
160 StreamDataCounters* rtx_counters) const; | 137 StreamDataCounters* rtx_counters) const; |
161 | 138 |
162 // Gets received stream data counters. | 139 // Gets received stream data counters. |
163 void GetReceiveStreamDataCounters(StreamDataCounters* rtp_counters, | 140 void GetReceiveStreamDataCounters(StreamDataCounters* rtp_counters, |
164 StreamDataCounters* rtx_counters) const; | 141 StreamDataCounters* rtx_counters) const; |
165 | 142 |
166 // Called on update of RTP statistics. | 143 // Called on update of RTP statistics. |
167 void RegisterSendChannelRtpStatisticsCallback( | 144 void RegisterSendChannelRtpStatisticsCallback( |
168 StreamDataCountersCallback* callback); | 145 StreamDataCountersCallback* callback); |
169 | 146 |
170 // Called on update of RTP statistics. | |
171 void RegisterReceiveChannelRtpStatisticsCallback( | |
172 StreamDataCountersCallback* callback); | |
173 | |
174 void GetSendRtcpPacketTypeCounter( | 147 void GetSendRtcpPacketTypeCounter( |
175 RtcpPacketTypeCounter* packet_counter) const; | 148 RtcpPacketTypeCounter* packet_counter) const; |
176 | 149 |
177 void GetReceiveRtcpPacketTypeCounter( | 150 void GetReceiveRtcpPacketTypeCounter( |
178 RtcpPacketTypeCounter* packet_counter) const; | 151 RtcpPacketTypeCounter* packet_counter) const; |
179 | 152 |
180 void RegisterSendSideDelayObserver(SendSideDelayObserver* observer); | 153 void RegisterSendSideDelayObserver(SendSideDelayObserver* observer); |
181 | 154 |
182 // Called on any new send bitrate estimate. | 155 // Called on any new send bitrate estimate. |
183 void RegisterSendBitrateObserver(BitrateStatisticsObserver* observer); | 156 void RegisterSendBitrateObserver(BitrateStatisticsObserver* observer); |
184 | 157 |
185 // Implements RtpFeedback. | 158 // Implements RtpFeedback. |
186 int32_t OnInitializeDecoder(const int8_t payload_type, | 159 int32_t OnInitializeDecoder(const int8_t payload_type, |
187 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 160 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
188 const int frequency, | 161 const int frequency, |
189 const size_t channels, | 162 const size_t channels, |
190 const uint32_t rate) override; | 163 const uint32_t rate) override; |
191 void OnIncomingSSRCChanged(const uint32_t ssrc) override; | 164 void OnIncomingSSRCChanged(const uint32_t ssrc) override; |
192 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override; | 165 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override; |
193 | 166 |
194 int32_t SetRemoteSSRCType(const StreamType usage, const uint32_t SSRC); | |
195 | |
196 int32_t StartSend(); | 167 int32_t StartSend(); |
197 int32_t StopSend(); | 168 int32_t StopSend(); |
198 bool Sending(); | 169 bool Sending(); |
199 void StartReceive(); | 170 void StartReceive(); |
200 void StopReceive(); | 171 void StopReceive(); |
201 | 172 |
202 int32_t ReceivedRTPPacket(const void* rtp_packet, | 173 int32_t ReceivedRTPPacket(const void* rtp_packet, |
203 const size_t rtp_packet_length, | 174 const size_t rtp_packet_length, |
204 const PacketTime& packet_time); | 175 const PacketTime& packet_time); |
205 int32_t ReceivedRTCPPacket(const void* rtcp_packet, | 176 int32_t ReceivedRTCPPacket(const void* rtcp_packet, |
206 const size_t rtcp_packet_length); | 177 const size_t rtcp_packet_length); |
207 | 178 |
208 // Sets the maximum transfer unit size for the network link, i.e. including | 179 // Sets the maximum transfer unit size for the network link, i.e. including |
209 // IP, UDP and RTP headers. | 180 // IP, UDP and RTP headers. |
210 int32_t SetMTU(uint16_t mtu); | 181 int32_t SetMTU(uint16_t mtu); |
211 | 182 |
212 // Gets the modules used by the channel. | 183 // Gets the modules used by the channel. |
213 RtpRtcp* rtp_rtcp(); | 184 RtpRtcp* rtp_rtcp(); |
| 185 ViEReceiver* vie_receiver(); |
214 VCMProtectionCallback* vcm_protection_callback(); | 186 VCMProtectionCallback* vcm_protection_callback(); |
215 | 187 |
216 | 188 |
217 CallStatsObserver* GetStatsObserver(); | 189 CallStatsObserver* GetStatsObserver(); |
218 | 190 |
219 // Implements VCMReceiveCallback. | 191 // Implements VCMReceiveCallback. |
220 virtual int32_t FrameToRender(VideoFrame& video_frame); // NOLINT | 192 virtual int32_t FrameToRender(VideoFrame& video_frame); // NOLINT |
221 | 193 |
222 // Implements VCMReceiveCallback. | 194 // Implements VCMReceiveCallback. |
223 virtual int32_t ReceivedDecodedReferenceFrame( | 195 virtual int32_t ReceivedDecodedReferenceFrame( |
(...skipping 25 matching lines...) Expand all Loading... |
249 const uint64_t picture_id); | 221 const uint64_t picture_id); |
250 | 222 |
251 // Implements VideoPacketRequestCallback. | 223 // Implements VideoPacketRequestCallback. |
252 int32_t ResendPackets(const uint16_t* sequence_numbers, | 224 int32_t ResendPackets(const uint16_t* sequence_numbers, |
253 uint16_t length) override; | 225 uint16_t length) override; |
254 | 226 |
255 int32_t SetVoiceChannel(int32_t ve_channel_id, | 227 int32_t SetVoiceChannel(int32_t ve_channel_id, |
256 VoEVideoSync* ve_sync_interface); | 228 VoEVideoSync* ve_sync_interface); |
257 int32_t VoiceChannel(); | 229 int32_t VoiceChannel(); |
258 | 230 |
259 // New-style callbacks, used by VideoReceiveStream. | |
260 void RegisterPreRenderCallback(I420FrameCallback* pre_render_callback); | 231 void RegisterPreRenderCallback(I420FrameCallback* pre_render_callback); |
261 void RegisterPreDecodeImageCallback( | |
262 EncodedImageCallback* pre_decode_callback); | |
263 | 232 |
264 void RegisterSendFrameCountObserver(FrameCountObserver* observer); | 233 void RegisterSendFrameCountObserver(FrameCountObserver* observer); |
265 void RegisterRtcpPacketTypeCounterObserver( | 234 void RegisterRtcpPacketTypeCounterObserver( |
266 RtcpPacketTypeCounterObserver* observer); | 235 RtcpPacketTypeCounterObserver* observer); |
267 void RegisterReceiveStatisticsProxy( | 236 void RegisterReceiveStatisticsProxy( |
268 ReceiveStatisticsProxy* receive_statistics_proxy); | 237 ReceiveStatisticsProxy* receive_statistics_proxy); |
269 void SetIncomingVideoStream(IncomingVideoStream* incoming_video_stream); | 238 void SetIncomingVideoStream(IncomingVideoStream* incoming_video_stream); |
270 | 239 |
271 protected: | 240 protected: |
272 static bool ChannelDecodeThreadFunction(void* obj); | 241 static bool ChannelDecodeThreadFunction(void* obj); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 const { | 355 const { |
387 rtc::CritScope lock(&critsect_); | 356 rtc::CritScope lock(&critsect_); |
388 return counter_map_; | 357 return counter_map_; |
389 } | 358 } |
390 | 359 |
391 private: | 360 private: |
392 std::map<uint32_t, RtcpPacketTypeCounter> counter_map_ | 361 std::map<uint32_t, RtcpPacketTypeCounter> counter_map_ |
393 GUARDED_BY(critsect_); | 362 GUARDED_BY(critsect_); |
394 } rtcp_packet_type_counter_observer_; | 363 } rtcp_packet_type_counter_observer_; |
395 | 364 |
396 const uint32_t number_of_cores_; | |
397 const bool sender_; | 365 const bool sender_; |
398 | 366 |
399 ProcessThread* const module_process_thread_; | 367 ProcessThread* const module_process_thread_; |
400 PayloadRouter* const send_payload_router_; | 368 PayloadRouter* const send_payload_router_; |
401 | 369 |
402 // Used for all registered callbacks except rendering. | 370 // Used for all registered callbacks except rendering. |
403 rtc::CriticalSection crit_; | 371 rtc::CriticalSection crit_; |
404 | 372 |
405 // Owned modules/classes. | 373 // Owned modules/classes. |
406 rtc::scoped_ptr<ViEChannelProtectionCallback> vcm_protection_callback_; | 374 rtc::scoped_ptr<ViEChannelProtectionCallback> vcm_protection_callback_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 size_t num_rtts_ GUARDED_BY(crit_); | 406 size_t num_rtts_ GUARDED_BY(crit_); |
439 | 407 |
440 // RtpRtcp modules, declared last as they use other members on construction. | 408 // RtpRtcp modules, declared last as they use other members on construction. |
441 const std::vector<RtpRtcp*> rtp_rtcp_modules_; | 409 const std::vector<RtpRtcp*> rtp_rtcp_modules_; |
442 size_t num_active_rtp_rtcp_modules_ GUARDED_BY(crit_); | 410 size_t num_active_rtp_rtcp_modules_ GUARDED_BY(crit_); |
443 }; | 411 }; |
444 | 412 |
445 } // namespace webrtc | 413 } // namespace webrtc |
446 | 414 |
447 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ | 415 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ |
OLD | NEW |