Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(966)

Side by Side Diff: webrtc/media/sctp/sctpdataengine.h

Issue 1995993002: Only initialize usrsctp when it's used and uninitialize when it's not being used. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove thread checker and add {}'s. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/media/sctp/sctpdataengine.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SCTPDATAENGINE_H_ 11 #ifndef WEBRTC_MEDIA_SCTP_SCTPDATAENGINE_H_
12 #define WEBRTC_MEDIA_SCTP_SCTPDATAENGINE_H_ 12 #define WEBRTC_MEDIA_SCTP_SCTPDATAENGINE_H_
13 13
14 #include <errno.h> 14 #include <errno.h>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 namespace cricket { 18 namespace cricket {
19 // Some ERRNO values get re-#defined to WSA* equivalents in some talk/ 19 // Some ERRNO values get re-#defined to WSA* equivalents in some talk/
20 // headers. We save the original ones in an enum. 20 // headers. We save the original ones in an enum.
21 enum PreservedErrno { 21 enum PreservedErrno {
22 SCTP_EINPROGRESS = EINPROGRESS, 22 SCTP_EINPROGRESS = EINPROGRESS,
23 SCTP_EWOULDBLOCK = EWOULDBLOCK 23 SCTP_EWOULDBLOCK = EWOULDBLOCK
24 }; 24 };
25 } // namespace cricket 25 } // namespace cricket
26 26
27 #include "webrtc/base/copyonwritebuffer.h" 27 #include "webrtc/base/copyonwritebuffer.h"
28 #include "webrtc/base/gtest_prod_util.h"
28 #include "webrtc/media/base/codec.h" 29 #include "webrtc/media/base/codec.h"
29 #include "webrtc/media/base/mediachannel.h" 30 #include "webrtc/media/base/mediachannel.h"
30 #include "webrtc/media/base/mediaengine.h" 31 #include "webrtc/media/base/mediaengine.h"
31 32
32 // Defined by "usrsctplib/usrsctp.h" 33 // Defined by "usrsctplib/usrsctp.h"
33 struct sockaddr_conn; 34 struct sockaddr_conn;
34 struct sctp_assoc_change; 35 struct sctp_assoc_change;
35 struct sctp_stream_reset_event; 36 struct sctp_stream_reset_event;
36 // Defined by <sys/socket.h> 37 // Defined by <sys/socket.h>
37 struct socket; 38 struct socket;
(...skipping 30 matching lines...) Expand all
68 // [sctp thread returns having posted a message fot the worker thread] 69 // [sctp thread returns having posted a message fot the worker thread]
69 // 11. SctpDataMediaChannel::OnMessage(inboundpacket) 70 // 11. SctpDataMediaChannel::OnMessage(inboundpacket)
70 // 12. SctpDataMediaChannel::OnInboundPacketFromSctpToChannel(inboundpacket) 71 // 12. SctpDataMediaChannel::OnInboundPacketFromSctpToChannel(inboundpacket)
71 // 13. SctpDataMediaChannel::OnDataFromSctpToChannel(data) 72 // 13. SctpDataMediaChannel::OnDataFromSctpToChannel(data)
72 // 14. SctpDataMediaChannel::SignalDataReceived(data) 73 // 14. SctpDataMediaChannel::SignalDataReceived(data)
73 // [from the same thread, methods registered/connected to 74 // [from the same thread, methods registered/connected to
74 // SctpDataMediaChannel are called with the recieved data] 75 // SctpDataMediaChannel are called with the recieved data]
75 class SctpDataEngine : public DataEngineInterface, public sigslot::has_slots<> { 76 class SctpDataEngine : public DataEngineInterface, public sigslot::has_slots<> {
76 public: 77 public:
77 SctpDataEngine(); 78 SctpDataEngine();
78 virtual ~SctpDataEngine(); 79 ~SctpDataEngine() override;
79 80
80 virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type); 81 DataMediaChannel* CreateChannel(DataChannelType data_channel_type) override;
81 82 const std::vector<DataCodec>& data_codecs() override { return codecs_; }
82 virtual const std::vector<DataCodec>& data_codecs() { return codecs_; }
83
84 static int SendThresholdCallback(struct socket* sock, uint32_t sb_free);
85 83
86 private: 84 private:
87 static int usrsctp_engines_count; 85 const std::vector<DataCodec> codecs_;
88 std::vector<DataCodec> codecs_;
89
90 static SctpDataMediaChannel* GetChannelFromSocket(struct socket* sock);
91 }; 86 };
92 87
93 // TODO(ldixon): Make into a special type of TypedMessageData. 88 // TODO(ldixon): Make into a special type of TypedMessageData.
94 // Holds data to be passed on to a channel. 89 // Holds data to be passed on to a channel.
95 struct SctpInboundPacket; 90 struct SctpInboundPacket;
96 91
97 class SctpDataMediaChannel : public DataMediaChannel, 92 class SctpDataMediaChannel : public DataMediaChannel,
98 public rtc::MessageHandler { 93 public rtc::MessageHandler {
99 public: 94 public:
100 // DataMessageType is used for the SCTP "Payload Protocol Identifier", as 95 // DataMessageType is used for the SCTP "Payload Protocol Identifier", as
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 rtc::Thread* worker_thread() const { return worker_thread_; } 149 rtc::Thread* worker_thread() const { return worker_thread_; }
155 150
156 // Many of these things are unused by SCTP, but are needed to fulfill 151 // Many of these things are unused by SCTP, but are needed to fulfill
157 // the MediaChannel interface. 152 // the MediaChannel interface.
158 virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet, 153 virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet,
159 const rtc::PacketTime& packet_time) {} 154 const rtc::PacketTime& packet_time) {}
160 virtual void OnReadyToSend(bool ready) {} 155 virtual void OnReadyToSend(bool ready) {}
161 156
162 void OnSendThresholdCallback(); 157 void OnSendThresholdCallback();
163 // Helper for debugging. 158 // Helper for debugging.
164 void set_debug_name(const std::string& debug_name) { 159 void set_debug_name_for_testing(const char* debug_name) {
165 debug_name_ = debug_name; 160 debug_name_ = debug_name;
166 } 161 }
167 const std::string& debug_name() const { return debug_name_; }
168 const struct socket* socket() const { return sock_; } 162 const struct socket* socket() const { return sock_; }
163
164 private:
165 FRIEND_TEST_ALL_PREFIXES(SctpDataMediaChannelTest, EngineSignalsRightChannel);
166 static int SendThresholdCallback(struct socket* sock, uint32_t sb_free);
167 static SctpDataMediaChannel* GetChannelFromSocket(struct socket* sock);
168
169 private: 169 private:
170 sockaddr_conn GetSctpSockAddr(int port); 170 sockaddr_conn GetSctpSockAddr(int port);
171 171
172 bool SetSendCodecs(const std::vector<DataCodec>& codecs); 172 bool SetSendCodecs(const std::vector<DataCodec>& codecs);
173 bool SetRecvCodecs(const std::vector<DataCodec>& codecs); 173 bool SetRecvCodecs(const std::vector<DataCodec>& codecs);
174 174
175 // Creates the socket and connects. Sets sending_ to true. 175 // Creates the socket and connects. Sets sending_ to true.
176 bool Connect(); 176 bool Connect();
177 // Closes the socket. Sets sending_ to false. 177 // Closes the socket. Sets sending_ to false.
178 void Disconnect(); 178 void Disconnect();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // want to close it, the stream's ID goes into queued_reset_streams_. When 222 // want to close it, the stream's ID goes into queued_reset_streams_. When
223 // we actually transmit a RE-CONFIG chunk with that stream ID, the ID goes 223 // we actually transmit a RE-CONFIG chunk with that stream ID, the ID goes
224 // into sent_reset_streams_. When we get a response RE-CONFIG chunk back 224 // into sent_reset_streams_. When we get a response RE-CONFIG chunk back
225 // acknowledging the reset, we remove the stream ID from 225 // acknowledging the reset, we remove the stream ID from
226 // sent_reset_streams_. We use sent_reset_streams_ to differentiate 226 // sent_reset_streams_. We use sent_reset_streams_ to differentiate
227 // between acknowledgment RE-CONFIG and peer-initiated RE-CONFIGs. 227 // between acknowledgment RE-CONFIG and peer-initiated RE-CONFIGs.
228 StreamSet open_streams_; 228 StreamSet open_streams_;
229 StreamSet queued_reset_streams_; 229 StreamSet queued_reset_streams_;
230 StreamSet sent_reset_streams_; 230 StreamSet sent_reset_streams_;
231 231
232 // A human-readable name for debugging messages. 232 // A static human-readable name for debugging messages.
233 std::string debug_name_; 233 const char* debug_name_;
234 }; 234 };
235 235
236 } // namespace cricket 236 } // namespace cricket
237 237
238 #endif // WEBRTC_MEDIA_SCTP_SCTPDATAENGINE_H_ 238 #endif // WEBRTC_MEDIA_SCTP_SCTPDATAENGINE_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/media/sctp/sctpdataengine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698