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

The extension (and thus structures to carry it) are designed in particular for client<->SFU link. Putting the structure into api acknowledges it can be reused by SFU projects Bug: webrtc:10342 Change-Id: I8ca1f5046abadf6aa16200443c4892e9a2a928b4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166467 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30324}
75 lines
2.6 KiB
C++
75 lines
2.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.
|
|
*/
|
|
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_READER_H_
|
|
#define MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_READER_H_
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "api/array_view.h"
|
|
#include "api/transport/rtp/dependency_descriptor.h"
|
|
#include "rtc_base/bit_buffer.h"
|
|
|
|
namespace webrtc {
|
|
// Deserializes DependencyDescriptor rtp header extension.
|
|
class RtpDependencyDescriptorReader {
|
|
public:
|
|
// Parses the dependency descriptor.
|
|
RtpDependencyDescriptorReader(rtc::ArrayView<const uint8_t> raw_data,
|
|
const FrameDependencyStructure* structure,
|
|
DependencyDescriptor* descriptor);
|
|
RtpDependencyDescriptorReader(const RtpDependencyDescriptorReader&) = delete;
|
|
RtpDependencyDescriptorReader& operator=(
|
|
const RtpDependencyDescriptorReader&) = delete;
|
|
|
|
// Returns true if parse was successful.
|
|
bool ParseSuccessful() { return !parsing_failed_; }
|
|
|
|
private:
|
|
// Reads bits from |buffer_|. If it fails, returns 0 and marks parsing as
|
|
// failed, but doesn't stop the parsing.
|
|
uint32_t ReadBits(size_t bit_count);
|
|
uint32_t ReadNonSymmetric(size_t num_values);
|
|
|
|
// Functions to read template dependency structure.
|
|
void ReadTemplateDependencyStructure();
|
|
void ReadTemplateLayers();
|
|
void ReadTemplateDtis();
|
|
void ReadTemplateFdiffs();
|
|
void ReadTemplateChains();
|
|
void ReadResolutions();
|
|
|
|
// Function to read details for the current frame.
|
|
void ReadMandatoryFields();
|
|
void ReadExtendedFields();
|
|
void ReadFrameDependencyDefinition();
|
|
|
|
void ReadFrameDtis();
|
|
void ReadFrameFdiffs();
|
|
void ReadFrameChains();
|
|
|
|
// Output.
|
|
bool parsing_failed_ = false;
|
|
DependencyDescriptor* const descriptor_;
|
|
// Values that are needed while reading the descriptor, but can be discarded
|
|
// when reading is complete.
|
|
rtc::BitBuffer buffer_;
|
|
int frame_dependency_template_id_ = 0;
|
|
bool active_decode_targets_present_flag_ = false;
|
|
bool custom_dtis_flag_ = false;
|
|
bool custom_fdiffs_flag_ = false;
|
|
bool custom_chains_flag_ = false;
|
|
const FrameDependencyStructure* structure_ = nullptr;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_READER_H_
|