Index: webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.cc b/webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.cc |
similarity index 52% |
copy from webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.cc |
copy to webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.cc |
index 367349105830025cf544cf256b19e227743bd927..829f3a9db98aa8f6c6e1c8a0c24507c9780242ba 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.cc |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
* |
* Use of this source code is governed by a BSD-style license |
* that can be found in the LICENSE file in the root of the source |
@@ -8,16 +8,16 @@ |
* be found in the AUTHORS file in the root of the source tree. |
*/ |
-#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" |
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" |
#include "webrtc/base/checks.h" |
#include "webrtc/base/logging.h" |
+#include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
using webrtc::RTCPUtility::RtcpCommonHeader; |
namespace webrtc { |
namespace rtcp { |
- |
// RFC 4585: Feedback format. |
// |
// Common packet format: |
@@ -33,36 +33,74 @@ namespace rtcp { |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
// : Feedback Control Information (FCI) : |
// : : |
- |
// |
-// Picture loss indication (PLI) (RFC 4585). |
-// FCI: no feedback control information. |
-bool Pli::Parse(const RtcpCommonHeader& header, const uint8_t* payload) { |
+// Slice loss indication (SLI) (RFC 4585). |
+// FCI: |
+// 0 1 2 3 |
+// 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 |
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+// | First | Number | PictureID | |
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+Sli::Macroblocks::Macroblocks(uint8_t picture_id, |
+ uint16_t first, |
+ uint16_t number) { |
+ RTC_DCHECK_LE(first, 0x1fff); |
+ RTC_DCHECK_LE(number, 0x1fff); |
+ RTC_DCHECK_LE(picture_id, 0x3f); |
+ item_ = (first << 19) | (number << 6) | picture_id; |
+} |
+ |
+void Sli::Macroblocks::Parse(const uint8_t* buffer) { |
+ item_ = ByteReader<uint32_t>::ReadBigEndian(buffer); |
+} |
+ |
+void Sli::Macroblocks::Create(uint8_t* buffer) const { |
+ ByteWriter<uint32_t>::WriteBigEndian(buffer, item_); |
+} |
+ |
+bool Sli::Parse(const RtcpCommonHeader& header, const uint8_t* payload) { |
RTC_DCHECK(header.packet_type == kPacketType); |
RTC_DCHECK(header.count_or_format == kFeedbackMessageType); |
- if (header.payload_size_bytes < kCommonFeedbackLength) { |
- LOG(LS_WARNING) << "Packet is too small to be a valid PLI packet"; |
+ if (header.payload_size_bytes < |
+ kCommonFeedbackLength + Macroblocks::kLength) { |
+ LOG(LS_WARNING) << "Packet is too small to be a valid SLI packet"; |
return false; |
} |
+ size_t number_of_items = |
+ (header.payload_size_bytes - kCommonFeedbackLength) / |
+ Macroblocks::kLength; |
+ |
ParseCommonFeedback(payload); |
+ items_.resize(number_of_items); |
+ |
+ const uint8_t* next_item = payload + kCommonFeedbackLength; |
+ for (Macroblocks& item : items_) { |
+ item.Parse(next_item); |
+ next_item += Macroblocks::kLength; |
+ } |
+ |
return true; |
} |
-bool Pli::Create(uint8_t* packet, |
+bool Sli::Create(uint8_t* packet, |
size_t* index, |
size_t max_length, |
RtcpPacket::PacketReadyCallback* callback) const { |
+ RTC_DCHECK(!items_.empty()); |
while (*index + BlockLength() > max_length) { |
if (!OnBufferFull(packet, index, callback)) |
return false; |
} |
- |
CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, |
index); |
CreateCommonFeedback(packet + *index); |
*index += kCommonFeedbackLength; |
+ for (const Macroblocks& item : items_) { |
+ item.Create(packet + *index); |
+ *index += Macroblocks::kLength; |
+ } |
return true; |
} |