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

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

Issue 1811933002: [rtcp] Pli::Parse updated not to use RTCPUtility (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months 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
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
12 12
13 #include "webrtc/base/checks.h" 13 #include "webrtc/base/checks.h"
14 #include "webrtc/base/logging.h" 14 #include "webrtc/base/logging.h"
15 15 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
16 using webrtc::RTCPUtility::RtcpCommonHeader;
17 16
18 namespace webrtc { 17 namespace webrtc {
19 namespace rtcp { 18 namespace rtcp {
20 19
21 // RFC 4585: Feedback format. 20 // RFC 4585: Feedback format.
22 // 21 //
23 // Common packet format: 22 // Common packet format:
24 // 23 //
25 // 0 1 2 3 24 // 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 25 // 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 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
28 // |V=2|P| FMT | PT | length | 27 // |V=2|P| FMT | PT | length |
29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30 // | SSRC of packet sender | 29 // | SSRC of packet sender |
31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 30 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32 // | SSRC of media source | 31 // | SSRC of media source |
33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 // : Feedback Control Information (FCI) : 33 // : Feedback Control Information (FCI) :
35 // : : 34 // : :
36 35
37 // 36 //
38 // Picture loss indication (PLI) (RFC 4585). 37 // Picture loss indication (PLI) (RFC 4585).
39 // FCI: no feedback control information. 38 // FCI: no feedback control information.
40 bool Pli::Parse(const RtcpCommonHeader& header, const uint8_t* payload) { 39 bool Pli::Parse(const CommonHeader& packet) {
41 RTC_DCHECK(header.packet_type == kPacketType); 40 RTC_DCHECK(packet.type() == kPacketType);
42 RTC_DCHECK(header.count_or_format == kFeedbackMessageType); 41 RTC_DCHECK(packet.fmt() == kFeedbackMessageType);
43 42
44 if (header.payload_size_bytes < kCommonFeedbackLength) { 43 if (packet.payload_size_bytes() < kCommonFeedbackLength) {
45 LOG(LS_WARNING) << "Packet is too small to be a valid PLI packet"; 44 LOG(LS_WARNING) << "Packet is too small to be a valid PLI packet";
46 return false; 45 return false;
47 } 46 }
48 47
49 ParseCommonFeedback(payload); 48 ParseCommonFeedback(packet.payload());
50 return true; 49 return true;
51 } 50 }
52 51
53 bool Pli::Create(uint8_t* packet, 52 bool Pli::Create(uint8_t* packet,
54 size_t* index, 53 size_t* index,
55 size_t max_length, 54 size_t max_length,
56 RtcpPacket::PacketReadyCallback* callback) const { 55 RtcpPacket::PacketReadyCallback* callback) const {
57 while (*index + BlockLength() > max_length) { 56 while (*index + BlockLength() > max_length) {
58 if (!OnBufferFull(packet, index, callback)) 57 if (!OnBufferFull(packet, index, callback))
59 return false; 58 return false;
60 } 59 }
61 60
62 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, 61 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet,
63 index); 62 index);
64 CreateCommonFeedback(packet + *index); 63 CreateCommonFeedback(packet + *index);
65 *index += kCommonFeedbackLength; 64 *index += kCommonFeedbackLength;
66 return true; 65 return true;
67 } 66 }
68 67
69 } // namespace rtcp 68 } // namespace rtcp
70 } // namespace webrtc 69 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698