video_rtp_depacketizer.cc (1330B)
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/rtp_rtcp/source/video_rtp_depacketizer.h" 12 13 #include <cstddef> 14 #include <cstdint> 15 #include <cstring> 16 17 #include "api/array_view.h" 18 #include "api/scoped_refptr.h" 19 #include "api/video/encoded_image.h" 20 #include "rtc_base/checks.h" 21 22 namespace webrtc { 23 24 scoped_refptr<EncodedImageBuffer> VideoRtpDepacketizer::AssembleFrame( 25 ArrayView<const ArrayView<const uint8_t>> rtp_payloads) { 26 size_t frame_size = 0; 27 for (ArrayView<const uint8_t> payload : rtp_payloads) { 28 frame_size += payload.size(); 29 } 30 31 scoped_refptr<EncodedImageBuffer> bitstream = 32 EncodedImageBuffer::Create(frame_size); 33 34 uint8_t* write_at = bitstream->data(); 35 for (ArrayView<const uint8_t> payload : rtp_payloads) { 36 memcpy(write_at, payload.data(), payload.size()); 37 write_at += payload.size(); 38 } 39 RTC_DCHECK_EQ(write_at - bitstream->data(), bitstream->size()); 40 return bitstream; 41 } 42 43 } // namespace webrtc