OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2011 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 |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "webrtc/api/jsepsessiondescription.h" | 15 #include "webrtc/api/jsepsessiondescription.h" |
16 #ifdef WEBRTC_ANDROID | 16 #ifdef WEBRTC_ANDROID |
17 #include "webrtc/api/test/androidtestinitializer.h" | 17 #include "webrtc/api/test/androidtestinitializer.h" |
18 #endif | 18 #endif |
19 #include "webrtc/api/webrtcsdp.h" | 19 #include "webrtc/api/webrtcsdp.h" |
20 #include "webrtc/base/gunit.h" | 20 #include "webrtc/base/gunit.h" |
21 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
22 #include "webrtc/base/messagedigest.h" | 22 #include "webrtc/base/messagedigest.h" |
23 #include "webrtc/base/scoped_ptr.h" | 23 #include "webrtc/base/scoped_ptr.h" |
24 #include "webrtc/base/sslfingerprint.h" | 24 #include "webrtc/base/sslfingerprint.h" |
25 #include "webrtc/base/stringencode.h" | 25 #include "webrtc/base/stringencode.h" |
26 #include "webrtc/base/stringutils.h" | 26 #include "webrtc/base/stringutils.h" |
27 #include "webrtc/media/base/mediaconstants.h" | 27 #include "webrtc/media/base/mediaconstants.h" |
| 28 #include "webrtc/media/engine/webrtcvideoengine2.h" |
| 29 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
28 #include "webrtc/p2p/base/p2pconstants.h" | 30 #include "webrtc/p2p/base/p2pconstants.h" |
29 #include "webrtc/pc/mediasession.h" | 31 #include "webrtc/pc/mediasession.h" |
30 | 32 |
31 using cricket::AudioCodec; | 33 using cricket::AudioCodec; |
32 using cricket::AudioContentDescription; | 34 using cricket::AudioContentDescription; |
33 using cricket::Candidate; | 35 using cricket::Candidate; |
34 using cricket::ContentInfo; | 36 using cricket::ContentInfo; |
35 using cricket::CryptoParams; | 37 using cricket::CryptoParams; |
36 using cricket::ContentGroup; | 38 using cricket::ContentGroup; |
37 using cricket::DataCodec; | 39 using cricket::DataCodec; |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 "", "", LOCAL_PORT_TYPE, kCandidateGeneration, | 2083 "", "", LOCAL_PORT_TYPE, kCandidateGeneration, |
2082 kCandidateFoundation1); | 2084 kCandidateFoundation1); |
2083 candidate.set_tcptype(cricket::TCPTYPE_ACTIVE_STR); | 2085 candidate.set_tcptype(cricket::TCPTYPE_ACTIVE_STR); |
2084 rtc::scoped_ptr<IceCandidateInterface> jcandidate( | 2086 rtc::scoped_ptr<IceCandidateInterface> jcandidate( |
2085 new JsepIceCandidate(std::string("audio_content_name"), 0, candidate)); | 2087 new JsepIceCandidate(std::string("audio_content_name"), 0, candidate)); |
2086 | 2088 |
2087 std::string message = webrtc::SdpSerializeCandidate(*jcandidate); | 2089 std::string message = webrtc::SdpSerializeCandidate(*jcandidate); |
2088 EXPECT_EQ(std::string(kSdpTcpActiveCandidate), message); | 2090 EXPECT_EQ(std::string(kSdpTcpActiveCandidate), message); |
2089 } | 2091 } |
2090 | 2092 |
| 2093 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithH264) { |
| 2094 if (!webrtc::H264Encoder::IsSupported()) |
| 2095 return; |
| 2096 for (const auto& codec : cricket::DefaultVideoCodecList()) { |
| 2097 video_desc_->AddCodec(codec); |
| 2098 } |
| 2099 jdesc_.Initialize(desc_.Copy(), kSessionId, kSessionVersion); |
| 2100 |
| 2101 std::string message = webrtc::SdpSerialize(jdesc_, false); |
| 2102 size_t after_pt = message.find(" H264/90000"); |
| 2103 ASSERT_NE(after_pt, std::string::npos); |
| 2104 size_t before_pt = message.rfind("a=rtpmap:", after_pt); |
| 2105 ASSERT_NE(before_pt, std::string::npos); |
| 2106 before_pt += strlen("a=rtpmap:"); |
| 2107 std::string pt = message.substr(before_pt, after_pt - before_pt); |
| 2108 // TODO(hta): Check if payload type |pt| occurs in the m=video line. |
| 2109 std::string to_find = "a=fmtp:" + pt + " "; |
| 2110 size_t fmtp_pos = message.find(to_find); |
| 2111 ASSERT_NE(std::string::npos, fmtp_pos) << "Failed to find " << to_find; |
| 2112 size_t fmtp_endpos = message.find("\n", fmtp_pos); |
| 2113 ASSERT_NE(std::string::npos, fmtp_endpos); |
| 2114 std::string fmtp_value = message.substr(fmtp_pos, fmtp_endpos); |
| 2115 EXPECT_NE(std::string::npos, fmtp_value.find("level-asymmetry-allowed=1")); |
| 2116 EXPECT_NE(std::string::npos, fmtp_value.find("packetization-mode=1")); |
| 2117 EXPECT_NE(std::string::npos, fmtp_value.find("profile-level-id=42e01f")); |
| 2118 } |
| 2119 |
2091 TEST_F(WebRtcSdpTest, DeserializeSessionDescription) { | 2120 TEST_F(WebRtcSdpTest, DeserializeSessionDescription) { |
2092 JsepSessionDescription jdesc(kDummyString); | 2121 JsepSessionDescription jdesc(kDummyString); |
2093 // Deserialize | 2122 // Deserialize |
2094 EXPECT_TRUE(SdpDeserialize(kSdpFullString, &jdesc)); | 2123 EXPECT_TRUE(SdpDeserialize(kSdpFullString, &jdesc)); |
2095 // Verify | 2124 // Verify |
2096 EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc)); | 2125 EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc)); |
2097 } | 2126 } |
2098 | 2127 |
2099 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutMline) { | 2128 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutMline) { |
2100 JsepSessionDescription jdesc(kDummyString); | 2129 JsepSessionDescription jdesc(kDummyString); |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3112 EXPECT_TRUE( | 3141 EXPECT_TRUE( |
3113 SdpDeserialize(kUnifiedPlanSdpFullString, &deserialized_description)); | 3142 SdpDeserialize(kUnifiedPlanSdpFullString, &deserialized_description)); |
3114 | 3143 |
3115 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); | 3144 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); |
3116 } | 3145 } |
3117 | 3146 |
3118 TEST_F(WebRtcSdpTest, SerializeUnifiedPlanSessionDescription) { | 3147 TEST_F(WebRtcSdpTest, SerializeUnifiedPlanSessionDescription) { |
3119 MakeUnifiedPlanDescription(); | 3148 MakeUnifiedPlanDescription(); |
3120 TestSerialize(jdesc_, true); | 3149 TestSerialize(jdesc_, true); |
3121 } | 3150 } |
OLD | NEW |