• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2017 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/rtp_packet_received.h"
12 
13 #include <stddef.h>
14 
15 #include <cstdint>
16 #include <vector>
17 
18 #include "modules/rtp_rtcp/source/rtp_header_extensions.h"
19 #include "rtc_base/numerics/safe_conversions.h"
20 
21 namespace webrtc {
22 
23 RtpPacketReceived::RtpPacketReceived() = default;
RtpPacketReceived(const ExtensionManager * extensions)24 RtpPacketReceived::RtpPacketReceived(const ExtensionManager* extensions)
25     : RtpPacket(extensions) {}
26 RtpPacketReceived::RtpPacketReceived(const RtpPacketReceived& packet) = default;
27 RtpPacketReceived::RtpPacketReceived(RtpPacketReceived&& packet) = default;
28 
29 RtpPacketReceived& RtpPacketReceived::operator=(
30     const RtpPacketReceived& packet) = default;
31 RtpPacketReceived& RtpPacketReceived::operator=(RtpPacketReceived&& packet) =
32     default;
33 
~RtpPacketReceived()34 RtpPacketReceived::~RtpPacketReceived() {}
35 
GetHeader(RTPHeader * header) const36 void RtpPacketReceived::GetHeader(RTPHeader* header) const {
37   header->markerBit = Marker();
38   header->payloadType = PayloadType();
39   header->sequenceNumber = SequenceNumber();
40   header->timestamp = Timestamp();
41   header->ssrc = Ssrc();
42   std::vector<uint32_t> csrcs = Csrcs();
43   header->numCSRCs = rtc::dchecked_cast<uint8_t>(csrcs.size());
44   for (size_t i = 0; i < csrcs.size(); ++i) {
45     header->arrOfCSRCs[i] = csrcs[i];
46   }
47   header->paddingLength = padding_size();
48   header->headerLength = headers_size();
49   header->payload_type_frequency = payload_type_frequency();
50   header->extension.hasTransmissionTimeOffset =
51       GetExtension<TransmissionOffset>(
52           &header->extension.transmissionTimeOffset);
53   header->extension.hasAbsoluteSendTime =
54       GetExtension<AbsoluteSendTime>(&header->extension.absoluteSendTime);
55   header->extension.absolute_capture_time =
56       GetExtension<AbsoluteCaptureTimeExtension>();
57   header->extension.hasTransportSequenceNumber =
58       GetExtension<TransportSequenceNumberV2>(
59           &header->extension.transportSequenceNumber,
60           &header->extension.feedback_request) ||
61       GetExtension<TransportSequenceNumber>(
62           &header->extension.transportSequenceNumber);
63   header->extension.hasAudioLevel = GetExtension<AudioLevel>(
64       &header->extension.voiceActivity, &header->extension.audioLevel);
65   header->extension.hasVideoRotation =
66       GetExtension<VideoOrientation>(&header->extension.videoRotation);
67   header->extension.hasVideoContentType =
68       GetExtension<VideoContentTypeExtension>(
69           &header->extension.videoContentType);
70   header->extension.has_video_timing =
71       GetExtension<VideoTimingExtension>(&header->extension.video_timing);
72   GetExtension<RtpStreamId>(&header->extension.stream_id);
73   GetExtension<RepairedRtpStreamId>(&header->extension.repaired_stream_id);
74   GetExtension<RtpMid>(&header->extension.mid);
75   GetExtension<PlayoutDelayLimits>(&header->extension.playout_delay);
76   header->extension.color_space = GetExtension<ColorSpaceExtension>();
77 }
78 
79 }  // namespace webrtc
80