• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "modules/rtp_rtcp/source/video_rtp_depacketizer_raw.h"
12 
13 #include <cstdint>
14 
15 #include "absl/types/optional.h"
16 #include "rtc_base/copy_on_write_buffer.h"
17 #include "test/gtest.h"
18 
19 namespace webrtc {
20 namespace {
21 
TEST(VideoRtpDepacketizerRaw,PassRtpPayloadAsVideoPayload)22 TEST(VideoRtpDepacketizerRaw, PassRtpPayloadAsVideoPayload) {
23   const uint8_t kPayload[] = {0x05, 0x25, 0x52};
24   rtc::CopyOnWriteBuffer rtp_payload(kPayload);
25 
26   VideoRtpDepacketizerRaw depacketizer;
27   absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed =
28       depacketizer.Parse(rtp_payload);
29 
30   ASSERT_TRUE(parsed);
31   EXPECT_EQ(parsed->video_payload.size(), rtp_payload.size());
32   // Check there was no memcpy involved by verifying return and original buffers
33   // point to the same buffer.
34   EXPECT_EQ(parsed->video_payload.cdata(), rtp_payload.cdata());
35 }
36 
TEST(VideoRtpDepacketizerRaw,UsesDefaultValuesForVideoHeader)37 TEST(VideoRtpDepacketizerRaw, UsesDefaultValuesForVideoHeader) {
38   const uint8_t kPayload[] = {0x05, 0x25, 0x52};
39   rtc::CopyOnWriteBuffer rtp_payload(kPayload);
40 
41   VideoRtpDepacketizerRaw depacketizer;
42   absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed =
43       depacketizer.Parse(rtp_payload);
44 
45   ASSERT_TRUE(parsed);
46   EXPECT_FALSE(parsed->video_header.generic);
47   EXPECT_EQ(parsed->video_header.codec, kVideoCodecGeneric);
48 }
49 
50 }  // namespace
51 }  // namespace webrtc
52