1 /* 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef PC_CHANNEL_H_ 12 #define PC_CHANNEL_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include <map> 18 #include <memory> 19 #include <set> 20 #include <string> 21 #include <utility> 22 #include <vector> 23 24 #include "absl/types/optional.h" 25 #include "api/call/audio_sink.h" 26 #include "api/crypto/crypto_options.h" 27 #include "api/function_view.h" 28 #include "api/jsep.h" 29 #include "api/media_types.h" 30 #include "api/rtp_receiver_interface.h" 31 #include "api/rtp_transceiver_direction.h" 32 #include "api/scoped_refptr.h" 33 #include "api/sequence_checker.h" 34 #include "api/video/video_sink_interface.h" 35 #include "api/video/video_source_interface.h" 36 #include "call/rtp_demuxer.h" 37 #include "call/rtp_packet_sink_interface.h" 38 #include "media/base/media_channel.h" 39 #include "media/base/media_engine.h" 40 #include "media/base/stream_params.h" 41 #include "modules/rtp_rtcp/source/rtp_packet_received.h" 42 #include "p2p/base/dtls_transport_internal.h" 43 #include "p2p/base/packet_transport_internal.h" 44 #include "pc/channel_interface.h" 45 #include "pc/dtls_srtp_transport.h" 46 #include "pc/media_session.h" 47 #include "pc/rtp_transport.h" 48 #include "pc/rtp_transport_internal.h" 49 #include "pc/session_description.h" 50 #include "pc/srtp_filter.h" 51 #include "pc/srtp_transport.h" 52 #include "rtc_base/async_packet_socket.h" 53 #include "rtc_base/async_udp_socket.h" 54 #include "rtc_base/checks.h" 55 #include "rtc_base/copy_on_write_buffer.h" 56 #include "rtc_base/location.h" 57 #include "rtc_base/message_handler.h" 58 #include "rtc_base/network.h" 59 #include "rtc_base/network/sent_packet.h" 60 #include "rtc_base/network_route.h" 61 #include "rtc_base/socket.h" 62 #include "rtc_base/synchronization/mutex.h" 63 #include "rtc_base/task_utils/pending_task_safety_flag.h" 64 #include "rtc_base/third_party/sigslot/sigslot.h" 65 #include "rtc_base/thread.h" 66 #include "rtc_base/thread_annotations.h" 67 #include "rtc_base/thread_message.h" 68 #include "rtc_base/unique_id_generator.h" 69 70 namespace webrtc { 71 class AudioSinkInterface; 72 } // namespace webrtc 73 74 namespace cricket { 75 76 struct CryptoParams; 77 78 // BaseChannel contains logic common to voice and video, including enable, 79 // marshaling calls to a worker and network threads, and connection and media 80 // monitors. 81 // 82 // BaseChannel assumes signaling and other threads are allowed to make 83 // synchronous calls to the worker thread, the worker thread makes synchronous 84 // calls only to the network thread, and the network thread can't be blocked by 85 // other threads. 86 // All methods with _n suffix must be called on network thread, 87 // methods with _w suffix on worker thread 88 // and methods with _s suffix on signaling thread. 89 // Network and worker threads may be the same thread. 90 // 91 // WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS! 92 // This is required to avoid a data race between the destructor modifying the 93 // vtable, and the media channel's thread using BaseChannel as the 94 // NetworkInterface. 95 96 class BaseChannel : public ChannelInterface, 97 public rtc::MessageHandlerAutoCleanup, 98 public sigslot::has_slots<>, 99 public MediaChannel::NetworkInterface, 100 public webrtc::RtpPacketSinkInterface { 101 public: 102 // If |srtp_required| is true, the channel will not send or receive any 103 // RTP/RTCP packets without using SRTP (either using SDES or DTLS-SRTP). 104 // The BaseChannel does not own the UniqueRandomIdGenerator so it is the 105 // responsibility of the user to ensure it outlives this object. 106 // TODO(zhihuang:) Create a BaseChannel::Config struct for the parameter lists 107 // which will make it easier to change the constructor. 108 BaseChannel(rtc::Thread* worker_thread, 109 rtc::Thread* network_thread, 110 rtc::Thread* signaling_thread, 111 std::unique_ptr<MediaChannel> media_channel, 112 const std::string& content_name, 113 bool srtp_required, 114 webrtc::CryptoOptions crypto_options, 115 rtc::UniqueRandomIdGenerator* ssrc_generator); 116 virtual ~BaseChannel(); 117 virtual void Init_w(webrtc::RtpTransportInternal* rtp_transport); 118 119 // Deinit may be called multiple times and is simply ignored if it's already 120 // done. 121 void Deinit(); 122 worker_thread()123 rtc::Thread* worker_thread() const { return worker_thread_; } network_thread()124 rtc::Thread* network_thread() const { return network_thread_; } content_name()125 const std::string& content_name() const override { return content_name_; } 126 // TODO(deadbeef): This is redundant; remove this. transport_name()127 const std::string& transport_name() const override { return transport_name_; } enabled()128 bool enabled() const override { return enabled_; } 129 130 // This function returns true if using SRTP (DTLS-based keying or SDES). srtp_active()131 bool srtp_active() const { 132 RTC_DCHECK_RUN_ON(network_thread()); 133 return rtp_transport_ && rtp_transport_->IsSrtpActive(); 134 } 135 136 // Set an RTP level transport which could be an RtpTransport without 137 // encryption, an SrtpTransport for SDES or a DtlsSrtpTransport for DTLS-SRTP. 138 // This can be called from any thread and it hops to the network thread 139 // internally. It would replace the |SetTransports| and its variants. 140 bool SetRtpTransport(webrtc::RtpTransportInternal* rtp_transport) override; 141 rtp_transport()142 webrtc::RtpTransportInternal* rtp_transport() const { 143 RTC_DCHECK_RUN_ON(network_thread()); 144 return rtp_transport_; 145 } 146 147 // Channel control 148 bool SetLocalContent(const MediaContentDescription* content, 149 webrtc::SdpType type, 150 std::string* error_desc) override; 151 bool SetRemoteContent(const MediaContentDescription* content, 152 webrtc::SdpType type, 153 std::string* error_desc) override; 154 // Controls whether this channel will receive packets on the basis of 155 // matching payload type alone. This is needed for legacy endpoints that 156 // don't signal SSRCs or use MID/RID, but doesn't make sense if there is 157 // more than channel of specific media type, As that creates an ambiguity. 158 // 159 // This method will also remove any existing streams that were bound to this 160 // channel on the basis of payload type, since one of these streams might 161 // actually belong to a new channel. See: crbug.com/webrtc/11477 162 bool SetPayloadTypeDemuxingEnabled(bool enabled) override; 163 164 bool Enable(bool enable) override; 165 local_streams()166 const std::vector<StreamParams>& local_streams() const override { 167 return local_streams_; 168 } remote_streams()169 const std::vector<StreamParams>& remote_streams() const override { 170 return remote_streams_; 171 } 172 173 // Used for latency measurements. 174 sigslot::signal1<ChannelInterface*>& SignalFirstPacketReceived() override; 175 176 // Forward SignalSentPacket to worker thread. 177 sigslot::signal1<const rtc::SentPacket&>& SignalSentPacket(); 178 179 // From RtpTransport - public for testing only 180 void OnTransportReadyToSend(bool ready); 181 182 // Only public for unit tests. Otherwise, consider protected. 183 int SetOption(SocketType type, rtc::Socket::Option o, int val) override; 184 int SetOption_n(SocketType type, rtc::Socket::Option o, int val) 185 RTC_RUN_ON(network_thread()); 186 187 // RtpPacketSinkInterface overrides. 188 void OnRtpPacket(const webrtc::RtpPacketReceived& packet) override; 189 media_channel()190 MediaChannel* media_channel() const override { 191 return media_channel_.get(); 192 } 193 194 protected: was_ever_writable()195 bool was_ever_writable() const { 196 RTC_DCHECK_RUN_ON(worker_thread()); 197 return was_ever_writable_; 198 } set_local_content_direction(webrtc::RtpTransceiverDirection direction)199 void set_local_content_direction(webrtc::RtpTransceiverDirection direction) { 200 RTC_DCHECK_RUN_ON(worker_thread()); 201 local_content_direction_ = direction; 202 } set_remote_content_direction(webrtc::RtpTransceiverDirection direction)203 void set_remote_content_direction(webrtc::RtpTransceiverDirection direction) { 204 RTC_DCHECK_RUN_ON(worker_thread()); 205 remote_content_direction_ = direction; 206 } 207 // These methods verify that: 208 // * The required content description directions have been set. 209 // * The channel is enabled. 210 // * And for sending: 211 // - The SRTP filter is active if it's needed. 212 // - The transport has been writable before, meaning it should be at least 213 // possible to succeed in sending a packet. 214 // 215 // When any of these properties change, UpdateMediaSendRecvState_w should be 216 // called. 217 bool IsReadyToReceiveMedia_w() const RTC_RUN_ON(worker_thread()); 218 bool IsReadyToSendMedia_w() const RTC_RUN_ON(worker_thread()); signaling_thread()219 rtc::Thread* signaling_thread() const { return signaling_thread_; } 220 221 void FlushRtcpMessages_n() RTC_RUN_ON(network_thread()); 222 223 // NetworkInterface implementation, called by MediaEngine 224 bool SendPacket(rtc::CopyOnWriteBuffer* packet, 225 const rtc::PacketOptions& options) override; 226 bool SendRtcp(rtc::CopyOnWriteBuffer* packet, 227 const rtc::PacketOptions& options) override; 228 229 // From RtpTransportInternal 230 void OnWritableState(bool writable); 231 232 void OnNetworkRouteChanged(absl::optional<rtc::NetworkRoute> network_route); 233 234 bool SendPacket(bool rtcp, 235 rtc::CopyOnWriteBuffer* packet, 236 const rtc::PacketOptions& options); 237 238 void EnableMedia_w() RTC_RUN_ON(worker_thread()); 239 void DisableMedia_w() RTC_RUN_ON(worker_thread()); 240 241 // Performs actions if the RTP/RTCP writable state changed. This should 242 // be called whenever a channel's writable state changes or when RTCP muxing 243 // becomes active/inactive. 244 void UpdateWritableState_n() RTC_RUN_ON(network_thread()); 245 void ChannelWritable_n() RTC_RUN_ON(network_thread()); 246 void ChannelNotWritable_n() RTC_RUN_ON(network_thread()); 247 248 bool AddRecvStream_w(const StreamParams& sp) RTC_RUN_ON(worker_thread()); 249 bool RemoveRecvStream_w(uint32_t ssrc) RTC_RUN_ON(worker_thread()); 250 void ResetUnsignaledRecvStream_w() RTC_RUN_ON(worker_thread()); 251 bool SetPayloadTypeDemuxingEnabled_w(bool enabled) 252 RTC_RUN_ON(worker_thread()); 253 bool AddSendStream_w(const StreamParams& sp) RTC_RUN_ON(worker_thread()); 254 bool RemoveSendStream_w(uint32_t ssrc) RTC_RUN_ON(worker_thread()); 255 256 // Should be called whenever the conditions for 257 // IsReadyToReceiveMedia/IsReadyToSendMedia are satisfied (or unsatisfied). 258 // Updates the send/recv state of the media channel. 259 virtual void UpdateMediaSendRecvState_w() RTC_RUN_ON(worker_thread()) = 0; 260 261 bool UpdateLocalStreams_w(const std::vector<StreamParams>& streams, 262 webrtc::SdpType type, 263 std::string* error_desc) 264 RTC_RUN_ON(worker_thread()); 265 bool UpdateRemoteStreams_w(const std::vector<StreamParams>& streams, 266 webrtc::SdpType type, 267 std::string* error_desc) 268 RTC_RUN_ON(worker_thread()); 269 virtual bool SetLocalContent_w(const MediaContentDescription* content, 270 webrtc::SdpType type, 271 std::string* error_desc) 272 RTC_RUN_ON(worker_thread()) = 0; 273 virtual bool SetRemoteContent_w(const MediaContentDescription* content, 274 webrtc::SdpType type, 275 std::string* error_desc) 276 RTC_RUN_ON(worker_thread()) = 0; 277 // Return a list of RTP header extensions with the non-encrypted extensions 278 // removed depending on the current crypto_options_ and only if both the 279 // non-encrypted and encrypted extension is present for the same URI. 280 RtpHeaderExtensions GetFilteredRtpHeaderExtensions( 281 const RtpHeaderExtensions& extensions); 282 283 // From MessageHandler 284 void OnMessage(rtc::Message* pmsg) override; 285 286 // Helper function template for invoking methods on the worker thread. 287 template <class T> InvokeOnWorker(const rtc::Location & posted_from,rtc::FunctionView<T ()> functor)288 T InvokeOnWorker(const rtc::Location& posted_from, 289 rtc::FunctionView<T()> functor) { 290 return worker_thread_->Invoke<T>(posted_from, functor); 291 } 292 293 // Add |payload_type| to |demuxer_criteria_| if payload type demuxing is 294 // enabled. 295 void MaybeAddHandledPayloadType(int payload_type) RTC_RUN_ON(worker_thread()); 296 297 void ClearHandledPayloadTypes() RTC_RUN_ON(worker_thread()); 298 299 void UpdateRtpHeaderExtensionMap( 300 const RtpHeaderExtensions& header_extensions); 301 302 bool RegisterRtpDemuxerSink_w() RTC_RUN_ON(worker_thread()); 303 304 // Return description of media channel to facilitate logging 305 std::string ToString() const; 306 307 void SetNegotiatedHeaderExtensions_w(const RtpHeaderExtensions& extensions) 308 RTC_RUN_ON(worker_thread()); 309 310 // ChannelInterface overrides 311 RtpHeaderExtensions GetNegotiatedRtpHeaderExtensions() const override; 312 313 private: 314 bool ConnectToRtpTransport() RTC_RUN_ON(network_thread()); 315 void DisconnectFromRtpTransport() RTC_RUN_ON(network_thread()); 316 void SignalSentPacket_n(const rtc::SentPacket& sent_packet) 317 RTC_RUN_ON(network_thread()); 318 319 rtc::Thread* const worker_thread_; 320 rtc::Thread* const network_thread_; 321 rtc::Thread* const signaling_thread_; 322 rtc::scoped_refptr<webrtc::PendingTaskSafetyFlag> alive_; 323 sigslot::signal1<ChannelInterface*> SignalFirstPacketReceived_ 324 RTC_GUARDED_BY(signaling_thread_); 325 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket_ 326 RTC_GUARDED_BY(worker_thread_); 327 328 const std::string content_name_; 329 330 bool has_received_packet_ = false; 331 332 // Won't be set when using raw packet transports. SDP-specific thing. 333 // TODO(bugs.webrtc.org/12230): Written on network thread, read on 334 // worker thread (at least). 335 std::string transport_name_; 336 337 webrtc::RtpTransportInternal* rtp_transport_ 338 RTC_GUARDED_BY(network_thread()) = nullptr; 339 340 std::vector<std::pair<rtc::Socket::Option, int> > socket_options_ 341 RTC_GUARDED_BY(network_thread()); 342 std::vector<std::pair<rtc::Socket::Option, int> > rtcp_socket_options_ 343 RTC_GUARDED_BY(network_thread()); 344 bool writable_ RTC_GUARDED_BY(network_thread()) = false; 345 bool was_ever_writable_n_ RTC_GUARDED_BY(network_thread()) = false; 346 bool was_ever_writable_ RTC_GUARDED_BY(worker_thread()) = false; 347 const bool srtp_required_ = true; 348 const webrtc::CryptoOptions crypto_options_; 349 350 // MediaChannel related members that should be accessed from the worker 351 // thread. 352 const std::unique_ptr<MediaChannel> media_channel_; 353 // Currently the |enabled_| flag is accessed from the signaling thread as 354 // well, but it can be changed only when signaling thread does a synchronous 355 // call to the worker thread, so it should be safe. 356 bool enabled_ = false; 357 bool payload_type_demuxing_enabled_ RTC_GUARDED_BY(worker_thread()) = true; 358 std::vector<StreamParams> local_streams_ RTC_GUARDED_BY(worker_thread()); 359 std::vector<StreamParams> remote_streams_ RTC_GUARDED_BY(worker_thread()); 360 // TODO(bugs.webrtc.org/12230): local_content_direction and 361 // remote_content_direction are set on the worker thread, but accessed on the 362 // network thread. 363 webrtc::RtpTransceiverDirection local_content_direction_ = 364 webrtc::RtpTransceiverDirection::kInactive; 365 webrtc::RtpTransceiverDirection remote_content_direction_ = 366 webrtc::RtpTransceiverDirection::kInactive; 367 368 // Cached list of payload types, used if payload type demuxing is re-enabled. 369 std::set<uint8_t> payload_types_ RTC_GUARDED_BY(worker_thread()); 370 // TODO(bugs.webrtc.org/12239): Modified on worker thread, accessed 371 // on network thread in RegisterRtpDemuxerSink_n (called from Init_w) 372 webrtc::RtpDemuxerCriteria demuxer_criteria_; 373 // Accessed on the worker thread, modified on the network thread from 374 // RegisterRtpDemuxerSink_w's Invoke. 375 webrtc::RtpDemuxerCriteria previous_demuxer_criteria_; 376 // This generator is used to generate SSRCs for local streams. 377 // This is needed in cases where SSRCs are not negotiated or set explicitly 378 // like in Simulcast. 379 // This object is not owned by the channel so it must outlive it. 380 rtc::UniqueRandomIdGenerator* const ssrc_generator_; 381 382 // |negotiated_header_extensions_| is read on the signaling thread, but 383 // written on the worker thread while being sync-invoked from the signal 384 // thread in SdpOfferAnswerHandler::PushdownMediaDescription(). Hence the lock 385 // isn't strictly needed, but it's anyway placed here for future safeness. 386 mutable webrtc::Mutex negotiated_header_extensions_lock_; 387 RtpHeaderExtensions negotiated_header_extensions_ 388 RTC_GUARDED_BY(negotiated_header_extensions_lock_); 389 }; 390 391 // VoiceChannel is a specialization that adds support for early media, DTMF, 392 // and input/output level monitoring. 393 class VoiceChannel : public BaseChannel { 394 public: 395 VoiceChannel(rtc::Thread* worker_thread, 396 rtc::Thread* network_thread, 397 rtc::Thread* signaling_thread, 398 std::unique_ptr<VoiceMediaChannel> channel, 399 const std::string& content_name, 400 bool srtp_required, 401 webrtc::CryptoOptions crypto_options, 402 rtc::UniqueRandomIdGenerator* ssrc_generator); 403 ~VoiceChannel(); 404 405 // downcasts a MediaChannel media_channel()406 VoiceMediaChannel* media_channel() const override { 407 return static_cast<VoiceMediaChannel*>(BaseChannel::media_channel()); 408 } 409 media_type()410 cricket::MediaType media_type() const override { 411 return cricket::MEDIA_TYPE_AUDIO; 412 } 413 414 private: 415 // overrides from BaseChannel 416 void UpdateMediaSendRecvState_w() override; 417 bool SetLocalContent_w(const MediaContentDescription* content, 418 webrtc::SdpType type, 419 std::string* error_desc) override; 420 bool SetRemoteContent_w(const MediaContentDescription* content, 421 webrtc::SdpType type, 422 std::string* error_desc) override; 423 424 // Last AudioSendParameters sent down to the media_channel() via 425 // SetSendParameters. 426 AudioSendParameters last_send_params_; 427 // Last AudioRecvParameters sent down to the media_channel() via 428 // SetRecvParameters. 429 AudioRecvParameters last_recv_params_; 430 }; 431 432 // VideoChannel is a specialization for video. 433 class VideoChannel : public BaseChannel { 434 public: 435 VideoChannel(rtc::Thread* worker_thread, 436 rtc::Thread* network_thread, 437 rtc::Thread* signaling_thread, 438 std::unique_ptr<VideoMediaChannel> media_channel, 439 const std::string& content_name, 440 bool srtp_required, 441 webrtc::CryptoOptions crypto_options, 442 rtc::UniqueRandomIdGenerator* ssrc_generator); 443 ~VideoChannel(); 444 445 // downcasts a MediaChannel media_channel()446 VideoMediaChannel* media_channel() const override { 447 return static_cast<VideoMediaChannel*>(BaseChannel::media_channel()); 448 } 449 450 void FillBitrateInfo(BandwidthEstimationInfo* bwe_info); 451 media_type()452 cricket::MediaType media_type() const override { 453 return cricket::MEDIA_TYPE_VIDEO; 454 } 455 456 private: 457 // overrides from BaseChannel 458 void UpdateMediaSendRecvState_w() override; 459 bool SetLocalContent_w(const MediaContentDescription* content, 460 webrtc::SdpType type, 461 std::string* error_desc) override; 462 bool SetRemoteContent_w(const MediaContentDescription* content, 463 webrtc::SdpType type, 464 std::string* error_desc) override; 465 466 // Last VideoSendParameters sent down to the media_channel() via 467 // SetSendParameters. 468 VideoSendParameters last_send_params_; 469 // Last VideoRecvParameters sent down to the media_channel() via 470 // SetRecvParameters. 471 VideoRecvParameters last_recv_params_; 472 }; 473 474 // RtpDataChannel is a specialization for data. 475 class RtpDataChannel : public BaseChannel { 476 public: 477 RtpDataChannel(rtc::Thread* worker_thread, 478 rtc::Thread* network_thread, 479 rtc::Thread* signaling_thread, 480 std::unique_ptr<DataMediaChannel> channel, 481 const std::string& content_name, 482 bool srtp_required, 483 webrtc::CryptoOptions crypto_options, 484 rtc::UniqueRandomIdGenerator* ssrc_generator); 485 ~RtpDataChannel(); 486 // TODO(zhihuang): Remove this once the RtpTransport can be shared between 487 // BaseChannels. 488 void Init_w(DtlsTransportInternal* rtp_dtls_transport, 489 DtlsTransportInternal* rtcp_dtls_transport, 490 rtc::PacketTransportInternal* rtp_packet_transport, 491 rtc::PacketTransportInternal* rtcp_packet_transport); 492 void Init_w(webrtc::RtpTransportInternal* rtp_transport) override; 493 494 virtual bool SendData(const SendDataParams& params, 495 const rtc::CopyOnWriteBuffer& payload, 496 SendDataResult* result); 497 498 // Should be called on the signaling thread only. ready_to_send_data()499 bool ready_to_send_data() const { return ready_to_send_data_; } 500 501 sigslot::signal2<const ReceiveDataParams&, const rtc::CopyOnWriteBuffer&> 502 SignalDataReceived; 503 // Signal for notifying when the channel becomes ready to send data. 504 // That occurs when the channel is enabled, the transport is writable, 505 // both local and remote descriptions are set, and the channel is unblocked. 506 sigslot::signal1<bool> SignalReadyToSendData; media_type()507 cricket::MediaType media_type() const override { 508 return cricket::MEDIA_TYPE_DATA; 509 } 510 511 protected: 512 // downcasts a MediaChannel. media_channel()513 DataMediaChannel* media_channel() const override { 514 return static_cast<DataMediaChannel*>(BaseChannel::media_channel()); 515 } 516 517 private: 518 struct SendDataMessageData : public rtc::MessageData { SendDataMessageDataSendDataMessageData519 SendDataMessageData(const SendDataParams& params, 520 const rtc::CopyOnWriteBuffer* payload, 521 SendDataResult* result) 522 : params(params), payload(payload), result(result), succeeded(false) {} 523 524 const SendDataParams& params; 525 const rtc::CopyOnWriteBuffer* payload; 526 SendDataResult* result; 527 bool succeeded; 528 }; 529 530 struct DataReceivedMessageData : public rtc::MessageData { 531 // We copy the data because the data will become invalid after we 532 // handle DataMediaChannel::SignalDataReceived but before we fire 533 // SignalDataReceived. DataReceivedMessageDataDataReceivedMessageData534 DataReceivedMessageData(const ReceiveDataParams& params, 535 const char* data, 536 size_t len) 537 : params(params), payload(data, len) {} 538 const ReceiveDataParams params; 539 const rtc::CopyOnWriteBuffer payload; 540 }; 541 542 typedef rtc::TypedMessageData<bool> DataChannelReadyToSendMessageData; 543 544 // overrides from BaseChannel 545 // Checks that data channel type is RTP. 546 bool CheckDataChannelTypeFromContent(const MediaContentDescription* content, 547 std::string* error_desc); 548 bool SetLocalContent_w(const MediaContentDescription* content, 549 webrtc::SdpType type, 550 std::string* error_desc) override; 551 bool SetRemoteContent_w(const MediaContentDescription* content, 552 webrtc::SdpType type, 553 std::string* error_desc) override; 554 void UpdateMediaSendRecvState_w() override; 555 556 void OnMessage(rtc::Message* pmsg) override; 557 void OnDataReceived(const ReceiveDataParams& params, 558 const char* data, 559 size_t len); 560 void OnDataChannelReadyToSend(bool writable); 561 562 bool ready_to_send_data_ = false; 563 564 // Last DataSendParameters sent down to the media_channel() via 565 // SetSendParameters. 566 DataSendParameters last_send_params_; 567 // Last DataRecvParameters sent down to the media_channel() via 568 // SetRecvParameters. 569 DataRecvParameters last_recv_params_; 570 }; 571 572 } // namespace cricket 573 574 #endif // PC_CHANNEL_H_ 575