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 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 return transport_controller_->signaling_thread(); | 184 return transport_controller_->signaling_thread(); |
185 } | 185 } |
186 bool rtcp_transport_enabled() const { return rtcp_transport_enabled_; } | 186 bool rtcp_transport_enabled() const { return rtcp_transport_enabled_; } |
187 | 187 |
188 void ConnectToTransportChannel(TransportChannel* tc); | 188 void ConnectToTransportChannel(TransportChannel* tc); |
189 void DisconnectFromTransportChannel(TransportChannel* tc); | 189 void DisconnectFromTransportChannel(TransportChannel* tc); |
190 | 190 |
191 void FlushRtcpMessages(); | 191 void FlushRtcpMessages(); |
192 | 192 |
193 // NetworkInterface implementation, called by MediaEngine | 193 // NetworkInterface implementation, called by MediaEngine |
194 bool SendPacket(rtc::Buffer* packet, | 194 bool SendPacket(rtc::CopyOnWriteBuffer* packet, |
195 const rtc::PacketOptions& options) override; | 195 const rtc::PacketOptions& options) override; |
196 bool SendRtcp(rtc::Buffer* packet, const rtc::PacketOptions& options) | 196 bool SendRtcp(rtc::CopyOnWriteBuffer* packet, |
197 override; | 197 const rtc::PacketOptions& options) override; |
198 | 198 |
199 // From TransportChannel | 199 // From TransportChannel |
200 void OnWritableState(TransportChannel* channel); | 200 void OnWritableState(TransportChannel* channel); |
201 virtual void OnChannelRead(TransportChannel* channel, | 201 virtual void OnChannelRead(TransportChannel* channel, |
202 const char* data, | 202 const char* data, |
203 size_t len, | 203 size_t len, |
204 const rtc::PacketTime& packet_time, | 204 const rtc::PacketTime& packet_time, |
205 int flags); | 205 int flags); |
206 void OnReadyToSend(TransportChannel* channel); | 206 void OnReadyToSend(TransportChannel* channel); |
207 | 207 |
208 void OnDtlsState(TransportChannel* channel, DtlsTransportState state); | 208 void OnDtlsState(TransportChannel* channel, DtlsTransportState state); |
209 | 209 |
210 bool PacketIsRtcp(const TransportChannel* channel, const char* data, | 210 bool PacketIsRtcp(const TransportChannel* channel, const char* data, |
211 size_t len); | 211 size_t len); |
212 bool SendPacket(bool rtcp, | 212 bool SendPacket(bool rtcp, |
213 rtc::Buffer* packet, | 213 rtc::CopyOnWriteBuffer* packet, |
214 const rtc::PacketOptions& options); | 214 const rtc::PacketOptions& options); |
215 virtual bool WantsPacket(bool rtcp, rtc::Buffer* packet); | 215 virtual bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); |
216 void HandlePacket(bool rtcp, rtc::Buffer* packet, | 216 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, |
217 const rtc::PacketTime& packet_time); | 217 const rtc::PacketTime& packet_time); |
218 | 218 |
219 void EnableMedia_w(); | 219 void EnableMedia_w(); |
220 void DisableMedia_w(); | 220 void DisableMedia_w(); |
221 void UpdateWritableState_w(); | 221 void UpdateWritableState_w(); |
222 void ChannelWritable_w(); | 222 void ChannelWritable_w(); |
223 void ChannelNotWritable_w(); | 223 void ChannelNotWritable_w(); |
224 bool AddRecvStream_w(const StreamParams& sp); | 224 bool AddRecvStream_w(const StreamParams& sp); |
225 bool RemoveRecvStream_w(uint32_t ssrc); | 225 bool RemoveRecvStream_w(uint32_t ssrc); |
226 bool AddSendStream_w(const StreamParams& sp); | 226 bool AddSendStream_w(const StreamParams& sp); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 public: | 495 public: |
496 DataChannel(rtc::Thread* thread, | 496 DataChannel(rtc::Thread* thread, |
497 DataMediaChannel* media_channel, | 497 DataMediaChannel* media_channel, |
498 TransportController* transport_controller, | 498 TransportController* transport_controller, |
499 const std::string& content_name, | 499 const std::string& content_name, |
500 bool rtcp); | 500 bool rtcp); |
501 ~DataChannel(); | 501 ~DataChannel(); |
502 bool Init(); | 502 bool Init(); |
503 | 503 |
504 virtual bool SendData(const SendDataParams& params, | 504 virtual bool SendData(const SendDataParams& params, |
505 const rtc::Buffer& payload, | 505 const rtc::CopyOnWriteBuffer& payload, |
506 SendDataResult* result); | 506 SendDataResult* result); |
507 | 507 |
508 void StartMediaMonitor(int cms); | 508 void StartMediaMonitor(int cms); |
509 void StopMediaMonitor(); | 509 void StopMediaMonitor(); |
510 | 510 |
511 // Should be called on the signaling thread only. | 511 // Should be called on the signaling thread only. |
512 bool ready_to_send_data() const { | 512 bool ready_to_send_data() const { |
513 return ready_to_send_data_; | 513 return ready_to_send_data_; |
514 } | 514 } |
515 | 515 |
516 sigslot::signal2<DataChannel*, const DataMediaInfo&> SignalMediaMonitor; | 516 sigslot::signal2<DataChannel*, const DataMediaInfo&> SignalMediaMonitor; |
517 sigslot::signal2<DataChannel*, const std::vector<ConnectionInfo>&> | 517 sigslot::signal2<DataChannel*, const std::vector<ConnectionInfo>&> |
518 SignalConnectionMonitor; | 518 SignalConnectionMonitor; |
519 sigslot::signal3<DataChannel*, const ReceiveDataParams&, const rtc::Buffer&> | 519 sigslot::signal3<DataChannel*, const ReceiveDataParams&, |
520 SignalDataReceived; | 520 const rtc::CopyOnWriteBuffer&> SignalDataReceived; |
521 // Signal for notifying when the channel becomes ready to send data. | 521 // Signal for notifying when the channel becomes ready to send data. |
522 // That occurs when the channel is enabled, the transport is writable, | 522 // That occurs when the channel is enabled, the transport is writable, |
523 // both local and remote descriptions are set, and the channel is unblocked. | 523 // both local and remote descriptions are set, and the channel is unblocked. |
524 sigslot::signal1<bool> SignalReadyToSendData; | 524 sigslot::signal1<bool> SignalReadyToSendData; |
525 // Signal for notifying that the remote side has closed the DataChannel. | 525 // Signal for notifying that the remote side has closed the DataChannel. |
526 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; | 526 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; |
527 | 527 |
528 protected: | 528 protected: |
529 // downcasts a MediaChannel. | 529 // downcasts a MediaChannel. |
530 virtual DataMediaChannel* media_channel() const { | 530 virtual DataMediaChannel* media_channel() const { |
531 return static_cast<DataMediaChannel*>(BaseChannel::media_channel()); | 531 return static_cast<DataMediaChannel*>(BaseChannel::media_channel()); |
532 } | 532 } |
533 | 533 |
534 private: | 534 private: |
535 struct SendDataMessageData : public rtc::MessageData { | 535 struct SendDataMessageData : public rtc::MessageData { |
536 SendDataMessageData(const SendDataParams& params, | 536 SendDataMessageData(const SendDataParams& params, |
537 const rtc::Buffer* payload, | 537 const rtc::CopyOnWriteBuffer* payload, |
538 SendDataResult* result) | 538 SendDataResult* result) |
539 : params(params), | 539 : params(params), |
540 payload(payload), | 540 payload(payload), |
541 result(result), | 541 result(result), |
542 succeeded(false) { | 542 succeeded(false) { |
543 } | 543 } |
544 | 544 |
545 const SendDataParams& params; | 545 const SendDataParams& params; |
546 const rtc::Buffer* payload; | 546 const rtc::CopyOnWriteBuffer* payload; |
547 SendDataResult* result; | 547 SendDataResult* result; |
548 bool succeeded; | 548 bool succeeded; |
549 }; | 549 }; |
550 | 550 |
551 struct DataReceivedMessageData : public rtc::MessageData { | 551 struct DataReceivedMessageData : public rtc::MessageData { |
552 // We copy the data because the data will become invalid after we | 552 // We copy the data because the data will become invalid after we |
553 // handle DataMediaChannel::SignalDataReceived but before we fire | 553 // handle DataMediaChannel::SignalDataReceived but before we fire |
554 // SignalDataReceived. | 554 // SignalDataReceived. |
555 DataReceivedMessageData( | 555 DataReceivedMessageData( |
556 const ReceiveDataParams& params, const char* data, size_t len) | 556 const ReceiveDataParams& params, const char* data, size_t len) |
557 : params(params), | 557 : params(params), |
558 payload(data, len) { | 558 payload(data, len) { |
559 } | 559 } |
560 const ReceiveDataParams params; | 560 const ReceiveDataParams params; |
561 const rtc::Buffer payload; | 561 const rtc::CopyOnWriteBuffer payload; |
562 }; | 562 }; |
563 | 563 |
564 typedef rtc::TypedMessageData<bool> DataChannelReadyToSendMessageData; | 564 typedef rtc::TypedMessageData<bool> DataChannelReadyToSendMessageData; |
565 | 565 |
566 // overrides from BaseChannel | 566 // overrides from BaseChannel |
567 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); | 567 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); |
568 // If data_channel_type_ is DCT_NONE, set it. Otherwise, check that | 568 // If data_channel_type_ is DCT_NONE, set it. Otherwise, check that |
569 // it's the same as what was set previously. Returns false if it's | 569 // it's the same as what was set previously. Returns false if it's |
570 // set to one type one type and changed to another type later. | 570 // set to one type one type and changed to another type later. |
571 bool SetDataChannelType(DataChannelType new_data_channel_type, | 571 bool SetDataChannelType(DataChannelType new_data_channel_type, |
572 std::string* error_desc); | 572 std::string* error_desc); |
573 // Same as SetDataChannelType, but extracts the type from the | 573 // Same as SetDataChannelType, but extracts the type from the |
574 // DataContentDescription. | 574 // DataContentDescription. |
575 bool SetDataChannelTypeFromContent(const DataContentDescription* content, | 575 bool SetDataChannelTypeFromContent(const DataContentDescription* content, |
576 std::string* error_desc); | 576 std::string* error_desc); |
577 virtual bool SetLocalContent_w(const MediaContentDescription* content, | 577 virtual bool SetLocalContent_w(const MediaContentDescription* content, |
578 ContentAction action, | 578 ContentAction action, |
579 std::string* error_desc); | 579 std::string* error_desc); |
580 virtual bool SetRemoteContent_w(const MediaContentDescription* content, | 580 virtual bool SetRemoteContent_w(const MediaContentDescription* content, |
581 ContentAction action, | 581 ContentAction action, |
582 std::string* error_desc); | 582 std::string* error_desc); |
583 virtual void ChangeState(); | 583 virtual void ChangeState(); |
584 virtual bool WantsPacket(bool rtcp, rtc::Buffer* packet); | 584 virtual bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); |
585 | 585 |
586 virtual void OnMessage(rtc::Message* pmsg); | 586 virtual void OnMessage(rtc::Message* pmsg); |
587 virtual void GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const; | 587 virtual void GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const; |
588 virtual void OnConnectionMonitorUpdate( | 588 virtual void OnConnectionMonitorUpdate( |
589 ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos); | 589 ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos); |
590 virtual void OnMediaMonitorUpdate( | 590 virtual void OnMediaMonitorUpdate( |
591 DataMediaChannel* media_channel, const DataMediaInfo& info); | 591 DataMediaChannel* media_channel, const DataMediaInfo& info); |
592 virtual bool ShouldSetupDtlsSrtp() const; | 592 virtual bool ShouldSetupDtlsSrtp() const; |
593 void OnDataReceived( | 593 void OnDataReceived( |
594 const ReceiveDataParams& params, const char* data, size_t len); | 594 const ReceiveDataParams& params, const char* data, size_t len); |
(...skipping 11 matching lines...) Expand all Loading... |
606 // SetSendParameters. | 606 // SetSendParameters. |
607 DataSendParameters last_send_params_; | 607 DataSendParameters last_send_params_; |
608 // Last DataRecvParameters sent down to the media_channel() via | 608 // Last DataRecvParameters sent down to the media_channel() via |
609 // SetRecvParameters. | 609 // SetRecvParameters. |
610 DataRecvParameters last_recv_params_; | 610 DataRecvParameters last_recv_params_; |
611 }; | 611 }; |
612 | 612 |
613 } // namespace cricket | 613 } // namespace cricket |
614 | 614 |
615 #endif // WEBRTC_PC_CHANNEL_H_ | 615 #endif // WEBRTC_PC_CHANNEL_H_ |
OLD | NEW |