• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <stddef.h>
14 #include <stdint.h>
15 
16 #include "api/array_view.h"
17 #include "api/scoped_refptr.h"
18 #include "api/video/encoded_image.h"
19 #include "rtc_base/checks.h"
20 
21 namespace webrtc {
22 
AssembleFrame(rtc::ArrayView<const rtc::ArrayView<const uint8_t>> rtp_payloads)23 rtc::scoped_refptr<EncodedImageBuffer> VideoRtpDepacketizer::AssembleFrame(
24     rtc::ArrayView<const rtc::ArrayView<const uint8_t>> rtp_payloads) {
25   size_t frame_size = 0;
26   for (rtc::ArrayView<const uint8_t> payload : rtp_payloads) {
27     frame_size += payload.size();
28   }
29 
30   rtc::scoped_refptr<EncodedImageBuffer> bitstream =
31       EncodedImageBuffer::Create(frame_size);
32 
33   uint8_t* write_at = bitstream->data();
34   for (rtc::ArrayView<const uint8_t> payload : rtp_payloads) {
35     memcpy(write_at, payload.data(), payload.size());
36     write_at += payload.size();
37   }
38   RTC_DCHECK_EQ(write_at - bitstream->data(), bitstream->size());
39   return bitstream;
40 }
41 
42 }  // namespace webrtc
43