mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 22:30:40 +01:00

while suboptimal, these implementions are complete and allow to swap code from using RtpDepacketizer interface to VideoRtpDepacketizer Bug: webrtc:11152 Change-Id: Ie7823feeb5b0563b74754255aaedfada9d446ac5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161380 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30031}
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "modules/rtp_rtcp/source/video_rtp_depacketizer_raw.h"
|
|
|
|
#include <cstdint>
|
|
|
|
#include "absl/types/optional.h"
|
|
#include "rtc_base/copy_on_write_buffer.h"
|
|
#include "test/gtest.h"
|
|
|
|
namespace webrtc {
|
|
namespace {
|
|
|
|
TEST(VideoRtpDepacketizerRaw, PassRtpPayloadAsVideoPayload) {
|
|
const uint8_t kPayload[] = {0x05, 0x25, 0x52};
|
|
rtc::CopyOnWriteBuffer rtp_payload(kPayload);
|
|
|
|
VideoRtpDepacketizerRaw depacketizer;
|
|
absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed =
|
|
depacketizer.Parse(rtp_payload);
|
|
|
|
ASSERT_TRUE(parsed);
|
|
EXPECT_EQ(parsed->video_payload.size(), rtp_payload.size());
|
|
// Check there was no memcpy involved by verifying return and original buffers
|
|
// point to the same buffer.
|
|
EXPECT_EQ(parsed->video_payload.cdata(), rtp_payload.cdata());
|
|
}
|
|
|
|
TEST(VideoRtpDepacketizerRaw, UsesDefaultValuesForVideoHeader) {
|
|
const uint8_t kPayload[] = {0x05, 0x25, 0x52};
|
|
rtc::CopyOnWriteBuffer rtp_payload(kPayload);
|
|
|
|
VideoRtpDepacketizerRaw depacketizer;
|
|
absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed =
|
|
depacketizer.Parse(rtp_payload);
|
|
|
|
ASSERT_TRUE(parsed);
|
|
EXPECT_FALSE(parsed->video_header.generic);
|
|
EXPECT_EQ(parsed->video_header.codec, kVideoCodecGeneric);
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace webrtc
|