Add trait to Build/Parse DependencyDescriptor rtp header extension

TBR=aleloi@webrtc.org

Bug: webrtc:10342
Change-Id: I9d321ec47ed748ccfac2be6793923c46d0a88d16
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144032
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28415}
This commit is contained in:
Danil Chapovalov 2019-06-27 16:45:40 +02:00 committed by Commit Bot
parent 225842ced8
commit 52e5242593
10 changed files with 175 additions and 0 deletions

View file

@ -44,6 +44,9 @@ rtc_source_set("rtp_rtcp_format") {
"source/rtcp_packet/tmmbn.h",
"source/rtcp_packet/tmmbr.h",
"source/rtcp_packet/transport_feedback.h",
"source/rtp_dependency_descriptor_extension.h",
"source/rtp_dependency_descriptor_reader.h",
"source/rtp_dependency_descriptor_writer.h",
"source/rtp_generic_frame_descriptor.h",
"source/rtp_generic_frame_descriptor_extension.h",
"source/rtp_header_extensions.h",
@ -80,6 +83,7 @@ rtc_source_set("rtp_rtcp_format") {
"source/rtcp_packet/tmmbn.cc",
"source/rtcp_packet/tmmbr.cc",
"source/rtcp_packet/transport_feedback.cc",
"source/rtp_dependency_descriptor_extension.cc",
"source/rtp_generic_frame_descriptor.cc",
"source/rtp_generic_frame_descriptor_extension.cc",
"source/rtp_header_extension_map.cc",
@ -101,6 +105,7 @@ rtc_source_set("rtp_rtcp_format") {
"../../api/video:video_frame",
"../../api/video:video_rtp_headers",
"../../common_video",
"../../common_video/generic_frame_descriptor",
"../../rtc_base:checks",
"../../rtc_base:deprecation",
"../../rtc_base:rtc_base_approved",

View file

@ -69,6 +69,7 @@ enum RTPExtensionType : int {
kRtpExtensionGenericFrameDescriptor00,
kRtpExtensionGenericFrameDescriptor = kRtpExtensionGenericFrameDescriptor00,
kRtpExtensionGenericFrameDescriptor01,
kRtpExtensionGenericFrameDescriptor02,
kRtpExtensionColorSpace,
kRtpExtensionNumberOfExtensions // Must be the last entity in the enum.
};

View file

@ -0,0 +1,18 @@
/*
* 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/rtp_dependency_descriptor_extension.h"
namespace webrtc {
constexpr RTPExtensionType RtpDependencyDescriptorExtension::kId;
constexpr char RtpDependencyDescriptorExtension::kUri[];
} // namespace webrtc

View file

@ -0,0 +1,53 @@
/*
* 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.
*/
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_EXTENSION_H_
#define MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_EXTENSION_H_
#include <cstdint>
#include "api/array_view.h"
#include "common_video/generic_frame_descriptor/generic_frame_info.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.h"
#include "modules/rtp_rtcp/source/rtp_dependency_descriptor_writer.h"
namespace webrtc {
// Trait to read/write the dependency descriptor extension as described in
// https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension
// While the format is still in design, the code might change without backward
// compatibility.
class RtpDependencyDescriptorExtension {
public:
static constexpr RTPExtensionType kId = kRtpExtensionGenericFrameDescriptor02;
// TODO(bugs.webrtc.org/10342): Use uri from the spec when there is one.
static constexpr char kUri[] =
"http://www.webrtc.org/experiments/rtp-hdrext/"
"generic-frame-descriptor-02";
static bool Parse(rtc::ArrayView<const uint8_t> data,
RtpDependencyDescriptorReader* reader,
DependencyDescriptor* descriptor) {
return reader->Parse(data, descriptor);
}
static size_t ValueSize(RtpDependencyDescriptorWriter* writer,
const DependencyDescriptor& descriptor) {
return writer->ValueSizeBytes(descriptor);
}
static bool Write(rtc::ArrayView<uint8_t> data,
RtpDependencyDescriptorWriter* writer,
const DependencyDescriptor& descriptor) {
return writer->Write(descriptor, data);
}
};
} // namespace webrtc
#endif // MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_EXTENSION_H_

View file

@ -0,0 +1,41 @@
/*
* 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.
*/
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_READER_H_
#define MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_READER_H_
#include <cstdint>
#include "api/array_view.h"
#include "common_video/generic_frame_descriptor/generic_frame_info.h"
namespace webrtc {
// Keeps and updates state required to deserialize DependencyDescriptor
// rtp header extension.
class RtpDependencyDescriptorReader {
public:
// Parses the dependency descriptor. Returns false on failure.
// Updates frame dependency structures if parsed descriptor has a new one.
// Doesn't update own state when Parse fails.
bool Parse(rtc::ArrayView<const uint8_t> raw_data,
DependencyDescriptor* descriptor) {
// TODO(bugs.webrtc.org/10342): Implement.
return false;
}
// Returns latest valid parsed structure or nullptr if none was parsed so far.
const FrameDependencyStructure* GetStructure() const {
// TODO(bugs.webrtc.org/10342): Implement.
return nullptr;
}
};
} // namespace webrtc
#endif // MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_READER_H_

View file

@ -0,0 +1,49 @@
/*
* 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.
*/
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_WRITER_H_
#define MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_WRITER_H_
#include <cstdint>
#include "api/array_view.h"
#include "common_video/generic_frame_descriptor/generic_frame_info.h"
namespace webrtc {
// Serialize DependencyDescriptor with respect to set FrameDependencyStructure.
class RtpDependencyDescriptorWriter {
public:
// Returns minimum number of bits needed to serialize descriptor with respect
// to current FrameDependencyStructure. Returns 0 if |descriptor| can't be
// serialized.
size_t ValueSizeBits(const DependencyDescriptor& descriptor) const {
// TODO(bugs.webrtc.org/10342): Implement.
return 0;
}
size_t ValueSizeBytes(const DependencyDescriptor& descriptor) const {
return (ValueSizeBits(descriptor) + 7) / 8;
}
bool Write(const DependencyDescriptor& frame_info,
rtc::ArrayView<uint8_t> raw_data) const {
// TODO(bugs.webrtc.org/10342): Implement.
return false;
}
// Sets FrameDependencyStructure to derive individual descriptors from.
// Returns false on failure, e.g. structure is invalid or oversized.
bool SetStructure(const FrameDependencyStructure& structure) {
// TODO(bugs.webrtc.org/10342): Implement.
return false;
}
};
} // namespace webrtc
#endif // MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_WRITER_H_

View file

@ -10,6 +10,7 @@
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h"
#include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor_extension.h"
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "rtc_base/arraysize.h"
@ -45,6 +46,7 @@ constexpr ExtensionInfo kExtensions[] = {
CreateExtensionInfo<RtpMid>(),
CreateExtensionInfo<RtpGenericFrameDescriptorExtension00>(),
CreateExtensionInfo<RtpGenericFrameDescriptorExtension01>(),
CreateExtensionInfo<RtpDependencyDescriptorExtension>(),
CreateExtensionInfo<ColorSpaceExtension>(),
};

View file

@ -187,6 +187,7 @@ void RtpPacket::CopyAndZeroMutableExtensions(
case RTPExtensionType::kRtpExtensionFrameMarking:
case RTPExtensionType::kRtpExtensionGenericFrameDescriptor00:
case RTPExtensionType::kRtpExtensionGenericFrameDescriptor01:
case RTPExtensionType::kRtpExtensionGenericFrameDescriptor02:
case RTPExtensionType::kRtpExtensionMid:
case RTPExtensionType::kRtpExtensionNumberOfExtensions:
case RTPExtensionType::kRtpExtensionPlayoutDelay:

View file

@ -523,6 +523,7 @@ void RtpHeaderParser::ParseOneByteExtensionHeader(
}
case kRtpExtensionGenericFrameDescriptor00:
case kRtpExtensionGenericFrameDescriptor01:
case kRtpExtensionGenericFrameDescriptor02:
RTC_LOG(WARNING)
<< "RtpGenericFrameDescriptor unsupported by rtp header parser.";
break;

View file

@ -140,6 +140,10 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
packet.GetExtension<ColorSpaceExtension>(&color_space);
break;
}
case kRtpExtensionGenericFrameDescriptor02:
// This extension requires state to read and so complicated that
// deserves own fuzzer.
break;
}
}
}