mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00

Remove VCMEncodedFrame from the inheritance chain of EncodedFrames by - moving getters for EncodedImage fields up to EncodedImage - copying other non-deprecated fields & Methods from VCMEncodedFrame over to EncodedFrame - Removing EncodedFrame's inheritance of VCMEncodedFrame We leave VCMEncodedFrame as part of the (near) deprecated VideoCodingModule code. The only place which needs to accept either is in the generic decoder. Bug: webrtc:9378, b:296992877 Change-Id: I60706aebbb6eacc7fd4b35ec90cc903efdbe14c8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/317160 Reviewed-by: Åsa Persson <asapersson@webrtc.org> Auto-Submit: Tony Herre <herre@google.com> Commit-Queue: Tony Herre <herre@google.com> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40639}
130 lines
4.9 KiB
C++
130 lines
4.9 KiB
C++
/*
|
|
* Copyright (c) 2018 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 "api/video/encoded_frame.h"
|
|
|
|
#include "absl/types/optional.h"
|
|
#include "modules/rtp_rtcp/source/rtp_video_header.h"
|
|
|
|
namespace webrtc {
|
|
|
|
absl::optional<Timestamp> EncodedFrame::ReceivedTimestamp() const {
|
|
return ReceivedTime() >= 0
|
|
? absl::make_optional(Timestamp::Millis(ReceivedTime()))
|
|
: absl::nullopt;
|
|
}
|
|
|
|
absl::optional<Timestamp> EncodedFrame::RenderTimestamp() const {
|
|
return RenderTimeMs() >= 0
|
|
? absl::make_optional(Timestamp::Millis(RenderTimeMs()))
|
|
: absl::nullopt;
|
|
}
|
|
|
|
bool EncodedFrame::delayed_by_retransmission() const {
|
|
return false;
|
|
}
|
|
|
|
void EncodedFrame::CopyCodecSpecific(const RTPVideoHeader* header) {
|
|
if (header) {
|
|
switch (header->codec) {
|
|
case kVideoCodecVP8: {
|
|
const auto& vp8_header =
|
|
absl::get<RTPVideoHeaderVP8>(header->video_type_header);
|
|
if (_codecSpecificInfo.codecType != kVideoCodecVP8) {
|
|
// This is the first packet for this frame.
|
|
_codecSpecificInfo.codecSpecific.VP8.temporalIdx = 0;
|
|
_codecSpecificInfo.codecSpecific.VP8.layerSync = false;
|
|
_codecSpecificInfo.codecSpecific.VP8.keyIdx = -1;
|
|
_codecSpecificInfo.codecType = kVideoCodecVP8;
|
|
}
|
|
_codecSpecificInfo.codecSpecific.VP8.nonReference =
|
|
vp8_header.nonReference;
|
|
if (vp8_header.temporalIdx != kNoTemporalIdx) {
|
|
_codecSpecificInfo.codecSpecific.VP8.temporalIdx =
|
|
vp8_header.temporalIdx;
|
|
_codecSpecificInfo.codecSpecific.VP8.layerSync = vp8_header.layerSync;
|
|
}
|
|
if (vp8_header.keyIdx != kNoKeyIdx) {
|
|
_codecSpecificInfo.codecSpecific.VP8.keyIdx = vp8_header.keyIdx;
|
|
}
|
|
break;
|
|
}
|
|
case kVideoCodecVP9: {
|
|
const auto& vp9_header =
|
|
absl::get<RTPVideoHeaderVP9>(header->video_type_header);
|
|
if (_codecSpecificInfo.codecType != kVideoCodecVP9) {
|
|
// This is the first packet for this frame.
|
|
_codecSpecificInfo.codecSpecific.VP9.temporal_idx = 0;
|
|
_codecSpecificInfo.codecSpecific.VP9.gof_idx = 0;
|
|
_codecSpecificInfo.codecSpecific.VP9.inter_layer_predicted = false;
|
|
_codecSpecificInfo.codecType = kVideoCodecVP9;
|
|
}
|
|
_codecSpecificInfo.codecSpecific.VP9.inter_pic_predicted =
|
|
vp9_header.inter_pic_predicted;
|
|
_codecSpecificInfo.codecSpecific.VP9.flexible_mode =
|
|
vp9_header.flexible_mode;
|
|
_codecSpecificInfo.codecSpecific.VP9.num_ref_pics =
|
|
vp9_header.num_ref_pics;
|
|
for (uint8_t r = 0; r < vp9_header.num_ref_pics; ++r) {
|
|
_codecSpecificInfo.codecSpecific.VP9.p_diff[r] =
|
|
vp9_header.pid_diff[r];
|
|
}
|
|
_codecSpecificInfo.codecSpecific.VP9.ss_data_available =
|
|
vp9_header.ss_data_available;
|
|
if (vp9_header.temporal_idx != kNoTemporalIdx) {
|
|
_codecSpecificInfo.codecSpecific.VP9.temporal_idx =
|
|
vp9_header.temporal_idx;
|
|
_codecSpecificInfo.codecSpecific.VP9.temporal_up_switch =
|
|
vp9_header.temporal_up_switch;
|
|
}
|
|
if (vp9_header.spatial_idx != kNoSpatialIdx) {
|
|
_codecSpecificInfo.codecSpecific.VP9.inter_layer_predicted =
|
|
vp9_header.inter_layer_predicted;
|
|
SetSpatialIndex(vp9_header.spatial_idx);
|
|
}
|
|
if (vp9_header.gof_idx != kNoGofIdx) {
|
|
_codecSpecificInfo.codecSpecific.VP9.gof_idx = vp9_header.gof_idx;
|
|
}
|
|
if (vp9_header.ss_data_available) {
|
|
_codecSpecificInfo.codecSpecific.VP9.num_spatial_layers =
|
|
vp9_header.num_spatial_layers;
|
|
_codecSpecificInfo.codecSpecific.VP9
|
|
.spatial_layer_resolution_present =
|
|
vp9_header.spatial_layer_resolution_present;
|
|
if (vp9_header.spatial_layer_resolution_present) {
|
|
for (size_t i = 0; i < vp9_header.num_spatial_layers; ++i) {
|
|
_codecSpecificInfo.codecSpecific.VP9.width[i] =
|
|
vp9_header.width[i];
|
|
_codecSpecificInfo.codecSpecific.VP9.height[i] =
|
|
vp9_header.height[i];
|
|
}
|
|
}
|
|
_codecSpecificInfo.codecSpecific.VP9.gof.CopyGofInfoVP9(
|
|
vp9_header.gof);
|
|
}
|
|
break;
|
|
}
|
|
case kVideoCodecH264: {
|
|
_codecSpecificInfo.codecType = kVideoCodecH264;
|
|
break;
|
|
}
|
|
case kVideoCodecAV1: {
|
|
_codecSpecificInfo.codecType = kVideoCodecAV1;
|
|
break;
|
|
}
|
|
default: {
|
|
_codecSpecificInfo.codecType = kVideoCodecGeneric;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace webrtc
|