rtp_generic_ref_finder.cc (2038B)
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 <cstddef> 14 #include <memory> 15 #include <utility> 16 17 #include "api/video/encoded_frame.h" 18 #include "api/video/video_codec_constants.h" 19 #include "modules/rtp_rtcp/source/frame_object.h" 20 #include "modules/rtp_rtcp/source/rtp_video_header.h" 21 #include "modules/video_coding/codecs/interface/common_constants.h" 22 #include "modules/video_coding/rtp_frame_reference_finder.h" 23 #include "rtc_base/logging.h" 24 25 namespace webrtc { 26 27 RtpFrameReferenceFinder::ReturnVector RtpGenericFrameRefFinder::ManageFrame( 28 std::unique_ptr<RtpFrameObject> frame, 29 const RTPVideoHeader::GenericDescriptorInfo& descriptor) { 30 RtpFrameReferenceFinder::ReturnVector res; 31 if (descriptor.spatial_index >= kMaxSpatialLayers) { 32 RTC_LOG(LS_WARNING) << "Spatial index " << descriptor.spatial_index 33 << " is unsupported."; 34 return res; 35 } 36 37 // Frame IDs are unwrapped in the RtpVideoStreamReceiver, no need to unwrap 38 // them here. 39 frame->SetId(descriptor.frame_id); 40 frame->SetSpatialIndex(descriptor.spatial_index); 41 if (descriptor.temporal_index != kNoTemporalIdx) 42 frame->SetTemporalIndex(descriptor.temporal_index); 43 44 if (EncodedFrame::kMaxFrameReferences < descriptor.dependencies.size()) { 45 RTC_LOG(LS_WARNING) << "Too many dependencies in generic descriptor."; 46 return res; 47 } 48 49 frame->num_references = descriptor.dependencies.size(); 50 for (size_t i = 0; i < descriptor.dependencies.size(); ++i) { 51 frame->references[i] = descriptor.dependencies[i]; 52 } 53 54 res.push_back(std::move(frame)); 55 return res; 56 } 57 58 } // namespace webrtc