Cleanup of unused RTP structs and packetizer for stereo codec
This CL is a followup to https://webrtc-review.googlesource.com/c/src/+/38481. With the new approach we can just use the generic RTP packetizer to pass frames over the wire as the specific info is contained within the bitstream. This makes the new codec more modular and reduces its footprint. Bug: webrtc:7671 Change-Id: Ib07f72a9d338e3cbfdbf39cba9891a959b5f7552 Reviewed-on: https://webrtc-review.googlesource.com/43220 Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> Commit-Queue: Emircan Uysaler <emircan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21753}
This commit is contained in:

committed by
Commit Bot

parent
be5e208b3e
commit
9bb8f0553d
@ -23,7 +23,6 @@
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/include/module_common_types_public.h"
|
||||
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
|
||||
#include "modules/video_coding/codecs/stereo/include/stereo_globals.h"
|
||||
#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
|
||||
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
@ -46,20 +45,13 @@ enum RtpVideoCodecTypes {
|
||||
kRtpVideoGeneric = 1,
|
||||
kRtpVideoVp8 = 2,
|
||||
kRtpVideoVp9 = 3,
|
||||
kRtpVideoH264 = 4,
|
||||
kRtpVideoStereo = 5
|
||||
};
|
||||
|
||||
struct RTPVideoHeaderStereo {
|
||||
RtpVideoCodecTypes associated_codec_type;
|
||||
StereoIndices indices;
|
||||
kRtpVideoH264 = 4
|
||||
};
|
||||
|
||||
union RTPVideoTypeHeader {
|
||||
RTPVideoHeaderVP8 VP8;
|
||||
RTPVideoHeaderVP9 VP9;
|
||||
RTPVideoHeaderH264 H264;
|
||||
RTPVideoHeaderStereo stereo;
|
||||
};
|
||||
|
||||
// Since RTPVideoHeader is used as a member of a union, it can't have a
|
||||
|
@ -139,8 +139,6 @@ rtc_static_library("rtp_rtcp") {
|
||||
"source/rtp_format_h264.h",
|
||||
"source/rtp_format_video_generic.cc",
|
||||
"source/rtp_format_video_generic.h",
|
||||
"source/rtp_format_video_stereo.cc",
|
||||
"source/rtp_format_video_stereo.h",
|
||||
"source/rtp_format_vp8.cc",
|
||||
"source/rtp_format_vp8.h",
|
||||
"source/rtp_format_vp9.cc",
|
||||
@ -368,7 +366,6 @@ if (rtc_include_tests) {
|
||||
"source/rtp_fec_unittest.cc",
|
||||
"source/rtp_format_h264_unittest.cc",
|
||||
"source/rtp_format_video_generic_unittest.cc",
|
||||
"source/rtp_format_video_stereo_unittest.cc",
|
||||
"source/rtp_format_vp8_test_helper.cc",
|
||||
"source/rtp_format_vp8_test_helper.h",
|
||||
"source/rtp_format_vp8_unittest.cc",
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include "modules/rtp_rtcp/source/rtp_format_h264.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_format_video_generic.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_format_video_stereo.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_format_vp8.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_format_vp9.h"
|
||||
|
||||
@ -37,10 +36,6 @@ RtpPacketizer* RtpPacketizer::Create(RtpVideoCodecTypes type,
|
||||
RTC_CHECK(rtp_type_header);
|
||||
return new RtpPacketizerVp9(rtp_type_header->VP9, max_payload_len,
|
||||
last_packet_reduction_len);
|
||||
case kRtpVideoStereo:
|
||||
return new RtpPacketizerStereo(rtp_type_header->stereo, frame_type,
|
||||
max_payload_len,
|
||||
last_packet_reduction_len);
|
||||
case kRtpVideoGeneric:
|
||||
return new RtpPacketizerGeneric(frame_type, max_payload_len,
|
||||
last_packet_reduction_len);
|
||||
@ -58,8 +53,6 @@ RtpDepacketizer* RtpDepacketizer::Create(RtpVideoCodecTypes type) {
|
||||
return new RtpDepacketizerVp8();
|
||||
case kRtpVideoVp9:
|
||||
return new RtpDepacketizerVp9();
|
||||
case kRtpVideoStereo:
|
||||
return new RtpDepacketizerStereo();
|
||||
case kRtpVideoGeneric:
|
||||
return new RtpDepacketizerGeneric();
|
||||
case kRtpVideoNone:
|
||||
|
@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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 <memory>
|
||||
#include <string>
|
||||
|
||||
#include "modules/include/module_common_types.h"
|
||||
#include "modules/rtp_rtcp/source/byte_io.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_format_video_stereo.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
||||
#include "rtc_base/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
// Write the Stereo header descriptor.
|
||||
// 0 1 2 3 4 5 6 7 8
|
||||
// +-+-+-+-+-+-+-+-+-+
|
||||
// | VideoCodecType | (optional)
|
||||
// +-+-+-+-+-+-+-+-+-+
|
||||
// | frame_index | (optional)
|
||||
// +-+-+-+-+-+-+-+-+-+
|
||||
// | frame_count | (optional)
|
||||
// +-+-+-+-+-+-+-+-+-+
|
||||
// | picture_index | (optional)
|
||||
// | (16 bits) |
|
||||
// +-+-+-+-+-+-+-+-+-+
|
||||
// | HeaderMarker | (mandatory)
|
||||
// +-+-+-+-+-+-+-+-+-+
|
||||
constexpr size_t kStereoHeaderLength =
|
||||
sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint16_t);
|
||||
|
||||
constexpr size_t kHeaderMarkerLength = 1;
|
||||
constexpr uint8_t kHeaderMarkerBit = 0x02;
|
||||
} // namespace
|
||||
|
||||
RtpPacketizerStereo::RtpPacketizerStereo(const RTPVideoHeaderStereo& header,
|
||||
FrameType frame_type,
|
||||
size_t max_payload_len,
|
||||
size_t last_packet_reduction_len)
|
||||
: header_(header),
|
||||
max_payload_len_(max_payload_len - kHeaderMarkerLength),
|
||||
last_packet_reduction_len_(last_packet_reduction_len +
|
||||
kStereoHeaderLength),
|
||||
packetizer_(frame_type, max_payload_len_, last_packet_reduction_len_) {}
|
||||
|
||||
RtpPacketizerStereo::~RtpPacketizerStereo() {}
|
||||
|
||||
size_t RtpPacketizerStereo::SetPayloadData(
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
num_packets_remaining_ =
|
||||
packetizer_.SetPayloadData(payload_data, payload_size, fragmentation);
|
||||
return num_packets_remaining_;
|
||||
}
|
||||
|
||||
bool RtpPacketizerStereo::NextPacket(RtpPacketToSend* packet) {
|
||||
if (max_payload_len_ <= last_packet_reduction_len_) {
|
||||
RTC_LOG(LS_ERROR) << "Payload length not large enough.";
|
||||
return false;
|
||||
}
|
||||
|
||||
RTC_DCHECK(packet);
|
||||
if (!packetizer_.NextPacket(packet))
|
||||
return false;
|
||||
|
||||
RTC_DCHECK_GT(num_packets_remaining_, 0);
|
||||
const bool last_packet = --num_packets_remaining_ == 0;
|
||||
const size_t header_length = last_packet
|
||||
? kHeaderMarkerLength + kStereoHeaderLength
|
||||
: kHeaderMarkerLength;
|
||||
|
||||
const uint8_t* payload_ptr = packet->payload().data();
|
||||
const size_t payload_size = packet->payload_size();
|
||||
uint8_t* padded_payload_ptr =
|
||||
packet->SetPayloadSize(header_length + packet->payload_size());
|
||||
RTC_DCHECK(padded_payload_ptr);
|
||||
|
||||
padded_payload_ptr += payload_size;
|
||||
if (last_packet) {
|
||||
ByteWriter<uint8_t>::WriteBigEndian(
|
||||
padded_payload_ptr,
|
||||
static_cast<uint8_t>(header_.associated_codec_type));
|
||||
padded_payload_ptr += sizeof(uint8_t);
|
||||
ByteWriter<uint8_t>::WriteBigEndian(padded_payload_ptr,
|
||||
header_.indices.frame_index);
|
||||
padded_payload_ptr += sizeof(uint8_t);
|
||||
ByteWriter<uint8_t>::WriteBigEndian(padded_payload_ptr,
|
||||
header_.indices.frame_count);
|
||||
padded_payload_ptr += sizeof(uint8_t);
|
||||
ByteWriter<uint16_t>::WriteBigEndian(padded_payload_ptr,
|
||||
header_.indices.picture_index);
|
||||
padded_payload_ptr += sizeof(uint16_t);
|
||||
RTC_DCHECK_EQ(payload_size + kStereoHeaderLength,
|
||||
padded_payload_ptr - payload_ptr);
|
||||
}
|
||||
padded_payload_ptr[0] = last_packet ? kHeaderMarkerBit : 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string RtpPacketizerStereo::ToString() {
|
||||
return "RtpPacketizerStereo";
|
||||
}
|
||||
|
||||
RtpDepacketizerStereo::~RtpDepacketizerStereo() {}
|
||||
|
||||
bool RtpDepacketizerStereo::Parse(ParsedPayload* parsed_payload,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_data_length) {
|
||||
RTC_DCHECK(parsed_payload);
|
||||
if (payload_data_length == 0) {
|
||||
RTC_LOG(LS_ERROR) << "Empty payload.";
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t header_marker = payload_data[payload_data_length - 1];
|
||||
--payload_data_length;
|
||||
const bool last_packet = (header_marker & kHeaderMarkerBit) != 0;
|
||||
|
||||
if (last_packet) {
|
||||
if (payload_data_length <= kStereoHeaderLength) {
|
||||
RTC_LOG(LS_WARNING) << "Payload not large enough.";
|
||||
return false;
|
||||
}
|
||||
size_t offset = payload_data_length - kStereoHeaderLength;
|
||||
uint8_t associated_codec_type =
|
||||
ByteReader<uint8_t>::ReadBigEndian(&payload_data[offset]);
|
||||
switch (associated_codec_type) {
|
||||
case kRtpVideoVp8:
|
||||
case kRtpVideoVp9:
|
||||
case kRtpVideoH264:
|
||||
break;
|
||||
default:
|
||||
RTC_LOG(LS_WARNING) << "Unexpected codec type.";
|
||||
return false;
|
||||
}
|
||||
parsed_payload->type.Video.codecHeader.stereo.associated_codec_type =
|
||||
static_cast<RtpVideoCodecTypes>(associated_codec_type);
|
||||
offset += sizeof(uint8_t);
|
||||
parsed_payload->type.Video.codecHeader.stereo.indices.frame_index =
|
||||
ByteReader<uint8_t>::ReadBigEndian(&payload_data[offset]);
|
||||
offset += sizeof(uint8_t);
|
||||
parsed_payload->type.Video.codecHeader.stereo.indices.frame_count =
|
||||
ByteReader<uint8_t>::ReadBigEndian(&payload_data[offset]);
|
||||
offset += sizeof(uint8_t);
|
||||
parsed_payload->type.Video.codecHeader.stereo.indices.picture_index =
|
||||
ByteReader<uint16_t>::ReadBigEndian(&payload_data[offset]);
|
||||
RTC_DCHECK_EQ(payload_data_length, offset + sizeof(uint16_t));
|
||||
payload_data_length -= kStereoHeaderLength;
|
||||
}
|
||||
if (!depacketizer_.Parse(parsed_payload, payload_data, payload_data_length))
|
||||
return false;
|
||||
parsed_payload->type.Video.codec = kRtpVideoStereo;
|
||||
return true;
|
||||
}
|
||||
} // namespace webrtc
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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.
|
||||
*/
|
||||
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_STEREO_H_
|
||||
#define MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_STEREO_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modules/rtp_rtcp/source/rtp_format.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_format_video_generic.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class RtpPacketizerStereo : public RtpPacketizer {
|
||||
public:
|
||||
RtpPacketizerStereo(const RTPVideoHeaderStereo& header,
|
||||
FrameType frame_type,
|
||||
size_t max_payload_len,
|
||||
size_t last_packet_reduction_len);
|
||||
|
||||
~RtpPacketizerStereo() override;
|
||||
|
||||
size_t SetPayloadData(const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation) override;
|
||||
|
||||
// Get the next payload with generic payload header.
|
||||
// Write payload and set marker bit of the |packet|.
|
||||
// Returns true on success, false otherwise.
|
||||
bool NextPacket(RtpPacketToSend* packet) override;
|
||||
|
||||
std::string ToString() override;
|
||||
|
||||
private:
|
||||
const RTPVideoHeaderStereo header_;
|
||||
const size_t max_payload_len_;
|
||||
const size_t last_packet_reduction_len_;
|
||||
size_t num_packets_remaining_ = 0;
|
||||
// TODO(emircan): Use codec specific packetizers. If not possible, refactor
|
||||
// this class to have similar logic to generic packetizer.
|
||||
RtpPacketizerGeneric packetizer_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerStereo);
|
||||
};
|
||||
|
||||
class RtpDepacketizerStereo : public RtpDepacketizer {
|
||||
public:
|
||||
~RtpDepacketizerStereo() override;
|
||||
|
||||
bool Parse(ParsedPayload* parsed_payload,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_data_length) override;
|
||||
|
||||
private:
|
||||
RtpDepacketizerGeneric depacketizer_;
|
||||
};
|
||||
} // namespace webrtc
|
||||
#endif // MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_STEREO_H_
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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 <vector>
|
||||
|
||||
#include "modules/rtp_rtcp/source/rtp_format_video_stereo.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
using ::testing::Each;
|
||||
using ::testing::ElementsAreArray;
|
||||
using ::testing::Le;
|
||||
using ::testing::SizeIs;
|
||||
|
||||
constexpr RtpVideoCodecTypes kTestAssociatedCodecType = kRtpVideoVp9;
|
||||
constexpr uint8_t kTestFrameIndex = 23;
|
||||
constexpr uint8_t kTestFrameCount = 34;
|
||||
constexpr uint16_t kTestPictureIndex = 123;
|
||||
|
||||
RTPVideoHeaderStereo GenerateTestStereoHeader() {
|
||||
RTPVideoHeaderStereo header;
|
||||
header.associated_codec_type = kTestAssociatedCodecType;
|
||||
header.indices.frame_index = kTestFrameIndex;
|
||||
header.indices.frame_count = kTestFrameCount;
|
||||
header.indices.picture_index = kTestPictureIndex;
|
||||
return header;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> GenerateTestPayload() {
|
||||
const size_t kPayloadSize = 68;
|
||||
return std::vector<uint8_t>(kPayloadSize, 0);
|
||||
}
|
||||
|
||||
std::vector<size_t> NextPacketFillPayloadSizes(
|
||||
RtpPacketizerStereo* packetizer) {
|
||||
RtpPacketToSend packet(nullptr);
|
||||
std::vector<size_t> result;
|
||||
while (packetizer->NextPacket(&packet))
|
||||
result.push_back(packet.payload_size());
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(RtpPacketizerVideoStereo, SmallMaxPayloadSizeThrowsErrors) {
|
||||
const size_t kMaxPayloadLen = 7;
|
||||
const size_t kLastPacketReductionLen = 2;
|
||||
RtpPacketizerStereo packetizer(GenerateTestStereoHeader(), kVideoFrameKey,
|
||||
kMaxPayloadLen, kLastPacketReductionLen);
|
||||
const std::vector<uint8_t>& test_payload = GenerateTestPayload();
|
||||
packetizer.SetPayloadData(test_payload.data(), test_payload.size(), nullptr);
|
||||
RtpPacketToSend packet(nullptr);
|
||||
EXPECT_FALSE(packetizer.NextPacket(&packet));
|
||||
}
|
||||
|
||||
TEST(RtpPacketizerVideoStereo, AllPacketsRespectMaxPayloadSize) {
|
||||
const size_t kMaxPayloadLen = 34;
|
||||
const size_t kLastPacketReductionLen = 2;
|
||||
RtpPacketizerStereo packetizer(GenerateTestStereoHeader(), kVideoFrameKey,
|
||||
kMaxPayloadLen, kLastPacketReductionLen);
|
||||
const std::vector<uint8_t>& test_payload = GenerateTestPayload();
|
||||
size_t num_packets = packetizer.SetPayloadData(test_payload.data(),
|
||||
test_payload.size(), nullptr);
|
||||
std::vector<size_t> payload_sizes = NextPacketFillPayloadSizes(&packetizer);
|
||||
EXPECT_THAT(payload_sizes, SizeIs(num_packets));
|
||||
EXPECT_THAT(payload_sizes, Each(Le(kMaxPayloadLen)));
|
||||
}
|
||||
|
||||
TEST(RtpPacketizerVideoStereo, PreservesTypeAndHeader) {
|
||||
const size_t kMaxPayloadLen = 34;
|
||||
const size_t kLastPacketReductionLen = 2;
|
||||
const auto kFrameType = kVideoFrameKey;
|
||||
RtpPacketizerStereo packetizer(GenerateTestStereoHeader(), kFrameType,
|
||||
kMaxPayloadLen, kLastPacketReductionLen);
|
||||
const std::vector<uint8_t>& test_payload = GenerateTestPayload();
|
||||
packetizer.SetPayloadData(test_payload.data(), test_payload.size(), nullptr);
|
||||
RtpPacketToSend packet(nullptr);
|
||||
std::vector<RtpPacketToSend> result;
|
||||
while (packetizer.NextPacket(&packet)) {
|
||||
result.push_back(packet);
|
||||
packet = RtpPacketToSend(nullptr);
|
||||
}
|
||||
|
||||
RtpDepacketizerStereo depacketizer;
|
||||
const auto& first_payload = result.front().payload();
|
||||
RtpDepacketizer::ParsedPayload parsed_payload;
|
||||
ASSERT_TRUE(depacketizer.Parse(&parsed_payload, first_payload.data(),
|
||||
first_payload.size()));
|
||||
EXPECT_TRUE(parsed_payload.type.Video.is_first_packet_in_frame);
|
||||
|
||||
const auto& last_payload = result.back().payload();
|
||||
ASSERT_TRUE(depacketizer.Parse(&parsed_payload, last_payload.data(),
|
||||
last_payload.size()));
|
||||
EXPECT_EQ(kFrameType, parsed_payload.frame_type);
|
||||
EXPECT_EQ(kRtpVideoStereo, parsed_payload.type.Video.codec);
|
||||
EXPECT_EQ(kTestAssociatedCodecType,
|
||||
parsed_payload.type.Video.codecHeader.stereo.associated_codec_type);
|
||||
EXPECT_EQ(kTestFrameIndex,
|
||||
parsed_payload.type.Video.codecHeader.stereo.indices.frame_index);
|
||||
EXPECT_EQ(kTestFrameCount,
|
||||
parsed_payload.type.Video.codecHeader.stereo.indices.frame_count);
|
||||
EXPECT_EQ(kTestPictureIndex,
|
||||
parsed_payload.type.Video.codecHeader.stereo.indices.picture_index);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -58,11 +58,14 @@ RtpVideoCodecTypes ConvertToRtpVideoCodecType(VideoCodecType type) {
|
||||
case kVideoCodecRED:
|
||||
case kVideoCodecULPFEC:
|
||||
return kRtpVideoNone;
|
||||
case kVideoCodecI420:
|
||||
case kVideoCodecFlexfec:
|
||||
case kVideoCodecGeneric:
|
||||
case kVideoCodecStereo:
|
||||
return kRtpVideoStereo;
|
||||
default:
|
||||
case kVideoCodecUnknown:
|
||||
return kRtpVideoGeneric;
|
||||
}
|
||||
return kRtpVideoGeneric;
|
||||
}
|
||||
|
||||
RtpUtility::Payload CreatePayloadType(const VideoCodec& video_codec) {
|
||||
|
@ -90,7 +90,7 @@ RtpUtility::Payload* RTPSenderVideo::CreateVideoPayload(
|
||||
} else if (RtpUtility::StringCompare(payload_name, "I420", 4)) {
|
||||
video_type = kRtpVideoGeneric;
|
||||
} else if (RtpUtility::StringCompare(payload_name, "stereo", 6)) {
|
||||
video_type = kRtpVideoStereo;
|
||||
video_type = kRtpVideoGeneric;
|
||||
} else {
|
||||
video_type = kRtpVideoGeneric;
|
||||
}
|
||||
|
@ -160,7 +160,6 @@ rtc_source_set("codec_globals_headers") {
|
||||
sources = [
|
||||
"codecs/h264/include/h264_globals.h",
|
||||
"codecs/interface/common_constants.h",
|
||||
"codecs/stereo/include/stereo_globals.h",
|
||||
"codecs/vp8/include/vp8_globals.h",
|
||||
"codecs/vp9/include/vp9_globals.h",
|
||||
]
|
||||
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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.
|
||||
*/
|
||||
|
||||
#ifndef MODULES_VIDEO_CODING_CODECS_STEREO_INCLUDE_STEREO_GLOBALS_H_
|
||||
#define MODULES_VIDEO_CODING_CODECS_STEREO_INCLUDE_STEREO_GLOBALS_H_
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
struct StereoIndices {
|
||||
uint8_t frame_index;
|
||||
uint8_t frame_count;
|
||||
uint16_t picture_index;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_VIDEO_CODING_CODECS_STEREO_INCLUDE_STEREO_GLOBALS_H_
|
@ -212,8 +212,6 @@ EncodedImageCallback::Result StereoEncoderAdapter::OnEncodedImage(
|
||||
const EncodedImage& encodedImage,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
CodecSpecificInfo codec_info = *codecSpecificInfo;
|
||||
codec_info.codecType = kVideoCodecStereo;
|
||||
const auto& stashed_image_itr = stashed_images_.find(encodedImage._timeStamp);
|
||||
const auto& stashed_image_next_itr = std::next(stashed_image_itr, 1);
|
||||
RTC_DCHECK(stashed_image_itr != stashed_images_.end());
|
||||
@ -246,6 +244,10 @@ EncodedImageCallback::Result StereoEncoderAdapter::OnEncodedImage(
|
||||
delete[] combined_image_._buffer;
|
||||
combined_image_ =
|
||||
MultiplexEncodedImagePacker::PackAndRelease(iter->second);
|
||||
|
||||
CodecSpecificInfo codec_info = *codecSpecificInfo;
|
||||
codec_info.codecType = kVideoCodecStereo;
|
||||
codec_info.codecSpecific.generic.simulcast_idx = 0;
|
||||
encoded_complete_callback_->OnEncodedImage(combined_image_, &codec_info,
|
||||
fragmentation);
|
||||
iter++;
|
||||
|
@ -193,29 +193,8 @@ void VCMEncodedFrame::CopyCodecSpecific(const RTPVideoHeader* header) {
|
||||
_codecSpecificInfo.codecType = kVideoCodecH264;
|
||||
break;
|
||||
}
|
||||
case kRtpVideoStereo: {
|
||||
_codecSpecificInfo.codecType = kVideoCodecStereo;
|
||||
VideoCodecType associated_codec_type = kVideoCodecUnknown;
|
||||
switch (header->codecHeader.stereo.associated_codec_type) {
|
||||
case kRtpVideoVp8:
|
||||
associated_codec_type = kVideoCodecVP8;
|
||||
break;
|
||||
case kRtpVideoVp9:
|
||||
associated_codec_type = kVideoCodecVP9;
|
||||
break;
|
||||
case kRtpVideoH264:
|
||||
associated_codec_type = kVideoCodecH264;
|
||||
break;
|
||||
default:
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
_codecSpecificInfo.codecSpecific.stereo.associated_codec_type =
|
||||
associated_codec_type;
|
||||
_codecSpecificInfo.codecSpecific.stereo.indices =
|
||||
header->codecHeader.stereo.indices;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
case kRtpVideoNone:
|
||||
case kRtpVideoGeneric: {
|
||||
_codecSpecificInfo.codecType = kVideoCodecUnknown;
|
||||
break;
|
||||
}
|
||||
|
@ -43,14 +43,9 @@ RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer,
|
||||
frame_type_ = first_packet->frameType;
|
||||
codec_type_ = first_packet->codec;
|
||||
|
||||
// Stereo codec appends CopyCodecSpecific to last packet to avoid copy.
|
||||
VCMPacket* packet_with_codec_specific =
|
||||
codec_type_ == kVideoCodecStereo ? packet_buffer_->GetPacket(last_seq_num)
|
||||
: first_packet;
|
||||
|
||||
// TODO(philipel): Remove when encoded image is replaced by FrameObject.
|
||||
// VCMEncodedFrame members
|
||||
CopyCodecSpecific(&packet_with_codec_specific->video_header);
|
||||
CopyCodecSpecific(&first_packet->video_header);
|
||||
_completeFrame = true;
|
||||
_payloadType = first_packet->payloadType;
|
||||
_timeStamp = first_packet->timestamp;
|
||||
|
@ -73,17 +73,11 @@ struct CodecSpecificInfoH264 {
|
||||
H264PacketizationMode packetization_mode;
|
||||
};
|
||||
|
||||
struct CodecSpecificInfoStereo {
|
||||
VideoCodecType associated_codec_type;
|
||||
StereoIndices indices;
|
||||
};
|
||||
|
||||
union CodecSpecificInfoUnion {
|
||||
CodecSpecificInfoGeneric generic;
|
||||
CodecSpecificInfoVP8 VP8;
|
||||
CodecSpecificInfoVP9 VP9;
|
||||
CodecSpecificInfoH264 H264;
|
||||
CodecSpecificInfoStereo stereo;
|
||||
};
|
||||
|
||||
// Note: if any pointers are added to this struct or its sub-structs, it
|
||||
|
@ -133,9 +133,6 @@ void VCMPacket::CopyCodecSpecifics(const RTPVideoHeader& videoHeader) {
|
||||
}
|
||||
codec = kVideoCodecH264;
|
||||
return;
|
||||
case kRtpVideoStereo:
|
||||
codec = kVideoCodecStereo;
|
||||
return;
|
||||
case kRtpVideoGeneric:
|
||||
codec = kVideoCodecGeneric;
|
||||
return;
|
||||
|
@ -81,26 +81,7 @@ void CopyCodecSpecific(const CodecSpecificInfo* info, RTPVideoHeader* rtp) {
|
||||
rtp->codecHeader.H264.packetization_mode =
|
||||
info->codecSpecific.H264.packetization_mode;
|
||||
return;
|
||||
case kVideoCodecStereo: {
|
||||
rtp->codec = kRtpVideoStereo;
|
||||
RtpVideoCodecTypes associated_codec_type = kRtpVideoNone;
|
||||
switch (info->codecSpecific.stereo.associated_codec_type) {
|
||||
case kVideoCodecVP8:
|
||||
associated_codec_type = kRtpVideoVp8;
|
||||
break;
|
||||
case kVideoCodecVP9:
|
||||
associated_codec_type = kRtpVideoVp9;
|
||||
break;
|
||||
case kVideoCodecH264:
|
||||
associated_codec_type = kRtpVideoH264;
|
||||
break;
|
||||
default:
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
rtp->codecHeader.stereo.associated_codec_type = associated_codec_type;
|
||||
rtp->codecHeader.stereo.indices = info->codecSpecific.stereo.indices;
|
||||
return;
|
||||
}
|
||||
case kVideoCodecStereo:
|
||||
case kVideoCodecGeneric:
|
||||
rtp->codec = kRtpVideoGeneric;
|
||||
rtp->simulcastIdx = info->codecSpecific.generic.simulcast_idx;
|
||||
|
Reference in New Issue
Block a user