| Index: talk/app/webrtc/datachannel.h
|
| diff --git a/talk/app/webrtc/datachannel.h b/talk/app/webrtc/datachannel.h
|
| index 4506f71b146c71f95ab22a04fbcffca97b43bb32..2713ae3b553ed7a79f32de9f34a214c3396e1877 100644
|
| --- a/talk/app/webrtc/datachannel.h
|
| +++ b/talk/app/webrtc/datachannel.h
|
| @@ -29,6 +29,7 @@
|
| #define TALK_APP_WEBRTC_DATACHANNEL_H_
|
|
|
| #include <deque>
|
| +#include <set>
|
| #include <string>
|
|
|
| #include "talk/app/webrtc/datachannelinterface.h"
|
| @@ -83,6 +84,28 @@ struct InternalDataChannelInit : public DataChannelInit {
|
| OpenHandshakeRole open_handshake_role;
|
| };
|
|
|
| +// Helper class to allocate unique IDs for SCTP DataChannels
|
| +class SctpSidAllocator {
|
| + public:
|
| + // Gets the first unused odd/even id based on the DTLS role. If |role| is
|
| + // SSL_CLIENT, the allocated id starts from 0 and takes even numbers;
|
| + // otherwise, the id starts from 1 and takes odd numbers.
|
| + // Returns false if no id can be allocated.
|
| + bool AllocateSid(rtc::SSLRole role, int* sid);
|
| +
|
| + // Attempts to reserve a specific sid. Returns false if it's unavailable.
|
| + bool ReserveSid(int sid);
|
| +
|
| + // Indicates that |sid| isn't in use any more, and is thus available again.
|
| + void ReleaseSid(int sid);
|
| +
|
| + private:
|
| + // Checks if |sid| is available to be assigned to a new SCTP data channel.
|
| + bool IsSidAvailable(int sid) const;
|
| +
|
| + std::set<int> used_sids_;
|
| +};
|
| +
|
| // DataChannel is a an implementation of the DataChannelInterface based on
|
| // libjingle's data engine. It provides an implementation of unreliable or
|
| // reliabledata channels. Currently this class is specifically designed to use
|
| @@ -129,9 +152,6 @@ class DataChannel : public DataChannelInterface,
|
| // rtc::MessageHandler override.
|
| virtual void OnMessage(rtc::Message* msg);
|
|
|
| - // Called if the underlying data engine is closing.
|
| - void OnDataEngineClose();
|
| -
|
| // Called when the channel's ready to use. That can happen when the
|
| // underlying DataMediaChannel becomes ready, or when this channel is a new
|
| // stream on an existing DataMediaChannel, and we've finished negotiation.
|
| @@ -141,6 +161,7 @@ class DataChannel : public DataChannelInterface,
|
| void OnDataReceived(cricket::DataChannel* channel,
|
| const cricket::ReceiveDataParams& params,
|
| const rtc::Buffer& payload);
|
| + void OnStreamClosedRemotely(uint32_t sid);
|
|
|
| // The remote peer request that this channel should be closed.
|
| void RemotePeerRequestClose();
|
| @@ -151,7 +172,10 @@ class DataChannel : public DataChannelInterface,
|
| // be called once.
|
| void SetSctpSid(int sid);
|
| // Called when the transport channel is created.
|
| + // Only needs to be called for SCTP data channels.
|
| void OnTransportChannelCreated();
|
| + // Called when the transport channel is destroyed.
|
| + void OnTransportChannelDestroyed();
|
|
|
| // The following methods are for RTP only.
|
|
|
| @@ -167,6 +191,11 @@ class DataChannel : public DataChannelInterface,
|
| return data_channel_type_;
|
| }
|
|
|
| + // Emitted when state transitions to kClosed.
|
| + // In the case of SCTP channels, this signal can be used to tell when the
|
| + // channel's sid is free.
|
| + sigslot::signal1<DataChannel*> SignalClosed;
|
| +
|
| protected:
|
| DataChannel(DataChannelProviderInterface* client,
|
| cricket::DataChannelType dct,
|
| @@ -247,16 +276,6 @@ class DataChannel : public DataChannelInterface,
|
| PacketQueue queued_send_data_;
|
| };
|
|
|
| -class DataChannelFactory {
|
| - public:
|
| - virtual rtc::scoped_refptr<DataChannel> CreateDataChannel(
|
| - const std::string& label,
|
| - const InternalDataChannelInit* config) = 0;
|
| -
|
| - protected:
|
| - virtual ~DataChannelFactory() {}
|
| -};
|
| -
|
| // Define proxy for DataChannelInterface.
|
| BEGIN_PROXY_MAP(DataChannel)
|
| PROXY_METHOD1(void, RegisterObserver, DataChannelObserver*)
|
|
|