OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 current_preference = preference; | 709 current_preference = preference; |
710 current_family = family; | 710 current_family = family; |
711 *port = it->address().PortAsString(); | 711 *port = it->address().PortAsString(); |
712 *ip = it->address().ipaddr().ToString(); | 712 *ip = it->address().ipaddr().ToString(); |
713 } | 713 } |
714 } | 714 } |
715 | 715 |
716 // Update |mline|'s default destination and append a c line after it. | 716 // Update |mline|'s default destination and append a c line after it. |
717 static void UpdateMediaDefaultDestination( | 717 static void UpdateMediaDefaultDestination( |
718 const std::vector<Candidate>& candidates, | 718 const std::vector<Candidate>& candidates, |
719 const std::string mline, | 719 const std::string& mline, |
720 std::string* message) { | 720 std::string* message) { |
721 std::string new_lines; | 721 std::string new_lines; |
722 AddLine(mline, &new_lines); | 722 AddLine(mline, &new_lines); |
723 // RFC 4566 | 723 // RFC 4566 |
724 // m=<media> <port> <proto> <fmt> ... | 724 // m=<media> <port> <proto> <fmt> ... |
725 std::vector<std::string> fields; | 725 std::vector<std::string> fields; |
726 rtc::split(mline, kSdpDelimiterSpace, &fields); | 726 rtc::split(mline, kSdpDelimiterSpace, &fields); |
727 if (fields.size() < 3) { | 727 if (fields.size() < 3) { |
728 return; | 728 return; |
729 } | 729 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 std::string message; | 801 std::string message; |
802 | 802 |
803 // Session Description. | 803 // Session Description. |
804 AddLine(kSessionVersion, &message); | 804 AddLine(kSessionVersion, &message); |
805 // Session Origin | 805 // Session Origin |
806 // RFC 4566 | 806 // RFC 4566 |
807 // o=<username> <sess-id> <sess-version> <nettype> <addrtype> | 807 // o=<username> <sess-id> <sess-version> <nettype> <addrtype> |
808 // <unicast-address> | 808 // <unicast-address> |
809 std::ostringstream os; | 809 std::ostringstream os; |
810 InitLine(kLineTypeOrigin, kSessionOriginUsername, &os); | 810 InitLine(kLineTypeOrigin, kSessionOriginUsername, &os); |
811 const std::string session_id = jdesc.session_id().empty() ? | 811 const std::string& session_id = jdesc.session_id().empty() ? |
812 kSessionOriginSessionId : jdesc.session_id(); | 812 kSessionOriginSessionId : jdesc.session_id(); |
813 const std::string session_version = jdesc.session_version().empty() ? | 813 const std::string& session_version = jdesc.session_version().empty() ? |
814 kSessionOriginSessionVersion : jdesc.session_version(); | 814 kSessionOriginSessionVersion : jdesc.session_version(); |
815 os << " " << session_id << " " << session_version << " " | 815 os << " " << session_id << " " << session_version << " " |
816 << kSessionOriginNettype << " " << kSessionOriginAddrtype << " " | 816 << kSessionOriginNettype << " " << kSessionOriginAddrtype << " " |
817 << kSessionOriginAddress; | 817 << kSessionOriginAddress; |
818 AddLine(os.str(), &message); | 818 AddLine(os.str(), &message); |
819 AddLine(kSessionName, &message); | 819 AddLine(kSessionName, &message); |
820 | 820 |
821 // Time Description. | 821 // Time Description. |
822 AddLine(kTimeDescription, &message); | 822 AddLine(kTimeDescription, &message); |
823 | 823 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 // RFC 5245 | 994 // RFC 5245 |
995 // a=candidate:<foundation> <component-id> <transport> <priority> | 995 // a=candidate:<foundation> <component-id> <transport> <priority> |
996 // <connection-address> <port> typ <candidate-types> | 996 // <connection-address> <port> typ <candidate-types> |
997 // [raddr <connection-address>] [rport <port>] | 997 // [raddr <connection-address>] [rport <port>] |
998 // *(SP extension-att-name SP extension-att-value) | 998 // *(SP extension-att-name SP extension-att-value) |
999 const size_t expected_min_fields = 8; | 999 const size_t expected_min_fields = 8; |
1000 if (fields.size() < expected_min_fields || | 1000 if (fields.size() < expected_min_fields || |
1001 (fields[6] != kAttributeCandidateTyp)) { | 1001 (fields[6] != kAttributeCandidateTyp)) { |
1002 return ParseFailedExpectMinFieldNum(first_line, expected_min_fields, error); | 1002 return ParseFailedExpectMinFieldNum(first_line, expected_min_fields, error); |
1003 } | 1003 } |
1004 std::string foundation = fields[0]; | 1004 const std::string& foundation = fields[0]; |
1005 | 1005 |
1006 int component_id = 0; | 1006 int component_id = 0; |
1007 if (!GetValueFromString(first_line, fields[1], &component_id, error)) { | 1007 if (!GetValueFromString(first_line, fields[1], &component_id, error)) { |
1008 return false; | 1008 return false; |
1009 } | 1009 } |
1010 const std::string transport = fields[2]; | 1010 const std::string& transport = fields[2]; |
1011 uint32 priority = 0; | 1011 uint32 priority = 0; |
1012 if (!GetValueFromString(first_line, fields[3], &priority, error)) { | 1012 if (!GetValueFromString(first_line, fields[3], &priority, error)) { |
1013 return false; | 1013 return false; |
1014 } | 1014 } |
1015 const std::string connection_address = fields[4]; | 1015 const std::string& connection_address = fields[4]; |
1016 int port = 0; | 1016 int port = 0; |
1017 if (!GetValueFromString(first_line, fields[5], &port, error)) { | 1017 if (!GetValueFromString(first_line, fields[5], &port, error)) { |
1018 return false; | 1018 return false; |
1019 } | 1019 } |
1020 SocketAddress address(connection_address, port); | 1020 SocketAddress address(connection_address, port); |
1021 | 1021 |
1022 cricket::ProtocolType protocol; | 1022 cricket::ProtocolType protocol; |
1023 if (!StringToProto(transport.c_str(), &protocol)) { | 1023 if (!StringToProto(transport.c_str(), &protocol)) { |
1024 return ParseFailed(first_line, "Unsupported transport type.", error); | 1024 return ParseFailed(first_line, "Unsupported transport type.", error); |
1025 } | 1025 } |
1026 | 1026 |
1027 std::string candidate_type; | 1027 std::string candidate_type; |
1028 const std::string type = fields[7]; | 1028 const std::string& type = fields[7]; |
1029 if (type == kCandidateHost) { | 1029 if (type == kCandidateHost) { |
1030 candidate_type = cricket::LOCAL_PORT_TYPE; | 1030 candidate_type = cricket::LOCAL_PORT_TYPE; |
1031 } else if (type == kCandidateSrflx) { | 1031 } else if (type == kCandidateSrflx) { |
1032 candidate_type = cricket::STUN_PORT_TYPE; | 1032 candidate_type = cricket::STUN_PORT_TYPE; |
1033 } else if (type == kCandidateRelay) { | 1033 } else if (type == kCandidateRelay) { |
1034 candidate_type = cricket::RELAY_PORT_TYPE; | 1034 candidate_type = cricket::RELAY_PORT_TYPE; |
1035 } else { | 1035 } else { |
1036 return ParseFailed(first_line, "Unsupported candidate type.", error); | 1036 return ParseFailed(first_line, "Unsupported candidate type.", error); |
1037 } | 1037 } |
1038 | 1038 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 // to 0. | 1253 // to 0. |
1254 if (fmt.empty()) { | 1254 if (fmt.empty()) { |
1255 fmt = " 0"; | 1255 fmt = " 0"; |
1256 } | 1256 } |
1257 | 1257 |
1258 // The port number in the m line will be updated later when associate with | 1258 // The port number in the m line will be updated later when associate with |
1259 // the candidates. | 1259 // the candidates. |
1260 // RFC 3264 | 1260 // RFC 3264 |
1261 // To reject an offered stream, the port number in the corresponding stream in | 1261 // To reject an offered stream, the port number in the corresponding stream in |
1262 // the answer MUST be set to zero. | 1262 // the answer MUST be set to zero. |
1263 const std::string port = content_info->rejected ? | 1263 const std::string& port = content_info->rejected ? |
1264 kMediaPortRejected : kDummyPort; | 1264 kMediaPortRejected : kDummyPort; |
1265 | 1265 |
1266 rtc::SSLFingerprint* fp = (transport_info) ? | 1266 rtc::SSLFingerprint* fp = (transport_info) ? |
1267 transport_info->description.identity_fingerprint.get() : NULL; | 1267 transport_info->description.identity_fingerprint.get() : NULL; |
1268 | 1268 |
1269 // Add the m and c lines. | 1269 // Add the m and c lines. |
1270 InitLine(kLineTypeMedia, type, &os); | 1270 InitLine(kLineTypeMedia, type, &os); |
1271 os << " " << port << " " << media_desc->protocol() << fmt; | 1271 os << " " << port << " " << media_desc->protocol() << fmt; |
1272 std::string mline = os.str(); | 1272 std::string mline = os.str(); |
1273 UpdateMediaDefaultDestination(candidates, mline, message); | 1273 UpdateMediaDefaultDestination(candidates, mline, message); |
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 return ParseFailedExpectMinFieldNum(line, expected_min_fields, error); | 2838 return ParseFailedExpectMinFieldNum(line, expected_min_fields, error); |
2839 } | 2839 } |
2840 std::string tag_value; | 2840 std::string tag_value; |
2841 if (!GetValue(fields[0], kAttributeCrypto, &tag_value, error)) { | 2841 if (!GetValue(fields[0], kAttributeCrypto, &tag_value, error)) { |
2842 return false; | 2842 return false; |
2843 } | 2843 } |
2844 int tag = 0; | 2844 int tag = 0; |
2845 if (!GetValueFromString(line, tag_value, &tag, error)) { | 2845 if (!GetValueFromString(line, tag_value, &tag, error)) { |
2846 return false; | 2846 return false; |
2847 } | 2847 } |
2848 const std::string crypto_suite = fields[1]; | 2848 const std::string& crypto_suite = fields[1]; |
2849 const std::string key_params = fields[2]; | 2849 const std::string& key_params = fields[2]; |
2850 std::string session_params; | 2850 std::string session_params; |
2851 if (fields.size() > 3) { | 2851 if (fields.size() > 3) { |
2852 session_params = fields[3]; | 2852 session_params = fields[3]; |
2853 } | 2853 } |
2854 media_desc->AddCrypto(CryptoParams(tag, crypto_suite, key_params, | 2854 media_desc->AddCrypto(CryptoParams(tag, crypto_suite, key_params, |
2855 session_params)); | 2855 session_params)); |
2856 return true; | 2856 return true; |
2857 } | 2857 } |
2858 | 2858 |
2859 // Updates or creates a new codec entry in the audio description with according | 2859 // Updates or creates a new codec entry in the audio description with according |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2919 // Set the preference order depending on the order of the pl type in the | 2919 // Set the preference order depending on the order of the pl type in the |
2920 // <fmt> of the m-line. | 2920 // <fmt> of the m-line. |
2921 const int preference = codec_preference.end() - | 2921 const int preference = codec_preference.end() - |
2922 std::find(codec_preference.begin(), codec_preference.end(), | 2922 std::find(codec_preference.begin(), codec_preference.end(), |
2923 payload_type); | 2923 payload_type); |
2924 if (preference == 0) { | 2924 if (preference == 0) { |
2925 LOG(LS_WARNING) << "Ignore rtpmap line that did not appear in the " | 2925 LOG(LS_WARNING) << "Ignore rtpmap line that did not appear in the " |
2926 << "<fmt> of the m-line: " << line; | 2926 << "<fmt> of the m-line: " << line; |
2927 return true; | 2927 return true; |
2928 } | 2928 } |
2929 const std::string encoder = fields[1]; | 2929 const std::string& encoder = fields[1]; |
2930 std::vector<std::string> codec_params; | 2930 std::vector<std::string> codec_params; |
2931 rtc::split(encoder, '/', &codec_params); | 2931 rtc::split(encoder, '/', &codec_params); |
2932 // <encoding name>/<clock rate>[/<encodingparameters>] | 2932 // <encoding name>/<clock rate>[/<encodingparameters>] |
2933 // 2 mandatory fields | 2933 // 2 mandatory fields |
2934 if (codec_params.size() < 2 || codec_params.size() > 3) { | 2934 if (codec_params.size() < 2 || codec_params.size() > 3) { |
2935 return ParseFailed(line, | 2935 return ParseFailed(line, |
2936 "Expected format \"<encoding name>/<clock rate>" | 2936 "Expected format \"<encoding name>/<clock rate>" |
2937 "[/<encodingparameters>]\".", | 2937 "[/<encodingparameters>]\".", |
2938 error); | 2938 error); |
2939 } | 2939 } |
2940 const std::string encoding_name = codec_params[0]; | 2940 const std::string& encoding_name = codec_params[0]; |
2941 int clock_rate = 0; | 2941 int clock_rate = 0; |
2942 if (!GetValueFromString(line, codec_params[1], &clock_rate, error)) { | 2942 if (!GetValueFromString(line, codec_params[1], &clock_rate, error)) { |
2943 return false; | 2943 return false; |
2944 } | 2944 } |
2945 if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 2945 if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
2946 VideoContentDescription* video_desc = | 2946 VideoContentDescription* video_desc = |
2947 static_cast<VideoContentDescription*>(media_desc); | 2947 static_cast<VideoContentDescription*>(media_desc); |
2948 // TODO: We will send resolution in SDP. For now use | 2948 // TODO: We will send resolution in SDP. For now use |
2949 // JsepSessionDescription::kMaxVideoCodecWidth and kMaxVideoCodecHeight. | 2949 // JsepSessionDescription::kMaxVideoCodecWidth and kMaxVideoCodecHeight. |
2950 UpdateCodec(payload_type, encoding_name, | 2950 UpdateCodec(payload_type, encoding_name, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3098 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( | 3098 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( |
3099 media_desc, payload_type, feedback_param); | 3099 media_desc, payload_type, feedback_param); |
3100 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 3100 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
3101 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( | 3101 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( |
3102 media_desc, payload_type, feedback_param); | 3102 media_desc, payload_type, feedback_param); |
3103 } | 3103 } |
3104 return true; | 3104 return true; |
3105 } | 3105 } |
3106 | 3106 |
3107 } // namespace webrtc | 3107 } // namespace webrtc |
OLD | NEW |