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