Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: talk/session/media/mediasession.cc

Issue 1473013002: Fixing direction attribute in answer for non-RTP protocols. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/peerconnection_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 if (!target_cryptos) { 626 if (!target_cryptos) {
627 return; 627 return;
628 } 628 }
629 target_cryptos->erase(std::remove_if(target_cryptos->begin(), 629 target_cryptos->erase(std::remove_if(target_cryptos->begin(),
630 target_cryptos->end(), 630 target_cryptos->end(),
631 bind2nd(ptr_fun(CryptoNotFound), 631 bind2nd(ptr_fun(CryptoNotFound),
632 &filter)), 632 &filter)),
633 target_cryptos->end()); 633 target_cryptos->end());
634 } 634 }
635 635
636 static bool IsRtpProtocol(const std::string& protocol) {
637 return protocol.empty() ||
638 (protocol.find(cricket::kMediaProtocolRtpPrefix) != std::string::npos);
639 }
640
636 static bool IsRtpContent(SessionDescription* sdesc, 641 static bool IsRtpContent(SessionDescription* sdesc,
637 const std::string& content_name) { 642 const std::string& content_name) {
638 bool is_rtp = false; 643 bool is_rtp = false;
639 ContentInfo* content = sdesc->GetContentByName(content_name); 644 ContentInfo* content = sdesc->GetContentByName(content_name);
640 if (IsMediaContent(content)) { 645 if (IsMediaContent(content)) {
641 MediaContentDescription* media_desc = 646 MediaContentDescription* media_desc =
642 static_cast<MediaContentDescription*>(content->description); 647 static_cast<MediaContentDescription*>(content->description);
643 if (!media_desc) { 648 if (!media_desc) {
644 return false; 649 return false;
645 } 650 }
646 is_rtp = media_desc->protocol().empty() || 651 is_rtp = IsRtpProtocol(media_desc->protocol());
647 (media_desc->protocol().find(cricket::kMediaProtocolRtpPrefix) !=
648 std::string::npos);
649 } 652 }
650 return is_rtp; 653 return is_rtp;
651 } 654 }
652 655
653 // Updates the crypto parameters of the |sdesc| according to the given 656 // Updates the crypto parameters of the |sdesc| according to the given
654 // |bundle_group|. The crypto parameters of all the contents within the 657 // |bundle_group|. The crypto parameters of all the contents within the
655 // |bundle_group| should be updated to use the common subset of the 658 // |bundle_group| should be updated to use the common subset of the
656 // available cryptos. 659 // available cryptos.
657 static bool UpdateCryptoParamsForBundle(const ContentGroup& bundle_group, 660 static bool UpdateCryptoParamsForBundle(const ContentGroup& bundle_group,
658 SessionDescription* sdesc) { 661 SessionDescription* sdesc) {
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 // Make sure the answer media content direction is per default set as 1063 // Make sure the answer media content direction is per default set as
1061 // described in RFC3264 section 6.1. 1064 // described in RFC3264 section 6.1.
1062 switch (offer->direction()) { 1065 switch (offer->direction()) {
1063 case MD_INACTIVE: 1066 case MD_INACTIVE:
1064 answer->set_direction(MD_INACTIVE); 1067 answer->set_direction(MD_INACTIVE);
1065 break; 1068 break;
1066 case MD_SENDONLY: 1069 case MD_SENDONLY:
1067 answer->set_direction(MD_RECVONLY); 1070 answer->set_direction(MD_RECVONLY);
1068 break; 1071 break;
1069 case MD_RECVONLY: 1072 case MD_RECVONLY:
1070 answer->set_direction(answer->streams().empty() ? MD_INACTIVE 1073 answer->set_direction(IsRtpProtocol(answer->protocol()) &&
1071 : MD_SENDONLY); 1074 answer->streams().empty()
1075 ? MD_INACTIVE
1076 : MD_SENDONLY);
1072 break; 1077 break;
1073 case MD_SENDRECV: 1078 case MD_SENDRECV:
1074 answer->set_direction(answer->streams().empty() ? MD_RECVONLY 1079 answer->set_direction(IsRtpProtocol(answer->protocol()) &&
1075 : MD_SENDRECV); 1080 answer->streams().empty()
1081 ? MD_RECVONLY
1082 : MD_SENDRECV);
1076 break; 1083 break;
1077 default: 1084 default:
1078 RTC_DCHECK(false && "MediaContentDescription has unexpected direction."); 1085 RTC_DCHECK(false && "MediaContentDescription has unexpected direction.");
1079 break; 1086 break;
1080 } 1087 }
1081 1088
1082 return true; 1089 return true;
1083 } 1090 }
1084 1091
1085 static bool IsMediaProtocolSupported(MediaType type, 1092 static bool IsMediaProtocolSupported(MediaType type,
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); 1962 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO));
1956 } 1963 }
1957 1964
1958 const DataContentDescription* GetFirstDataContentDescription( 1965 const DataContentDescription* GetFirstDataContentDescription(
1959 const SessionDescription* sdesc) { 1966 const SessionDescription* sdesc) {
1960 return static_cast<const DataContentDescription*>( 1967 return static_cast<const DataContentDescription*>(
1961 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); 1968 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA));
1962 } 1969 }
1963 1970
1964 } // namespace cricket 1971 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/app/webrtc/peerconnection_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698