OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 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 25 matching lines...) Expand all Loading... | |
36 std::unique_ptr<webrtc::AudioSinkInterface>* sink) { | 36 std::unique_ptr<webrtc::AudioSinkInterface>* sink) { |
37 channel->SetRawAudioSink(ssrc, std::move(*sink)); | 37 channel->SetRawAudioSink(ssrc, std::move(*sink)); |
38 return true; | 38 return true; |
39 } | 39 } |
40 | 40 |
41 struct SendPacketMessageData : public rtc::MessageData { | 41 struct SendPacketMessageData : public rtc::MessageData { |
42 rtc::CopyOnWriteBuffer packet; | 42 rtc::CopyOnWriteBuffer packet; |
43 rtc::PacketOptions options; | 43 rtc::PacketOptions options; |
44 }; | 44 }; |
45 | 45 |
46 #if defined(ENABLE_EXTERNAL_AUTH) | |
47 // Returns the named header extension if found among all extensions, | 46 // Returns the named header extension if found among all extensions, |
48 // nullptr otherwise. | 47 // nullptr otherwise. |
49 const webrtc::RtpExtension* FindHeaderExtension( | 48 const webrtc::RtpExtension* FindHeaderExtension( |
50 const std::vector<webrtc::RtpExtension>& extensions, | 49 const std::vector<webrtc::RtpExtension>& extensions, |
51 const std::string& uri) { | 50 const std::string& uri) { |
52 for (const auto& extension : extensions) { | 51 for (const auto& extension : extensions) { |
53 if (extension.uri == uri) | 52 if (extension.uri == uri) |
54 return &extension; | 53 return &extension; |
55 } | 54 } |
56 return nullptr; | 55 return nullptr; |
57 } | 56 } |
58 #endif | |
59 | 57 |
60 } // namespace | 58 } // namespace |
61 | 59 |
62 enum { | 60 enum { |
63 MSG_EARLYMEDIATIMEOUT = 1, | 61 MSG_EARLYMEDIATIMEOUT = 1, |
64 MSG_SEND_RTP_PACKET, | 62 MSG_SEND_RTP_PACKET, |
65 MSG_SEND_RTCP_PACKET, | 63 MSG_SEND_RTCP_PACKET, |
66 MSG_CHANNEL_ERROR, | 64 MSG_CHANNEL_ERROR, |
67 MSG_READYTOSENDDATA, | 65 MSG_READYTOSENDDATA, |
68 MSG_DATARECEIVED, | 66 MSG_DATARECEIVED, |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 TRACE_EVENT0("webrtc", "SRTP Encode"); | 727 TRACE_EVENT0("webrtc", "SRTP Encode"); |
730 bool res; | 728 bool res; |
731 uint8_t* data = packet->data(); | 729 uint8_t* data = packet->data(); |
732 int len = static_cast<int>(packet->size()); | 730 int len = static_cast<int>(packet->size()); |
733 if (!rtcp) { | 731 if (!rtcp) { |
734 // If ENABLE_EXTERNAL_AUTH flag is on then packet authentication is not done | 732 // If ENABLE_EXTERNAL_AUTH flag is on then packet authentication is not done |
735 // inside libsrtp for a RTP packet. A external HMAC module will be writing | 733 // inside libsrtp for a RTP packet. A external HMAC module will be writing |
736 // a fake HMAC value. This is ONLY done for a RTP packet. | 734 // a fake HMAC value. This is ONLY done for a RTP packet. |
737 // Socket layer will update rtp sendtime extension header if present in | 735 // Socket layer will update rtp sendtime extension header if present in |
738 // packet with current time before updating the HMAC. | 736 // packet with current time before updating the HMAC. |
739 #if !defined(ENABLE_EXTERNAL_AUTH) | 737 if (!srtp_filter_.AllowExternalAuth()) { |
740 res = srtp_filter_.ProtectRtp( | 738 res = srtp_filter_.ProtectRtp( |
741 data, len, static_cast<int>(packet->capacity()), &len); | 739 data, len, static_cast<int>(packet->capacity()), &len); |
742 #else | 740 } else { |
743 updated_options.packet_time_params.rtp_sendtime_extension_id = | 741 updated_options.packet_time_params.rtp_sendtime_extension_id = |
744 rtp_abs_sendtime_extn_id_; | 742 rtp_abs_sendtime_extn_id_; |
745 res = srtp_filter_.ProtectRtp( | 743 res = srtp_filter_.ProtectRtp( |
746 data, len, static_cast<int>(packet->capacity()), &len, | 744 data, len, static_cast<int>(packet->capacity()), &len, |
747 &updated_options.packet_time_params.srtp_packet_index); | 745 &updated_options.packet_time_params.srtp_packet_index); |
748 // If protection succeeds, let's get auth params from srtp. | 746 // If protection succeeds, let's get auth params from srtp. |
749 if (res) { | |
750 uint8_t* auth_key = NULL; | |
751 int key_len; | |
752 res = srtp_filter_.GetRtpAuthParams( | |
753 &auth_key, &key_len, | |
754 &updated_options.packet_time_params.srtp_auth_tag_len); | |
755 if (res) { | 747 if (res) { |
756 updated_options.packet_time_params.srtp_auth_key.resize(key_len); | 748 uint8_t* auth_key = NULL; |
757 updated_options.packet_time_params.srtp_auth_key.assign( | 749 int key_len; |
758 auth_key, auth_key + key_len); | 750 res = srtp_filter_.GetRtpAuthParams( |
751 &auth_key, &key_len, | |
752 &updated_options.packet_time_params.srtp_auth_tag_len); | |
753 if (res) { | |
754 updated_options.packet_time_params.srtp_auth_key.resize(key_len); | |
755 updated_options.packet_time_params.srtp_auth_key.assign( | |
756 auth_key, auth_key + key_len); | |
757 } | |
759 } | 758 } |
760 } | 759 } |
761 #endif | |
762 if (!res) { | 760 if (!res) { |
763 int seq_num = -1; | 761 int seq_num = -1; |
764 uint32_t ssrc = 0; | 762 uint32_t ssrc = 0; |
765 GetRtpSeqNum(data, len, &seq_num); | 763 GetRtpSeqNum(data, len, &seq_num); |
766 GetRtpSsrc(data, len, &ssrc); | 764 GetRtpSsrc(data, len, &ssrc); |
767 LOG(LS_ERROR) << "Failed to protect " << content_name_ | 765 LOG(LS_ERROR) << "Failed to protect " << content_name_ |
768 << " RTP packet: size=" << len | 766 << " RTP packet: size=" << len |
769 << ", seqnum=" << seq_num << ", SSRC=" << ssrc; | 767 << ", seqnum=" << seq_num << ", SSRC=" << ssrc; |
770 return false; | 768 return false; |
771 } | 769 } |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1453 } | 1451 } |
1454 remote_streams_ = streams; | 1452 remote_streams_ = streams; |
1455 return ret; | 1453 return ret; |
1456 } | 1454 } |
1457 | 1455 |
1458 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w( | 1456 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w( |
1459 const std::vector<webrtc::RtpExtension>& extensions) { | 1457 const std::vector<webrtc::RtpExtension>& extensions) { |
1460 // Absolute Send Time extension id is used only with external auth, | 1458 // Absolute Send Time extension id is used only with external auth, |
1461 // so do not bother searching for it and making asyncronious call to set | 1459 // so do not bother searching for it and making asyncronious call to set |
1462 // something that is not used. | 1460 // something that is not used. |
1463 #if defined(ENABLE_EXTERNAL_AUTH) | |
Taylor Brandstetter
2017/02/28 22:53:40
Replace #ifdef with "if (external_auth_enabled_)"?
| |
1464 const webrtc::RtpExtension* send_time_extension = | 1461 const webrtc::RtpExtension* send_time_extension = |
1465 FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri); | 1462 FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri); |
1466 int rtp_abs_sendtime_extn_id = | 1463 int rtp_abs_sendtime_extn_id = |
1467 send_time_extension ? send_time_extension->id : -1; | 1464 send_time_extension ? send_time_extension->id : -1; |
1468 invoker_.AsyncInvoke<void>( | 1465 invoker_.AsyncInvoke<void>( |
1469 RTC_FROM_HERE, network_thread_, | 1466 RTC_FROM_HERE, network_thread_, |
1470 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this, | 1467 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this, |
1471 rtp_abs_sendtime_extn_id)); | 1468 rtp_abs_sendtime_extn_id)); |
1472 #endif | |
1473 } | 1469 } |
1474 | 1470 |
1475 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( | 1471 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( |
1476 int rtp_abs_sendtime_extn_id) { | 1472 int rtp_abs_sendtime_extn_id) { |
1477 rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id; | 1473 rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id; |
1478 } | 1474 } |
1479 | 1475 |
1480 void BaseChannel::OnMessage(rtc::Message *pmsg) { | 1476 void BaseChannel::OnMessage(rtc::Message *pmsg) { |
1481 TRACE_EVENT0("webrtc", "BaseChannel::OnMessage"); | 1477 TRACE_EVENT0("webrtc", "BaseChannel::OnMessage"); |
1482 switch (pmsg->message_id) { | 1478 switch (pmsg->message_id) { |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2457 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, | 2453 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, |
2458 new DataChannelReadyToSendMessageData(writable)); | 2454 new DataChannelReadyToSendMessageData(writable)); |
2459 } | 2455 } |
2460 | 2456 |
2461 void RtpDataChannel::GetSrtpCryptoSuites_n( | 2457 void RtpDataChannel::GetSrtpCryptoSuites_n( |
2462 std::vector<int>* crypto_suites) const { | 2458 std::vector<int>* crypto_suites) const { |
2463 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); | 2459 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); |
2464 } | 2460 } |
2465 | 2461 |
2466 } // namespace cricket | 2462 } // namespace cricket |
OLD | NEW |