OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 for (size_t i = 0; i < mapped_codecs.size(); ++i) { | 848 for (size_t i = 0; i < mapped_codecs.size(); ++i) { |
849 const VideoCodecSettings& codec = mapped_codecs[i]; | 849 const VideoCodecSettings& codec = mapped_codecs[i]; |
850 if (CodecIsInternallySupported(codec.codec.name) || | 850 if (CodecIsInternallySupported(codec.codec.name) || |
851 CodecIsExternallySupported(codec.codec.name)) { | 851 CodecIsExternallySupported(codec.codec.name)) { |
852 supported_codecs.push_back(codec); | 852 supported_codecs.push_back(codec); |
853 } | 853 } |
854 } | 854 } |
855 return supported_codecs; | 855 return supported_codecs; |
856 } | 856 } |
857 | 857 |
| 858 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { |
| 859 // TODO(pbos): Refactor this to only recreate the send streams once |
| 860 // instead of 4 times. |
| 861 return (SetSendCodecs(params.codecs) && |
| 862 SetSendRtpHeaderExtensions(params.extensions) && |
| 863 SetMaxSendBandwidth(params.max_bandwidth_bps) && |
| 864 SetOptions(params.options)); |
| 865 } |
| 866 |
| 867 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { |
| 868 // TODO(pbos): Refactor this to only recreate the recv streams once |
| 869 // instead of twice. |
| 870 return (SetRecvCodecs(params.codecs) && |
| 871 SetRecvRtpHeaderExtensions(params.extensions)); |
| 872 } |
| 873 |
858 bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector<VideoCodec>& codecs) { | 874 bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector<VideoCodec>& codecs) { |
859 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvCodecs"); | 875 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvCodecs"); |
860 LOG(LS_INFO) << "SetRecvCodecs: " << CodecVectorToString(codecs); | 876 LOG(LS_INFO) << "SetRecvCodecs: " << CodecVectorToString(codecs); |
861 if (!ValidateCodecFormats(codecs)) { | 877 if (!ValidateCodecFormats(codecs)) { |
862 return false; | 878 return false; |
863 } | 879 } |
864 | 880 |
865 const std::vector<VideoCodecSettings> mapped_codecs = MapCodecs(codecs); | 881 const std::vector<VideoCodecSettings> mapped_codecs = MapCodecs(codecs); |
866 if (mapped_codecs.empty()) { | 882 if (mapped_codecs.empty()) { |
867 LOG(LS_ERROR) << "SetRecvCodecs called without any video codecs."; | 883 LOG(LS_ERROR) << "SetRecvCodecs called without any video codecs."; |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 for (auto& kv : send_streams_) | 1543 for (auto& kv : send_streams_) |
1528 kv.second->SetMaxBitrateBps(max_bitrate_bps); | 1544 kv.second->SetMaxBitrateBps(max_bitrate_bps); |
1529 return true; | 1545 return true; |
1530 } | 1546 } |
1531 | 1547 |
1532 bool WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { | 1548 bool WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { |
1533 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetOptions"); | 1549 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetOptions"); |
1534 LOG(LS_INFO) << "SetOptions: " << options.ToString(); | 1550 LOG(LS_INFO) << "SetOptions: " << options.ToString(); |
1535 VideoOptions old_options = options_; | 1551 VideoOptions old_options = options_; |
1536 options_.SetAll(options); | 1552 options_.SetAll(options); |
1537 if (options_ == old_options) { | 1553 |
| 1554 if (options_ == old_options && options_set_) { |
1538 // No new options to set. | 1555 // No new options to set. |
1539 return true; | 1556 return true; |
1540 } | 1557 } |
1541 { | 1558 { |
1542 rtc::CritScope lock(&capturer_crit_); | 1559 rtc::CritScope lock(&capturer_crit_); |
1543 options_.cpu_overuse_detection.Get(&signal_cpu_adaptation_); | 1560 options_.cpu_overuse_detection.Get(&signal_cpu_adaptation_); |
1544 } | 1561 } |
| 1562 |
1545 rtc::DiffServCodePoint dscp = options_.dscp.GetWithDefaultIfUnset(false) | 1563 rtc::DiffServCodePoint dscp = options_.dscp.GetWithDefaultIfUnset(false) |
1546 ? rtc::DSCP_AF41 | 1564 ? rtc::DSCP_AF41 |
1547 : rtc::DSCP_DEFAULT; | 1565 : rtc::DSCP_DEFAULT; |
1548 MediaChannel::SetDscp(dscp); | 1566 MediaChannel::SetDscp(dscp); |
| 1567 |
1549 rtc::CritScope stream_lock(&stream_crit_); | 1568 rtc::CritScope stream_lock(&stream_crit_); |
1550 for (std::map<uint32, WebRtcVideoSendStream*>::iterator it = | 1569 for (std::map<uint32, WebRtcVideoSendStream*>::iterator it = |
1551 send_streams_.begin(); | 1570 send_streams_.begin(); |
1552 it != send_streams_.end(); | 1571 it != send_streams_.end(); |
1553 ++it) { | 1572 ++it) { |
1554 it->second->SetOptions(options_); | 1573 it->second->SetOptions(options_); |
1555 } | 1574 } |
| 1575 options_set_ = true; |
1556 return true; | 1576 return true; |
1557 } | 1577 } |
1558 | 1578 |
1559 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { | 1579 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { |
1560 MediaChannel::SetInterface(iface); | 1580 MediaChannel::SetInterface(iface); |
1561 // Set the RTP recv/send buffer to a bigger size | 1581 // Set the RTP recv/send buffer to a bigger size |
1562 MediaChannel::SetOption(NetworkInterface::ST_RTP, | 1582 MediaChannel::SetOption(NetworkInterface::ST_RTP, |
1563 rtc::Socket::OPT_RCVBUF, | 1583 rtc::Socket::OPT_RCVBUF, |
1564 kVideoRtpBufferSize); | 1584 kVideoRtpBufferSize); |
1565 | 1585 |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2610 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2630 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2611 } | 2631 } |
2612 } | 2632 } |
2613 | 2633 |
2614 return video_codecs; | 2634 return video_codecs; |
2615 } | 2635 } |
2616 | 2636 |
2617 } // namespace cricket | 2637 } // namespace cricket |
2618 | 2638 |
2619 #endif // HAVE_WEBRTC_VIDEO | 2639 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |