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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 kv.second->SetFeedbackParameters( | 890 kv.second->SetFeedbackParameters( |
891 HasNack(send_codec_->codec), HasRemb(send_codec_->codec), | 891 HasNack(send_codec_->codec), HasRemb(send_codec_->codec), |
892 HasTransportCc(send_codec_->codec), | 892 HasTransportCc(send_codec_->codec), |
893 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize | 893 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize |
894 : webrtc::RtcpMode::kCompound); | 894 : webrtc::RtcpMode::kCompound); |
895 } | 895 } |
896 } | 896 } |
897 if (changed_params.codec) { | 897 if (changed_params.codec) { |
898 bool red_was_disabled = red_disabled_by_remote_side_; | 898 bool red_was_disabled = red_disabled_by_remote_side_; |
899 red_disabled_by_remote_side_ = | 899 red_disabled_by_remote_side_ = |
900 changed_params.codec->fec.red_payload_type == -1; | 900 changed_params.codec->ulpfec.red_payload_type == -1; |
901 if (red_was_disabled != red_disabled_by_remote_side_) { | 901 if (red_was_disabled != red_disabled_by_remote_side_) { |
902 for (auto& kv : receive_streams_) { | 902 for (auto& kv : receive_streams_) { |
903 // In practice VideoChannel::SetRemoteContent appears to most of the | 903 // In practice VideoChannel::SetRemoteContent appears to most of the |
904 // time also call UpdateRemoteStreams, which recreates the receive | 904 // time also call UpdateRemoteStreams, which recreates the receive |
905 // streams. If that's always true this call isn't needed. | 905 // streams. If that's always true this call isn't needed. |
906 kv.second->SetFecDisabledRemotely(red_disabled_by_remote_side_); | 906 kv.second->SetUlpfecDisabledRemotely(red_disabled_by_remote_side_); |
907 } | 907 } |
908 } | 908 } |
909 } | 909 } |
910 } | 910 } |
911 send_params_ = params; | 911 send_params_ = params; |
912 return true; | 912 return true; |
913 } | 913 } |
914 | 914 |
915 webrtc::RtpParameters WebRtcVideoChannel2::GetRtpSendParameters( | 915 webrtc::RtpParameters WebRtcVideoChannel2::GetRtpSendParameters( |
916 uint32_t ssrc) const { | 916 uint32_t ssrc) const { |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 return; | 1468 return; |
1469 } | 1469 } |
1470 | 1470 |
1471 // See if this payload_type is registered as one that usually gets its own | 1471 // See if this payload_type is registered as one that usually gets its own |
1472 // SSRC (RTX) or at least is safe to drop either way (ULPFEC). If it is, and | 1472 // SSRC (RTX) or at least is safe to drop either way (ULPFEC). If it is, and |
1473 // it wasn't handled above by DeliverPacket, that means we don't know what | 1473 // it wasn't handled above by DeliverPacket, that means we don't know what |
1474 // stream it associates with, and we shouldn't ever create an implicit channel | 1474 // stream it associates with, and we shouldn't ever create an implicit channel |
1475 // for these. | 1475 // for these. |
1476 for (auto& codec : recv_codecs_) { | 1476 for (auto& codec : recv_codecs_) { |
1477 if (payload_type == codec.rtx_payload_type || | 1477 if (payload_type == codec.rtx_payload_type || |
1478 payload_type == codec.fec.red_rtx_payload_type || | 1478 payload_type == codec.ulpfec.red_rtx_payload_type || |
1479 payload_type == codec.fec.ulpfec_payload_type) { | 1479 payload_type == codec.ulpfec.ulpfec_payload_type) { |
1480 return; | 1480 return; |
1481 } | 1481 } |
1482 } | 1482 } |
1483 | 1483 |
1484 switch (unsignalled_ssrc_handler_->OnUnsignalledSsrc(this, ssrc)) { | 1484 switch (unsignalled_ssrc_handler_->OnUnsignalledSsrc(this, ssrc)) { |
1485 case UnsignalledSsrcHandler::kDropPacket: | 1485 case UnsignalledSsrcHandler::kDropPacket: |
1486 return; | 1486 return; |
1487 case UnsignalledSsrcHandler::kDeliverPacket: | 1487 case UnsignalledSsrcHandler::kDeliverPacket: |
1488 break; | 1488 break; |
1489 } | 1489 } |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 AllocatedEncoder new_encoder = CreateVideoEncoder(codec_settings.codec); | 1839 AllocatedEncoder new_encoder = CreateVideoEncoder(codec_settings.codec); |
1840 parameters_.config.encoder_settings.encoder = new_encoder.encoder; | 1840 parameters_.config.encoder_settings.encoder = new_encoder.encoder; |
1841 parameters_.config.encoder_settings.full_overuse_time = new_encoder.external; | 1841 parameters_.config.encoder_settings.full_overuse_time = new_encoder.external; |
1842 parameters_.config.encoder_settings.payload_name = codec_settings.codec.name; | 1842 parameters_.config.encoder_settings.payload_name = codec_settings.codec.name; |
1843 parameters_.config.encoder_settings.payload_type = codec_settings.codec.id; | 1843 parameters_.config.encoder_settings.payload_type = codec_settings.codec.id; |
1844 if (new_encoder.external) { | 1844 if (new_encoder.external) { |
1845 webrtc::VideoCodecType type = CodecTypeFromName(codec_settings.codec.name); | 1845 webrtc::VideoCodecType type = CodecTypeFromName(codec_settings.codec.name); |
1846 parameters_.config.encoder_settings.internal_source = | 1846 parameters_.config.encoder_settings.internal_source = |
1847 external_encoder_factory_->EncoderTypeHasInternalSource(type); | 1847 external_encoder_factory_->EncoderTypeHasInternalSource(type); |
1848 } | 1848 } |
1849 parameters_.config.rtp.fec = codec_settings.fec; | 1849 parameters_.config.rtp.ulpfec = codec_settings.ulpfec; |
1850 | 1850 |
1851 // Set RTX payload type if RTX is enabled. | 1851 // Set RTX payload type if RTX is enabled. |
1852 if (!parameters_.config.rtp.rtx.ssrcs.empty()) { | 1852 if (!parameters_.config.rtp.rtx.ssrcs.empty()) { |
1853 if (codec_settings.rtx_payload_type == -1) { | 1853 if (codec_settings.rtx_payload_type == -1) { |
1854 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " | 1854 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " |
1855 "payload type. Ignoring."; | 1855 "payload type. Ignoring."; |
1856 parameters_.config.rtp.rtx.ssrcs.clear(); | 1856 parameters_.config.rtp.rtx.ssrcs.clear(); |
1857 } else { | 1857 } else { |
1858 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; | 1858 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; |
1859 } | 1859 } |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 | 2387 |
2388 webrtc::VideoReceiveStream::Decoder decoder; | 2388 webrtc::VideoReceiveStream::Decoder decoder; |
2389 decoder.decoder = allocated_decoder.decoder; | 2389 decoder.decoder = allocated_decoder.decoder; |
2390 decoder.payload_type = recv_codecs[i].codec.id; | 2390 decoder.payload_type = recv_codecs[i].codec.id; |
2391 decoder.payload_name = recv_codecs[i].codec.name; | 2391 decoder.payload_name = recv_codecs[i].codec.name; |
2392 ConfigureDecoderSpecifics(&decoder, recv_codecs[i].codec); | 2392 ConfigureDecoderSpecifics(&decoder, recv_codecs[i].codec); |
2393 config_.decoders.push_back(decoder); | 2393 config_.decoders.push_back(decoder); |
2394 } | 2394 } |
2395 | 2395 |
2396 // TODO(pbos): Reconfigure RTX based on incoming recv_codecs. | 2396 // TODO(pbos): Reconfigure RTX based on incoming recv_codecs. |
2397 config_.rtp.fec = recv_codecs.front().fec; | 2397 config_.rtp.ulpfec = recv_codecs.front().ulpfec; |
2398 config_.rtp.nack.rtp_history_ms = | 2398 config_.rtp.nack.rtp_history_ms = |
2399 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0; | 2399 HasNack(recv_codecs.begin()->codec) ? kNackHistoryMs : 0; |
2400 } | 2400 } |
2401 | 2401 |
2402 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc( | 2402 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetLocalSsrc( |
2403 uint32_t local_ssrc) { | 2403 uint32_t local_ssrc) { |
2404 // TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You | 2404 // TODO(pbos): Consider turning this sanity check into a RTC_DCHECK. You |
2405 // should not be able to create a sender with the same SSRC as a receiver, but | 2405 // should not be able to create a sender with the same SSRC as a receiver, but |
2406 // right now this can't be done due to unittests depending on receiving what | 2406 // right now this can't be done due to unittests depending on receiving what |
2407 // they are sending from the same MediaChannel. | 2407 // they are sending from the same MediaChannel. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 ClearDecoders(&old_decoders); | 2464 ClearDecoders(&old_decoders); |
2465 } | 2465 } |
2466 } | 2466 } |
2467 | 2467 |
2468 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { | 2468 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { |
2469 if (stream_ != NULL) { | 2469 if (stream_ != NULL) { |
2470 call_->DestroyVideoReceiveStream(stream_); | 2470 call_->DestroyVideoReceiveStream(stream_); |
2471 } | 2471 } |
2472 webrtc::VideoReceiveStream::Config config = config_.Copy(); | 2472 webrtc::VideoReceiveStream::Config config = config_.Copy(); |
2473 if (red_disabled_by_remote_side_) { | 2473 if (red_disabled_by_remote_side_) { |
2474 config.rtp.fec.red_payload_type = -1; | 2474 config.rtp.ulpfec.red_payload_type = -1; |
2475 config.rtp.fec.ulpfec_payload_type = -1; | 2475 config.rtp.ulpfec.ulpfec_payload_type = -1; |
2476 config.rtp.fec.red_rtx_payload_type = -1; | 2476 config.rtp.ulpfec.red_rtx_payload_type = -1; |
2477 } | 2477 } |
2478 stream_ = call_->CreateVideoReceiveStream(std::move(config)); | 2478 stream_ = call_->CreateVideoReceiveStream(std::move(config)); |
2479 stream_->Start(); | 2479 stream_->Start(); |
2480 } | 2480 } |
2481 | 2481 |
2482 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( | 2482 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( |
2483 std::vector<AllocatedDecoder>* allocated_decoders) { | 2483 std::vector<AllocatedDecoder>* allocated_decoders) { |
2484 for (size_t i = 0; i < allocated_decoders->size(); ++i) { | 2484 for (size_t i = 0; i < allocated_decoders->size(); ++i) { |
2485 if ((*allocated_decoders)[i].external) { | 2485 if ((*allocated_decoders)[i].external) { |
2486 external_decoder_factory_->DestroyVideoDecoder( | 2486 external_decoder_factory_->DestroyVideoDecoder( |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; | 2577 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; |
2578 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; | 2578 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; |
2579 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; | 2579 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; |
2580 | 2580 |
2581 if (log_stats) | 2581 if (log_stats) |
2582 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis()); | 2582 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis()); |
2583 | 2583 |
2584 return info; | 2584 return info; |
2585 } | 2585 } |
2586 | 2586 |
2587 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetFecDisabledRemotely( | 2587 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetUlpfecDisabledRemotely( |
2588 bool disable) { | 2588 bool disable) { |
2589 red_disabled_by_remote_side_ = disable; | 2589 red_disabled_by_remote_side_ = disable; |
2590 RecreateWebRtcStream(); | 2590 RecreateWebRtcStream(); |
2591 } | 2591 } |
2592 | 2592 |
2593 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() | 2593 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() |
2594 : rtx_payload_type(-1) {} | 2594 : rtx_payload_type(-1) {} |
2595 | 2595 |
2596 bool WebRtcVideoChannel2::VideoCodecSettings::operator==( | 2596 bool WebRtcVideoChannel2::VideoCodecSettings::operator==( |
2597 const WebRtcVideoChannel2::VideoCodecSettings& other) const { | 2597 const WebRtcVideoChannel2::VideoCodecSettings& other) const { |
2598 return codec == other.codec && | 2598 return codec == other.codec && |
2599 fec.ulpfec_payload_type == other.fec.ulpfec_payload_type && | 2599 ulpfec.ulpfec_payload_type == other.ulpfec.ulpfec_payload_type && |
2600 fec.red_payload_type == other.fec.red_payload_type && | 2600 ulpfec.red_payload_type == other.ulpfec.red_payload_type && |
2601 fec.red_rtx_payload_type == other.fec.red_rtx_payload_type && | 2601 ulpfec.red_rtx_payload_type == other.ulpfec.red_rtx_payload_type && |
2602 rtx_payload_type == other.rtx_payload_type; | 2602 rtx_payload_type == other.rtx_payload_type; |
2603 } | 2603 } |
2604 | 2604 |
2605 bool WebRtcVideoChannel2::VideoCodecSettings::operator!=( | 2605 bool WebRtcVideoChannel2::VideoCodecSettings::operator!=( |
2606 const WebRtcVideoChannel2::VideoCodecSettings& other) const { | 2606 const WebRtcVideoChannel2::VideoCodecSettings& other) const { |
2607 return !(*this == other); | 2607 return !(*this == other); |
2608 } | 2608 } |
2609 | 2609 |
2610 std::vector<WebRtcVideoChannel2::VideoCodecSettings> | 2610 std::vector<WebRtcVideoChannel2::VideoCodecSettings> |
2611 WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs) { | 2611 WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs) { |
2612 RTC_DCHECK(!codecs.empty()); | 2612 RTC_DCHECK(!codecs.empty()); |
2613 | 2613 |
2614 std::vector<VideoCodecSettings> video_codecs; | 2614 std::vector<VideoCodecSettings> video_codecs; |
2615 std::map<int, bool> payload_used; | 2615 std::map<int, bool> payload_used; |
2616 std::map<int, VideoCodec::CodecType> payload_codec_type; | 2616 std::map<int, VideoCodec::CodecType> payload_codec_type; |
2617 // |rtx_mapping| maps video payload type to rtx payload type. | 2617 // |rtx_mapping| maps video payload type to rtx payload type. |
2618 std::map<int, int> rtx_mapping; | 2618 std::map<int, int> rtx_mapping; |
2619 | 2619 |
2620 webrtc::FecConfig fec_settings; | 2620 webrtc::UlpfecConfig ulpfec_config; |
2621 | 2621 |
2622 for (size_t i = 0; i < codecs.size(); ++i) { | 2622 for (size_t i = 0; i < codecs.size(); ++i) { |
2623 const VideoCodec& in_codec = codecs[i]; | 2623 const VideoCodec& in_codec = codecs[i]; |
2624 int payload_type = in_codec.id; | 2624 int payload_type = in_codec.id; |
2625 | 2625 |
2626 if (payload_used[payload_type]) { | 2626 if (payload_used[payload_type]) { |
2627 LOG(LS_ERROR) << "Payload type already registered: " | 2627 LOG(LS_ERROR) << "Payload type already registered: " |
2628 << in_codec.ToString(); | 2628 << in_codec.ToString(); |
2629 return std::vector<VideoCodecSettings>(); | 2629 return std::vector<VideoCodecSettings>(); |
2630 } | 2630 } |
2631 payload_used[payload_type] = true; | 2631 payload_used[payload_type] = true; |
2632 payload_codec_type[payload_type] = in_codec.GetCodecType(); | 2632 payload_codec_type[payload_type] = in_codec.GetCodecType(); |
2633 | 2633 |
2634 switch (in_codec.GetCodecType()) { | 2634 switch (in_codec.GetCodecType()) { |
2635 case VideoCodec::CODEC_RED: { | 2635 case VideoCodec::CODEC_RED: { |
2636 // RED payload type, should not have duplicates. | 2636 // RED payload type, should not have duplicates. |
2637 RTC_DCHECK(fec_settings.red_payload_type == -1); | 2637 RTC_DCHECK(ulpfec_config.red_payload_type == -1); |
2638 fec_settings.red_payload_type = in_codec.id; | 2638 ulpfec_config.red_payload_type = in_codec.id; |
2639 continue; | 2639 continue; |
2640 } | 2640 } |
2641 | 2641 |
2642 case VideoCodec::CODEC_ULPFEC: { | 2642 case VideoCodec::CODEC_ULPFEC: { |
2643 // ULPFEC payload type, should not have duplicates. | 2643 // ULPFEC payload type, should not have duplicates. |
2644 RTC_DCHECK(fec_settings.ulpfec_payload_type == -1); | 2644 RTC_DCHECK(ulpfec_config.ulpfec_payload_type == -1); |
2645 fec_settings.ulpfec_payload_type = in_codec.id; | 2645 ulpfec_config.ulpfec_payload_type = in_codec.id; |
2646 continue; | 2646 continue; |
2647 } | 2647 } |
2648 | 2648 |
2649 case VideoCodec::CODEC_RTX: { | 2649 case VideoCodec::CODEC_RTX: { |
2650 int associated_payload_type; | 2650 int associated_payload_type; |
2651 if (!in_codec.GetParam(kCodecParamAssociatedPayloadType, | 2651 if (!in_codec.GetParam(kCodecParamAssociatedPayloadType, |
2652 &associated_payload_type) || | 2652 &associated_payload_type) || |
2653 !IsValidRtpPayloadType(associated_payload_type)) { | 2653 !IsValidRtpPayloadType(associated_payload_type)) { |
2654 LOG(LS_ERROR) | 2654 LOG(LS_ERROR) |
2655 << "RTX codec with invalid or no associated payload type: " | 2655 << "RTX codec with invalid or no associated payload type: " |
(...skipping 22 matching lines...) Expand all Loading... |
2678 if (!payload_used[it->first]) { | 2678 if (!payload_used[it->first]) { |
2679 LOG(LS_ERROR) << "RTX mapped to payload not in codec list."; | 2679 LOG(LS_ERROR) << "RTX mapped to payload not in codec list."; |
2680 return std::vector<VideoCodecSettings>(); | 2680 return std::vector<VideoCodecSettings>(); |
2681 } | 2681 } |
2682 if (payload_codec_type[it->first] != VideoCodec::CODEC_VIDEO && | 2682 if (payload_codec_type[it->first] != VideoCodec::CODEC_VIDEO && |
2683 payload_codec_type[it->first] != VideoCodec::CODEC_RED) { | 2683 payload_codec_type[it->first] != VideoCodec::CODEC_RED) { |
2684 LOG(LS_ERROR) << "RTX not mapped to regular video codec or RED codec."; | 2684 LOG(LS_ERROR) << "RTX not mapped to regular video codec or RED codec."; |
2685 return std::vector<VideoCodecSettings>(); | 2685 return std::vector<VideoCodecSettings>(); |
2686 } | 2686 } |
2687 | 2687 |
2688 if (it->first == fec_settings.red_payload_type) { | 2688 if (it->first == ulpfec_config.red_payload_type) { |
2689 fec_settings.red_rtx_payload_type = it->second; | 2689 ulpfec_config.red_rtx_payload_type = it->second; |
2690 } | 2690 } |
2691 } | 2691 } |
2692 | 2692 |
2693 for (size_t i = 0; i < video_codecs.size(); ++i) { | 2693 for (size_t i = 0; i < video_codecs.size(); ++i) { |
2694 video_codecs[i].fec = fec_settings; | 2694 video_codecs[i].ulpfec = ulpfec_config; |
2695 if (rtx_mapping[video_codecs[i].codec.id] != 0 && | 2695 if (rtx_mapping[video_codecs[i].codec.id] != 0 && |
2696 rtx_mapping[video_codecs[i].codec.id] != | 2696 rtx_mapping[video_codecs[i].codec.id] != |
2697 fec_settings.red_payload_type) { | 2697 ulpfec_config.red_payload_type) { |
2698 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2698 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2699 } | 2699 } |
2700 } | 2700 } |
2701 | 2701 |
2702 return video_codecs; | 2702 return video_codecs; |
2703 } | 2703 } |
2704 | 2704 |
2705 } // namespace cricket | 2705 } // namespace cricket |
OLD | NEW |