| Index: talk/app/webrtc/datachannel.h
|
| diff --git a/talk/app/webrtc/datachannel.h b/talk/app/webrtc/datachannel.h
|
| index 8e58d0664b2dfb755753d0b7fb707e4d9675c6a0..ddb42f3b4f240948e0f9dee7012be0f2f12ce87d 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 AllocateSctpSid(rtc::SSLRole role, int* sid);
|
| +
|
| + // Attempts to reserve a specific sid. Returns false if it's unavailable.
|
| + bool ReserveSctpSid(int sid);
|
| +
|
| + // Indicates that |sid| isn't in use any more, and is thus available again.
|
| + void ReleaseSctpSid(int sid);
|
| +
|
| + private:
|
| + // Checks if |sid| is available to be assigned to a new SCTP data channel.
|
| + bool IsSctpSidAvailable(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
|
| @@ -143,6 +166,7 @@ class DataChannel : public DataChannelInterface,
|
| void OnDataReceived(cricket::DataChannel* channel,
|
| const cricket::ReceiveDataParams& params,
|
| const rtc::Buffer& payload);
|
| + void OnStreamClosedRemotely(uint32 sid);
|
|
|
| // The remote peer request that this channel should be closed.
|
| void RemotePeerRequestClose();
|
| @@ -169,6 +193,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,
|
| @@ -249,16 +278,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*)
|
|
|