OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 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 #include "webrtc/api/datachannel.h" | 11 #include "webrtc/api/datachannel.h" |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "webrtc/api/sctputils.h" | 16 #include "webrtc/api/sctputils.h" |
17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
18 #include "webrtc/base/refcount.h" | 18 #include "webrtc/base/refcount.h" |
19 #include "webrtc/media/sctp/sctpdataengine.h" | 19 #include "webrtc/media/sctp/sctptransportinternal.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 static size_t kMaxQueuedReceivedDataBytes = 16 * 1024 * 1024; | 23 static size_t kMaxQueuedReceivedDataBytes = 16 * 1024 * 1024; |
24 static size_t kMaxQueuedSendDataBytes = 16 * 1024 * 1024; | 24 static size_t kMaxQueuedSendDataBytes = 16 * 1024 * 1024; |
25 | 25 |
26 enum { | 26 enum { |
27 MSG_CHANNELREADY, | 27 MSG_CHANNELREADY, |
28 }; | 28 }; |
29 | 29 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 321 } |
322 | 322 |
323 void DataChannel::OnMessage(rtc::Message* msg) { | 323 void DataChannel::OnMessage(rtc::Message* msg) { |
324 switch (msg->message_id) { | 324 switch (msg->message_id) { |
325 case MSG_CHANNELREADY: | 325 case MSG_CHANNELREADY: |
326 OnChannelReady(true); | 326 OnChannelReady(true); |
327 break; | 327 break; |
328 } | 328 } |
329 } | 329 } |
330 | 330 |
331 void DataChannel::OnDataReceived(cricket::DataChannel* channel, | 331 void DataChannel::OnDataReceived(const cricket::ReceiveDataParams& params, |
332 const cricket::ReceiveDataParams& params, | |
333 const rtc::CopyOnWriteBuffer& payload) { | 332 const rtc::CopyOnWriteBuffer& payload) { |
334 uint32_t expected_ssrc = | 333 uint32_t expected_ssrc = |
335 (data_channel_type_ == cricket::DCT_RTP) ? receive_ssrc_ : config_.id; | 334 (data_channel_type_ == cricket::DCT_RTP) ? receive_ssrc_ : config_.id; |
336 if (params.ssrc != expected_ssrc) { | 335 if (params.ssrc != expected_ssrc) { |
337 return; | 336 return; |
338 } | 337 } |
339 | 338 |
340 if (params.type == cricket::DMT_CONTROL) { | 339 if (params.type == cricket::DMT_CONTROL) { |
341 ASSERT(data_channel_type_ == cricket::DCT_SCTP); | 340 ASSERT(data_channel_type_ == cricket::DCT_SCTP); |
342 if (handshake_state_ != kHandshakeWaitingForAck) { | 341 if (handshake_state_ != kHandshakeWaitingForAck) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 if (data_channel_type_ != cricket::DCT_RTP) { | 382 if (data_channel_type_ != cricket::DCT_RTP) { |
384 Close(); | 383 Close(); |
385 } | 384 } |
386 | 385 |
387 return; | 386 return; |
388 } | 387 } |
389 queued_received_data_.Push(buffer.release()); | 388 queued_received_data_.Push(buffer.release()); |
390 } | 389 } |
391 } | 390 } |
392 | 391 |
393 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { | 392 void DataChannel::OnStreamClosedRemotely(int sid) { |
394 if (data_channel_type_ == cricket::DCT_SCTP && | 393 if (data_channel_type_ == cricket::DCT_SCTP && sid == config_.id) { |
395 sid == static_cast<uint32_t>(config_.id)) { | |
396 Close(); | 394 Close(); |
397 } | 395 } |
398 } | 396 } |
399 | 397 |
400 void DataChannel::OnChannelReady(bool writable) { | 398 void DataChannel::OnChannelReady(bool writable) { |
401 writable_ = writable; | 399 writable_ = writable; |
402 if (!writable) { | 400 if (!writable) { |
403 return; | 401 return; |
404 } | 402 } |
405 | 403 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 QueueControlMessage(buffer); | 642 QueueControlMessage(buffer); |
645 } else { | 643 } else { |
646 LOG(LS_ERROR) << "Closing the DataChannel due to a failure to send" | 644 LOG(LS_ERROR) << "Closing the DataChannel due to a failure to send" |
647 << " the CONTROL message, send_result = " << send_result; | 645 << " the CONTROL message, send_result = " << send_result; |
648 Close(); | 646 Close(); |
649 } | 647 } |
650 return retval; | 648 return retval; |
651 } | 649 } |
652 | 650 |
653 } // namespace webrtc | 651 } // namespace webrtc |
OLD | NEW |