| OLD | NEW |
| 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 |
| 11 #ifndef WEBRTC_PC_CHANNEL_H_ | 11 #ifndef WEBRTC_PC_CHANNEL_H_ |
| 12 #define WEBRTC_PC_CHANNEL_H_ | 12 #define WEBRTC_PC_CHANNEL_H_ |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <set> | 16 #include <set> |
| 17 #include <string> | 17 #include <string> |
| 18 #include <utility> | 18 #include <utility> |
| 19 #include <vector> | 19 #include <vector> |
| 20 | 20 |
| 21 #include "webrtc/audio_sink.h" | 21 #include "webrtc/audio_sink.h" |
| 22 #include "webrtc/base/asyncinvoker.h" |
| 22 #include "webrtc/base/asyncudpsocket.h" | 23 #include "webrtc/base/asyncudpsocket.h" |
| 23 #include "webrtc/base/criticalsection.h" | 24 #include "webrtc/base/criticalsection.h" |
| 24 #include "webrtc/base/network.h" | 25 #include "webrtc/base/network.h" |
| 25 #include "webrtc/base/sigslot.h" | 26 #include "webrtc/base/sigslot.h" |
| 26 #include "webrtc/base/window.h" | 27 #include "webrtc/base/window.h" |
| 27 #include "webrtc/media/base/mediachannel.h" | 28 #include "webrtc/media/base/mediachannel.h" |
| 28 #include "webrtc/media/base/mediaengine.h" | 29 #include "webrtc/media/base/mediaengine.h" |
| 29 #include "webrtc/media/base/streamparams.h" | 30 #include "webrtc/media/base/streamparams.h" |
| 30 #include "webrtc/media/base/videosinkinterface.h" | 31 #include "webrtc/media/base/videosinkinterface.h" |
| 31 #include "webrtc/media/base/videosourceinterface.h" | 32 #include "webrtc/media/base/videosourceinterface.h" |
| 32 #include "webrtc/p2p/base/transportcontroller.h" | 33 #include "webrtc/p2p/base/transportcontroller.h" |
| 33 #include "webrtc/p2p/client/socketmonitor.h" | 34 #include "webrtc/p2p/client/socketmonitor.h" |
| 34 #include "webrtc/pc/audiomonitor.h" | 35 #include "webrtc/pc/audiomonitor.h" |
| 35 #include "webrtc/pc/bundlefilter.h" | 36 #include "webrtc/pc/bundlefilter.h" |
| 36 #include "webrtc/pc/mediamonitor.h" | 37 #include "webrtc/pc/mediamonitor.h" |
| 37 #include "webrtc/pc/mediasession.h" | 38 #include "webrtc/pc/mediasession.h" |
| 38 #include "webrtc/pc/rtcpmuxfilter.h" | 39 #include "webrtc/pc/rtcpmuxfilter.h" |
| 39 #include "webrtc/pc/srtpfilter.h" | 40 #include "webrtc/pc/srtpfilter.h" |
| 40 | 41 |
| 41 namespace webrtc { | 42 namespace webrtc { |
| 42 class AudioSinkInterface; | 43 class AudioSinkInterface; |
| 43 } // namespace webrtc | 44 } // namespace webrtc |
| 44 | 45 |
| 45 namespace cricket { | 46 namespace cricket { |
| 46 | 47 |
| 47 struct CryptoParams; | 48 struct CryptoParams; |
| 48 class MediaContentDescription; | 49 class MediaContentDescription; |
| 49 | 50 |
| 50 enum SinkType { | |
| 51 SINK_PRE_CRYPTO, // Sink packets before encryption or after decryption. | |
| 52 SINK_POST_CRYPTO // Sink packets after encryption or before decryption. | |
| 53 }; | |
| 54 | |
| 55 // BaseChannel contains logic common to voice and video, including | 51 // BaseChannel contains logic common to voice and video, including |
| 56 // enable, marshaling calls to a worker thread, and | 52 // enable, marshaling calls to a worker and network threads, and |
| 57 // connection and media monitors. | 53 // connection and media monitors. |
| 54 // BaseChannel assumes signaling and other threads are allowed to make |
| 55 // synchronous calls to the worker thread, the worker thread makes synchronous |
| 56 // calls only to the network thread, and the network thread can't be blocked by |
| 57 // other threads. |
| 58 // All methods with _n suffix must be called on network thread, |
| 59 // methods with _w suffix - on worker thread |
| 60 // and methods with _s suffix on signaling thread. |
| 61 // Network and worker threads may be the same thread. |
| 58 // | 62 // |
| 59 // WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS! | 63 // WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS! |
| 60 // This is required to avoid a data race between the destructor modifying the | 64 // This is required to avoid a data race between the destructor modifying the |
| 61 // vtable, and the media channel's thread using BaseChannel as the | 65 // vtable, and the media channel's thread using BaseChannel as the |
| 62 // NetworkInterface. | 66 // NetworkInterface. |
| 63 | 67 |
| 64 class BaseChannel | 68 class BaseChannel |
| 65 : public rtc::MessageHandler, public sigslot::has_slots<>, | 69 : public rtc::MessageHandler, public sigslot::has_slots<>, |
| 66 public MediaChannel::NetworkInterface, | 70 public MediaChannel::NetworkInterface, |
| 67 public ConnectionStatsGetter { | 71 public ConnectionStatsGetter { |
| 68 public: | 72 public: |
| 69 BaseChannel(rtc::Thread* thread, | 73 BaseChannel(rtc::Thread* worker_thread, |
| 74 rtc::Thread* network_thread, |
| 70 MediaChannel* channel, | 75 MediaChannel* channel, |
| 71 TransportController* transport_controller, | 76 TransportController* transport_controller, |
| 72 const std::string& content_name, | 77 const std::string& content_name, |
| 73 bool rtcp); | 78 bool rtcp); |
| 74 virtual ~BaseChannel(); | 79 virtual ~BaseChannel(); |
| 75 bool Init(); | 80 bool Init_w(); |
| 76 // Deinit may be called multiple times and is simply ignored if it's alreay | 81 // Deinit may be called multiple times and is simply ignored if it's already |
| 77 // done. | 82 // done. |
| 78 void Deinit(); | 83 void Deinit(); |
| 79 | 84 |
| 80 rtc::Thread* worker_thread() const { return worker_thread_; } | 85 rtc::Thread* worker_thread() const { return worker_thread_; } |
| 86 rtc::Thread* network_thread() const { return network_thread_; } |
| 81 const std::string& content_name() const { return content_name_; } | 87 const std::string& content_name() const { return content_name_; } |
| 82 const std::string& transport_name() const { return transport_name_; } | 88 const std::string& transport_name() const { return transport_name_; } |
| 83 TransportChannel* transport_channel() const { | |
| 84 return transport_channel_; | |
| 85 } | |
| 86 TransportChannel* rtcp_transport_channel() const { | |
| 87 return rtcp_transport_channel_; | |
| 88 } | |
| 89 bool enabled() const { return enabled_; } | 89 bool enabled() const { return enabled_; } |
| 90 | 90 |
| 91 // This function returns true if we are using SRTP. | 91 // This function returns true if we are using SRTP. |
| 92 bool secure() const { return srtp_filter_.IsActive(); } | 92 bool secure() const { return srtp_filter_.IsActive(); } |
| 93 // The following function returns true if we are using | 93 // The following function returns true if we are using |
| 94 // DTLS-based keying. If you turned off SRTP later, however | 94 // DTLS-based keying. If you turned off SRTP later, however |
| 95 // you could have secure() == false and dtls_secure() == true. | 95 // you could have secure() == false and dtls_secure() == true. |
| 96 bool secure_dtls() const { return dtls_keyed_; } | 96 bool secure_dtls() const { return dtls_keyed_; } |
| 97 // This function returns true if we require secure channel for call setup. | 97 // This function returns true if we require secure channel for call setup. |
| 98 bool secure_required() const { return secure_required_; } | 98 bool secure_required() const { return secure_required_; } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 BundleFilter* bundle_filter() { return &bundle_filter_; } | 136 BundleFilter* bundle_filter() { return &bundle_filter_; } |
| 137 | 137 |
| 138 const std::vector<StreamParams>& local_streams() const { | 138 const std::vector<StreamParams>& local_streams() const { |
| 139 return local_streams_; | 139 return local_streams_; |
| 140 } | 140 } |
| 141 const std::vector<StreamParams>& remote_streams() const { | 141 const std::vector<StreamParams>& remote_streams() const { |
| 142 return remote_streams_; | 142 return remote_streams_; |
| 143 } | 143 } |
| 144 | 144 |
| 145 sigslot::signal2<BaseChannel*, bool> SignalDtlsSetupFailure; | 145 sigslot::signal2<BaseChannel*, bool> SignalDtlsSetupFailure; |
| 146 void SignalDtlsSetupFailure_w(bool rtcp); | 146 void SignalDtlsSetupFailure_n(bool rtcp); |
| 147 void SignalDtlsSetupFailure_s(bool rtcp); | 147 void SignalDtlsSetupFailure_s(bool rtcp); |
| 148 | 148 |
| 149 // Used for latency measurements. | 149 // Used for latency measurements. |
| 150 sigslot::signal1<BaseChannel*> SignalFirstPacketReceived; | 150 sigslot::signal1<BaseChannel*> SignalFirstPacketReceived; |
| 151 | 151 |
| 152 // Forward TransportChannel SignalSentPacket to worker thread. |
| 153 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket; |
| 154 |
| 155 // Only public for unit tests. Otherwise, consider private. |
| 156 TransportChannel* transport_channel() const { return transport_channel_; } |
| 157 TransportChannel* rtcp_transport_channel() const { |
| 158 return rtcp_transport_channel_; |
| 159 } |
| 160 |
| 152 // Made public for easier testing. | 161 // Made public for easier testing. |
| 153 void SetReadyToSend(bool rtcp, bool ready); | 162 void SetReadyToSend(bool rtcp, bool ready); |
| 154 | 163 |
| 155 // Only public for unit tests. Otherwise, consider protected. | 164 // Only public for unit tests. Otherwise, consider protected. |
| 156 int SetOption(SocketType type, rtc::Socket::Option o, int val) | 165 int SetOption(SocketType type, rtc::Socket::Option o, int val) |
| 157 override; | 166 override; |
| 167 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); |
| 158 | 168 |
| 159 SrtpFilter* srtp_filter() { return &srtp_filter_; } | 169 SrtpFilter* srtp_filter() { return &srtp_filter_; } |
| 160 | 170 |
| 161 protected: | 171 protected: |
| 162 virtual MediaChannel* media_channel() const { return media_channel_; } | 172 virtual MediaChannel* media_channel() const { return media_channel_; } |
| 163 // Sets the |transport_channel_| (and |rtcp_transport_channel_|, if |rtcp_| is | 173 // Sets the |transport_channel_| (and |rtcp_transport_channel_|, if |rtcp_| is |
| 164 // true). Gets the transport channels from |transport_controller_|. | 174 // true). Gets the transport channels from |transport_controller_|. |
| 165 bool SetTransport_w(const std::string& transport_name); | 175 bool SetTransport_n(const std::string& transport_name); |
| 166 | 176 |
| 167 void set_transport_channel(TransportChannel* transport); | 177 void SetTransportChannel_n(TransportChannel* transport); |
| 168 void set_rtcp_transport_channel(TransportChannel* transport, | 178 void SetRtcpTransportChannel_n(TransportChannel* transport, |
| 169 bool update_writablity); | 179 bool update_writablity); |
| 170 | 180 |
| 171 bool was_ever_writable() const { return was_ever_writable_; } | 181 bool was_ever_writable() const { return was_ever_writable_; } |
| 172 void set_local_content_direction(MediaContentDirection direction) { | 182 void set_local_content_direction(MediaContentDirection direction) { |
| 173 local_content_direction_ = direction; | 183 local_content_direction_ = direction; |
| 174 } | 184 } |
| 175 void set_remote_content_direction(MediaContentDirection direction) { | 185 void set_remote_content_direction(MediaContentDirection direction) { |
| 176 remote_content_direction_ = direction; | 186 remote_content_direction_ = direction; |
| 177 } | 187 } |
| 178 void set_secure_required(bool secure_required) { | 188 void set_secure_required(bool secure_required) { |
| 179 secure_required_ = secure_required; | 189 secure_required_ = secure_required; |
| 180 } | 190 } |
| 181 bool IsReadyToReceive() const; | 191 bool IsReadyToReceive_w() const; |
| 182 bool IsReadyToSend() const; | 192 bool IsReadyToSend_w() const; |
| 183 rtc::Thread* signaling_thread() { | 193 rtc::Thread* signaling_thread() { |
| 184 return transport_controller_->signaling_thread(); | 194 return transport_controller_->signaling_thread(); |
| 185 } | 195 } |
| 186 bool rtcp_transport_enabled() const { return rtcp_transport_enabled_; } | 196 bool rtcp_transport_enabled() const { return rtcp_transport_enabled_; } |
| 187 | 197 |
| 188 void ConnectToTransportChannel(TransportChannel* tc); | 198 void ConnectToTransportChannel(TransportChannel* tc); |
| 189 void DisconnectFromTransportChannel(TransportChannel* tc); | 199 void DisconnectFromTransportChannel(TransportChannel* tc); |
| 190 | 200 |
| 191 void FlushRtcpMessages(); | 201 void FlushRtcpMessages_n(); |
| 192 | 202 |
| 193 // NetworkInterface implementation, called by MediaEngine | 203 // NetworkInterface implementation, called by MediaEngine |
| 194 bool SendPacket(rtc::CopyOnWriteBuffer* packet, | 204 bool SendPacket(rtc::CopyOnWriteBuffer* packet, |
| 195 const rtc::PacketOptions& options) override; | 205 const rtc::PacketOptions& options) override; |
| 196 bool SendRtcp(rtc::CopyOnWriteBuffer* packet, | 206 bool SendRtcp(rtc::CopyOnWriteBuffer* packet, |
| 197 const rtc::PacketOptions& options) override; | 207 const rtc::PacketOptions& options) override; |
| 198 | 208 |
| 199 // From TransportChannel | 209 // From TransportChannel |
| 200 void OnWritableState(TransportChannel* channel); | 210 void OnWritableState(TransportChannel* channel); |
| 201 virtual void OnChannelRead(TransportChannel* channel, | 211 virtual void OnChannelRead(TransportChannel* channel, |
| 202 const char* data, | 212 const char* data, |
| 203 size_t len, | 213 size_t len, |
| 204 const rtc::PacketTime& packet_time, | 214 const rtc::PacketTime& packet_time, |
| 205 int flags); | 215 int flags); |
| 206 void OnReadyToSend(TransportChannel* channel); | 216 void OnReadyToSend(TransportChannel* channel); |
| 207 | 217 |
| 208 void OnDtlsState(TransportChannel* channel, DtlsTransportState state); | 218 void OnDtlsState(TransportChannel* channel, DtlsTransportState state); |
| 209 | 219 |
| 210 void OnSelectedCandidatePairChanged( | 220 void OnSelectedCandidatePairChanged( |
| 211 TransportChannel* channel, | 221 TransportChannel* channel, |
| 212 CandidatePairInterface* selected_candidate_pair, | 222 CandidatePairInterface* selected_candidate_pair, |
| 213 int last_sent_packet_id); | 223 int last_sent_packet_id); |
| 214 | 224 |
| 215 bool PacketIsRtcp(const TransportChannel* channel, const char* data, | 225 bool PacketIsRtcp(const TransportChannel* channel, const char* data, |
| 216 size_t len); | 226 size_t len); |
| 217 bool SendPacket(bool rtcp, | 227 bool SendPacket(bool rtcp, |
| 218 rtc::CopyOnWriteBuffer* packet, | 228 rtc::CopyOnWriteBuffer* packet, |
| 219 const rtc::PacketOptions& options); | 229 const rtc::PacketOptions& options); |
| 230 |
| 220 virtual bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); | 231 virtual bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); |
| 221 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, | 232 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, |
| 222 const rtc::PacketTime& packet_time); | 233 const rtc::PacketTime& packet_time); |
| 234 void OnPacketReceived(bool rtcp, |
| 235 const rtc::CopyOnWriteBuffer& packet, |
| 236 const rtc::PacketTime& packet_time); |
| 223 | 237 |
| 224 void EnableMedia_w(); | 238 void EnableMedia_w(); |
| 225 void DisableMedia_w(); | 239 void DisableMedia_w(); |
| 226 void UpdateWritableState_w(); | 240 void UpdateWritableState_n(); |
| 227 void ChannelWritable_w(); | 241 void ChannelWritable_n(); |
| 228 void ChannelNotWritable_w(); | 242 void ChannelNotWritable_n(); |
| 229 bool AddRecvStream_w(const StreamParams& sp); | 243 bool AddRecvStream_w(const StreamParams& sp); |
| 230 bool RemoveRecvStream_w(uint32_t ssrc); | 244 bool RemoveRecvStream_w(uint32_t ssrc); |
| 231 bool AddSendStream_w(const StreamParams& sp); | 245 bool AddSendStream_w(const StreamParams& sp); |
| 232 bool RemoveSendStream_w(uint32_t ssrc); | 246 bool RemoveSendStream_w(uint32_t ssrc); |
| 233 virtual bool ShouldSetupDtlsSrtp() const; | 247 virtual bool ShouldSetupDtlsSrtp_n() const; |
| 234 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. | 248 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. |
| 235 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. | 249 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. |
| 236 bool SetupDtlsSrtp(bool rtcp_channel); | 250 bool SetupDtlsSrtp_n(bool rtcp_channel); |
| 237 void MaybeSetupDtlsSrtp_w(); | 251 void MaybeSetupDtlsSrtp_n(); |
| 238 // Set the DTLS-SRTP cipher policy on this channel as appropriate. | 252 // Set the DTLS-SRTP cipher policy on this channel as appropriate. |
| 239 bool SetDtlsSrtpCryptoSuites(TransportChannel* tc, bool rtcp); | 253 bool SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp); |
| 240 | 254 |
| 241 virtual void ChangeState() = 0; | 255 void ChangeState(); |
| 256 virtual void ChangeState_w() = 0; |
| 242 | 257 |
| 243 // Gets the content info appropriate to the channel (audio or video). | 258 // Gets the content info appropriate to the channel (audio or video). |
| 244 virtual const ContentInfo* GetFirstContent( | 259 virtual const ContentInfo* GetFirstContent( |
| 245 const SessionDescription* sdesc) = 0; | 260 const SessionDescription* sdesc) = 0; |
| 246 bool UpdateLocalStreams_w(const std::vector<StreamParams>& streams, | 261 bool UpdateLocalStreams_w(const std::vector<StreamParams>& streams, |
| 247 ContentAction action, | 262 ContentAction action, |
| 248 std::string* error_desc); | 263 std::string* error_desc); |
| 249 bool UpdateRemoteStreams_w(const std::vector<StreamParams>& streams, | 264 bool UpdateRemoteStreams_w(const std::vector<StreamParams>& streams, |
| 250 ContentAction action, | 265 ContentAction action, |
| 251 std::string* error_desc); | 266 std::string* error_desc); |
| 252 virtual bool SetLocalContent_w(const MediaContentDescription* content, | 267 virtual bool SetLocalContent_w(const MediaContentDescription* content, |
| 253 ContentAction action, | 268 ContentAction action, |
| 254 std::string* error_desc) = 0; | 269 std::string* error_desc) = 0; |
| 255 virtual bool SetRemoteContent_w(const MediaContentDescription* content, | 270 virtual bool SetRemoteContent_w(const MediaContentDescription* content, |
| 256 ContentAction action, | 271 ContentAction action, |
| 257 std::string* error_desc) = 0; | 272 std::string* error_desc) = 0; |
| 258 bool SetRtpTransportParameters_w(const MediaContentDescription* content, | 273 bool SetRtpTransportParameters(const MediaContentDescription* content, |
| 274 ContentAction action, |
| 275 ContentSource src, |
| 276 std::string* error_desc); |
| 277 bool SetRtpTransportParameters_n(const MediaContentDescription* content, |
| 259 ContentAction action, | 278 ContentAction action, |
| 260 ContentSource src, | 279 ContentSource src, |
| 261 std::string* error_desc); | 280 std::string* error_desc); |
| 262 | 281 |
| 263 // Helper method to get RTP Absoulute SendTime extension header id if | 282 // Helper method to get RTP Absoulute SendTime extension header id if |
| 264 // present in remote supported extensions list. | 283 // present in remote supported extensions list. |
| 265 void MaybeCacheRtpAbsSendTimeHeaderExtension( | 284 void MaybeCacheRtpAbsSendTimeHeaderExtension_w( |
| 266 const std::vector<RtpHeaderExtension>& extensions); | 285 const std::vector<RtpHeaderExtension>& extensions); |
| 267 | 286 |
| 268 bool CheckSrtpConfig(const std::vector<CryptoParams>& cryptos, | 287 bool CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, |
| 269 bool* dtls, | 288 bool* dtls, |
| 270 std::string* error_desc); | 289 std::string* error_desc); |
| 271 bool SetSrtp_w(const std::vector<CryptoParams>& params, | 290 bool SetSrtp_n(const std::vector<CryptoParams>& params, |
| 272 ContentAction action, | 291 ContentAction action, |
| 273 ContentSource src, | 292 ContentSource src, |
| 274 std::string* error_desc); | 293 std::string* error_desc); |
| 275 void ActivateRtcpMux_w(); | 294 void ActivateRtcpMux_n(); |
| 276 bool SetRtcpMux_w(bool enable, | 295 bool SetRtcpMux_n(bool enable, |
| 277 ContentAction action, | 296 ContentAction action, |
| 278 ContentSource src, | 297 ContentSource src, |
| 279 std::string* error_desc); | 298 std::string* error_desc); |
| 280 | 299 |
| 281 // From MessageHandler | 300 // From MessageHandler |
| 282 void OnMessage(rtc::Message* pmsg) override; | 301 void OnMessage(rtc::Message* pmsg) override; |
| 283 | 302 |
| 284 // Handled in derived classes | 303 // Handled in derived classes |
| 285 // Get the SRTP crypto suites to use for RTP media | 304 // Get the SRTP crypto suites to use for RTP media |
| 286 virtual void GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const = 0; | 305 virtual void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const = 0; |
| 287 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, | 306 virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, |
| 288 const std::vector<ConnectionInfo>& infos) = 0; | 307 const std::vector<ConnectionInfo>& infos) = 0; |
| 289 | 308 |
| 290 // Helper function for invoking bool-returning methods on the worker thread. | 309 // Helper function for invoking bool-returning methods on the worker thread. |
| 291 template <class FunctorT> | 310 template <class FunctorT> |
| 292 bool InvokeOnWorker(const FunctorT& functor) { | 311 bool InvokeOnWorker(const FunctorT& functor) { |
| 293 return worker_thread_->Invoke<bool>(functor); | 312 return worker_thread_->Invoke<bool>(functor); |
| 294 } | 313 } |
| 295 | 314 |
| 296 private: | 315 private: |
| 297 rtc::Thread* worker_thread_; | 316 bool InitNetwork_n(); |
| 298 TransportController* transport_controller_; | 317 void DeinitNetwork_n(); |
| 299 MediaChannel* media_channel_; | 318 void SignalSentPacket_n(TransportChannel* channel, |
| 300 std::vector<StreamParams> local_streams_; | 319 const rtc::SentPacket& sent_packet); |
| 301 std::vector<StreamParams> remote_streams_; | 320 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); |
| 321 bool IsTransportReadyToSend_n() const; |
| 322 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id); |
| 323 |
| 324 rtc::Thread* const worker_thread_; |
| 325 rtc::Thread* const network_thread_; |
| 326 rtc::AsyncInvoker invoker_; |
| 302 | 327 |
| 303 const std::string content_name_; | 328 const std::string content_name_; |
| 329 std::unique_ptr<ConnectionMonitor> connection_monitor_; |
| 330 |
| 331 // Transport related members that should be accessed from network thread. |
| 332 TransportController* const transport_controller_; |
| 304 std::string transport_name_; | 333 std::string transport_name_; |
| 305 bool rtcp_transport_enabled_; | 334 bool rtcp_transport_enabled_; |
| 306 TransportChannel* transport_channel_; | 335 TransportChannel* transport_channel_; |
| 307 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; | 336 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_; |
| 308 TransportChannel* rtcp_transport_channel_; | 337 TransportChannel* rtcp_transport_channel_; |
| 309 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; | 338 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_; |
| 310 SrtpFilter srtp_filter_; | 339 SrtpFilter srtp_filter_; |
| 311 RtcpMuxFilter rtcp_mux_filter_; | 340 RtcpMuxFilter rtcp_mux_filter_; |
| 312 BundleFilter bundle_filter_; | 341 BundleFilter bundle_filter_; |
| 313 std::unique_ptr<ConnectionMonitor> connection_monitor_; | |
| 314 bool enabled_; | |
| 315 bool writable_; | |
| 316 bool rtp_ready_to_send_; | 342 bool rtp_ready_to_send_; |
| 317 bool rtcp_ready_to_send_; | 343 bool rtcp_ready_to_send_; |
| 344 bool writable_; |
| 318 bool was_ever_writable_; | 345 bool was_ever_writable_; |
| 319 MediaContentDirection local_content_direction_; | |
| 320 MediaContentDirection remote_content_direction_; | |
| 321 bool has_received_packet_; | 346 bool has_received_packet_; |
| 322 bool dtls_keyed_; | 347 bool dtls_keyed_; |
| 323 bool secure_required_; | 348 bool secure_required_; |
| 324 int rtp_abs_sendtime_extn_id_; | 349 int rtp_abs_sendtime_extn_id_; |
| 350 |
| 351 // MediaChannel related members that should be access from worker thread. |
| 352 MediaChannel* const media_channel_; |
| 353 // Currently enabled_ flag accessed from signaling thread too, but it can |
| 354 // be changed only when signaling thread does sunchronious call to worker |
| 355 // thread, so it should be safe. |
| 356 bool enabled_; |
| 357 std::vector<StreamParams> local_streams_; |
| 358 std::vector<StreamParams> remote_streams_; |
| 359 MediaContentDirection local_content_direction_; |
| 360 MediaContentDirection remote_content_direction_; |
| 325 }; | 361 }; |
| 326 | 362 |
| 327 // VoiceChannel is a specialization that adds support for early media, DTMF, | 363 // VoiceChannel is a specialization that adds support for early media, DTMF, |
| 328 // and input/output level monitoring. | 364 // and input/output level monitoring. |
| 329 class VoiceChannel : public BaseChannel { | 365 class VoiceChannel : public BaseChannel { |
| 330 public: | 366 public: |
| 331 VoiceChannel(rtc::Thread* thread, | 367 VoiceChannel(rtc::Thread* worker_thread, |
| 368 rtc::Thread* network_thread, |
| 332 MediaEngineInterface* media_engine, | 369 MediaEngineInterface* media_engine, |
| 333 VoiceMediaChannel* channel, | 370 VoiceMediaChannel* channel, |
| 334 TransportController* transport_controller, | 371 TransportController* transport_controller, |
| 335 const std::string& content_name, | 372 const std::string& content_name, |
| 336 bool rtcp); | 373 bool rtcp); |
| 337 ~VoiceChannel(); | 374 ~VoiceChannel(); |
| 338 bool Init(); | 375 bool Init_w(); |
| 339 | 376 |
| 340 // Configure sending media on the stream with SSRC |ssrc| | 377 // Configure sending media on the stream with SSRC |ssrc| |
| 341 // If there is only one sending stream SSRC 0 can be used. | 378 // If there is only one sending stream SSRC 0 can be used. |
| 342 bool SetAudioSend(uint32_t ssrc, | 379 bool SetAudioSend(uint32_t ssrc, |
| 343 bool enable, | 380 bool enable, |
| 344 const AudioOptions* options, | 381 const AudioOptions* options, |
| 345 AudioSource* source); | 382 AudioSource* source); |
| 346 | 383 |
| 347 // downcasts a MediaChannel | 384 // downcasts a MediaChannel |
| 348 virtual VoiceMediaChannel* media_channel() const { | 385 VoiceMediaChannel* media_channel() const override { |
| 349 return static_cast<VoiceMediaChannel*>(BaseChannel::media_channel()); | 386 return static_cast<VoiceMediaChannel*>(BaseChannel::media_channel()); |
| 350 } | 387 } |
| 351 | 388 |
| 352 void SetEarlyMedia(bool enable); | 389 void SetEarlyMedia(bool enable); |
| 353 // This signal is emitted when we have gone a period of time without | 390 // This signal is emitted when we have gone a period of time without |
| 354 // receiving early media. When received, a UI should start playing its | 391 // receiving early media. When received, a UI should start playing its |
| 355 // own ringing sound | 392 // own ringing sound |
| 356 sigslot::signal1<VoiceChannel*> SignalEarlyMediaTimeout; | 393 sigslot::signal1<VoiceChannel*> SignalEarlyMediaTimeout; |
| 357 | 394 |
| 358 // Returns if the telephone-event has been negotiated. | 395 // Returns if the telephone-event has been negotiated. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 386 sigslot::signal2<VoiceChannel*, const AudioInfo&> SignalAudioMonitor; | 423 sigslot::signal2<VoiceChannel*, const AudioInfo&> SignalAudioMonitor; |
| 387 | 424 |
| 388 int GetInputLevel_w(); | 425 int GetInputLevel_w(); |
| 389 int GetOutputLevel_w(); | 426 int GetOutputLevel_w(); |
| 390 void GetActiveStreams_w(AudioInfo::StreamList* actives); | 427 void GetActiveStreams_w(AudioInfo::StreamList* actives); |
| 391 webrtc::RtpParameters GetRtpParameters_w(uint32_t ssrc) const; | 428 webrtc::RtpParameters GetRtpParameters_w(uint32_t ssrc) const; |
| 392 bool SetRtpParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); | 429 bool SetRtpParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); |
| 393 | 430 |
| 394 private: | 431 private: |
| 395 // overrides from BaseChannel | 432 // overrides from BaseChannel |
| 396 virtual void OnChannelRead(TransportChannel* channel, | 433 void OnChannelRead(TransportChannel* channel, |
| 397 const char* data, size_t len, | 434 const char* data, |
| 398 const rtc::PacketTime& packet_time, | 435 size_t len, |
| 399 int flags); | 436 const rtc::PacketTime& packet_time, |
| 400 virtual void ChangeState(); | 437 int flags) override; |
| 401 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); | 438 void ChangeState_w() override; |
| 402 virtual bool SetLocalContent_w(const MediaContentDescription* content, | 439 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; |
| 403 ContentAction action, | 440 bool SetLocalContent_w(const MediaContentDescription* content, |
| 404 std::string* error_desc); | 441 ContentAction action, |
| 405 virtual bool SetRemoteContent_w(const MediaContentDescription* content, | 442 std::string* error_desc) override; |
| 406 ContentAction action, | 443 bool SetRemoteContent_w(const MediaContentDescription* content, |
| 407 std::string* error_desc); | 444 ContentAction action, |
| 445 std::string* error_desc) override; |
| 408 void HandleEarlyMediaTimeout(); | 446 void HandleEarlyMediaTimeout(); |
| 409 bool InsertDtmf_w(uint32_t ssrc, int event, int duration); | 447 bool InsertDtmf_w(uint32_t ssrc, int event, int duration); |
| 410 bool SetOutputVolume_w(uint32_t ssrc, double volume); | 448 bool SetOutputVolume_w(uint32_t ssrc, double volume); |
| 411 bool GetStats_w(VoiceMediaInfo* stats); | 449 bool GetStats_w(VoiceMediaInfo* stats); |
| 412 | 450 |
| 413 virtual void OnMessage(rtc::Message* pmsg); | 451 void OnMessage(rtc::Message* pmsg) override; |
| 414 virtual void GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const; | 452 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override; |
| 415 virtual void OnConnectionMonitorUpdate( | 453 void OnConnectionMonitorUpdate( |
| 416 ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos); | 454 ConnectionMonitor* monitor, |
| 417 virtual void OnMediaMonitorUpdate( | 455 const std::vector<ConnectionInfo>& infos) override; |
| 418 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info); | 456 void OnMediaMonitorUpdate(VoiceMediaChannel* media_channel, |
| 457 const VoiceMediaInfo& info); |
| 419 void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info); | 458 void OnAudioMonitorUpdate(AudioMonitor* monitor, const AudioInfo& info); |
| 420 | 459 |
| 421 static const int kEarlyMediaTimeout = 1000; | 460 static const int kEarlyMediaTimeout = 1000; |
| 422 MediaEngineInterface* media_engine_; | 461 MediaEngineInterface* media_engine_; |
| 423 bool received_media_; | 462 bool received_media_; |
| 424 std::unique_ptr<VoiceMediaMonitor> media_monitor_; | 463 std::unique_ptr<VoiceMediaMonitor> media_monitor_; |
| 425 std::unique_ptr<AudioMonitor> audio_monitor_; | 464 std::unique_ptr<AudioMonitor> audio_monitor_; |
| 426 | 465 |
| 427 // Last AudioSendParameters sent down to the media_channel() via | 466 // Last AudioSendParameters sent down to the media_channel() via |
| 428 // SetSendParameters. | 467 // SetSendParameters. |
| 429 AudioSendParameters last_send_params_; | 468 AudioSendParameters last_send_params_; |
| 430 // Last AudioRecvParameters sent down to the media_channel() via | 469 // Last AudioRecvParameters sent down to the media_channel() via |
| 431 // SetRecvParameters. | 470 // SetRecvParameters. |
| 432 AudioRecvParameters last_recv_params_; | 471 AudioRecvParameters last_recv_params_; |
| 433 }; | 472 }; |
| 434 | 473 |
| 435 // VideoChannel is a specialization for video. | 474 // VideoChannel is a specialization for video. |
| 436 class VideoChannel : public BaseChannel { | 475 class VideoChannel : public BaseChannel { |
| 437 public: | 476 public: |
| 438 VideoChannel(rtc::Thread* thread, | 477 VideoChannel(rtc::Thread* worker_thread, |
| 478 rtc::Thread* netwokr_thread, |
| 439 VideoMediaChannel* channel, | 479 VideoMediaChannel* channel, |
| 440 TransportController* transport_controller, | 480 TransportController* transport_controller, |
| 441 const std::string& content_name, | 481 const std::string& content_name, |
| 442 bool rtcp); | 482 bool rtcp); |
| 443 ~VideoChannel(); | 483 ~VideoChannel(); |
| 444 bool Init(); | 484 bool Init_w(); |
| 445 | 485 |
| 446 // downcasts a MediaChannel | 486 // downcasts a MediaChannel |
| 447 virtual VideoMediaChannel* media_channel() const { | 487 VideoMediaChannel* media_channel() const override { |
| 448 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); | 488 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); |
| 449 } | 489 } |
| 450 | 490 |
| 451 bool SetSink(uint32_t ssrc, rtc::VideoSinkInterface<VideoFrame>* sink); | 491 bool SetSink(uint32_t ssrc, rtc::VideoSinkInterface<VideoFrame>* sink); |
| 452 // Register a source. The |ssrc| must correspond to a registered | 492 // Register a source. The |ssrc| must correspond to a registered |
| 453 // send stream. | 493 // send stream. |
| 454 void SetSource(uint32_t ssrc, | 494 void SetSource(uint32_t ssrc, |
| 455 rtc::VideoSourceInterface<cricket::VideoFrame>* source); | 495 rtc::VideoSourceInterface<cricket::VideoFrame>* source); |
| 456 // Get statistics about the current media session. | 496 // Get statistics about the current media session. |
| 457 bool GetStats(VideoMediaInfo* stats); | 497 bool GetStats(VideoMediaInfo* stats); |
| 458 | 498 |
| 459 sigslot::signal2<VideoChannel*, const std::vector<ConnectionInfo>&> | 499 sigslot::signal2<VideoChannel*, const std::vector<ConnectionInfo>&> |
| 460 SignalConnectionMonitor; | 500 SignalConnectionMonitor; |
| 461 | 501 |
| 462 void StartMediaMonitor(int cms); | 502 void StartMediaMonitor(int cms); |
| 463 void StopMediaMonitor(); | 503 void StopMediaMonitor(); |
| 464 sigslot::signal2<VideoChannel*, const VideoMediaInfo&> SignalMediaMonitor; | 504 sigslot::signal2<VideoChannel*, const VideoMediaInfo&> SignalMediaMonitor; |
| 465 | 505 |
| 466 bool SetVideoSend(uint32_t ssrc, bool enable, const VideoOptions* options); | 506 bool SetVideoSend(uint32_t ssrc, bool enable, const VideoOptions* options); |
| 467 webrtc::RtpParameters GetRtpParameters(uint32_t ssrc) const; | 507 webrtc::RtpParameters GetRtpParameters(uint32_t ssrc) const; |
| 468 bool SetRtpParameters(uint32_t ssrc, const webrtc::RtpParameters& parameters); | 508 bool SetRtpParameters(uint32_t ssrc, const webrtc::RtpParameters& parameters); |
| 469 | 509 |
| 470 private: | 510 private: |
| 471 // overrides from BaseChannel | 511 // overrides from BaseChannel |
| 472 virtual void ChangeState(); | 512 void ChangeState_w() override; |
| 473 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); | 513 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; |
| 474 virtual bool SetLocalContent_w(const MediaContentDescription* content, | 514 bool SetLocalContent_w(const MediaContentDescription* content, |
| 475 ContentAction action, | 515 ContentAction action, |
| 476 std::string* error_desc); | 516 std::string* error_desc) override; |
| 477 virtual bool SetRemoteContent_w(const MediaContentDescription* content, | 517 bool SetRemoteContent_w(const MediaContentDescription* content, |
| 478 ContentAction action, | 518 ContentAction action, |
| 479 std::string* error_desc); | 519 std::string* error_desc) override; |
| 480 bool GetStats_w(VideoMediaInfo* stats); | 520 bool GetStats_w(VideoMediaInfo* stats); |
| 481 webrtc::RtpParameters GetRtpParameters_w(uint32_t ssrc) const; | 521 webrtc::RtpParameters GetRtpParameters_w(uint32_t ssrc) const; |
| 482 bool SetRtpParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); | 522 bool SetRtpParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); |
| 483 | 523 |
| 484 virtual void OnMessage(rtc::Message* pmsg); | 524 void OnMessage(rtc::Message* pmsg) override; |
| 485 virtual void GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const; | 525 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override; |
| 486 virtual void OnConnectionMonitorUpdate( | 526 void OnConnectionMonitorUpdate( |
| 487 ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos); | 527 ConnectionMonitor* monitor, |
| 488 virtual void OnMediaMonitorUpdate( | 528 const std::vector<ConnectionInfo>& infos) override; |
| 489 VideoMediaChannel* media_channel, const VideoMediaInfo& info); | 529 void OnMediaMonitorUpdate(VideoMediaChannel* media_channel, |
| 530 const VideoMediaInfo& info); |
| 490 | 531 |
| 491 std::unique_ptr<VideoMediaMonitor> media_monitor_; | 532 std::unique_ptr<VideoMediaMonitor> media_monitor_; |
| 492 | 533 |
| 493 // Last VideoSendParameters sent down to the media_channel() via | 534 // Last VideoSendParameters sent down to the media_channel() via |
| 494 // SetSendParameters. | 535 // SetSendParameters. |
| 495 VideoSendParameters last_send_params_; | 536 VideoSendParameters last_send_params_; |
| 496 // Last VideoRecvParameters sent down to the media_channel() via | 537 // Last VideoRecvParameters sent down to the media_channel() via |
| 497 // SetRecvParameters. | 538 // SetRecvParameters. |
| 498 VideoRecvParameters last_recv_params_; | 539 VideoRecvParameters last_recv_params_; |
| 499 }; | 540 }; |
| 500 | 541 |
| 501 // DataChannel is a specialization for data. | 542 // DataChannel is a specialization for data. |
| 502 class DataChannel : public BaseChannel { | 543 class DataChannel : public BaseChannel { |
| 503 public: | 544 public: |
| 504 DataChannel(rtc::Thread* thread, | 545 DataChannel(rtc::Thread* worker_thread, |
| 546 rtc::Thread* network_thread, |
| 505 DataMediaChannel* media_channel, | 547 DataMediaChannel* media_channel, |
| 506 TransportController* transport_controller, | 548 TransportController* transport_controller, |
| 507 const std::string& content_name, | 549 const std::string& content_name, |
| 508 bool rtcp); | 550 bool rtcp); |
| 509 ~DataChannel(); | 551 ~DataChannel(); |
| 510 bool Init(); | 552 bool Init_w(); |
| 511 | 553 |
| 512 virtual bool SendData(const SendDataParams& params, | 554 virtual bool SendData(const SendDataParams& params, |
| 513 const rtc::CopyOnWriteBuffer& payload, | 555 const rtc::CopyOnWriteBuffer& payload, |
| 514 SendDataResult* result); | 556 SendDataResult* result); |
| 515 | 557 |
| 516 void StartMediaMonitor(int cms); | 558 void StartMediaMonitor(int cms); |
| 517 void StopMediaMonitor(); | 559 void StopMediaMonitor(); |
| 518 | 560 |
| 519 // Should be called on the signaling thread only. | 561 // Should be called on the signaling thread only. |
| 520 bool ready_to_send_data() const { | 562 bool ready_to_send_data() const { |
| 521 return ready_to_send_data_; | 563 return ready_to_send_data_; |
| 522 } | 564 } |
| 523 | 565 |
| 524 sigslot::signal2<DataChannel*, const DataMediaInfo&> SignalMediaMonitor; | 566 sigslot::signal2<DataChannel*, const DataMediaInfo&> SignalMediaMonitor; |
| 525 sigslot::signal2<DataChannel*, const std::vector<ConnectionInfo>&> | 567 sigslot::signal2<DataChannel*, const std::vector<ConnectionInfo>&> |
| 526 SignalConnectionMonitor; | 568 SignalConnectionMonitor; |
| 527 sigslot::signal3<DataChannel*, const ReceiveDataParams&, | 569 sigslot::signal3<DataChannel*, const ReceiveDataParams&, |
| 528 const rtc::CopyOnWriteBuffer&> SignalDataReceived; | 570 const rtc::CopyOnWriteBuffer&> SignalDataReceived; |
| 529 // Signal for notifying when the channel becomes ready to send data. | 571 // Signal for notifying when the channel becomes ready to send data. |
| 530 // That occurs when the channel is enabled, the transport is writable, | 572 // That occurs when the channel is enabled, the transport is writable, |
| 531 // both local and remote descriptions are set, and the channel is unblocked. | 573 // both local and remote descriptions are set, and the channel is unblocked. |
| 532 sigslot::signal1<bool> SignalReadyToSendData; | 574 sigslot::signal1<bool> SignalReadyToSendData; |
| 533 // Signal for notifying that the remote side has closed the DataChannel. | 575 // Signal for notifying that the remote side has closed the DataChannel. |
| 534 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; | 576 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; |
| 535 | 577 |
| 536 protected: | 578 protected: |
| 537 // downcasts a MediaChannel. | 579 // downcasts a MediaChannel. |
| 538 virtual DataMediaChannel* media_channel() const { | 580 DataMediaChannel* media_channel() const override { |
| 539 return static_cast<DataMediaChannel*>(BaseChannel::media_channel()); | 581 return static_cast<DataMediaChannel*>(BaseChannel::media_channel()); |
| 540 } | 582 } |
| 541 | 583 |
| 542 private: | 584 private: |
| 543 struct SendDataMessageData : public rtc::MessageData { | 585 struct SendDataMessageData : public rtc::MessageData { |
| 544 SendDataMessageData(const SendDataParams& params, | 586 SendDataMessageData(const SendDataParams& params, |
| 545 const rtc::CopyOnWriteBuffer* payload, | 587 const rtc::CopyOnWriteBuffer* payload, |
| 546 SendDataResult* result) | 588 SendDataResult* result) |
| 547 : params(params), | 589 : params(params), |
| 548 payload(payload), | 590 payload(payload), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 565 : params(params), | 607 : params(params), |
| 566 payload(data, len) { | 608 payload(data, len) { |
| 567 } | 609 } |
| 568 const ReceiveDataParams params; | 610 const ReceiveDataParams params; |
| 569 const rtc::CopyOnWriteBuffer payload; | 611 const rtc::CopyOnWriteBuffer payload; |
| 570 }; | 612 }; |
| 571 | 613 |
| 572 typedef rtc::TypedMessageData<bool> DataChannelReadyToSendMessageData; | 614 typedef rtc::TypedMessageData<bool> DataChannelReadyToSendMessageData; |
| 573 | 615 |
| 574 // overrides from BaseChannel | 616 // overrides from BaseChannel |
| 575 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); | 617 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; |
| 576 // If data_channel_type_ is DCT_NONE, set it. Otherwise, check that | 618 // If data_channel_type_ is DCT_NONE, set it. Otherwise, check that |
| 577 // it's the same as what was set previously. Returns false if it's | 619 // it's the same as what was set previously. Returns false if it's |
| 578 // set to one type one type and changed to another type later. | 620 // set to one type one type and changed to another type later. |
| 579 bool SetDataChannelType(DataChannelType new_data_channel_type, | 621 bool SetDataChannelType(DataChannelType new_data_channel_type, |
| 580 std::string* error_desc); | 622 std::string* error_desc); |
| 581 // Same as SetDataChannelType, but extracts the type from the | 623 // Same as SetDataChannelType, but extracts the type from the |
| 582 // DataContentDescription. | 624 // DataContentDescription. |
| 583 bool SetDataChannelTypeFromContent(const DataContentDescription* content, | 625 bool SetDataChannelTypeFromContent(const DataContentDescription* content, |
| 584 std::string* error_desc); | 626 std::string* error_desc); |
| 585 virtual bool SetLocalContent_w(const MediaContentDescription* content, | 627 bool SetLocalContent_w(const MediaContentDescription* content, |
| 586 ContentAction action, | 628 ContentAction action, |
| 587 std::string* error_desc); | 629 std::string* error_desc) override; |
| 588 virtual bool SetRemoteContent_w(const MediaContentDescription* content, | 630 bool SetRemoteContent_w(const MediaContentDescription* content, |
| 589 ContentAction action, | 631 ContentAction action, |
| 590 std::string* error_desc); | 632 std::string* error_desc) override; |
| 591 virtual void ChangeState(); | 633 void ChangeState_w() override; |
| 592 virtual bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); | 634 bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) override; |
| 593 | 635 |
| 594 virtual void OnMessage(rtc::Message* pmsg); | 636 void OnMessage(rtc::Message* pmsg) override; |
| 595 virtual void GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const; | 637 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override; |
| 596 virtual void OnConnectionMonitorUpdate( | 638 void OnConnectionMonitorUpdate( |
| 597 ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos); | 639 ConnectionMonitor* monitor, |
| 598 virtual void OnMediaMonitorUpdate( | 640 const std::vector<ConnectionInfo>& infos) override; |
| 599 DataMediaChannel* media_channel, const DataMediaInfo& info); | 641 void OnMediaMonitorUpdate(DataMediaChannel* media_channel, |
| 600 virtual bool ShouldSetupDtlsSrtp() const; | 642 const DataMediaInfo& info); |
| 643 bool ShouldSetupDtlsSrtp_n() const override; |
| 601 void OnDataReceived( | 644 void OnDataReceived( |
| 602 const ReceiveDataParams& params, const char* data, size_t len); | 645 const ReceiveDataParams& params, const char* data, size_t len); |
| 603 void OnDataChannelError(uint32_t ssrc, DataMediaChannel::Error error); | 646 void OnDataChannelError(uint32_t ssrc, DataMediaChannel::Error error); |
| 604 void OnDataChannelReadyToSend(bool writable); | 647 void OnDataChannelReadyToSend(bool writable); |
| 605 void OnStreamClosedRemotely(uint32_t sid); | 648 void OnStreamClosedRemotely(uint32_t sid); |
| 606 | 649 |
| 607 std::unique_ptr<DataMediaMonitor> media_monitor_; | 650 std::unique_ptr<DataMediaMonitor> media_monitor_; |
| 608 // TODO(pthatcher): Make a separate SctpDataChannel and | 651 // TODO(pthatcher): Make a separate SctpDataChannel and |
| 609 // RtpDataChannel instead of using this. | 652 // RtpDataChannel instead of using this. |
| 610 DataChannelType data_channel_type_; | 653 DataChannelType data_channel_type_; |
| 611 bool ready_to_send_data_; | 654 bool ready_to_send_data_; |
| 612 | 655 |
| 613 // Last DataSendParameters sent down to the media_channel() via | 656 // Last DataSendParameters sent down to the media_channel() via |
| 614 // SetSendParameters. | 657 // SetSendParameters. |
| 615 DataSendParameters last_send_params_; | 658 DataSendParameters last_send_params_; |
| 616 // Last DataRecvParameters sent down to the media_channel() via | 659 // Last DataRecvParameters sent down to the media_channel() via |
| 617 // SetRecvParameters. | 660 // SetRecvParameters. |
| 618 DataRecvParameters last_recv_params_; | 661 DataRecvParameters last_recv_params_; |
| 619 }; | 662 }; |
| 620 | 663 |
| 621 } // namespace cricket | 664 } // namespace cricket |
| 622 | 665 |
| 623 #endif // WEBRTC_PC_CHANNEL_H_ | 666 #endif // WEBRTC_PC_CHANNEL_H_ |
| OLD | NEW |