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/rapid_resync_request.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 // RFC 4585: Feedback format. |
| 21 // Rapid Resynchronisation Request (draft-perkins-avt-rapid-rtp-sync-03). |
| 22 // |
| 23 // 0 1 2 3 |
| 24 // 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 |
| 25 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 26 // |V=2|P| FMT=5 | PT=205 | length=2 | |
| 27 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 28 // | SSRC of packet sender | |
| 29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 30 // | SSRC of media source | |
| 31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 32 bool RapidResyncRequest::Parse(const RtcpCommonHeader& header, |
| 33 const uint8_t* payload) { |
| 34 RTC_CHECK(header.packet_type == kPacketType); |
| 35 RTC_CHECK(header.count_or_format == kFeedbackMessageType); |
| 36 |
| 37 if (header.payload_size_bytes != kCommonFeedbackLength) { |
| 38 LOG(LS_WARNING) << "Packet payload size should be " << kCommonFeedbackLength |
| 39 << " instead of " << header.payload_size_bytes |
| 40 << " to be a valid Rapid Resynchronisation Request"; |
| 41 return false; |
| 42 } |
| 43 |
| 44 ParseCommonFeedback(payload); |
| 45 return true; |
| 46 } |
| 47 |
| 48 bool RapidResyncRequest::Create( |
| 49 uint8_t* packet, |
| 50 size_t* index, |
| 51 size_t max_length, |
| 52 RtcpPacket::PacketReadyCallback* callback) const { |
| 53 while (*index + BlockLength() > max_length) { |
| 54 if (!OnBufferFull(packet, index, callback)) |
| 55 return false; |
| 56 } |
| 57 |
| 58 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, |
| 59 index); |
| 60 CreateCommonFeedback(packet + *index); |
| 61 *index += kCommonFeedbackLength; |
| 62 return true; |
| 63 } |
| 64 } // namespace rtcp |
| 65 } // namespace webrtc |
OLD | NEW |