1e0e9324cSopenharmony_ci/* 2e0e9324cSopenharmony_ci * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3e0e9324cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e0e9324cSopenharmony_ci * you may not use this file except in compliance with the License. 5e0e9324cSopenharmony_ci * You may obtain a copy of the License at 6e0e9324cSopenharmony_ci * 7e0e9324cSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e0e9324cSopenharmony_ci * 9e0e9324cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e0e9324cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e0e9324cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e0e9324cSopenharmony_ci * See the License for the specific language governing permissions and 13e0e9324cSopenharmony_ci * limitations under the License. 14e0e9324cSopenharmony_ci */ 15e0e9324cSopenharmony_ci 16e0e9324cSopenharmony_ci#ifndef OHOS_SHARING_RTCP_H 17e0e9324cSopenharmony_ci#define OHOS_SHARING_RTCP_H 18e0e9324cSopenharmony_ci 19e0e9324cSopenharmony_ci#include <memory> 20e0e9324cSopenharmony_ci#include <cstdint> 21e0e9324cSopenharmony_ci#include <string> 22e0e9324cSopenharmony_ci#include <sys/time.h> 23e0e9324cSopenharmony_ci#include <vector> 24e0e9324cSopenharmony_ci#include "rtcp_def.h" 25e0e9324cSopenharmony_ci 26e0e9324cSopenharmony_cinamespace OHOS { 27e0e9324cSopenharmony_cinamespace Sharing { 28e0e9324cSopenharmony_ci/* 29e0e9324cSopenharmony_ci RTCP Header 30e0e9324cSopenharmony_ci 31e0e9324cSopenharmony_ci 0 1 2 3 32e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 33e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 34e0e9324cSopenharmony_ci |V=2|P| RC | PT | length | 35e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36e0e9324cSopenharmony_ci*/ 37e0e9324cSopenharmony_ci 38e0e9324cSopenharmony_cistruct RtcpHeader { 39e0e9324cSopenharmony_cipublic: 40e0e9324cSopenharmony_ci void SetSize(int32_t size); 41e0e9324cSopenharmony_ci 42e0e9324cSopenharmony_ci int32_t GetSize() const; 43e0e9324cSopenharmony_ci int32_t GetPaddingSize() const; 44e0e9324cSopenharmony_ci 45e0e9324cSopenharmony_cipublic: 46e0e9324cSopenharmony_ci uint8_t pt_; 47e0e9324cSopenharmony_ci uint8_t padding_ : 1; 48e0e9324cSopenharmony_ci uint8_t version_ : 2; 49e0e9324cSopenharmony_ci uint8_t reportCount_ : 5; 50e0e9324cSopenharmony_ci 51e0e9324cSopenharmony_ciprivate: 52e0e9324cSopenharmony_ci uint16_t length_; 53e0e9324cSopenharmony_ci}; 54e0e9324cSopenharmony_ci 55e0e9324cSopenharmony_ci// ReportBlock 56e0e9324cSopenharmony_cistruct ReportItem { 57e0e9324cSopenharmony_cipublic: 58e0e9324cSopenharmony_ci // Highest sequence number received 59e0e9324cSopenharmony_ci uint16_t seqMax_; 60e0e9324cSopenharmony_ci // Sequence number cycles count 61e0e9324cSopenharmony_ci uint16_t seqCycles_; 62e0e9324cSopenharmony_ci 63e0e9324cSopenharmony_ci uint32_t ssrc_; 64e0e9324cSopenharmony_ci // Interarrival jitter 65e0e9324cSopenharmony_ci uint32_t jitter_; 66e0e9324cSopenharmony_ci // Last SR timestamp, NTP timestamp,(ntpmsw & 0xFFFF) << 16 | (ntplsw >> 16) & 0xFFFF) 67e0e9324cSopenharmony_ci uint32_t lastSrStamp_; 68e0e9324cSopenharmony_ci // Cumulative number of packets lost 69e0e9324cSopenharmony_ci uint32_t cumulative_ : 24; 70e0e9324cSopenharmony_ci // Packet loss rate (percentage) * 256 71e0e9324cSopenharmony_ci uint32_t fractionLost_ : 8; 72e0e9324cSopenharmony_ci // Delay since last SR timestamp,expressed in units of 1/65536 seconds 73e0e9324cSopenharmony_ci uint32_t delaySinceLastSr_; 74e0e9324cSopenharmony_ci}; 75e0e9324cSopenharmony_ci 76e0e9324cSopenharmony_ci//------------------------------ RtcpSR ------------------------------// 77e0e9324cSopenharmony_ci 78e0e9324cSopenharmony_ci/* 79e0e9324cSopenharmony_ci SR: Sender Report RTCP Packet 80e0e9324cSopenharmony_ci 81e0e9324cSopenharmony_ci 0 1 2 3 82e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 83e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 84e0e9324cSopenharmony_ciheader |V=2|P| RC | PT=SR=200 | length | 85e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 86e0e9324cSopenharmony_ci | SSRC of sender | 87e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 88e0e9324cSopenharmony_cisender | NTP timestamp, most significant word | 89e0e9324cSopenharmony_ciinfo +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 90e0e9324cSopenharmony_ci | NTP timestamp, least significant word | 91e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 92e0e9324cSopenharmony_ci | RTP timestamp | 93e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 94e0e9324cSopenharmony_ci | sender's packet count | 95e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 96e0e9324cSopenharmony_ci | sender's octet count | 97e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 98e0e9324cSopenharmony_cireport | SSRC_1 (SSRC of first source) | 99e0e9324cSopenharmony_ciblock +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 100e0e9324cSopenharmony_ci 1 | fraction lost | cumulative number of packets lost | 101e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 102e0e9324cSopenharmony_ci | extended highest sequence number received | 103e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 104e0e9324cSopenharmony_ci | interarrival jitter | 105e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 106e0e9324cSopenharmony_ci | last SR (LSR) | 107e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 108e0e9324cSopenharmony_ci | delay since last SR (DLSR) | 109e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 110e0e9324cSopenharmony_cireport | SSRC_2 (SSRC of second source) | 111e0e9324cSopenharmony_ciblock +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 112e0e9324cSopenharmony_ci 2 : ... : 113e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 114e0e9324cSopenharmony_ci | profile-specific extensions | 115e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 116e0e9324cSopenharmony_ci*/ 117e0e9324cSopenharmony_ci 118e0e9324cSopenharmony_ci// sender report 119e0e9324cSopenharmony_cistruct RtcpSR : public RtcpHeader { 120e0e9324cSopenharmony_cipublic: 121e0e9324cSopenharmony_ci static std::shared_ptr<RtcpSR> Create(int32_t itemCount); 122e0e9324cSopenharmony_ci 123e0e9324cSopenharmony_ci RtcpSR &SetSsrc(uint32_t ssrc); 124e0e9324cSopenharmony_ci RtcpSR &SetNtpStamp(timeval tv); 125e0e9324cSopenharmony_ci RtcpSR &SetPacketCount(uint32_t); 126e0e9324cSopenharmony_ci RtcpSR &SetNtpStamp(uint64_t unixStampMs); 127e0e9324cSopenharmony_ci 128e0e9324cSopenharmony_ci uint32_t GetSsrc() const; 129e0e9324cSopenharmony_ci uint32_t GetPacketCount() const; 130e0e9324cSopenharmony_ci uint64_t GetNtpUnixStampMS() const; 131e0e9324cSopenharmony_ci 132e0e9324cSopenharmony_ci std::string GetNtpStamp() const; 133e0e9324cSopenharmony_ci std::vector<ReportItem *> GetItemList(); 134e0e9324cSopenharmony_ci 135e0e9324cSopenharmony_cipublic: 136e0e9324cSopenharmony_ci uint32_t ssrc_; 137e0e9324cSopenharmony_ci // rtp timestamp 138e0e9324cSopenharmony_ci uint32_t rtpts_; 139e0e9324cSopenharmony_ci // ntp timestamp MSW(in second) 140e0e9324cSopenharmony_ci uint32_t ntpmsw_; 141e0e9324cSopenharmony_ci // ntp timestamp LSW(in picosecond) 142e0e9324cSopenharmony_ci uint32_t ntplsw_; 143e0e9324cSopenharmony_ci // sender octet count 144e0e9324cSopenharmony_ci uint32_t octetCount_; 145e0e9324cSopenharmony_ci // sender packet count 146e0e9324cSopenharmony_ci uint32_t packetCount_; 147e0e9324cSopenharmony_ci 148e0e9324cSopenharmony_ci ReportItem items_; 149e0e9324cSopenharmony_ci}; 150e0e9324cSopenharmony_ci 151e0e9324cSopenharmony_ci//------------------------------ RtcpRR ------------------------------// 152e0e9324cSopenharmony_ci 153e0e9324cSopenharmony_ci/* 154e0e9324cSopenharmony_ci RR: Receiver Report RTCP Packet 155e0e9324cSopenharmony_ci 156e0e9324cSopenharmony_ci 0 1 2 3 157e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 158e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 159e0e9324cSopenharmony_ciheader |V=2|P| RC | PT=RR=201 | length | 160e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 161e0e9324cSopenharmony_ci | SSRC of packet sender | 162e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 163e0e9324cSopenharmony_cireport | SSRC_1 (SSRC of first source) | 164e0e9324cSopenharmony_ciblock +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 165e0e9324cSopenharmony_ci 1 | fraction lost | cumulative number of packets lost | 166e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 167e0e9324cSopenharmony_ci | extended highest sequence number received | 168e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 169e0e9324cSopenharmony_ci | interarrival jitter | 170e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 171e0e9324cSopenharmony_ci | last SR (LSR) | 172e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 173e0e9324cSopenharmony_ci | delay since last SR (DLSR) | 174e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 175e0e9324cSopenharmony_cireport | SSRC_2 (SSRC of second source) | 176e0e9324cSopenharmony_ciblock +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 177e0e9324cSopenharmony_ci 2 : ... : 178e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 179e0e9324cSopenharmony_ci | profile-specific extensions | 180e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 181e0e9324cSopenharmony_ci*/ 182e0e9324cSopenharmony_ci 183e0e9324cSopenharmony_ci// Receiver Report 184e0e9324cSopenharmony_cistruct RtcpRR : public RtcpHeader { 185e0e9324cSopenharmony_cipublic: 186e0e9324cSopenharmony_ci std::vector<ReportItem *> GetItemList(); 187e0e9324cSopenharmony_ci static std::shared_ptr<RtcpRR> Create(size_t itemCount); 188e0e9324cSopenharmony_ci 189e0e9324cSopenharmony_cipublic: 190e0e9324cSopenharmony_ci uint32_t ssrc_; 191e0e9324cSopenharmony_ci ReportItem items_; 192e0e9324cSopenharmony_ci}; 193e0e9324cSopenharmony_ci 194e0e9324cSopenharmony_ci//------------------------------ RtcpSdes ------------------------------// 195e0e9324cSopenharmony_ci 196e0e9324cSopenharmony_ci/* 197e0e9324cSopenharmony_ci SDES: Source Description RTCP Packet 198e0e9324cSopenharmony_ci 0 1 2 3 199e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 200e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 201e0e9324cSopenharmony_ciheader |V=2|P| SC | PT=SDES=202 | length | 202e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 203e0e9324cSopenharmony_cichunk | SSRC/CSRC_1 | 204e0e9324cSopenharmony_ci 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 205e0e9324cSopenharmony_ci | SDES items | 206e0e9324cSopenharmony_ci | ... | 207e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 208e0e9324cSopenharmony_cichunk | SSRC/CSRC_2 | 209e0e9324cSopenharmony_ci 2 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 210e0e9324cSopenharmony_ci | SDES items | 211e0e9324cSopenharmony_ci | ... | 212e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 213e0e9324cSopenharmony_ci*/ 214e0e9324cSopenharmony_ci 215e0e9324cSopenharmony_ci/* 216e0e9324cSopenharmony_ci SDES items 217e0e9324cSopenharmony_ci 0 1 2 3 218e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 219e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 220e0e9324cSopenharmony_ci | SdesType | length | user and domain name ... 221e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 222e0e9324cSopenharmony_ci*/ 223e0e9324cSopenharmony_ci 224e0e9324cSopenharmony_ci// Source description Chunk 225e0e9324cSopenharmony_cistruct SdesChunk { 226e0e9324cSopenharmony_cipublic: 227e0e9324cSopenharmony_ci static size_t MinSize(); 228e0e9324cSopenharmony_ci size_t TotalBytes() const; 229e0e9324cSopenharmony_ci 230e0e9324cSopenharmony_cipublic: 231e0e9324cSopenharmony_ci char text_[1]; // variable length field 232e0e9324cSopenharmony_ci 233e0e9324cSopenharmony_ci uint8_t end_; // placeholder 234e0e9324cSopenharmony_ci uint8_t txtLen_; 235e0e9324cSopenharmony_ci 236e0e9324cSopenharmony_ci uint32_t ssrc_; 237e0e9324cSopenharmony_ci 238e0e9324cSopenharmony_ci SdesType type_; // uint8_t 239e0e9324cSopenharmony_ci}; 240e0e9324cSopenharmony_ci 241e0e9324cSopenharmony_ci// Source description 242e0e9324cSopenharmony_cistruct RtcpSdes : public RtcpHeader { 243e0e9324cSopenharmony_cipublic: 244e0e9324cSopenharmony_ci std::vector<SdesChunk *> GetChunkList(); 245e0e9324cSopenharmony_ci static std::shared_ptr<RtcpSdes> Create(const std::vector<std::string> &itemText); 246e0e9324cSopenharmony_ci 247e0e9324cSopenharmony_cipublic: 248e0e9324cSopenharmony_ci SdesChunk chunks_; 249e0e9324cSopenharmony_ci}; 250e0e9324cSopenharmony_ci 251e0e9324cSopenharmony_ci//------------------------------ RtcpFB ------------------------------// 252e0e9324cSopenharmony_ci 253e0e9324cSopenharmony_ci/* Common Packet Format for Feedback Messages 254e0e9324cSopenharmony_ci 255e0e9324cSopenharmony_ci All FB messages MUST use a common packet format that is depicted in 256e0e9324cSopenharmony_ci Figure 3: 257e0e9324cSopenharmony_ci 258e0e9324cSopenharmony_ci 0 1 2 3 259e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 260e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 261e0e9324cSopenharmony_ci |V=2|P| FMT | PT | length | 262e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 263e0e9324cSopenharmony_ci | SSRC of packet sender | 264e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 265e0e9324cSopenharmony_ci | SSRC of media source | 266e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 267e0e9324cSopenharmony_ci : Feedback Control Information (FCI) : 268e0e9324cSopenharmony_ci : : 269e0e9324cSopenharmony_ci*/ 270e0e9324cSopenharmony_ci 271e0e9324cSopenharmony_ci// RtcpFB: Rtpfb or Psfb 272e0e9324cSopenharmony_cistruct RtcpFB : public RtcpHeader { 273e0e9324cSopenharmony_cipublic: 274e0e9324cSopenharmony_ci int32_t GetFciSize() const; 275e0e9324cSopenharmony_ci const uint8_t *GetFciPtr() const; 276e0e9324cSopenharmony_ci // for psfb fb 277e0e9324cSopenharmony_ci static std::shared_ptr<RtcpFB> Create(PsfbType fmt, const void *fci = nullptr, size_t fci_len = 0); 278e0e9324cSopenharmony_ci // for rtpfb fb 279e0e9324cSopenharmony_ci static std::shared_ptr<RtcpFB> Create(RtpfbType fmt, const void *fci = nullptr, size_t fci_len = 0); 280e0e9324cSopenharmony_ci 281e0e9324cSopenharmony_ciprivate: 282e0e9324cSopenharmony_ci static std::shared_ptr<RtcpFB> CreateInner(RtcpType type, int32_t fmt, const void *fci, size_t fci_len); 283e0e9324cSopenharmony_ci 284e0e9324cSopenharmony_cipublic: 285e0e9324cSopenharmony_ci uint32_t ssrc_; 286e0e9324cSopenharmony_ci uint32_t ssrcMedia_; 287e0e9324cSopenharmony_ci}; 288e0e9324cSopenharmony_ci 289e0e9324cSopenharmony_ci//------------------------------ RtcpBye ------------------------------// 290e0e9324cSopenharmony_ci 291e0e9324cSopenharmony_ci/* 292e0e9324cSopenharmony_ci BYE 293e0e9324cSopenharmony_ci 294e0e9324cSopenharmony_ci 0 1 2 3 295e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 296e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 297e0e9324cSopenharmony_ci |V=2|P| SC | PT=BYE=203 | length | 298e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 299e0e9324cSopenharmony_ci | SSRC/CSRC | 300e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 301e0e9324cSopenharmony_ci : ... : 302e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 303e0e9324cSopenharmony_ci(opt) | length | reason for leaving ... 304e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 305e0e9324cSopenharmony_ci*/ 306e0e9324cSopenharmony_ci 307e0e9324cSopenharmony_cistruct RtcpBye : public RtcpHeader { 308e0e9324cSopenharmony_cipublic: 309e0e9324cSopenharmony_ci std::string GetReason() const; 310e0e9324cSopenharmony_ci std::vector<uint32_t> GetSSRC() const; 311e0e9324cSopenharmony_ci static std::shared_ptr<RtcpBye> Create(const std::vector<uint32_t> &ssrc, const std::string &reason); 312e0e9324cSopenharmony_ci 313e0e9324cSopenharmony_cipublic: 314e0e9324cSopenharmony_ci char reason_[1]; 315e0e9324cSopenharmony_ci // optional 316e0e9324cSopenharmony_ci uint8_t reasonLen_; 317e0e9324cSopenharmony_ci // variable length for multiple ssrc 318e0e9324cSopenharmony_ci uint32_t ssrc_[1]; 319e0e9324cSopenharmony_ci}; 320e0e9324cSopenharmony_ci 321e0e9324cSopenharmony_ci//------------------------------ XR - RtcpXRRRTR ------------------------------// 322e0e9324cSopenharmony_ci 323e0e9324cSopenharmony_ci/* 324e0e9324cSopenharmony_ci RTCP Extended Reports (RTCP XR) Packet Format 325e0e9324cSopenharmony_ci 326e0e9324cSopenharmony_ci 0 1 2 3 327e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 328e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 329e0e9324cSopenharmony_ci |V=2|P|reserved | PT=XR=207 | length | 330e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 331e0e9324cSopenharmony_ci | SSRC | 332e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 333e0e9324cSopenharmony_ci : report blocks : 334e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 335e0e9324cSopenharmony_ci 336e0e9324cSopenharmony_ci*/ 337e0e9324cSopenharmony_ci/* 338e0e9324cSopenharmony_ci RTCP XR - Receiver Reference Time Report Block 339e0e9324cSopenharmony_ci 340e0e9324cSopenharmony_ci 0 1 2 3 341e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 342e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 343e0e9324cSopenharmony_ci | BT=4 | reserved | block length = 2 | 344e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 345e0e9324cSopenharmony_ci | NTP timestamp, most significant word | 346e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 347e0e9324cSopenharmony_ci | NTP timestamp, least significant word | 348e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 349e0e9324cSopenharmony_ci 350e0e9324cSopenharmony_ci*/ 351e0e9324cSopenharmony_ci 352e0e9324cSopenharmony_ci// XR - Receiver Reference Time Report 353e0e9324cSopenharmony_cistruct RtcpXRRRTR : public RtcpHeader { 354e0e9324cSopenharmony_cipublic: 355e0e9324cSopenharmony_ci uint8_t bt_ = 4; 356e0e9324cSopenharmony_ci uint8_t reserved_; 357e0e9324cSopenharmony_ci uint16_t blockLength_ = 0x0200; // = htons(2) 358e0e9324cSopenharmony_ci 359e0e9324cSopenharmony_ci uint32_t ssrc_; 360e0e9324cSopenharmony_ci // ntp timestamp MSW(in second) 361e0e9324cSopenharmony_ci uint32_t ntpmsw_; 362e0e9324cSopenharmony_ci // ntp timestamp LSW(in picosecond) 363e0e9324cSopenharmony_ci uint32_t ntplsw_; 364e0e9324cSopenharmony_ci}; 365e0e9324cSopenharmony_ci 366e0e9324cSopenharmony_ci//------------------------------ XR - RtcpXRDLRR ------------------------------// 367e0e9324cSopenharmony_ci 368e0e9324cSopenharmony_ci/* 369e0e9324cSopenharmony_ci RTCP XR - Delay since the Last Receiver Report (DLRR) 370e0e9324cSopenharmony_ci 371e0e9324cSopenharmony_ci 0 1 2 3 372e0e9324cSopenharmony_ci 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 373e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 374e0e9324cSopenharmony_ci | BT=5 | reserved | block length | 375e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 376e0e9324cSopenharmony_ci | SSRC_1 (SSRC of first receiver) | sub- 377e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block 378e0e9324cSopenharmony_ci | last RR (LRR) | 1 379e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 380e0e9324cSopenharmony_ci | delay since last RR (DLRR) | 381e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 382e0e9324cSopenharmony_ci | SSRC_2 (SSRC of second receiver) | sub- 383e0e9324cSopenharmony_ci +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block 384e0e9324cSopenharmony_ci : ... : 2 385e0e9324cSopenharmony_ci +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 386e0e9324cSopenharmony_ci*/ 387e0e9324cSopenharmony_ci 388e0e9324cSopenharmony_cistruct RtcpXRDLRRReportItem { 389e0e9324cSopenharmony_cipublic: 390e0e9324cSopenharmony_ci uint32_t lrr_; 391e0e9324cSopenharmony_ci uint32_t ssrc_; 392e0e9324cSopenharmony_ci uint32_t dlrr_; 393e0e9324cSopenharmony_ci}; 394e0e9324cSopenharmony_ci 395e0e9324cSopenharmony_ci// RTCP XR - Delay since the Last Receiver Report (DLRR) 396e0e9324cSopenharmony_cistruct RtcpXRDLRR : public RtcpHeader { 397e0e9324cSopenharmony_cipublic: 398e0e9324cSopenharmony_ci std::vector<RtcpXRDLRRReportItem *> GetItemList(); 399e0e9324cSopenharmony_ci static std::shared_ptr<RtcpXRDLRR> Create(size_t itemCount); 400e0e9324cSopenharmony_ci 401e0e9324cSopenharmony_cipublic: 402e0e9324cSopenharmony_ci uint8_t bt_; 403e0e9324cSopenharmony_ci uint8_t reserved_; 404e0e9324cSopenharmony_ci uint16_t blockLength_; 405e0e9324cSopenharmony_ci uint32_t ssrc_; 406e0e9324cSopenharmony_ci 407e0e9324cSopenharmony_ci RtcpXRDLRRReportItem items_; 408e0e9324cSopenharmony_ci}; 409e0e9324cSopenharmony_ci} // namespace Sharing 410e0e9324cSopenharmony_ci} // namespace OHOS 411e0e9324cSopenharmony_ci#endif