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

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

Issue 1823503002: Reland Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
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/buffer.h" 27 #include "webrtc/base/copyonwritebuffer.h"
28 #include "webrtc/media/base/codec.h" 28 #include "webrtc/media/base/codec.h"
29 #include "webrtc/media/base/mediachannel.h" 29 #include "webrtc/media/base/mediachannel.h"
30 #include "webrtc/media/base/mediaengine.h" 30 #include "webrtc/media/base/mediaengine.h"
31 31
32 // Defined by "usrsctplib/usrsctp.h" 32 // Defined by "usrsctplib/usrsctp.h"
33 struct sockaddr_conn; 33 struct sockaddr_conn;
34 struct sctp_assoc_change; 34 struct sctp_assoc_change;
35 struct sctp_stream_reset_event; 35 struct sctp_stream_reset_event;
36 // Defined by <sys/socket.h> 36 // Defined by <sys/socket.h>
37 struct socket; 37 struct socket;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 virtual bool AddRecvStream(const StreamParams& sp); 137 virtual bool AddRecvStream(const StreamParams& sp);
138 virtual bool RemoveRecvStream(uint32_t ssrc); 138 virtual bool RemoveRecvStream(uint32_t ssrc);
139 139
140 // Called when Sctp gets data. The data may be a notification or data for 140 // Called when Sctp gets data. The data may be a notification or data for
141 // OnSctpInboundData. Called from the worker thread. 141 // OnSctpInboundData. Called from the worker thread.
142 virtual void OnMessage(rtc::Message* msg); 142 virtual void OnMessage(rtc::Message* msg);
143 // Send data down this channel (will be wrapped as SCTP packets then given to 143 // Send data down this channel (will be wrapped as SCTP packets then given to
144 // sctp that will then post the network interface by OnMessage). 144 // sctp that will then post the network interface by OnMessage).
145 // Returns true iff successful data somewhere on the send-queue/network. 145 // Returns true iff successful data somewhere on the send-queue/network.
146 virtual bool SendData(const SendDataParams& params, 146 virtual bool SendData(const SendDataParams& params,
147 const rtc::Buffer& payload, 147 const rtc::CopyOnWriteBuffer& payload,
148 SendDataResult* result = NULL); 148 SendDataResult* result = NULL);
149 // A packet is received from the network interface. Posted to OnMessage. 149 // A packet is received from the network interface. Posted to OnMessage.
150 virtual void OnPacketReceived(rtc::Buffer* packet, 150 virtual void OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
151 const rtc::PacketTime& packet_time); 151 const rtc::PacketTime& packet_time);
152 152
153 // Exposed to allow Post call from c-callbacks. 153 // Exposed to allow Post call from c-callbacks.
154 rtc::Thread* worker_thread() const { return worker_thread_; } 154 rtc::Thread* worker_thread() const { return worker_thread_; }
155 155
156 // Many of these things are unused by SCTP, but are needed to fulfill 156 // Many of these things are unused by SCTP, but are needed to fulfill
157 // the MediaChannel interface. 157 // the MediaChannel interface.
158 virtual void OnRtcpReceived(rtc::Buffer* packet, 158 virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet,
159 const rtc::PacketTime& packet_time) {} 159 const rtc::PacketTime& packet_time) {}
160 virtual void OnReadyToSend(bool ready) {} 160 virtual void OnReadyToSend(bool ready) {}
161 161
162 void OnSendThresholdCallback(); 162 void OnSendThresholdCallback();
163 // Helper for debugging. 163 // Helper for debugging.
164 void set_debug_name(const std::string& debug_name) { 164 void set_debug_name(const std::string& debug_name) {
165 debug_name_ = debug_name; 165 debug_name_ = debug_name;
166 } 166 }
167 const std::string& debug_name() const { return debug_name_; } 167 const std::string& debug_name() const { return debug_name_; }
168 const struct socket* socket() const { return sock_; } 168 const struct socket* socket() const { return sock_; }
(...skipping 16 matching lines...) Expand all
185 185
186 // Sends a SCTP_RESET_STREAM for all streams in closing_ssids_. 186 // Sends a SCTP_RESET_STREAM for all streams in closing_ssids_.
187 bool SendQueuedStreamResets(); 187 bool SendQueuedStreamResets();
188 188
189 // Adds a stream. 189 // Adds a stream.
190 bool AddStream(const StreamParams &sp); 190 bool AddStream(const StreamParams &sp);
191 // Queues a stream for reset. 191 // Queues a stream for reset.
192 bool ResetStream(uint32_t ssrc); 192 bool ResetStream(uint32_t ssrc);
193 193
194 // Called by OnMessage to send packet on the network. 194 // Called by OnMessage to send packet on the network.
195 void OnPacketFromSctpToNetwork(rtc::Buffer* buffer); 195 void OnPacketFromSctpToNetwork(rtc::CopyOnWriteBuffer* buffer);
196 // Called by OnMessage to decide what to do with the packet. 196 // Called by OnMessage to decide what to do with the packet.
197 void OnInboundPacketFromSctpToChannel(SctpInboundPacket* packet); 197 void OnInboundPacketFromSctpToChannel(SctpInboundPacket* packet);
198 void OnDataFromSctpToChannel(const ReceiveDataParams& params, 198 void OnDataFromSctpToChannel(const ReceiveDataParams& params,
199 rtc::Buffer* buffer); 199 const rtc::CopyOnWriteBuffer& buffer);
200 void OnNotificationFromSctp(rtc::Buffer* buffer); 200 void OnNotificationFromSctp(const rtc::CopyOnWriteBuffer& buffer);
201 void OnNotificationAssocChange(const sctp_assoc_change& change); 201 void OnNotificationAssocChange(const sctp_assoc_change& change);
202 202
203 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt); 203 void OnStreamResetEvent(const struct sctp_stream_reset_event* evt);
204 204
205 // Responsible for marshalling incoming data to the channels listeners, and 205 // Responsible for marshalling incoming data to the channels listeners, and
206 // outgoing data to the network interface. 206 // outgoing data to the network interface.
207 rtc::Thread* worker_thread_; 207 rtc::Thread* worker_thread_;
208 // The local and remote SCTP port to use. These are passed along the wire 208 // The local and remote SCTP port to use. These are passed along the wire
209 // and the listener and connector must be using the same port. It is not 209 // and the listener and connector must be using the same port. It is not
210 // related to the ports at the IP level. If set to -1, we default to 210 // related to the ports at the IP level. If set to -1, we default to
(...skipping 18 matching lines...) Expand all
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 human-readable name for debugging messages.
233 std::string debug_name_; 233 std::string 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

Powered by Google App Engine
This is Rietveld 408576698