OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 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 "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" |
| 12 |
| 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 16 |
| 17 using webrtc::RTCPUtility::PT_PSFB; |
| 18 using webrtc::RTCPUtility::RTCPPacketPSFBFIR; |
| 19 using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem; |
| 20 |
| 21 namespace webrtc { |
| 22 namespace rtcp { |
| 23 namespace { |
| 24 const uint32_t kUnusedMediaSourceSsrc0 = 0; |
| 25 |
| 26 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) { |
| 27 buffer[(*offset)++] = value; |
| 28 } |
| 29 |
| 30 void AssignUWord24(uint8_t* buffer, size_t* offset, uint32_t value) { |
| 31 ByteWriter<uint32_t, 3>::WriteBigEndian(buffer + *offset, value); |
| 32 *offset += 3; |
| 33 } |
| 34 |
| 35 void AssignUWord32(uint8_t* buffer, size_t* offset, uint32_t value) { |
| 36 ByteWriter<uint32_t>::WriteBigEndian(buffer + *offset, value); |
| 37 *offset += 4; |
| 38 } |
| 39 |
| 40 // Full intra request (FIR) (RFC 5104). |
| 41 // |
| 42 // FCI: |
| 43 // |
| 44 // 0 1 2 3 |
| 45 // 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 |
| 46 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 47 // | SSRC | |
| 48 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 49 // | Seq nr. | Reserved | |
| 50 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 51 void CreateFir(const RTCPPacketPSFBFIR& fir, |
| 52 const RTCPPacketPSFBFIRItem& fir_item, |
| 53 uint8_t* buffer, |
| 54 size_t* pos) { |
| 55 AssignUWord32(buffer, pos, fir.SenderSSRC); |
| 56 AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0); |
| 57 AssignUWord32(buffer, pos, fir_item.SSRC); |
| 58 AssignUWord8(buffer, pos, fir_item.CommandSequenceNumber); |
| 59 AssignUWord24(buffer, pos, 0); |
| 60 } |
| 61 } // namespace |
| 62 |
| 63 bool Fir::Create(uint8_t* packet, |
| 64 size_t* index, |
| 65 size_t max_length, |
| 66 RtcpPacket::PacketReadyCallback* callback) const { |
| 67 while (*index + BlockLength() > max_length) { |
| 68 if (!OnBufferFull(packet, index, callback)) |
| 69 return false; |
| 70 } |
| 71 const uint8_t kFmt = 4; |
| 72 CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index); |
| 73 CreateFir(fir_, fir_item_, packet, index); |
| 74 return true; |
| 75 } |
| 76 |
| 77 } // namespace rtcp |
| 78 } // namespace webrtc |
OLD | NEW |