| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "talk/session/media/mediamonitor.h" | 45 #include "talk/session/media/mediamonitor.h" |
| 46 #include "talk/session/media/mediasession.h" | 46 #include "talk/session/media/mediasession.h" |
| 47 #include "talk/session/media/rtcpmuxfilter.h" | 47 #include "talk/session/media/rtcpmuxfilter.h" |
| 48 #include "talk/session/media/srtpfilter.h" | 48 #include "talk/session/media/srtpfilter.h" |
| 49 #include "webrtc/base/asyncudpsocket.h" | 49 #include "webrtc/base/asyncudpsocket.h" |
| 50 #include "webrtc/base/criticalsection.h" | 50 #include "webrtc/base/criticalsection.h" |
| 51 #include "webrtc/base/network.h" | 51 #include "webrtc/base/network.h" |
| 52 #include "webrtc/base/sigslot.h" | 52 #include "webrtc/base/sigslot.h" |
| 53 #include "webrtc/base/window.h" | 53 #include "webrtc/base/window.h" |
| 54 | 54 |
| 55 namespace webrtc { |
| 56 class MediaControllerInterface; |
| 57 } // namespace webrtc |
| 58 |
| 55 namespace cricket { | 59 namespace cricket { |
| 56 | 60 |
| 57 struct CryptoParams; | 61 struct CryptoParams; |
| 58 class MediaContentDescription; | 62 class MediaContentDescription; |
| 59 struct ViewRequest; | 63 struct ViewRequest; |
| 60 | 64 |
| 61 enum SinkType { | 65 enum SinkType { |
| 62 SINK_PRE_CRYPTO, // Sink packets before encryption or after decryption. | 66 SINK_PRE_CRYPTO, // Sink packets before encryption or after decryption. |
| 63 SINK_POST_CRYPTO // Sink packets after encryption or before decryption. | 67 SINK_POST_CRYPTO // Sink packets after encryption or before decryption. |
| 64 }; | 68 }; |
| 65 | 69 |
| 66 // BaseChannel contains logic common to voice and video, including | 70 // BaseChannel contains logic common to voice and video, including |
| 67 // enable, marshaling calls to a worker thread, and | 71 // enable, marshaling calls to a worker thread, and |
| 68 // connection and media monitors. | 72 // connection and media monitors. |
| 69 // | 73 // |
| 70 // WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS! | 74 // WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS! |
| 71 // This is required to avoid a data race between the destructor modifying the | 75 // This is required to avoid a data race between the destructor modifying the |
| 72 // vtable, and the media channel's thread using BaseChannel as the | 76 // vtable, and the media channel's thread using BaseChannel as the |
| 73 // NetworkInterface. | 77 // NetworkInterface. |
| 74 | 78 |
| 75 class BaseChannel | 79 class BaseChannel |
| 76 : public rtc::MessageHandler, public sigslot::has_slots<>, | 80 : public rtc::MessageHandler, public sigslot::has_slots<>, |
| 77 public MediaChannel::NetworkInterface, | 81 public MediaChannel::NetworkInterface, |
| 78 public ConnectionStatsGetter { | 82 public ConnectionStatsGetter { |
| 79 public: | 83 public: |
| 80 BaseChannel(rtc::Thread* thread, | 84 BaseChannel(rtc::Thread* thread, |
| 81 MediaChannel* channel, | 85 MediaChannel* channel, |
| 86 webrtc::MediaControllerInterface* media_controller, |
| 82 TransportController* transport_controller, | 87 TransportController* transport_controller, |
| 83 const std::string& content_name, | 88 const std::string& content_name, |
| 84 bool rtcp); | 89 bool rtcp); |
| 85 virtual ~BaseChannel(); | 90 virtual ~BaseChannel(); |
| 86 bool Init(); | 91 bool Init(); |
| 87 // Deinit may be called multiple times and is simply ignored if it's alreay | 92 // Deinit may be called multiple times and is simply ignored if it's alreay |
| 88 // done. | 93 // done. |
| 89 void Deinit(); | 94 void Deinit(); |
| 90 | 95 |
| 91 rtc::Thread* worker_thread() const { return worker_thread_; } | 96 rtc::Thread* worker_thread() const { return worker_thread_; } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 197 } |
| 193 bool rtcp_transport_enabled() const { return rtcp_transport_enabled_; } | 198 bool rtcp_transport_enabled() const { return rtcp_transport_enabled_; } |
| 194 | 199 |
| 195 void ConnectToTransportChannel(TransportChannel* tc); | 200 void ConnectToTransportChannel(TransportChannel* tc); |
| 196 void DisconnectFromTransportChannel(TransportChannel* tc); | 201 void DisconnectFromTransportChannel(TransportChannel* tc); |
| 197 | 202 |
| 198 void FlushRtcpMessages(); | 203 void FlushRtcpMessages(); |
| 199 | 204 |
| 200 // NetworkInterface implementation, called by MediaEngine | 205 // NetworkInterface implementation, called by MediaEngine |
| 201 virtual bool SendPacket(rtc::Buffer* packet, | 206 virtual bool SendPacket(rtc::Buffer* packet, |
| 202 rtc::DiffServCodePoint dscp); | 207 const rtc::PacketOptions& options); |
| 203 virtual bool SendRtcp(rtc::Buffer* packet, | 208 virtual bool SendRtcp(rtc::Buffer* packet, const rtc::PacketOptions& options); |
| 204 rtc::DiffServCodePoint dscp); | |
| 205 | 209 |
| 206 // From TransportChannel | 210 // From TransportChannel |
| 207 void OnWritableState(TransportChannel* channel); | 211 void OnWritableState(TransportChannel* channel); |
| 208 virtual void OnChannelRead(TransportChannel* channel, | 212 virtual void OnChannelRead(TransportChannel* channel, |
| 209 const char* data, | 213 const char* data, |
| 210 size_t len, | 214 size_t len, |
| 211 const rtc::PacketTime& packet_time, | 215 const rtc::PacketTime& packet_time, |
| 212 int flags); | 216 int flags); |
| 217 void OnPacketSent(TransportChannel* channel, |
| 218 const rtc::SentPacket& sent_packet); |
| 213 void OnReadyToSend(TransportChannel* channel); | 219 void OnReadyToSend(TransportChannel* channel); |
| 214 | 220 |
| 215 bool PacketIsRtcp(const TransportChannel* channel, const char* data, | 221 bool PacketIsRtcp(const TransportChannel* channel, const char* data, |
| 216 size_t len); | 222 size_t len); |
| 217 bool SendPacket(bool rtcp, rtc::Buffer* packet, | 223 bool SendPacket(bool rtcp, |
| 218 rtc::DiffServCodePoint dscp); | 224 rtc::Buffer* packet, |
| 225 const rtc::PacketOptions& options); |
| 219 virtual bool WantsPacket(bool rtcp, rtc::Buffer* packet); | 226 virtual bool WantsPacket(bool rtcp, rtc::Buffer* packet); |
| 220 void HandlePacket(bool rtcp, rtc::Buffer* packet, | 227 void HandlePacket(bool rtcp, rtc::Buffer* packet, |
| 221 const rtc::PacketTime& packet_time); | 228 const rtc::PacketTime& packet_time); |
| 222 | 229 |
| 223 void EnableMedia_w(); | 230 void EnableMedia_w(); |
| 224 void DisableMedia_w(); | 231 void DisableMedia_w(); |
| 225 void UpdateWritableState_w(); | 232 void UpdateWritableState_w(); |
| 226 void ChannelWritable_w(); | 233 void ChannelWritable_w(); |
| 227 void ChannelNotWritable_w(); | 234 void ChannelNotWritable_w(); |
| 228 bool AddRecvStream_w(const StreamParams& sp); | 235 bool AddRecvStream_w(const StreamParams& sp); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 254 ContentAction action, | 261 ContentAction action, |
| 255 std::string* error_desc) = 0; | 262 std::string* error_desc) = 0; |
| 256 bool SetRtpTransportParameters_w(const MediaContentDescription* content, | 263 bool SetRtpTransportParameters_w(const MediaContentDescription* content, |
| 257 ContentAction action, | 264 ContentAction action, |
| 258 ContentSource src, | 265 ContentSource src, |
| 259 std::string* error_desc); | 266 std::string* error_desc); |
| 260 | 267 |
| 261 // Helper method to get RTP Absoulute SendTime extension header id if | 268 // Helper method to get RTP Absoulute SendTime extension header id if |
| 262 // present in remote supported extensions list. | 269 // present in remote supported extensions list. |
| 263 void MaybeCacheRtpAbsSendTimeHeaderExtension( | 270 void MaybeCacheRtpAbsSendTimeHeaderExtension( |
| 264 const std::vector<RtpHeaderExtension>& extensions); | 271 const std::vector<RtpHeaderExtension>& extensions); |
| 265 | 272 |
| 266 bool CheckSrtpConfig(const std::vector<CryptoParams>& cryptos, | 273 bool CheckSrtpConfig(const std::vector<CryptoParams>& cryptos, |
| 267 bool* dtls, | 274 bool* dtls, |
| 268 std::string* error_desc); | 275 std::string* error_desc); |
| 269 bool SetSrtp_w(const std::vector<CryptoParams>& params, | 276 bool SetSrtp_w(const std::vector<CryptoParams>& params, |
| 270 ContentAction action, | 277 ContentAction action, |
| 271 ContentSource src, | 278 ContentSource src, |
| 272 std::string* error_desc); | 279 std::string* error_desc); |
| 273 void ActivateRtcpMux_w(); | 280 void ActivateRtcpMux_w(); |
| 274 bool SetRtcpMux_w(bool enable, | 281 bool SetRtcpMux_w(bool enable, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 289 // Helper function for invoking bool-returning methods on the worker thread. | 296 // Helper function for invoking bool-returning methods on the worker thread. |
| 290 template <class FunctorT> | 297 template <class FunctorT> |
| 291 bool InvokeOnWorker(const FunctorT& functor) { | 298 bool InvokeOnWorker(const FunctorT& functor) { |
| 292 return worker_thread_->Invoke<bool>(functor); | 299 return worker_thread_->Invoke<bool>(functor); |
| 293 } | 300 } |
| 294 | 301 |
| 295 private: | 302 private: |
| 296 rtc::Thread* worker_thread_; | 303 rtc::Thread* worker_thread_; |
| 297 TransportController* transport_controller_; | 304 TransportController* transport_controller_; |
| 298 MediaChannel* media_channel_; | 305 MediaChannel* media_channel_; |
| 306 webrtc::MediaControllerInterface* media_controller_; |
| 299 std::vector<StreamParams> local_streams_; | 307 std::vector<StreamParams> local_streams_; |
| 300 std::vector<StreamParams> remote_streams_; | 308 std::vector<StreamParams> remote_streams_; |
| 301 | 309 |
| 302 const std::string content_name_; | 310 const std::string content_name_; |
| 303 std::string transport_name_; | 311 std::string transport_name_; |
| 304 bool rtcp_transport_enabled_; | 312 bool rtcp_transport_enabled_; |
| 305 TransportChannel* transport_channel_; | 313 TransportChannel* transport_channel_; |
| 306 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; | 314 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; |
| 307 TransportChannel* rtcp_transport_channel_; | 315 TransportChannel* rtcp_transport_channel_; |
| 308 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; | 316 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; |
| 309 SrtpFilter srtp_filter_; | 317 SrtpFilter srtp_filter_; |
| 310 RtcpMuxFilter rtcp_mux_filter_; | 318 RtcpMuxFilter rtcp_mux_filter_; |
| 311 BundleFilter bundle_filter_; | 319 BundleFilter bundle_filter_; |
| 312 rtc::scoped_ptr<ConnectionMonitor> connection_monitor_; | 320 rtc::scoped_ptr<ConnectionMonitor> connection_monitor_; |
| 313 bool enabled_; | 321 bool enabled_; |
| 314 bool writable_; | 322 bool writable_; |
| 315 bool rtp_ready_to_send_; | 323 bool rtp_ready_to_send_; |
| 316 bool rtcp_ready_to_send_; | 324 bool rtcp_ready_to_send_; |
| 317 bool was_ever_writable_; | 325 bool was_ever_writable_; |
| 318 MediaContentDirection local_content_direction_; | 326 MediaContentDirection local_content_direction_; |
| 319 MediaContentDirection remote_content_direction_; | 327 MediaContentDirection remote_content_direction_; |
| 320 bool has_received_packet_; | 328 bool has_received_packet_; |
| 321 bool dtls_keyed_; | 329 bool dtls_keyed_; |
| 322 bool secure_required_; | 330 bool secure_required_; |
| 323 int rtp_abs_sendtime_extn_id_; | 331 int rtp_abs_sendtime_extn_id_; |
| 332 int rtp_transport_sequence_number_extn_id_; |
| 324 }; | 333 }; |
| 325 | 334 |
| 326 // VoiceChannel is a specialization that adds support for early media, DTMF, | 335 // VoiceChannel is a specialization that adds support for early media, DTMF, |
| 327 // and input/output level monitoring. | 336 // and input/output level monitoring. |
| 328 class VoiceChannel : public BaseChannel { | 337 class VoiceChannel : public BaseChannel { |
| 329 public: | 338 public: |
| 330 VoiceChannel(rtc::Thread* thread, | 339 VoiceChannel(rtc::Thread* thread, |
| 331 MediaEngineInterface* media_engine, | 340 MediaEngineInterface* media_engine, |
| 332 VoiceMediaChannel* channel, | 341 VoiceMediaChannel* channel, |
| 342 webrtc::MediaControllerInterface* media_controller, |
| 333 TransportController* transport_controller, | 343 TransportController* transport_controller, |
| 334 const std::string& content_name, | 344 const std::string& content_name, |
| 335 bool rtcp); | 345 bool rtcp); |
| 336 ~VoiceChannel(); | 346 ~VoiceChannel(); |
| 337 bool Init(); | 347 bool Init(); |
| 338 bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer); | 348 bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer); |
| 339 | 349 |
| 340 // Configure sending media on the stream with SSRC |ssrc| | 350 // Configure sending media on the stream with SSRC |ssrc| |
| 341 // If there is only one sending stream SSRC 0 can be used. | 351 // If there is only one sending stream SSRC 0 can be used. |
| 342 bool SetAudioSend(uint32 ssrc, | 352 bool SetAudioSend(uint32 ssrc, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 // Last AudioRecvParameters sent down to the media_channel() via | 435 // Last AudioRecvParameters sent down to the media_channel() via |
| 426 // SetRecvParameters. | 436 // SetRecvParameters. |
| 427 AudioRecvParameters last_recv_params_; | 437 AudioRecvParameters last_recv_params_; |
| 428 }; | 438 }; |
| 429 | 439 |
| 430 // VideoChannel is a specialization for video. | 440 // VideoChannel is a specialization for video. |
| 431 class VideoChannel : public BaseChannel { | 441 class VideoChannel : public BaseChannel { |
| 432 public: | 442 public: |
| 433 VideoChannel(rtc::Thread* thread, | 443 VideoChannel(rtc::Thread* thread, |
| 434 VideoMediaChannel* channel, | 444 VideoMediaChannel* channel, |
| 445 webrtc::MediaControllerInterface* media_controller, |
| 435 TransportController* transport_controller, | 446 TransportController* transport_controller, |
| 436 const std::string& content_name, | 447 const std::string& content_name, |
| 437 bool rtcp); | 448 bool rtcp); |
| 438 ~VideoChannel(); | 449 ~VideoChannel(); |
| 439 bool Init(); | 450 bool Init(); |
| 440 | 451 |
| 441 // downcasts a MediaChannel | 452 // downcasts a MediaChannel |
| 442 virtual VideoMediaChannel* media_channel() const { | 453 virtual VideoMediaChannel* media_channel() const { |
| 443 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); | 454 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); |
| 444 } | 455 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 464 SignalConnectionMonitor; | 475 SignalConnectionMonitor; |
| 465 | 476 |
| 466 void StartMediaMonitor(int cms); | 477 void StartMediaMonitor(int cms); |
| 467 void StopMediaMonitor(); | 478 void StopMediaMonitor(); |
| 468 sigslot::signal2<VideoChannel*, const VideoMediaInfo&> SignalMediaMonitor; | 479 sigslot::signal2<VideoChannel*, const VideoMediaInfo&> SignalMediaMonitor; |
| 469 sigslot::signal2<uint32, rtc::WindowEvent> SignalScreencastWindowEvent; | 480 sigslot::signal2<uint32, rtc::WindowEvent> SignalScreencastWindowEvent; |
| 470 | 481 |
| 471 bool SendIntraFrame(); | 482 bool SendIntraFrame(); |
| 472 bool RequestIntraFrame(); | 483 bool RequestIntraFrame(); |
| 473 | 484 |
| 474 // Configure sending media on the stream with SSRC |ssrc| | |
| 475 // If there is only one sending stream SSRC 0 can be used. | |
| 476 bool SetVideoSend(uint32 ssrc, bool enable, const VideoOptions* options); | 485 bool SetVideoSend(uint32 ssrc, bool enable, const VideoOptions* options); |
| 477 | 486 |
| 478 private: | 487 private: |
| 479 typedef std::map<uint32, VideoCapturer*> ScreencastMap; | 488 typedef std::map<uint32, VideoCapturer*> ScreencastMap; |
| 480 struct ScreencastDetailsData; | 489 struct ScreencastDetailsData; |
| 481 | 490 |
| 482 // overrides from BaseChannel | 491 // overrides from BaseChannel |
| 483 virtual void ChangeState(); | 492 virtual void ChangeState(); |
| 484 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); | 493 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); |
| 485 virtual bool SetLocalContent_w(const MediaContentDescription* content, | 494 virtual bool SetLocalContent_w(const MediaContentDescription* content, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 // SetSendParameters. | 649 // SetSendParameters. |
| 641 DataSendParameters last_send_params_; | 650 DataSendParameters last_send_params_; |
| 642 // Last DataRecvParameters sent down to the media_channel() via | 651 // Last DataRecvParameters sent down to the media_channel() via |
| 643 // SetRecvParameters. | 652 // SetRecvParameters. |
| 644 DataRecvParameters last_recv_params_; | 653 DataRecvParameters last_recv_params_; |
| 645 }; | 654 }; |
| 646 | 655 |
| 647 } // namespace cricket | 656 } // namespace cricket |
| 648 | 657 |
| 649 #endif // TALK_SESSION_MEDIA_CHANNEL_H_ | 658 #endif // TALK_SESSION_MEDIA_CHANNEL_H_ |
| OLD | NEW |