OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
11 #ifndef WEBRTC_MEDIA_SCTP_SCTPTRANSPORT_H_ | 11 #ifndef WEBRTC_MEDIA_SCTP_SCTPTRANSPORT_H_ |
12 #define WEBRTC_MEDIA_SCTP_SCTPTRANSPORT_H_ | 12 #define WEBRTC_MEDIA_SCTP_SCTPTRANSPORT_H_ |
13 | 13 |
14 #include <errno.h> | 14 #include <errno.h> |
15 | 15 |
16 #include <memory> // for unique_ptr. | 16 #include <memory> // for unique_ptr. |
17 #include <set> | 17 #include <set> |
18 #include <string> | 18 #include <string> |
19 #include <vector> | 19 #include <vector> |
20 | 20 |
21 #include "webrtc/base/asyncinvoker.h" | 21 #include "webrtc/base/asyncinvoker.h" |
22 #include "webrtc/base/constructormagic.h" | 22 #include "webrtc/base/constructormagic.h" |
23 #include "webrtc/base/copyonwritebuffer.h" | 23 #include "webrtc/base/copyonwritebuffer.h" |
24 #include "webrtc/base/sigslot.h" | 24 #include "webrtc/base/sigslot.h" |
25 #include "webrtc/base/thread.h" | 25 #include "webrtc/base/thread.h" |
26 // For SendDataParams/ReceiveDataParams. | 26 // For SendDataParams/ReceiveDataParams. |
27 #include "webrtc/media/base/mediachannel.h" | 27 #include "webrtc/media/base/mediachannel.h" |
28 #include "webrtc/media/sctp/sctptransportinternal.h" | 28 #include "webrtc/media/sctp/sctptransportinternal.h" |
29 #include "webrtc/p2p/base/transportchannel.h" | |
30 | 29 |
31 // Defined by "usrsctplib/usrsctp.h" | 30 // Defined by "usrsctplib/usrsctp.h" |
32 struct sockaddr_conn; | 31 struct sockaddr_conn; |
33 struct sctp_assoc_change; | 32 struct sctp_assoc_change; |
34 struct sctp_stream_reset_event; | 33 struct sctp_stream_reset_event; |
35 // Defined by <sys/socket.h> | 34 // Defined by <sys/socket.h> |
36 struct socket; | 35 struct socket; |
37 namespace cricket { | 36 namespace cricket { |
38 | 37 |
39 // Holds data to be passed on to a channel. | 38 // Holds data to be passed on to a channel. |
(...skipping 20 matching lines...) Expand all Loading... | |
60 // [from the same thread, methods registered/connected to | 59 // [from the same thread, methods registered/connected to |
61 // SctpTransport are called with the recieved data] | 60 // SctpTransport are called with the recieved data] |
62 class SctpTransport : public SctpTransportInternal, | 61 class SctpTransport : public SctpTransportInternal, |
63 public sigslot::has_slots<> { | 62 public sigslot::has_slots<> { |
64 public: | 63 public: |
65 // |network_thread| is where packets will be processed and callbacks from | 64 // |network_thread| is where packets will be processed and callbacks from |
66 // this transport will be posted, and is the only thread on which public | 65 // this transport will be posted, and is the only thread on which public |
67 // methods can be called. | 66 // methods can be called. |
68 // |channel| is required (must not be null). | 67 // |channel| is required (must not be null). |
69 SctpTransport(rtc::Thread* network_thread, | 68 SctpTransport(rtc::Thread* network_thread, |
70 cricket::TransportChannel* channel); | 69 cricket::DtlsTransportInternal* channel); |
pthatcher1
2017/01/17 20:16:48
Can SctpTransport take just a PacketTransportInter
| |
71 ~SctpTransport() override; | 70 ~SctpTransport() override; |
72 | 71 |
73 // SctpTransportInternal overrides (see sctptransportinternal.h for comments). | 72 // SctpTransportInternal overrides (see sctptransportinternal.h for comments). |
74 void SetTransportChannel(cricket::TransportChannel* channel) override; | 73 void SetTransportChannel(cricket::DtlsTransportInternal* channel) override; |
75 bool Start(int local_port, int remote_port) override; | 74 bool Start(int local_port, int remote_port) override; |
76 bool OpenStream(int sid) override; | 75 bool OpenStream(int sid) override; |
77 bool ResetStream(int sid) override; | 76 bool ResetStream(int sid) override; |
78 bool SendData(const SendDataParams& params, | 77 bool SendData(const SendDataParams& params, |
79 const rtc::CopyOnWriteBuffer& payload, | 78 const rtc::CopyOnWriteBuffer& payload, |
80 SendDataResult* result = nullptr) override; | 79 SendDataResult* result = nullptr) override; |
81 bool ReadyToSendData() override; | 80 bool ReadyToSendData() override; |
82 void set_debug_name_for_testing(const char* debug_name) override { | 81 void set_debug_name_for_testing(const char* debug_name) override { |
83 debug_name_ = debug_name; | 82 debug_name_ = debug_name; |
84 } | 83 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 void OnNotificationAssocChange(const sctp_assoc_change& change); | 132 void OnNotificationAssocChange(const sctp_assoc_change& change); |
134 | 133 |
135 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt); | 134 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt); |
136 | 135 |
137 // Responsible for marshalling incoming data to the channels listeners, and | 136 // Responsible for marshalling incoming data to the channels listeners, and |
138 // outgoing data to the network interface. | 137 // outgoing data to the network interface. |
139 rtc::Thread* network_thread_; | 138 rtc::Thread* network_thread_; |
140 // Helps pass inbound/outbound packets asynchronously to the network thread. | 139 // Helps pass inbound/outbound packets asynchronously to the network thread. |
141 rtc::AsyncInvoker invoker_; | 140 rtc::AsyncInvoker invoker_; |
142 // Underlying DTLS channel. | 141 // Underlying DTLS channel. |
143 TransportChannel* transport_channel_; | 142 DtlsTransportInternal* transport_channel_; |
pthatcher1
2017/01/17 20:16:48
This file could use some channel => transport rena
| |
144 bool was_ever_writable_ = false; | 143 bool was_ever_writable_ = false; |
145 int local_port_ = kSctpDefaultPort; | 144 int local_port_ = kSctpDefaultPort; |
146 int remote_port_ = kSctpDefaultPort; | 145 int remote_port_ = kSctpDefaultPort; |
147 struct socket* sock_ = nullptr; // The socket created by usrsctp_socket(...). | 146 struct socket* sock_ = nullptr; // The socket created by usrsctp_socket(...). |
148 | 147 |
149 // Has Start been called? Don't create SCTP socket until it has. | 148 // Has Start been called? Don't create SCTP socket until it has. |
150 bool started_ = false; | 149 bool started_ = false; |
151 // Are we ready to queue data (SCTP socket created, and not blocked due to | 150 // Are we ready to queue data (SCTP socket created, and not blocked due to |
152 // congestion control)? Different than |transport_channel_|'s "ready to | 151 // congestion control)? Different than |transport_channel_|'s "ready to |
153 // send". | 152 // send". |
(...skipping 18 matching lines...) Expand all Loading... | |
172 | 171 |
173 RTC_DISALLOW_COPY_AND_ASSIGN(SctpTransport); | 172 RTC_DISALLOW_COPY_AND_ASSIGN(SctpTransport); |
174 }; | 173 }; |
175 | 174 |
176 class SctpTransportFactory : public SctpTransportInternalFactory { | 175 class SctpTransportFactory : public SctpTransportInternalFactory { |
177 public: | 176 public: |
178 explicit SctpTransportFactory(rtc::Thread* network_thread) | 177 explicit SctpTransportFactory(rtc::Thread* network_thread) |
179 : network_thread_(network_thread) {} | 178 : network_thread_(network_thread) {} |
180 | 179 |
181 std::unique_ptr<SctpTransportInternal> CreateSctpTransport( | 180 std::unique_ptr<SctpTransportInternal> CreateSctpTransport( |
182 TransportChannel* channel) override { | 181 DtlsTransportInternal* channel) override { |
183 return std::unique_ptr<SctpTransportInternal>( | 182 return std::unique_ptr<SctpTransportInternal>( |
184 new SctpTransport(network_thread_, channel)); | 183 new SctpTransport(network_thread_, channel)); |
185 } | 184 } |
186 | 185 |
187 private: | 186 private: |
188 rtc::Thread* network_thread_; | 187 rtc::Thread* network_thread_; |
189 }; | 188 }; |
190 | 189 |
191 } // namespace cricket | 190 } // namespace cricket |
192 | 191 |
193 #endif // WEBRTC_MEDIA_SCTP_SCTPTRANSPORT_H_ | 192 #endif // WEBRTC_MEDIA_SCTP_SCTPTRANSPORT_H_ |
OLD | NEW |