| 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 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SLI_H_ | |
| 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SLI_H_ | |
| 13 | |
| 14 #include <vector> | |
| 15 | |
| 16 #include "webrtc/base/basictypes.h" | |
| 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" | |
| 18 | |
| 19 namespace webrtc { | |
| 20 namespace rtcp { | |
| 21 class CommonHeader; | |
| 22 | |
| 23 // Slice loss indication (SLI) (RFC 4585). | |
| 24 class Sli : public Psfb { | |
| 25 public: | |
| 26 static constexpr uint8_t kFeedbackMessageType = 2; | |
| 27 class Macroblocks { | |
| 28 public: | |
| 29 static constexpr size_t kLength = 4; | |
| 30 Macroblocks() : item_(0) {} | |
| 31 Macroblocks(uint8_t picture_id, uint16_t first, uint16_t number); | |
| 32 ~Macroblocks() {} | |
| 33 | |
| 34 void Parse(const uint8_t* buffer); | |
| 35 void Create(uint8_t* buffer) const; | |
| 36 | |
| 37 uint16_t first() const { return item_ >> 19; } | |
| 38 uint16_t number() const { return (item_ >> 6) & 0x1fff; } | |
| 39 uint8_t picture_id() const { return (item_ & 0x3f); } | |
| 40 | |
| 41 private: | |
| 42 uint32_t item_; | |
| 43 }; | |
| 44 | |
| 45 Sli() {} | |
| 46 ~Sli() override {} | |
| 47 | |
| 48 // Parse assumes header is already parsed and validated. | |
| 49 bool Parse(const CommonHeader& packet); | |
| 50 | |
| 51 void AddPictureId(uint8_t picture_id) { | |
| 52 items_.emplace_back(picture_id, 0, 0x1fff); | |
| 53 } | |
| 54 void AddPictureId(uint8_t picture_id, | |
| 55 uint16_t first_macroblock, | |
| 56 uint16_t number_macroblocks) { | |
| 57 items_.emplace_back(picture_id, first_macroblock, number_macroblocks); | |
| 58 } | |
| 59 | |
| 60 const std::vector<Macroblocks>& macroblocks() const { return items_; } | |
| 61 | |
| 62 protected: | |
| 63 bool Create(uint8_t* packet, | |
| 64 size_t* index, | |
| 65 size_t max_length, | |
| 66 RtcpPacket::PacketReadyCallback* callback) const override; | |
| 67 | |
| 68 private: | |
| 69 size_t BlockLength() const override { | |
| 70 return RtcpPacket::kHeaderLength + Psfb::kCommonFeedbackLength + | |
| 71 items_.size() * Macroblocks::kLength; | |
| 72 } | |
| 73 | |
| 74 std::vector<Macroblocks> items_; | |
| 75 }; | |
| 76 | |
| 77 } // namespace rtcp | |
| 78 } // namespace webrtc | |
| 79 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SLI_H_ | |
| OLD | NEW |