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 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 } | 326 } |
327 | 327 |
328 } // namespace | 328 } // namespace |
329 | 329 |
330 SctpDataEngine::SctpDataEngine() : codecs_(1, GetSctpDataCodec()) {} | 330 SctpDataEngine::SctpDataEngine() : codecs_(1, GetSctpDataCodec()) {} |
331 | 331 |
332 SctpDataEngine::~SctpDataEngine() {} | 332 SctpDataEngine::~SctpDataEngine() {} |
333 | 333 |
334 // Called on the worker thread. | 334 // Called on the worker thread. |
335 DataMediaChannel* SctpDataEngine::CreateChannel( | 335 DataMediaChannel* SctpDataEngine::CreateChannel( |
336 DataChannelType data_channel_type) { | 336 DataChannelType data_channel_type, |
| 337 const MediaConfig& config) { |
337 if (data_channel_type != DCT_SCTP) { | 338 if (data_channel_type != DCT_SCTP) { |
338 return NULL; | 339 return NULL; |
339 } | 340 } |
340 return new SctpDataMediaChannel(rtc::Thread::Current()); | 341 return new SctpDataMediaChannel(rtc::Thread::Current(), config); |
341 } | 342 } |
342 | 343 |
343 // static | 344 // static |
344 SctpDataMediaChannel* SctpDataMediaChannel::GetChannelFromSocket( | 345 SctpDataMediaChannel* SctpDataMediaChannel::GetChannelFromSocket( |
345 struct socket* sock) { | 346 struct socket* sock) { |
346 struct sockaddr* addrs = nullptr; | 347 struct sockaddr* addrs = nullptr; |
347 int naddrs = usrsctp_getladdrs(sock, 0, &addrs); | 348 int naddrs = usrsctp_getladdrs(sock, 0, &addrs); |
348 if (naddrs <= 0 || addrs[0].sa_family != AF_CONN) { | 349 if (naddrs <= 0 || addrs[0].sa_family != AF_CONN) { |
349 return nullptr; | 350 return nullptr; |
350 } | 351 } |
(...skipping 20 matching lines...) Expand all Loading... |
371 SctpDataMediaChannel* channel = GetChannelFromSocket(sock); | 372 SctpDataMediaChannel* channel = GetChannelFromSocket(sock); |
372 if (!channel) { | 373 if (!channel) { |
373 LOG(LS_ERROR) << "SendThresholdCallback: Failed to get channel for socket " | 374 LOG(LS_ERROR) << "SendThresholdCallback: Failed to get channel for socket " |
374 << sock; | 375 << sock; |
375 return 0; | 376 return 0; |
376 } | 377 } |
377 channel->OnSendThresholdCallback(); | 378 channel->OnSendThresholdCallback(); |
378 return 0; | 379 return 0; |
379 } | 380 } |
380 | 381 |
381 SctpDataMediaChannel::SctpDataMediaChannel(rtc::Thread* thread) | 382 SctpDataMediaChannel::SctpDataMediaChannel(rtc::Thread* thread, |
382 : worker_thread_(thread), | 383 const MediaConfig& config) |
| 384 : DataMediaChannel(config), |
| 385 worker_thread_(thread), |
383 local_port_(kSctpDefaultPort), | 386 local_port_(kSctpDefaultPort), |
384 remote_port_(kSctpDefaultPort), | 387 remote_port_(kSctpDefaultPort), |
385 sock_(NULL), | 388 sock_(NULL), |
386 sending_(false), | 389 sending_(false), |
387 receiving_(false), | 390 receiving_(false), |
388 debug_name_("SctpDataMediaChannel") { | 391 debug_name_("SctpDataMediaChannel") {} |
389 } | |
390 | 392 |
391 SctpDataMediaChannel::~SctpDataMediaChannel() { | 393 SctpDataMediaChannel::~SctpDataMediaChannel() { |
392 CloseSctpSocket(); | 394 CloseSctpSocket(); |
393 } | 395 } |
394 | 396 |
395 void SctpDataMediaChannel::OnSendThresholdCallback() { | 397 void SctpDataMediaChannel::OnSendThresholdCallback() { |
396 RTC_DCHECK(rtc::Thread::Current() == worker_thread_); | 398 RTC_DCHECK(rtc::Thread::Current() == worker_thread_); |
397 SignalReadyToSend(true); | 399 SignalReadyToSend(true); |
398 } | 400 } |
399 | 401 |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 } | 1059 } |
1058 case MSG_SCTPOUTBOUNDPACKET: { | 1060 case MSG_SCTPOUTBOUNDPACKET: { |
1059 std::unique_ptr<OutboundPacketMessage> pdata( | 1061 std::unique_ptr<OutboundPacketMessage> pdata( |
1060 static_cast<OutboundPacketMessage*>(msg->pdata)); | 1062 static_cast<OutboundPacketMessage*>(msg->pdata)); |
1061 OnPacketFromSctpToNetwork(pdata->data().get()); | 1063 OnPacketFromSctpToNetwork(pdata->data().get()); |
1062 break; | 1064 break; |
1063 } | 1065 } |
1064 } | 1066 } |
1065 } | 1067 } |
1066 } // namespace cricket | 1068 } // namespace cricket |
OLD | NEW |