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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 | 142 |
143 BundleFilter* bundle_filter() { return &bundle_filter_; } | 143 BundleFilter* bundle_filter() { return &bundle_filter_; } |
144 | 144 |
145 const std::vector<StreamParams>& local_streams() const { | 145 const std::vector<StreamParams>& local_streams() const { |
146 return local_streams_; | 146 return local_streams_; |
147 } | 147 } |
148 const std::vector<StreamParams>& remote_streams() const { | 148 const std::vector<StreamParams>& remote_streams() const { |
149 return remote_streams_; | 149 return remote_streams_; |
150 } | 150 } |
151 | 151 |
152 sigslot::signal2<BaseChannel*, bool> SignalDtlsSetupFailure; | 152 sigslot::signal2<BaseChannel*, bool> SignalDtlsSrtpSetupFailure; |
153 void SignalDtlsSetupFailure_n(bool rtcp); | 153 void SignalDtlsSrtpSetupFailure_n(bool rtcp); |
154 void SignalDtlsSetupFailure_s(bool rtcp); | 154 void SignalDtlsSrtpSetupFailure_s(bool rtcp); |
155 | 155 |
156 // Used for latency measurements. | 156 // Used for latency measurements. |
157 sigslot::signal1<BaseChannel*> SignalFirstPacketReceived; | 157 sigslot::signal1<BaseChannel*> SignalFirstPacketReceived; |
158 | 158 |
159 // Forward TransportChannel SignalSentPacket to worker thread. | 159 // Forward TransportChannel SignalSentPacket to worker thread. |
160 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket; | 160 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket; |
161 | 161 |
162 // Only public for unit tests. Otherwise, consider private. | 162 // Only public for unit tests. Otherwise, consider private. |
163 TransportChannel* transport_channel() const { return transport_channel_; } | 163 TransportChannel* transport_channel() const { return transport_channel_; } |
164 TransportChannel* rtcp_transport_channel() const { | 164 TransportChannel* rtcp_transport_channel() const { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 int last_sent_packet_id, | 254 int last_sent_packet_id, |
255 bool ready_to_send); | 255 bool ready_to_send); |
256 | 256 |
257 bool PacketIsRtcp(const rtc::PacketTransportInterface* transport, | 257 bool PacketIsRtcp(const rtc::PacketTransportInterface* transport, |
258 const char* data, | 258 const char* data, |
259 size_t len); | 259 size_t len); |
260 bool SendPacket(bool rtcp, | 260 bool SendPacket(bool rtcp, |
261 rtc::CopyOnWriteBuffer* packet, | 261 rtc::CopyOnWriteBuffer* packet, |
262 const rtc::PacketOptions& options); | 262 const rtc::PacketOptions& options); |
263 | 263 |
264 virtual bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); | 264 bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); |
265 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, | 265 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, |
266 const rtc::PacketTime& packet_time); | 266 const rtc::PacketTime& packet_time); |
267 void OnPacketReceived(bool rtcp, | 267 void OnPacketReceived(bool rtcp, |
268 const rtc::CopyOnWriteBuffer& packet, | 268 const rtc::CopyOnWriteBuffer& packet, |
269 const rtc::PacketTime& packet_time); | 269 const rtc::PacketTime& packet_time); |
270 | 270 |
271 void EnableMedia_w(); | 271 void EnableMedia_w(); |
272 void DisableMedia_w(); | 272 void DisableMedia_w(); |
273 | 273 |
274 // Performs actions if the RTP/RTCP writable state changed. This should | 274 // Performs actions if the RTP/RTCP writable state changed. This should |
275 // be called whenever a channel's writable state changes or when RTCP muxing | 275 // be called whenever a channel's writable state changes or when RTCP muxing |
276 // becomes active/inactive. | 276 // becomes active/inactive. |
277 void UpdateWritableState_n(); | 277 void UpdateWritableState_n(); |
278 void ChannelWritable_n(); | 278 void ChannelWritable_n(); |
279 void ChannelNotWritable_n(); | 279 void ChannelNotWritable_n(); |
280 | 280 |
281 bool AddRecvStream_w(const StreamParams& sp); | 281 bool AddRecvStream_w(const StreamParams& sp); |
282 bool RemoveRecvStream_w(uint32_t ssrc); | 282 bool RemoveRecvStream_w(uint32_t ssrc); |
283 bool AddSendStream_w(const StreamParams& sp); | 283 bool AddSendStream_w(const StreamParams& sp); |
284 bool RemoveSendStream_w(uint32_t ssrc); | 284 bool RemoveSendStream_w(uint32_t ssrc); |
285 virtual bool ShouldSetupDtlsSrtp_n() const; | 285 bool ShouldSetupDtlsSrtp_n() const; |
286 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. | 286 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. |
287 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. | 287 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. |
288 bool SetupDtlsSrtp_n(bool rtcp_channel); | 288 bool SetupDtlsSrtp_n(bool rtcp_channel); |
289 void MaybeSetupDtlsSrtp_n(); | 289 void MaybeSetupDtlsSrtp_n(); |
290 // Set the DTLS-SRTP cipher policy on this channel as appropriate. | 290 // Set the DTLS-SRTP cipher policy on this channel as appropriate. |
291 bool SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp); | 291 bool SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp); |
292 | 292 |
293 // Should be called whenever the conditions for | 293 // Should be called whenever the conditions for |
294 // IsReadyToReceiveMedia/IsReadyToSendMedia are satisfied (or unsatisfied). | 294 // IsReadyToReceiveMedia/IsReadyToSendMedia are satisfied (or unsatisfied). |
295 // Updates the send/recv state of the media channel. | 295 // Updates the send/recv state of the media channel. |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 std::unique_ptr<VideoMediaMonitor> media_monitor_; | 608 std::unique_ptr<VideoMediaMonitor> media_monitor_; |
609 | 609 |
610 // Last VideoSendParameters sent down to the media_channel() via | 610 // Last VideoSendParameters sent down to the media_channel() via |
611 // SetSendParameters. | 611 // SetSendParameters. |
612 VideoSendParameters last_send_params_; | 612 VideoSendParameters last_send_params_; |
613 // Last VideoRecvParameters sent down to the media_channel() via | 613 // Last VideoRecvParameters sent down to the media_channel() via |
614 // SetRecvParameters. | 614 // SetRecvParameters. |
615 VideoRecvParameters last_recv_params_; | 615 VideoRecvParameters last_recv_params_; |
616 }; | 616 }; |
617 | 617 |
618 // DataChannel is a specialization for data. | 618 // RtpDataChannel is a specialization for data. |
619 class DataChannel : public BaseChannel { | 619 class RtpDataChannel : public BaseChannel { |
620 public: | 620 public: |
621 DataChannel(rtc::Thread* worker_thread, | 621 RtpDataChannel(rtc::Thread* worker_thread, |
622 rtc::Thread* network_thread, | 622 rtc::Thread* network_thread, |
623 DataMediaChannel* media_channel, | 623 DataMediaChannel* media_channel, |
624 TransportController* transport_controller, | 624 TransportController* transport_controller, |
625 const std::string& content_name, | 625 const std::string& content_name, |
626 bool rtcp, | 626 bool rtcp, |
627 bool srtp_required); | 627 bool srtp_required); |
628 ~DataChannel(); | 628 ~RtpDataChannel(); |
629 bool Init_w(const std::string* bundle_transport_name); | 629 bool Init_w(const std::string* bundle_transport_name); |
630 | 630 |
631 virtual bool SendData(const SendDataParams& params, | 631 virtual bool SendData(const SendDataParams& params, |
632 const rtc::CopyOnWriteBuffer& payload, | 632 const rtc::CopyOnWriteBuffer& payload, |
633 SendDataResult* result); | 633 SendDataResult* result); |
634 | 634 |
635 void StartMediaMonitor(int cms); | 635 void StartMediaMonitor(int cms); |
636 void StopMediaMonitor(); | 636 void StopMediaMonitor(); |
637 | 637 |
638 // Should be called on the signaling thread only. | 638 // Should be called on the signaling thread only. |
639 bool ready_to_send_data() const { | 639 bool ready_to_send_data() const { |
640 return ready_to_send_data_; | 640 return ready_to_send_data_; |
641 } | 641 } |
642 | 642 |
643 sigslot::signal2<DataChannel*, const DataMediaInfo&> SignalMediaMonitor; | 643 sigslot::signal2<RtpDataChannel*, const DataMediaInfo&> SignalMediaMonitor; |
644 sigslot::signal2<DataChannel*, const std::vector<ConnectionInfo>&> | 644 sigslot::signal2<RtpDataChannel*, const std::vector<ConnectionInfo>&> |
645 SignalConnectionMonitor; | 645 SignalConnectionMonitor; |
646 sigslot::signal3<DataChannel*, const ReceiveDataParams&, | 646 |
647 const rtc::CopyOnWriteBuffer&> SignalDataReceived; | 647 sigslot::signal2<const ReceiveDataParams&, const rtc::CopyOnWriteBuffer&> |
648 SignalDataReceived; | |
648 // Signal for notifying when the channel becomes ready to send data. | 649 // Signal for notifying when the channel becomes ready to send data. |
649 // That occurs when the channel is enabled, the transport is writable, | 650 // That occurs when the channel is enabled, the transport is writable, |
650 // both local and remote descriptions are set, and the channel is unblocked. | 651 // both local and remote descriptions are set, and the channel is unblocked. |
651 sigslot::signal1<bool> SignalReadyToSendData; | 652 sigslot::signal1<bool> SignalReadyToSendData; |
652 // Signal for notifying that the remote side has closed the DataChannel. | |
653 sigslot::signal1<uint32_t> SignalStreamClosedRemotely; | |
654 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_DATA; } | 653 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_DATA; } |
655 | 654 |
656 protected: | 655 protected: |
657 // downcasts a MediaChannel. | 656 // downcasts a MediaChannel. |
658 DataMediaChannel* media_channel() const override { | 657 DataMediaChannel* media_channel() const override { |
659 return static_cast<DataMediaChannel*>(BaseChannel::media_channel()); | 658 return static_cast<DataMediaChannel*>(BaseChannel::media_channel()); |
660 } | 659 } |
661 | 660 |
662 private: | 661 private: |
663 struct SendDataMessageData : public rtc::MessageData { | 662 struct SendDataMessageData : public rtc::MessageData { |
(...skipping 22 matching lines...) Expand all Loading... | |
686 payload(data, len) { | 685 payload(data, len) { |
687 } | 686 } |
688 const ReceiveDataParams params; | 687 const ReceiveDataParams params; |
689 const rtc::CopyOnWriteBuffer payload; | 688 const rtc::CopyOnWriteBuffer payload; |
690 }; | 689 }; |
691 | 690 |
692 typedef rtc::TypedMessageData<bool> DataChannelReadyToSendMessageData; | 691 typedef rtc::TypedMessageData<bool> DataChannelReadyToSendMessageData; |
693 | 692 |
694 // overrides from BaseChannel | 693 // overrides from BaseChannel |
695 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; | 694 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; |
696 // If data_channel_type_ is DCT_NONE, set it. Otherwise, check that | 695 // Checks that data channel type is RTP. |
697 // it's the same as what was set previously. Returns false if it's | 696 bool CheckDataChannelTypeFromContent(const DataContentDescription* content, |
698 // set to one type one type and changed to another type later. | 697 std::string* error_desc); |
699 bool SetDataChannelType(DataChannelType new_data_channel_type, | |
700 std::string* error_desc); | |
701 // Same as SetDataChannelType, but extracts the type from the | |
702 // DataContentDescription. | |
703 bool SetDataChannelTypeFromContent(const DataContentDescription* content, | |
704 std::string* error_desc); | |
705 bool SetLocalContent_w(const MediaContentDescription* content, | 698 bool SetLocalContent_w(const MediaContentDescription* content, |
706 ContentAction action, | 699 ContentAction action, |
707 std::string* error_desc) override; | 700 std::string* error_desc) override; |
708 bool SetRemoteContent_w(const MediaContentDescription* content, | 701 bool SetRemoteContent_w(const MediaContentDescription* content, |
709 ContentAction action, | 702 ContentAction action, |
710 std::string* error_desc) override; | 703 std::string* error_desc) override; |
711 void UpdateMediaSendRecvState_w() override; | 704 void UpdateMediaSendRecvState_w() override; |
712 bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) override; | |
713 | 705 |
714 void OnMessage(rtc::Message* pmsg) override; | 706 void OnMessage(rtc::Message* pmsg) override; |
715 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override; | 707 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override; |
716 void OnConnectionMonitorUpdate( | 708 void OnConnectionMonitorUpdate( |
717 ConnectionMonitor* monitor, | 709 ConnectionMonitor* monitor, |
718 const std::vector<ConnectionInfo>& infos) override; | 710 const std::vector<ConnectionInfo>& infos) override; |
719 void OnMediaMonitorUpdate(DataMediaChannel* media_channel, | 711 void OnMediaMonitorUpdate(DataMediaChannel* media_channel, |
720 const DataMediaInfo& info); | 712 const DataMediaInfo& info); |
721 bool ShouldSetupDtlsSrtp_n() const override; | |
722 void OnDataReceived( | 713 void OnDataReceived( |
723 const ReceiveDataParams& params, const char* data, size_t len); | 714 const ReceiveDataParams& params, const char* data, size_t len); |
724 void OnDataChannelError(uint32_t ssrc, DataMediaChannel::Error error); | 715 void OnDataChannelError(uint32_t ssrc, DataMediaChannel::Error error); |
725 void OnDataChannelReadyToSend(bool writable); | 716 void OnDataChannelReadyToSend(bool writable); |
726 void OnStreamClosedRemotely(uint32_t sid); | |
727 | 717 |
728 std::unique_ptr<DataMediaMonitor> media_monitor_; | 718 std::unique_ptr<DataMediaMonitor> media_monitor_; |
729 // TODO(pthatcher): Make a separate SctpDataChannel and | 719 bool ready_to_send_data_ = false; |
730 // RtpDataChannel instead of using this. | |
Taylor Brandstetter
2016/12/22 22:59:48
Hey, I'm fixing your TODO!
| |
731 DataChannelType data_channel_type_; | |
732 bool ready_to_send_data_; | |
733 | 720 |
734 // Last DataSendParameters sent down to the media_channel() via | 721 // Last DataSendParameters sent down to the media_channel() via |
735 // SetSendParameters. | 722 // SetSendParameters. |
736 DataSendParameters last_send_params_; | 723 DataSendParameters last_send_params_; |
737 // Last DataRecvParameters sent down to the media_channel() via | 724 // Last DataRecvParameters sent down to the media_channel() via |
738 // SetRecvParameters. | 725 // SetRecvParameters. |
739 DataRecvParameters last_recv_params_; | 726 DataRecvParameters last_recv_params_; |
740 }; | 727 }; |
741 | 728 |
742 } // namespace cricket | 729 } // namespace cricket |
743 | 730 |
744 #endif // WEBRTC_PC_CHANNEL_H_ | 731 #endif // WEBRTC_PC_CHANNEL_H_ |
OLD | NEW |