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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // types. | 224 // types. |
225 const int kWildcardPayloadType = -1; | 225 const int kWildcardPayloadType = -1; |
226 | 226 |
227 struct SsrcInfo { | 227 struct SsrcInfo { |
228 SsrcInfo() | 228 SsrcInfo() |
229 : msid_identifier(kDefaultMsid), | 229 : msid_identifier(kDefaultMsid), |
230 // TODO(ronghuawu): What should we do if the appdata doesn't appear? | 230 // TODO(ronghuawu): What should we do if the appdata doesn't appear? |
231 // Create random string (which will be used as track label later)? | 231 // Create random string (which will be used as track label later)? |
232 msid_appdata(rtc::CreateRandomString(8)) { | 232 msid_appdata(rtc::CreateRandomString(8)) { |
233 } | 233 } |
234 uint32 ssrc_id; | 234 uint32_t ssrc_id; |
235 std::string cname; | 235 std::string cname; |
236 std::string msid_identifier; | 236 std::string msid_identifier; |
237 std::string msid_appdata; | 237 std::string msid_appdata; |
238 | 238 |
239 // For backward compatibility. | 239 // For backward compatibility. |
240 // TODO(ronghuawu): Remove below 2 fields once all the clients support msid. | 240 // TODO(ronghuawu): Remove below 2 fields once all the clients support msid. |
241 std::string label; | 241 std::string label; |
242 std::string mslabel; | 242 std::string mslabel; |
243 }; | 243 }; |
244 typedef std::vector<SsrcInfo> SsrcInfoVec; | 244 typedef std::vector<SsrcInfo> SsrcInfoVec; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 return false; | 518 return false; |
519 | 519 |
520 return true; | 520 return true; |
521 } | 521 } |
522 | 522 |
523 static bool HasAttribute(const std::string& line, | 523 static bool HasAttribute(const std::string& line, |
524 const std::string& attribute) { | 524 const std::string& attribute) { |
525 return (line.compare(kLinePrefixLength, attribute.size(), attribute) == 0); | 525 return (line.compare(kLinePrefixLength, attribute.size(), attribute) == 0); |
526 } | 526 } |
527 | 527 |
528 static bool AddSsrcLine(uint32 ssrc_id, const std::string& attribute, | 528 static bool AddSsrcLine(uint32_t ssrc_id, |
529 const std::string& value, std::string* message) { | 529 const std::string& attribute, |
| 530 const std::string& value, |
| 531 std::string* message) { |
530 // RFC 5576 | 532 // RFC 5576 |
531 // a=ssrc:<ssrc-id> <attribute>:<value> | 533 // a=ssrc:<ssrc-id> <attribute>:<value> |
532 std::ostringstream os; | 534 std::ostringstream os; |
533 InitAttrLine(kAttributeSsrc, &os); | 535 InitAttrLine(kAttributeSsrc, &os); |
534 os << kSdpDelimiterColon << ssrc_id << kSdpDelimiterSpace | 536 os << kSdpDelimiterColon << ssrc_id << kSdpDelimiterSpace |
535 << attribute << kSdpDelimiterColon << value; | 537 << attribute << kSdpDelimiterColon << value; |
536 return AddLine(os.str(), message); | 538 return AddLine(os.str(), message); |
537 } | 539 } |
538 | 540 |
539 // Get value only from <attribute>:<value>. | 541 // Get value only from <attribute>:<value>. |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 (fields[6] != kAttributeCandidateTyp)) { | 999 (fields[6] != kAttributeCandidateTyp)) { |
998 return ParseFailedExpectMinFieldNum(first_line, expected_min_fields, error); | 1000 return ParseFailedExpectMinFieldNum(first_line, expected_min_fields, error); |
999 } | 1001 } |
1000 const std::string& foundation = fields[0]; | 1002 const std::string& foundation = fields[0]; |
1001 | 1003 |
1002 int component_id = 0; | 1004 int component_id = 0; |
1003 if (!GetValueFromString(first_line, fields[1], &component_id, error)) { | 1005 if (!GetValueFromString(first_line, fields[1], &component_id, error)) { |
1004 return false; | 1006 return false; |
1005 } | 1007 } |
1006 const std::string& transport = fields[2]; | 1008 const std::string& transport = fields[2]; |
1007 uint32 priority = 0; | 1009 uint32_t priority = 0; |
1008 if (!GetValueFromString(first_line, fields[3], &priority, error)) { | 1010 if (!GetValueFromString(first_line, fields[3], &priority, error)) { |
1009 return false; | 1011 return false; |
1010 } | 1012 } |
1011 const std::string& connection_address = fields[4]; | 1013 const std::string& connection_address = fields[4]; |
1012 int port = 0; | 1014 int port = 0; |
1013 if (!GetValueFromString(first_line, fields[5], &port, error)) { | 1015 if (!GetValueFromString(first_line, fields[5], &port, error)) { |
1014 return false; | 1016 return false; |
1015 } | 1017 } |
1016 SocketAddress address(connection_address, port); | 1018 SocketAddress address(connection_address, port); |
1017 | 1019 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 } | 1073 } |
1072 } | 1074 } |
1073 | 1075 |
1074 // Extension | 1076 // Extension |
1075 // Empty string as the candidate username and password. | 1077 // Empty string as the candidate username and password. |
1076 // Will be updated later with the ice-ufrag and ice-pwd. | 1078 // Will be updated later with the ice-ufrag and ice-pwd. |
1077 // TODO: Remove the username/password extension, which is currently | 1079 // TODO: Remove the username/password extension, which is currently |
1078 // kept for backwards compatibility. | 1080 // kept for backwards compatibility. |
1079 std::string username; | 1081 std::string username; |
1080 std::string password; | 1082 std::string password; |
1081 uint32 generation = 0; | 1083 uint32_t generation = 0; |
1082 for (size_t i = current_position; i + 1 < fields.size(); ++i) { | 1084 for (size_t i = current_position; i + 1 < fields.size(); ++i) { |
1083 // RFC 5245 | 1085 // RFC 5245 |
1084 // *(SP extension-att-name SP extension-att-value) | 1086 // *(SP extension-att-name SP extension-att-value) |
1085 if (fields[i] == kAttributeCandidateGeneration) { | 1087 if (fields[i] == kAttributeCandidateGeneration) { |
1086 if (!GetValueFromString(first_line, fields[++i], &generation, error)) { | 1088 if (!GetValueFromString(first_line, fields[++i], &generation, error)) { |
1087 return false; | 1089 return false; |
1088 } | 1090 } |
1089 } else if (fields[i] == kAttributeCandidateUsername) { | 1091 } else if (fields[i] == kAttributeCandidateUsername) { |
1090 username = fields[++i]; | 1092 username = fields[++i]; |
1091 } else if (fields[i] == kAttributeCandidatePassword) { | 1093 } else if (fields[i] == kAttributeCandidatePassword) { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 // Build the ssrc-group lines. | 1436 // Build the ssrc-group lines. |
1435 for (size_t i = 0; i < track->ssrc_groups.size(); ++i) { | 1437 for (size_t i = 0; i < track->ssrc_groups.size(); ++i) { |
1436 // RFC 5576 | 1438 // RFC 5576 |
1437 // a=ssrc-group:<semantics> <ssrc-id> ... | 1439 // a=ssrc-group:<semantics> <ssrc-id> ... |
1438 if (track->ssrc_groups[i].ssrcs.empty()) { | 1440 if (track->ssrc_groups[i].ssrcs.empty()) { |
1439 continue; | 1441 continue; |
1440 } | 1442 } |
1441 std::ostringstream os; | 1443 std::ostringstream os; |
1442 InitAttrLine(kAttributeSsrcGroup, &os); | 1444 InitAttrLine(kAttributeSsrcGroup, &os); |
1443 os << kSdpDelimiterColon << track->ssrc_groups[i].semantics; | 1445 os << kSdpDelimiterColon << track->ssrc_groups[i].semantics; |
1444 std::vector<uint32>::const_iterator ssrc = | 1446 std::vector<uint32_t>::const_iterator ssrc = |
1445 track->ssrc_groups[i].ssrcs.begin(); | 1447 track->ssrc_groups[i].ssrcs.begin(); |
1446 for (; ssrc != track->ssrc_groups[i].ssrcs.end(); ++ssrc) { | 1448 for (; ssrc != track->ssrc_groups[i].ssrcs.end(); ++ssrc) { |
1447 os << kSdpDelimiterSpace << rtc::ToString<uint32>(*ssrc); | 1449 os << kSdpDelimiterSpace << rtc::ToString<uint32_t>(*ssrc); |
1448 } | 1450 } |
1449 AddLine(os.str(), message); | 1451 AddLine(os.str(), message); |
1450 } | 1452 } |
1451 // Build the ssrc lines for each ssrc. | 1453 // Build the ssrc lines for each ssrc. |
1452 for (size_t i = 0; i < track->ssrcs.size(); ++i) { | 1454 for (size_t i = 0; i < track->ssrcs.size(); ++i) { |
1453 uint32 ssrc = track->ssrcs[i]; | 1455 uint32_t ssrc = track->ssrcs[i]; |
1454 // RFC 5576 | 1456 // RFC 5576 |
1455 // a=ssrc:<ssrc-id> cname:<value> | 1457 // a=ssrc:<ssrc-id> cname:<value> |
1456 AddSsrcLine(ssrc, kSsrcAttributeCname, | 1458 AddSsrcLine(ssrc, kSsrcAttributeCname, |
1457 track->cname, message); | 1459 track->cname, message); |
1458 | 1460 |
1459 // draft-alvestrand-mmusic-msid-00 | 1461 // draft-alvestrand-mmusic-msid-00 |
1460 // a=ssrc:<ssrc-id> msid:identifier [appdata] | 1462 // a=ssrc:<ssrc-id> msid:identifier [appdata] |
1461 // The appdata consists of the "id" attribute of a MediaStreamTrack, which | 1463 // The appdata consists of the "id" attribute of a MediaStreamTrack, which |
1462 // is corresponding to the "name" attribute of StreamParams. | 1464 // is corresponding to the "name" attribute of StreamParams. |
1463 std::string appdata = track->id; | 1465 std::string appdata = track->id; |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2627 | 2629 |
2628 // Create tracks from the |ssrc_infos|. | 2630 // Create tracks from the |ssrc_infos|. |
2629 CreateTracksFromSsrcInfos(ssrc_infos, &tracks); | 2631 CreateTracksFromSsrcInfos(ssrc_infos, &tracks); |
2630 | 2632 |
2631 // Add the ssrc group to the track. | 2633 // Add the ssrc group to the track. |
2632 for (SsrcGroupVec::iterator ssrc_group = ssrc_groups.begin(); | 2634 for (SsrcGroupVec::iterator ssrc_group = ssrc_groups.begin(); |
2633 ssrc_group != ssrc_groups.end(); ++ssrc_group) { | 2635 ssrc_group != ssrc_groups.end(); ++ssrc_group) { |
2634 if (ssrc_group->ssrcs.empty()) { | 2636 if (ssrc_group->ssrcs.empty()) { |
2635 continue; | 2637 continue; |
2636 } | 2638 } |
2637 uint32 ssrc = ssrc_group->ssrcs.front(); | 2639 uint32_t ssrc = ssrc_group->ssrcs.front(); |
2638 for (StreamParamsVec::iterator track = tracks.begin(); | 2640 for (StreamParamsVec::iterator track = tracks.begin(); |
2639 track != tracks.end(); ++track) { | 2641 track != tracks.end(); ++track) { |
2640 if (track->has_ssrc(ssrc)) { | 2642 if (track->has_ssrc(ssrc)) { |
2641 track->ssrc_groups.push_back(*ssrc_group); | 2643 track->ssrc_groups.push_back(*ssrc_group); |
2642 } | 2644 } |
2643 } | 2645 } |
2644 } | 2646 } |
2645 | 2647 |
2646 // Add the new tracks to the |media_desc|. | 2648 // Add the new tracks to the |media_desc|. |
2647 for (StreamParamsVec::iterator track = tracks.begin(); | 2649 for (StreamParamsVec::iterator track = tracks.begin(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2699 &field1, &field2)) { | 2701 &field1, &field2)) { |
2700 const size_t expected_fields = 2; | 2702 const size_t expected_fields = 2; |
2701 return ParseFailedExpectFieldNum(line, expected_fields, error); | 2703 return ParseFailedExpectFieldNum(line, expected_fields, error); |
2702 } | 2704 } |
2703 | 2705 |
2704 // ssrc:<ssrc-id> | 2706 // ssrc:<ssrc-id> |
2705 std::string ssrc_id_s; | 2707 std::string ssrc_id_s; |
2706 if (!GetValue(field1, kAttributeSsrc, &ssrc_id_s, error)) { | 2708 if (!GetValue(field1, kAttributeSsrc, &ssrc_id_s, error)) { |
2707 return false; | 2709 return false; |
2708 } | 2710 } |
2709 uint32 ssrc_id = 0; | 2711 uint32_t ssrc_id = 0; |
2710 if (!GetValueFromString(line, ssrc_id_s, &ssrc_id, error)) { | 2712 if (!GetValueFromString(line, ssrc_id_s, &ssrc_id, error)) { |
2711 return false; | 2713 return false; |
2712 } | 2714 } |
2713 | 2715 |
2714 std::string attribute; | 2716 std::string attribute; |
2715 std::string value; | 2717 std::string value; |
2716 if (!rtc::tokenize_first(field2, kSdpDelimiterColon, &attribute, &value)) { | 2718 if (!rtc::tokenize_first(field2, kSdpDelimiterColon, &attribute, &value)) { |
2717 std::ostringstream description; | 2719 std::ostringstream description; |
2718 description << "Failed to get the ssrc attribute value from " << field2 | 2720 description << "Failed to get the ssrc attribute value from " << field2 |
2719 << ". Expected format <attribute>:<value>."; | 2721 << ". Expected format <attribute>:<value>."; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 rtc::split(line.substr(kLinePrefixLength), | 2778 rtc::split(line.substr(kLinePrefixLength), |
2777 kSdpDelimiterSpace, &fields); | 2779 kSdpDelimiterSpace, &fields); |
2778 const size_t expected_min_fields = 2; | 2780 const size_t expected_min_fields = 2; |
2779 if (fields.size() < expected_min_fields) { | 2781 if (fields.size() < expected_min_fields) { |
2780 return ParseFailedExpectMinFieldNum(line, expected_min_fields, error); | 2782 return ParseFailedExpectMinFieldNum(line, expected_min_fields, error); |
2781 } | 2783 } |
2782 std::string semantics; | 2784 std::string semantics; |
2783 if (!GetValue(fields[0], kAttributeSsrcGroup, &semantics, error)) { | 2785 if (!GetValue(fields[0], kAttributeSsrcGroup, &semantics, error)) { |
2784 return false; | 2786 return false; |
2785 } | 2787 } |
2786 std::vector<uint32> ssrcs; | 2788 std::vector<uint32_t> ssrcs; |
2787 for (size_t i = 1; i < fields.size(); ++i) { | 2789 for (size_t i = 1; i < fields.size(); ++i) { |
2788 uint32 ssrc = 0; | 2790 uint32_t ssrc = 0; |
2789 if (!GetValueFromString(line, fields[i], &ssrc, error)) { | 2791 if (!GetValueFromString(line, fields[i], &ssrc, error)) { |
2790 return false; | 2792 return false; |
2791 } | 2793 } |
2792 ssrcs.push_back(ssrc); | 2794 ssrcs.push_back(ssrc); |
2793 } | 2795 } |
2794 ssrc_groups->push_back(SsrcGroup(semantics, ssrcs)); | 2796 ssrc_groups->push_back(SsrcGroup(semantics, ssrcs)); |
2795 return true; | 2797 return true; |
2796 } | 2798 } |
2797 | 2799 |
2798 bool ParseCryptoAttribute(const std::string& line, | 2800 bool ParseCryptoAttribute(const std::string& line, |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3068 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( | 3070 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( |
3069 media_desc, payload_type, feedback_param); | 3071 media_desc, payload_type, feedback_param); |
3070 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 3072 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
3071 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( | 3073 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( |
3072 media_desc, payload_type, feedback_param); | 3074 media_desc, payload_type, feedback_param); |
3073 } | 3075 } |
3074 return true; | 3076 return true; |
3075 } | 3077 } |
3076 | 3078 |
3077 } // namespace webrtc | 3079 } // namespace webrtc |
OLD | NEW |