Skip to content

Commit

Permalink
Set generic frame descriptor extension for HEVC (open-webrtc-toolkit#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
taste1981 authored and jianjunz committed Dec 7, 2022
1 parent 3b8b0de commit 8110732
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
29 changes: 28 additions & 1 deletion call/rtp_payload_params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,32 @@ void RtpPayloadParams::SetGeneric(const CodecSpecificInfo* codec_specific_info,
int64_t frame_id,
bool is_keyframe,
RTPVideoHeader* rtp_video_header) {
if (codec_specific_info && codec_specific_info->generic_frame_info &&

#ifdef WEBRTC_USE_H265
if (codec_specific_info->codecType == webrtc::kVideoCodecH265 &&
codec_specific_info->codecSpecific.H265.picture_id > 0) {
// H265ToGeneric implementation. Only set it when picture id is valid.
rtp_video_header->generic->frame_id =
codec_specific_info->codecSpecific.H265.picture_id;
rtp_video_header->generic->discardable =
codec_specific_info->codecSpecific.H265.discardable;
rtp_video_header->generic->spatial_index = 0; // Not enabled at present.
rtp_video_header->generic->temporal_index = 0; // Not enabled at present.
for (int dep_idx = 0; dep_idx < 5; dep_idx++) {
if (codec_specific_info->codecSpecific.H265.dependencies[dep_idx] <= 0)
break;
rtp_video_header->generic->dependencies[dep_idx] =
codec_specific_info->codecSpecific.H265.dependencies[dep_idx];
}
// Not filling DTIs at present.
rtp_video_header->generic->discardable =
codec_specific_info->codecSpecific.H265.discardable;
return;
}
#else
if (codec_specific_info && codec_specific_info->generic_frame_info &&
!codec_specific_info->generic_frame_info->encoder_buffers.empty()) {
// If generic frame info is provided for other codecs, use generic frame info.
if (is_keyframe) {
// Key frame resets all chains it is in.
chains_calculator_.Reset(
Expand All @@ -328,6 +352,8 @@ void RtpPayloadParams::SetGeneric(const CodecSpecificInfo* codec_specific_info,
*codec_specific_info->generic_frame_info, frame_id);
return;
}
#endif


switch (rtp_video_header->codec) {
case VideoCodecType::kVideoCodecGeneric:
Expand Down Expand Up @@ -355,6 +381,7 @@ void RtpPayloadParams::SetGeneric(const CodecSpecificInfo* codec_specific_info,
}
return;
#ifndef DISABLE_H265
// No further special handling for H.265
case VideoCodecType::kVideoCodecH265:
#endif
case VideoCodecType::kVideoCodecMultiplex:
Expand Down
3 changes: 3 additions & 0 deletions modules/video_coding/include/video_codec_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ struct CodecSpecificInfoH265 {
bool idr_frame;
bool last_fragment_in_frame;
int16_t picture_id;
int dependencies[5];
int dtis[10];
bool discardable;
};
#endif

Expand Down

0 comments on commit 8110732

Please sign in to comment.