OLD | NEW |
| (Empty) |
1 /* | |
2 * libjingle | |
3 * Copyright 2004 Google Inc. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright notice, | |
9 * this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
11 * this list of conditions and the following disclaimer in the documentation | |
12 * and/or other materials provided with the distribution. | |
13 * 3. The name of the author may not be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 | |
28 #include "talk/session/media/bundlefilter.h" | |
29 #include "webrtc/base/gunit.h" | |
30 | |
31 using cricket::StreamParams; | |
32 | |
33 static const int kPayloadType1 = 0x11; | |
34 static const int kPayloadType2 = 0x22; | |
35 static const int kPayloadType3 = 0x33; | |
36 | |
37 // SSRC = 0x1111, Payload type = 0x11 | |
38 static const unsigned char kRtpPacketPt1Ssrc1[] = { | |
39 0x80, kPayloadType1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, | |
40 0x11, | |
41 }; | |
42 | |
43 // SSRC = 0x2222, Payload type = 0x22 | |
44 static const unsigned char kRtpPacketPt2Ssrc2[] = { | |
45 0x80, 0x80 + kPayloadType2, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
46 0x22, 0x22, | |
47 }; | |
48 | |
49 // SSRC = 0x2222, Payload type = 0x33 | |
50 static const unsigned char kRtpPacketPt3Ssrc2[] = { | |
51 0x80, kPayloadType3, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, | |
52 0x22, | |
53 }; | |
54 | |
55 // An SCTP packet. | |
56 static const unsigned char kSctpPacket[] = { | |
57 0x00, 0x01, 0x00, 0x01, | |
58 0xff, 0xff, 0xff, 0xff, | |
59 0x00, 0x00, 0x00, 0x00, | |
60 0x03, 0x00, 0x00, 0x04, | |
61 0x00, 0x00, 0x00, 0x00, | |
62 }; | |
63 | |
64 TEST(BundleFilterTest, RtpPacketTest) { | |
65 cricket::BundleFilter bundle_filter; | |
66 bundle_filter.AddPayloadType(kPayloadType1); | |
67 EXPECT_TRUE(bundle_filter.DemuxPacket(kRtpPacketPt1Ssrc1, | |
68 sizeof(kRtpPacketPt1Ssrc1))); | |
69 bundle_filter.AddPayloadType(kPayloadType2); | |
70 EXPECT_TRUE(bundle_filter.DemuxPacket(kRtpPacketPt2Ssrc2, | |
71 sizeof(kRtpPacketPt2Ssrc2))); | |
72 | |
73 // Payload type 0x33 is not added. | |
74 EXPECT_FALSE(bundle_filter.DemuxPacket(kRtpPacketPt3Ssrc2, | |
75 sizeof(kRtpPacketPt3Ssrc2))); | |
76 // Size is too small. | |
77 EXPECT_FALSE(bundle_filter.DemuxPacket(kRtpPacketPt1Ssrc1, 11)); | |
78 | |
79 bundle_filter.ClearAllPayloadTypes(); | |
80 EXPECT_FALSE(bundle_filter.DemuxPacket(kRtpPacketPt1Ssrc1, | |
81 sizeof(kRtpPacketPt1Ssrc1))); | |
82 EXPECT_FALSE(bundle_filter.DemuxPacket(kRtpPacketPt2Ssrc2, | |
83 sizeof(kRtpPacketPt2Ssrc2))); | |
84 } | |
85 | |
86 TEST(BundleFilterTest, InvalidRtpPacket) { | |
87 cricket::BundleFilter bundle_filter; | |
88 EXPECT_FALSE(bundle_filter.DemuxPacket(kSctpPacket, sizeof(kSctpPacket))); | |
89 } | |
OLD | NEW |