Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.cc

Issue 1446513002: rtcp::Pli moved into own file and got a Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
16 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
17
18 using webrtc::RTCPUtility::RtcpCommonHeader;
19
20 namespace webrtc {
21 namespace rtcp {
22
23 // RFC 4585: Feedback format.
24 //
25 // Common packet format:
26 //
27 // 0 1 2 3
28 // 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
29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30 // |V=2|P| FMT | PT | length |
31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32 // | SSRC of packet sender |
33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 // | SSRC of media source |
35 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 // : Feedback Control Information (FCI) :
37 // : :
38
39 //
40 // Picture loss indication (PLI) (RFC 4585).
41 // FCI: no feedback control information.
42 bool Pli::Parse(const RtcpCommonHeader& header, const uint8_t* payload) {
43 RTC_DCHECK(header.packet_type == kPacketType);
44 RTC_DCHECK(header.count_or_format == kFeedbackMessageType);
45
46 if (header.payload_size_bytes < kFeedbackLength) {
47 LOG(LS_WARNING) << "Packet is too small to be a valid PLI packet";
48 return false;
49 }
50
51 ParseBaseFeedback(payload);
52 return true;
53 }
54
55 bool Pli::Create(uint8_t* packet,
56 size_t* index,
57 size_t max_length,
58 RtcpPacket::PacketReadyCallback* callback) const {
59 while (*index + BlockLength() > max_length) {
60 if (!OnBufferFull(packet, index, callback))
61 return false;
62 }
63
64 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet,
65 index);
66 CreateBaseFeedback(packet + *index);
67 *index += kFeedbackLength;
68 return true;
69 }
70
71 } // namespace rtcp
72 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698