OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2015 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/pli.h" |
| 12 |
| 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/logging.h" |
| 15 |
| 16 using webrtc::RTCPUtility::RtcpCommonHeader; |
| 17 |
| 18 namespace webrtc { |
| 19 namespace rtcp { |
| 20 |
| 21 // RFC 4585: Feedback format. |
| 22 // |
| 23 // Common packet format: |
| 24 // |
| 25 // 0 1 2 3 |
| 26 // 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 |
| 27 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 28 // |V=2|P| FMT | PT | length | |
| 29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 30 // | SSRC of packet sender | |
| 31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 32 // | SSRC of media source | |
| 33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 34 // : Feedback Control Information (FCI) : |
| 35 // : : |
| 36 |
| 37 // |
| 38 // Picture loss indication (PLI) (RFC 4585). |
| 39 // FCI: no feedback control information. |
| 40 bool Pli::Parse(const RtcpCommonHeader& header, const uint8_t* payload) { |
| 41 RTC_DCHECK(header.packet_type == kPacketType); |
| 42 RTC_DCHECK(header.count_or_format == kFeedbackMessageType); |
| 43 |
| 44 if (header.payload_size_bytes < kCommonFeedbackLength) { |
| 45 LOG(LS_WARNING) << "Packet is too small to be a valid PLI packet"; |
| 46 return false; |
| 47 } |
| 48 |
| 49 ParseCommonFeedback(payload); |
| 50 return true; |
| 51 } |
| 52 |
| 53 bool Pli::Create(uint8_t* packet, |
| 54 size_t* index, |
| 55 size_t max_length, |
| 56 RtcpPacket::PacketReadyCallback* callback) const { |
| 57 while (*index + BlockLength() > max_length) { |
| 58 if (!OnBufferFull(packet, index, callback)) |
| 59 return false; |
| 60 } |
| 61 |
| 62 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, |
| 63 index); |
| 64 CreateCommonFeedback(packet + *index); |
| 65 *index += kCommonFeedbackLength; |
| 66 return true; |
| 67 } |
| 68 |
| 69 } // namespace rtcp |
| 70 } // namespace webrtc |
OLD | NEW |