xref: /aosp_15_r20/external/webrtc/modules/video_coding/rtp_generic_ref_finder.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "modules/video_coding/rtp_generic_ref_finder.h"
12 
13 #include <utility>
14 
15 #include "rtc_base/logging.h"
16 
17 namespace webrtc {
18 
ManageFrame(std::unique_ptr<RtpFrameObject> frame,const RTPVideoHeader::GenericDescriptorInfo & descriptor)19 RtpFrameReferenceFinder::ReturnVector RtpGenericFrameRefFinder::ManageFrame(
20     std::unique_ptr<RtpFrameObject> frame,
21     const RTPVideoHeader::GenericDescriptorInfo& descriptor) {
22   // Frame IDs are unwrapped in the RtpVideoStreamReceiver, no need to unwrap
23   // them here.
24   frame->SetId(descriptor.frame_id);
25   frame->SetSpatialIndex(descriptor.spatial_index);
26   if (descriptor.temporal_index != kNoTemporalIdx)
27     frame->SetTemporalIndex(descriptor.temporal_index);
28 
29   RtpFrameReferenceFinder::ReturnVector res;
30   if (EncodedFrame::kMaxFrameReferences < descriptor.dependencies.size()) {
31     RTC_LOG(LS_WARNING) << "Too many dependencies in generic descriptor.";
32     return res;
33   }
34 
35   frame->num_references = descriptor.dependencies.size();
36   for (size_t i = 0; i < descriptor.dependencies.size(); ++i) {
37     frame->references[i] = descriptor.dependencies[i];
38   }
39 
40   res.push_back(std::move(frame));
41   return res;
42 }
43 
44 }  // namespace webrtc
45