Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Side by Side Diff: webrtc/pc/channel.h

Issue 2890263003: Move RTP/RTCP demuxing logic from BaseChannel to RtpTransport. (Closed)
Patch Set: Move more demuxing logic from BaseChannel to RtpTransport. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 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 18 matching lines...) Expand all
29 #include "webrtc/media/base/mediachannel.h" 29 #include "webrtc/media/base/mediachannel.h"
30 #include "webrtc/media/base/mediaengine.h" 30 #include "webrtc/media/base/mediaengine.h"
31 #include "webrtc/media/base/streamparams.h" 31 #include "webrtc/media/base/streamparams.h"
32 #include "webrtc/media/base/videosinkinterface.h" 32 #include "webrtc/media/base/videosinkinterface.h"
33 #include "webrtc/media/base/videosourceinterface.h" 33 #include "webrtc/media/base/videosourceinterface.h"
34 #include "webrtc/p2p/base/dtlstransportinternal.h" 34 #include "webrtc/p2p/base/dtlstransportinternal.h"
35 #include "webrtc/p2p/base/packettransportinternal.h" 35 #include "webrtc/p2p/base/packettransportinternal.h"
36 #include "webrtc/p2p/base/transportcontroller.h" 36 #include "webrtc/p2p/base/transportcontroller.h"
37 #include "webrtc/p2p/client/socketmonitor.h" 37 #include "webrtc/p2p/client/socketmonitor.h"
38 #include "webrtc/pc/audiomonitor.h" 38 #include "webrtc/pc/audiomonitor.h"
39 #include "webrtc/pc/bundlefilter.h"
40 #include "webrtc/pc/mediamonitor.h" 39 #include "webrtc/pc/mediamonitor.h"
41 #include "webrtc/pc/mediasession.h" 40 #include "webrtc/pc/mediasession.h"
42 #include "webrtc/pc/rtcpmuxfilter.h" 41 #include "webrtc/pc/rtcpmuxfilter.h"
43 #include "webrtc/pc/rtptransport.h" 42 #include "webrtc/pc/rtptransport.h"
44 #include "webrtc/pc/srtpfilter.h" 43 #include "webrtc/pc/srtpfilter.h"
45 44
46 namespace webrtc { 45 namespace webrtc {
47 class AudioSinkInterface; 46 class AudioSinkInterface;
48 } // namespace webrtc 47 } // namespace webrtc
49 48
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 bool RemoveRecvStream(uint32_t ssrc); 141 bool RemoveRecvStream(uint32_t ssrc);
143 bool AddSendStream(const StreamParams& sp); 142 bool AddSendStream(const StreamParams& sp);
144 bool RemoveSendStream(uint32_t ssrc); 143 bool RemoveSendStream(uint32_t ssrc);
145 144
146 // Monitoring 145 // Monitoring
147 void StartConnectionMonitor(int cms); 146 void StartConnectionMonitor(int cms);
148 void StopConnectionMonitor(); 147 void StopConnectionMonitor();
149 // For ConnectionStatsGetter, used by ConnectionMonitor 148 // For ConnectionStatsGetter, used by ConnectionMonitor
150 bool GetConnectionStats(ConnectionInfos* infos) override; 149 bool GetConnectionStats(ConnectionInfos* infos) override;
151 150
152 BundleFilter* bundle_filter() { return &bundle_filter_; }
153
154 const std::vector<StreamParams>& local_streams() const { 151 const std::vector<StreamParams>& local_streams() const {
155 return local_streams_; 152 return local_streams_;
156 } 153 }
157 const std::vector<StreamParams>& remote_streams() const { 154 const std::vector<StreamParams>& remote_streams() const {
158 return remote_streams_; 155 return remote_streams_;
159 } 156 }
160 157
161 sigslot::signal2<BaseChannel*, bool> SignalDtlsSrtpSetupFailure; 158 sigslot::signal2<BaseChannel*, bool> SignalDtlsSrtpSetupFailure;
162 void SignalDtlsSrtpSetupFailure_n(bool rtcp); 159 void SignalDtlsSrtpSetupFailure_n(bool rtcp);
163 void SignalDtlsSrtpSetupFailure_s(bool rtcp); 160 void SignalDtlsSrtpSetupFailure_s(bool rtcp);
(...skipping 27 matching lines...) Expand all
191 override; 188 override;
192 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); 189 int SetOption_n(SocketType type, rtc::Socket::Option o, int val);
193 190
194 SrtpFilter* srtp_filter() { return &srtp_filter_; } 191 SrtpFilter* srtp_filter() { return &srtp_filter_; }
195 192
196 virtual cricket::MediaType media_type() = 0; 193 virtual cricket::MediaType media_type() = 0;
197 194
198 // This function returns true if we require SRTP for call setup. 195 // This function returns true if we require SRTP for call setup.
199 bool srtp_required_for_testing() const { return srtp_required_; } 196 bool srtp_required_for_testing() const { return srtp_required_; }
200 197
198 // Public for testing.
199 bool HandlesPayloadType(int payload_type) const;
200
201 protected: 201 protected:
202 virtual MediaChannel* media_channel() const { return media_channel_; } 202 virtual MediaChannel* media_channel() const { return media_channel_; }
203 203
204 void SetTransports_n(DtlsTransportInternal* rtp_dtls_transport, 204 void SetTransports_n(DtlsTransportInternal* rtp_dtls_transport,
205 DtlsTransportInternal* rtcp_dtls_transport, 205 DtlsTransportInternal* rtcp_dtls_transport,
206 rtc::PacketTransportInternal* rtp_packet_transport, 206 rtc::PacketTransportInternal* rtp_packet_transport,
207 rtc::PacketTransportInternal* rtcp_packet_transport); 207 rtc::PacketTransportInternal* rtcp_packet_transport);
208 208
209 // This does not update writability or "ready-to-send" state; it just 209 // This does not update writability or "ready-to-send" state; it just
210 // disconnects from the old channel and connects to the new one. 210 // disconnects from the old channel and connects to the new one.
(...skipping 30 matching lines...) Expand all
241 void FlushRtcpMessages_n(); 241 void FlushRtcpMessages_n();
242 242
243 // NetworkInterface implementation, called by MediaEngine 243 // NetworkInterface implementation, called by MediaEngine
244 bool SendPacket(rtc::CopyOnWriteBuffer* packet, 244 bool SendPacket(rtc::CopyOnWriteBuffer* packet,
245 const rtc::PacketOptions& options) override; 245 const rtc::PacketOptions& options) override;
246 bool SendRtcp(rtc::CopyOnWriteBuffer* packet, 246 bool SendRtcp(rtc::CopyOnWriteBuffer* packet,
247 const rtc::PacketOptions& options) override; 247 const rtc::PacketOptions& options) override;
248 248
249 // From TransportChannel 249 // From TransportChannel
250 void OnWritableState(rtc::PacketTransportInternal* transport); 250 void OnWritableState(rtc::PacketTransportInternal* transport);
251 virtual void OnPacketRead(rtc::PacketTransportInternal* transport,
252 const char* data,
253 size_t len,
254 const rtc::PacketTime& packet_time,
255 int flags);
256 251
257 void OnDtlsState(DtlsTransportInternal* transport, DtlsTransportState state); 252 void OnDtlsState(DtlsTransportInternal* transport, DtlsTransportState state);
258 253
259 void OnSelectedCandidatePairChanged( 254 void OnSelectedCandidatePairChanged(
260 IceTransportInternal* ice_transport, 255 IceTransportInternal* ice_transport,
261 CandidatePairInterface* selected_candidate_pair, 256 CandidatePairInterface* selected_candidate_pair,
262 int last_sent_packet_id, 257 int last_sent_packet_id,
263 bool ready_to_send); 258 bool ready_to_send);
264 259
265 bool PacketIsRtcp(const rtc::PacketTransportInternal* transport, 260 bool PacketIsRtcp(const rtc::PacketTransportInternal* transport,
266 const char* data, 261 const char* data,
267 size_t len); 262 size_t len);
268 bool SendPacket(bool rtcp, 263 bool SendPacket(bool rtcp,
269 rtc::CopyOnWriteBuffer* packet, 264 rtc::CopyOnWriteBuffer* packet,
270 const rtc::PacketOptions& options); 265 const rtc::PacketOptions& options);
271 266
272 bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); 267 bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet);
273 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, 268 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet,
274 const rtc::PacketTime& packet_time); 269 const rtc::PacketTime& packet_time);
275 void OnPacketReceived(bool rtcp, 270 void OnPacketReceived(bool rtcp,
276 const rtc::CopyOnWriteBuffer& packet, 271 rtc::CopyOnWriteBuffer& packet,
277 const rtc::PacketTime& packet_time); 272 const rtc::PacketTime& packet_time);
273 void ProcessPacket(bool rtcp,
274 const rtc::CopyOnWriteBuffer& packet,
275 const rtc::PacketTime& packet_time);
278 276
279 void EnableMedia_w(); 277 void EnableMedia_w();
280 void DisableMedia_w(); 278 void DisableMedia_w();
281 279
282 // Performs actions if the RTP/RTCP writable state changed. This should 280 // Performs actions if the RTP/RTCP writable state changed. This should
283 // be called whenever a channel's writable state changes or when RTCP muxing 281 // be called whenever a channel's writable state changes or when RTCP muxing
284 // becomes active/inactive. 282 // becomes active/inactive.
285 void UpdateWritableState_n(); 283 void UpdateWritableState_n();
286 void ChannelWritable_n(); 284 void ChannelWritable_n();
287 void ChannelNotWritable_n(); 285 void ChannelNotWritable_n();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, 348 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor,
351 const std::vector<ConnectionInfo>& infos) = 0; 349 const std::vector<ConnectionInfo>& infos) = 0;
352 350
353 // Helper function for invoking bool-returning methods on the worker thread. 351 // Helper function for invoking bool-returning methods on the worker thread.
354 template <class FunctorT> 352 template <class FunctorT>
355 bool InvokeOnWorker(const rtc::Location& posted_from, 353 bool InvokeOnWorker(const rtc::Location& posted_from,
356 const FunctorT& functor) { 354 const FunctorT& functor) {
357 return worker_thread_->Invoke<bool>(posted_from, functor); 355 return worker_thread_->Invoke<bool>(posted_from, functor);
358 } 356 }
359 357
358 void AddHandledPayloadType(int payload_type);
359
360 bool received_media() { return rtp_transport_.received_media(); }
361
360 private: 362 private:
361 bool InitNetwork_n(DtlsTransportInternal* rtp_dtls_transport, 363 bool InitNetwork_n(DtlsTransportInternal* rtp_dtls_transport,
362 DtlsTransportInternal* rtcp_dtls_transport, 364 DtlsTransportInternal* rtcp_dtls_transport,
363 rtc::PacketTransportInternal* rtp_packet_transport, 365 rtc::PacketTransportInternal* rtp_packet_transport,
364 rtc::PacketTransportInternal* rtcp_packet_transport); 366 rtc::PacketTransportInternal* rtcp_packet_transport);
365 void DisconnectTransportChannels_n(); 367 void DisconnectTransportChannels_n();
366 void SignalSentPacket_n(rtc::PacketTransportInternal* transport, 368 void SignalSentPacket_n(rtc::PacketTransportInternal* transport,
367 const rtc::SentPacket& sent_packet); 369 const rtc::SentPacket& sent_packet);
368 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); 370 void SignalSentPacket_w(const rtc::SentPacket& sent_packet);
369 bool IsReadyToSendMedia_n() const; 371 bool IsReadyToSendMedia_n() const;
370 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id); 372 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id);
371 int GetTransportOverheadPerPacket() const; 373 int GetTransportOverheadPerPacket() const;
372 void UpdateTransportOverhead(); 374 void UpdateTransportOverhead();
373 375
376 void OnFirstPacketReceived();
377
374 rtc::Thread* const worker_thread_; 378 rtc::Thread* const worker_thread_;
375 rtc::Thread* const network_thread_; 379 rtc::Thread* const network_thread_;
376 rtc::Thread* const signaling_thread_; 380 rtc::Thread* const signaling_thread_;
377 rtc::AsyncInvoker invoker_; 381 rtc::AsyncInvoker invoker_;
378 382
379 const std::string content_name_; 383 const std::string content_name_;
380 std::unique_ptr<ConnectionMonitor> connection_monitor_; 384 std::unique_ptr<ConnectionMonitor> connection_monitor_;
381 385
382 // Won't be set when using raw packet transports. SDP-specific thing. 386 // Won't be set when using raw packet transports. SDP-specific thing.
383 std::string transport_name_; 387 std::string transport_name_;
384 388
385 const bool rtcp_mux_required_; 389 const bool rtcp_mux_required_;
386 390
387 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS. 391 // Separate DTLS/non-DTLS pointers to support using BaseChannel without DTLS.
388 // Temporary measure until more refactoring is done. 392 // Temporary measure until more refactoring is done.
389 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_". 393 // If non-null, "X_dtls_transport_" will always equal "X_packet_transport_".
390 DtlsTransportInternal* rtp_dtls_transport_ = nullptr; 394 DtlsTransportInternal* rtp_dtls_transport_ = nullptr;
391 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; 395 DtlsTransportInternal* rtcp_dtls_transport_ = nullptr;
392 webrtc::RtpTransport rtp_transport_; 396 webrtc::RtpTransport rtp_transport_;
393 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; 397 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_;
394 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; 398 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_;
395 SrtpFilter srtp_filter_; 399 SrtpFilter srtp_filter_;
396 RtcpMuxFilter rtcp_mux_filter_; 400 RtcpMuxFilter rtcp_mux_filter_;
397 BundleFilter bundle_filter_;
398 bool writable_ = false; 401 bool writable_ = false;
399 bool was_ever_writable_ = false; 402 bool was_ever_writable_ = false;
400 bool has_received_packet_ = false; 403 bool has_received_packet_ = false;
401 bool dtls_keyed_ = false; 404 bool dtls_keyed_ = false;
402 const bool srtp_required_ = true; 405 const bool srtp_required_ = true;
403 int rtp_abs_sendtime_extn_id_ = -1; 406 int rtp_abs_sendtime_extn_id_ = -1;
404 407
405 // MediaChannel related members that should be accessed from the worker 408 // MediaChannel related members that should be accessed from the worker
406 // thread. 409 // thread.
407 MediaChannel* const media_channel_; 410 MediaChannel* const media_channel_;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 void GetActiveStreams_w(AudioInfo::StreamList* actives); 492 void GetActiveStreams_w(AudioInfo::StreamList* actives);
490 webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const; 493 webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const;
491 bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); 494 bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters);
492 webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const; 495 webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const;
493 bool SetRtpReceiveParameters_w(uint32_t ssrc, 496 bool SetRtpReceiveParameters_w(uint32_t ssrc,
494 webrtc::RtpParameters parameters); 497 webrtc::RtpParameters parameters);
495 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_AUDIO; } 498 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_AUDIO; }
496 499
497 private: 500 private:
498 // overrides from BaseChannel 501 // overrides from BaseChannel
499 void OnPacketRead(rtc::PacketTransportInternal* transport,
500 const char* data,
501 size_t len,
502 const rtc::PacketTime& packet_time,
503 int flags) override;
504 void UpdateMediaSendRecvState_w() override; 502 void UpdateMediaSendRecvState_w() override;
505 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; 503 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override;
506 bool SetLocalContent_w(const MediaContentDescription* content, 504 bool SetLocalContent_w(const MediaContentDescription* content,
507 ContentAction action, 505 ContentAction action,
508 std::string* error_desc) override; 506 std::string* error_desc) override;
509 bool SetRemoteContent_w(const MediaContentDescription* content, 507 bool SetRemoteContent_w(const MediaContentDescription* content,
510 ContentAction action, 508 ContentAction action,
511 std::string* error_desc) override; 509 std::string* error_desc) override;
512 void HandleEarlyMediaTimeout(); 510 void HandleEarlyMediaTimeout();
513 bool InsertDtmf_w(uint32_t ssrc, int event, int duration); 511 bool InsertDtmf_w(uint32_t ssrc, int event, int duration);
514 bool SetOutputVolume_w(uint32_t ssrc, double volume); 512 bool SetOutputVolume_w(uint32_t ssrc, double volume);
515 513
516 void OnMessage(rtc::Message* pmsg) override; 514 void OnMessage(rtc::Message* pmsg) override;
517 void OnConnectionMonitorUpdate( 515 void OnConnectionMonitorUpdate(
518 ConnectionMonitor* monitor, 516 ConnectionMonitor* monitor,
519 const std::vector<ConnectionInfo>& infos) override; 517 const std::vector<ConnectionInfo>& infos) override;
520 void OnMediaMonitorUpdate(VoiceMediaChannel* media_channel, 518 void OnMediaMonitorUpdate(VoiceMediaChannel* media_channel,
521 const VoiceMediaInfo& info); 519 const VoiceMediaInfo& info);
522 void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info); 520 void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info);
523 521
524 static const int kEarlyMediaTimeout = 1000; 522 static const int kEarlyMediaTimeout = 1000;
525 MediaEngineInterface* media_engine_; 523 MediaEngineInterface* media_engine_;
526 bool received_media_;
527 std::unique_ptr<VoiceMediaMonitor> media_monitor_; 524 std::unique_ptr<VoiceMediaMonitor> media_monitor_;
528 std::unique_ptr<AudioMonitor> audio_monitor_; 525 std::unique_ptr<AudioMonitor> audio_monitor_;
529 526
530 // Last AudioSendParameters sent down to the media_channel() via 527 // Last AudioSendParameters sent down to the media_channel() via
531 // SetSendParameters. 528 // SetSendParameters.
532 AudioSendParameters last_send_params_; 529 AudioSendParameters last_send_params_;
533 // Last AudioRecvParameters sent down to the media_channel() via 530 // Last AudioRecvParameters sent down to the media_channel() via
534 // SetRecvParameters. 531 // SetRecvParameters.
535 AudioRecvParameters last_recv_params_; 532 AudioRecvParameters last_recv_params_;
536 }; 533 };
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // SetSendParameters. 718 // SetSendParameters.
722 DataSendParameters last_send_params_; 719 DataSendParameters last_send_params_;
723 // Last DataRecvParameters sent down to the media_channel() via 720 // Last DataRecvParameters sent down to the media_channel() via
724 // SetRecvParameters. 721 // SetRecvParameters.
725 DataRecvParameters last_recv_params_; 722 DataRecvParameters last_recv_params_;
726 }; 723 };
727 724
728 } // namespace cricket 725 } // namespace cricket
729 726
730 #endif // WEBRTC_PC_CHANNEL_H_ 727 #endif // WEBRTC_PC_CHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698