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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS! | 69 // WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS! |
70 // This is required to avoid a data race between the destructor modifying the | 70 // This is required to avoid a data race between the destructor modifying the |
71 // vtable, and the media channel's thread using BaseChannel as the | 71 // vtable, and the media channel's thread using BaseChannel as the |
72 // NetworkInterface. | 72 // NetworkInterface. |
73 | 73 |
74 class BaseChannel | 74 class BaseChannel |
75 : public rtc::MessageHandler, public sigslot::has_slots<>, | 75 : public rtc::MessageHandler, public sigslot::has_slots<>, |
76 public MediaChannel::NetworkInterface, | 76 public MediaChannel::NetworkInterface, |
77 public ConnectionStatsGetter { | 77 public ConnectionStatsGetter { |
78 public: | 78 public: |
79 BaseChannel(rtc::Thread* thread, MediaEngineInterface* media_engine, | 79 BaseChannel(rtc::Thread* thread, MediaChannel* channel, BaseSession* session, |
80 MediaChannel* channel, BaseSession* session, | |
81 const std::string& content_name, bool rtcp); | 80 const std::string& content_name, bool rtcp); |
82 virtual ~BaseChannel(); | 81 virtual ~BaseChannel(); |
83 bool Init(); | 82 bool Init(); |
84 // Deinit may be called multiple times and is simply ignored if it's alreay | 83 // Deinit may be called multiple times and is simply ignored if it's alreay |
85 // done. | 84 // done. |
86 void Deinit(); | 85 void Deinit(); |
87 | 86 |
88 rtc::Thread* worker_thread() const { return worker_thread_; } | 87 rtc::Thread* worker_thread() const { return worker_thread_; } |
89 BaseSession* session() const { return session_; } | 88 BaseSession* session() const { return session_; } |
90 const std::string& content_name() { return content_name_; } | 89 const std::string& content_name() { return content_name_; } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Used to alert UI when the muted status changes, perhaps autonomously. | 166 // Used to alert UI when the muted status changes, perhaps autonomously. |
168 sigslot::repeater2<BaseChannel*, bool> SignalAutoMuted; | 167 sigslot::repeater2<BaseChannel*, bool> SignalAutoMuted; |
169 | 168 |
170 // Made public for easier testing. | 169 // Made public for easier testing. |
171 void SetReadyToSend(TransportChannel* channel, bool ready); | 170 void SetReadyToSend(TransportChannel* channel, bool ready); |
172 | 171 |
173 // Only public for unit tests. Otherwise, consider protected. | 172 // Only public for unit tests. Otherwise, consider protected. |
174 virtual int SetOption(SocketType type, rtc::Socket::Option o, int val); | 173 virtual int SetOption(SocketType type, rtc::Socket::Option o, int val); |
175 | 174 |
176 protected: | 175 protected: |
177 MediaEngineInterface* media_engine() const { return media_engine_; } | |
178 virtual MediaChannel* media_channel() const { return media_channel_; } | 176 virtual MediaChannel* media_channel() const { return media_channel_; } |
179 // Sets the transport_channel_ and rtcp_transport_channel_. If | 177 // Sets the transport_channel_ and rtcp_transport_channel_. If |
180 // |rtcp| is false, set rtcp_transport_channel_ is set to NULL. Get | 178 // |rtcp| is false, set rtcp_transport_channel_ is set to NULL. Get |
181 // the transport channels from |session|. | 179 // the transport channels from |session|. |
182 // TODO(pthatcher): Pass in a Transport instead of a BaseSession. | 180 // TODO(pthatcher): Pass in a Transport instead of a BaseSession. |
183 bool SetTransportChannels(BaseSession* session, bool rtcp); | 181 bool SetTransportChannels(BaseSession* session, bool rtcp); |
184 bool SetTransportChannels_w(BaseSession* session, bool rtcp); | 182 bool SetTransportChannels_w(BaseSession* session, bool rtcp); |
185 void set_transport_channel(TransportChannel* transport); | 183 void set_transport_channel(TransportChannel* transport); |
186 void set_rtcp_transport_channel(TransportChannel* transport); | 184 void set_rtcp_transport_channel(TransportChannel* transport); |
187 bool was_ever_writable() const { return was_ever_writable_; } | 185 bool was_ever_writable() const { return was_ever_writable_; } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 const std::vector<ConnectionInfo>& infos) = 0; | 303 const std::vector<ConnectionInfo>& infos) = 0; |
306 | 304 |
307 // Helper function for invoking bool-returning methods on the worker thread. | 305 // Helper function for invoking bool-returning methods on the worker thread. |
308 template <class FunctorT> | 306 template <class FunctorT> |
309 bool InvokeOnWorker(const FunctorT& functor) { | 307 bool InvokeOnWorker(const FunctorT& functor) { |
310 return worker_thread_->Invoke<bool>(functor); | 308 return worker_thread_->Invoke<bool>(functor); |
311 } | 309 } |
312 | 310 |
313 private: | 311 private: |
314 rtc::Thread* worker_thread_; | 312 rtc::Thread* worker_thread_; |
315 MediaEngineInterface* media_engine_; | |
316 BaseSession* session_; | 313 BaseSession* session_; |
317 MediaChannel* media_channel_; | 314 MediaChannel* media_channel_; |
318 std::vector<StreamParams> local_streams_; | 315 std::vector<StreamParams> local_streams_; |
319 std::vector<StreamParams> remote_streams_; | 316 std::vector<StreamParams> remote_streams_; |
320 | 317 |
321 const std::string content_name_; | 318 const std::string content_name_; |
322 bool rtcp_; | 319 bool rtcp_; |
323 TransportChannel* transport_channel_; | 320 TransportChannel* transport_channel_; |
324 TransportChannel* rtcp_transport_channel_; | 321 TransportChannel* rtcp_transport_channel_; |
325 SrtpFilter srtp_filter_; | 322 SrtpFilter srtp_filter_; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 virtual void OnConnectionMonitorUpdate( | 434 virtual void OnConnectionMonitorUpdate( |
438 ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos); | 435 ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos); |
439 virtual void OnMediaMonitorUpdate( | 436 virtual void OnMediaMonitorUpdate( |
440 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info); | 437 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info); |
441 void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info); | 438 void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info); |
442 void OnVoiceChannelError(uint32 ssrc, VoiceMediaChannel::Error error); | 439 void OnVoiceChannelError(uint32 ssrc, VoiceMediaChannel::Error error); |
443 void SendLastMediaError(); | 440 void SendLastMediaError(); |
444 void OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode, SrtpFilter::Error error); | 441 void OnSrtpError(uint32 ssrc, SrtpFilter::Mode mode, SrtpFilter::Error error); |
445 | 442 |
446 static const int kEarlyMediaTimeout = 1000; | 443 static const int kEarlyMediaTimeout = 1000; |
| 444 MediaEngineInterface* media_engine_; |
447 bool received_media_; | 445 bool received_media_; |
448 rtc::scoped_ptr<VoiceMediaMonitor> media_monitor_; | 446 rtc::scoped_ptr<VoiceMediaMonitor> media_monitor_; |
449 rtc::scoped_ptr<AudioMonitor> audio_monitor_; | 447 rtc::scoped_ptr<AudioMonitor> audio_monitor_; |
450 rtc::scoped_ptr<TypingMonitor> typing_monitor_; | 448 rtc::scoped_ptr<TypingMonitor> typing_monitor_; |
451 }; | 449 }; |
452 | 450 |
453 // VideoChannel is a specialization for video. | 451 // VideoChannel is a specialization for video. |
454 class VideoChannel : public BaseChannel { | 452 class VideoChannel : public BaseChannel { |
455 public: | 453 public: |
456 VideoChannel(rtc::Thread* thread, MediaEngineInterface* media_engine, | 454 VideoChannel(rtc::Thread* thread, VideoMediaChannel* channel, |
457 VideoMediaChannel* channel, BaseSession* session, | 455 BaseSession* session, const std::string& content_name, |
458 const std::string& content_name, bool rtcp); | 456 bool rtcp); |
459 ~VideoChannel(); | 457 ~VideoChannel(); |
460 bool Init(); | 458 bool Init(); |
461 | 459 |
462 // downcasts a MediaChannel | 460 // downcasts a MediaChannel |
463 virtual VideoMediaChannel* media_channel() const { | 461 virtual VideoMediaChannel* media_channel() const { |
464 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); | 462 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); |
465 } | 463 } |
466 | 464 |
467 bool SetRenderer(uint32 ssrc, VideoRenderer* renderer); | 465 bool SetRenderer(uint32 ssrc, VideoRenderer* renderer); |
468 bool ApplyViewRequest(const ViewRequest& request); | 466 bool ApplyViewRequest(const ViewRequest& request); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 rtc::scoped_ptr<DataMediaMonitor> media_monitor_; | 652 rtc::scoped_ptr<DataMediaMonitor> media_monitor_; |
655 // TODO(pthatcher): Make a separate SctpDataChannel and | 653 // TODO(pthatcher): Make a separate SctpDataChannel and |
656 // RtpDataChannel instead of using this. | 654 // RtpDataChannel instead of using this. |
657 DataChannelType data_channel_type_; | 655 DataChannelType data_channel_type_; |
658 bool ready_to_send_data_; | 656 bool ready_to_send_data_; |
659 }; | 657 }; |
660 | 658 |
661 } // namespace cricket | 659 } // namespace cricket |
662 | 660 |
663 #endif // TALK_SESSION_MEDIA_CHANNEL_H_ | 661 #endif // TALK_SESSION_MEDIA_CHANNEL_H_ |
OLD | NEW |