| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 // VP9 denoising is disabled by default. | 421 // VP9 denoising is disabled by default. |
| 422 vp9_settings.denoisingOn = codec_default_denoising ? true : denoising; | 422 vp9_settings.denoisingOn = codec_default_denoising ? true : denoising; |
| 423 vp9_settings.frameDroppingOn = frame_dropping; | 423 vp9_settings.frameDroppingOn = frame_dropping; |
| 424 return new rtc::RefCountedObject< | 424 return new rtc::RefCountedObject< |
| 425 webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); | 425 webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); |
| 426 } | 426 } |
| 427 return nullptr; | 427 return nullptr; |
| 428 } | 428 } |
| 429 | 429 |
| 430 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() | 430 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() |
| 431 : default_recv_ssrc_(0), default_sink_(NULL) {} | 431 : default_sink_(nullptr) {} |
| 432 | 432 |
| 433 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc( | 433 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc( |
| 434 WebRtcVideoChannel2* channel, | 434 WebRtcVideoChannel2* channel, |
| 435 uint32_t ssrc) { | 435 uint32_t ssrc) { |
| 436 if (default_recv_ssrc_ != 0) { // Already one default stream, so replace it. | 436 rtc::Optional<uint32_t> default_recv_ssrc = |
| 437 channel->RemoveRecvStream(default_recv_ssrc_); | 437 channel->GetDefaultReceiveStreamSsrc(); |
| 438 default_recv_ssrc_ = 0; | 438 |
| 439 if (default_recv_ssrc) { |
| 440 LOG(LS_INFO) << "Destroying old default receive stream for SSRC=" << ssrc |
| 441 << "."; |
| 442 channel->RemoveRecvStream(*default_recv_ssrc); |
| 439 } | 443 } |
| 440 | 444 |
| 441 StreamParams sp; | 445 StreamParams sp; |
| 442 sp.ssrcs.push_back(ssrc); | 446 sp.ssrcs.push_back(ssrc); |
| 443 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; | 447 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; |
| 444 if (!channel->AddRecvStream(sp, true)) { | 448 if (!channel->AddRecvStream(sp, true)) { |
| 445 LOG(LS_WARNING) << "Could not create default receive stream."; | 449 LOG(LS_WARNING) << "Could not create default receive stream."; |
| 446 } | 450 } |
| 447 | 451 |
| 448 channel->SetSink(ssrc, default_sink_); | 452 channel->SetSink(ssrc, default_sink_); |
| 449 default_recv_ssrc_ = ssrc; | |
| 450 return kDeliverPacket; | 453 return kDeliverPacket; |
| 451 } | 454 } |
| 452 | 455 |
| 453 rtc::VideoSinkInterface<webrtc::VideoFrame>* | 456 rtc::VideoSinkInterface<webrtc::VideoFrame>* |
| 454 DefaultUnsignalledSsrcHandler::GetDefaultSink() const { | 457 DefaultUnsignalledSsrcHandler::GetDefaultSink() const { |
| 455 return default_sink_; | 458 return default_sink_; |
| 456 } | 459 } |
| 457 | 460 |
| 458 void DefaultUnsignalledSsrcHandler::SetDefaultSink( | 461 void DefaultUnsignalledSsrcHandler::SetDefaultSink( |
| 459 VideoMediaChannel* channel, | 462 WebRtcVideoChannel2* channel, |
| 460 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { | 463 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { |
| 461 default_sink_ = sink; | 464 default_sink_ = sink; |
| 462 if (default_recv_ssrc_ != 0) { | 465 rtc::Optional<uint32_t> default_recv_ssrc = |
| 463 channel->SetSink(default_recv_ssrc_, default_sink_); | 466 channel->GetDefaultReceiveStreamSsrc(); |
| 467 if (default_recv_ssrc) { |
| 468 channel->SetSink(*default_recv_ssrc, default_sink_); |
| 464 } | 469 } |
| 465 } | 470 } |
| 466 | 471 |
| 467 WebRtcVideoEngine2::WebRtcVideoEngine2() | 472 WebRtcVideoEngine2::WebRtcVideoEngine2() |
| 468 : initialized_(false), | 473 : initialized_(false), |
| 469 external_decoder_factory_(NULL), | 474 external_decoder_factory_(NULL), |
| 470 external_encoder_factory_(NULL) { | 475 external_encoder_factory_(NULL) { |
| 471 LOG(LS_INFO) << "WebRtcVideoEngine2::WebRtcVideoEngine2()"; | 476 LOG(LS_INFO) << "WebRtcVideoEngine2::WebRtcVideoEngine2()"; |
| 472 } | 477 } |
| 473 | 478 |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 | 1319 |
| 1315 return true; | 1320 return true; |
| 1316 } | 1321 } |
| 1317 | 1322 |
| 1318 bool WebRtcVideoChannel2::SetSink( | 1323 bool WebRtcVideoChannel2::SetSink( |
| 1319 uint32_t ssrc, | 1324 uint32_t ssrc, |
| 1320 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { | 1325 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { |
| 1321 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " " | 1326 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " " |
| 1322 << (sink ? "(ptr)" : "nullptr"); | 1327 << (sink ? "(ptr)" : "nullptr"); |
| 1323 if (ssrc == 0) { | 1328 if (ssrc == 0) { |
| 1329 // Do not hold |stream_crit_| here, since SetDefaultSink will call |
| 1330 // WebRtcVideoChannel2::GetDefaultReceiveStreamSsrc(). |
| 1324 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink); | 1331 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink); |
| 1325 return true; | 1332 return true; |
| 1326 } | 1333 } |
| 1327 | 1334 |
| 1328 rtc::CritScope stream_lock(&stream_crit_); | 1335 rtc::CritScope stream_lock(&stream_crit_); |
| 1329 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = | 1336 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = |
| 1330 receive_streams_.find(ssrc); | 1337 receive_streams_.find(ssrc); |
| 1331 if (it == receive_streams_.end()) { | 1338 if (it == receive_streams_.end()) { |
| 1332 return false; | 1339 return false; |
| 1333 } | 1340 } |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 | 1529 |
| 1523 // Speculative change to increase the outbound socket buffer size. | 1530 // Speculative change to increase the outbound socket buffer size. |
| 1524 // In b/15152257, we are seeing a significant number of packets discarded | 1531 // In b/15152257, we are seeing a significant number of packets discarded |
| 1525 // due to lack of socket buffer space, although it's not yet clear what the | 1532 // due to lack of socket buffer space, although it's not yet clear what the |
| 1526 // ideal value should be. | 1533 // ideal value should be. |
| 1527 MediaChannel::SetOption(NetworkInterface::ST_RTP, | 1534 MediaChannel::SetOption(NetworkInterface::ST_RTP, |
| 1528 rtc::Socket::OPT_SNDBUF, | 1535 rtc::Socket::OPT_SNDBUF, |
| 1529 kVideoRtpBufferSize); | 1536 kVideoRtpBufferSize); |
| 1530 } | 1537 } |
| 1531 | 1538 |
| 1539 rtc::Optional<uint32_t> WebRtcVideoChannel2::GetDefaultReceiveStreamSsrc() { |
| 1540 rtc::CritScope stream_lock(&stream_crit_); |
| 1541 rtc::Optional<uint32_t> ssrc; |
| 1542 for (auto it = receive_streams_.begin(); it != receive_streams_.end(); ++it) { |
| 1543 if (it->second->IsDefaultStream()) { |
| 1544 ssrc.emplace(it->first); |
| 1545 break; |
| 1546 } |
| 1547 } |
| 1548 return ssrc; |
| 1549 } |
| 1550 |
| 1532 bool WebRtcVideoChannel2::SendRtp(const uint8_t* data, | 1551 bool WebRtcVideoChannel2::SendRtp(const uint8_t* data, |
| 1533 size_t len, | 1552 size_t len, |
| 1534 const webrtc::PacketOptions& options) { | 1553 const webrtc::PacketOptions& options) { |
| 1535 rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen); | 1554 rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen); |
| 1536 rtc::PacketOptions rtc_options; | 1555 rtc::PacketOptions rtc_options; |
| 1537 rtc_options.packet_id = options.packet_id; | 1556 rtc_options.packet_id = options.packet_id; |
| 1538 return MediaChannel::SendPacket(&packet, rtc_options); | 1557 return MediaChannel::SendPacket(&packet, rtc_options); |
| 1539 } | 1558 } |
| 1540 | 1559 |
| 1541 bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) { | 1560 bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) { |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 rtx_mapping[video_codecs[i].codec.id] != | 2626 rtx_mapping[video_codecs[i].codec.id] != |
| 2608 ulpfec_config.red_payload_type) { | 2627 ulpfec_config.red_payload_type) { |
| 2609 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2628 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2610 } | 2629 } |
| 2611 } | 2630 } |
| 2612 | 2631 |
| 2613 return video_codecs; | 2632 return video_codecs; |
| 2614 } | 2633 } |
| 2615 | 2634 |
| 2616 } // namespace cricket | 2635 } // namespace cricket |
| OLD | NEW |