1 /* 2 * Copyright (c) 2019 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 MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_LOSS_NOTIFICATION_H_ 12 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_LOSS_NOTIFICATION_H_ 13 14 #include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" 15 #include "modules/rtp_rtcp/source/rtcp_packet/psfb.h" 16 #include "rtc_base/system/unused.h" 17 18 namespace webrtc { 19 namespace rtcp { 20 21 class LossNotification : public Psfb { 22 public: 23 LossNotification(); 24 LossNotification(uint16_t last_decoded, 25 uint16_t last_received, 26 bool decodability_flag); 27 LossNotification(const LossNotification& other); 28 ~LossNotification() override; 29 30 size_t BlockLength() const override; 31 32 bool Create(uint8_t* packet, 33 size_t* index, 34 size_t max_length, 35 PacketReadyCallback callback) const override 36 RTC_WARN_UNUSED_RESULT; 37 38 // Parse assumes header is already parsed and validated. 39 bool Parse(const CommonHeader& packet) RTC_WARN_UNUSED_RESULT; 40 41 // Set all of the values transmitted by the loss notification message. 42 // If the values may not be represented by a loss notification message, 43 // false is returned, and no change is made to the object; this happens 44 // when |last_recieved| is ahead of |last_decoded| by more than 0x7fff. 45 // This is because |last_recieved| is represented on the wire as a delta, 46 // and only 15 bits are available for that delta. 47 bool Set(uint16_t last_decoded, 48 uint16_t last_received, 49 bool decodability_flag) RTC_WARN_UNUSED_RESULT; 50 51 // RTP sequence number of the first packet belong to the last decoded 52 // non-discardable frame. last_decoded()53 uint16_t last_decoded() const { return last_decoded_; } 54 55 // RTP sequence number of the last received packet. last_received()56 uint16_t last_received() const { return last_received_; } 57 58 // A decodability flag, whose specific meaning depends on the last-received 59 // RTP sequence number. The decodability flag is true if and only if all of 60 // the frame's dependencies are known to be decodable, and the frame itself 61 // is not yet known to be unassemblable. 62 // * Clarification #1: In a multi-packet frame, the first packet's 63 // dependencies are known, but it is not yet known whether all parts 64 // of the current frame will be received. 65 // * Clarification #2: In a multi-packet frame, the dependencies would be 66 // unknown if the first packet was not received. Then, the packet will 67 // be known-unassemblable. decodability_flag()68 bool decodability_flag() const { return decodability_flag_; } 69 70 private: 71 static constexpr uint32_t kUniqueIdentifier = 0x4C4E5446; // 'L' 'N' 'T' 'F'. 72 static constexpr size_t kLossNotificationPayloadLength = 8; 73 74 uint16_t last_decoded_; 75 uint16_t last_received_; 76 bool decodability_flag_; 77 }; 78 } // namespace rtcp 79 } // namespace webrtc 80 #endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_LOSS_NOTIFICATION_H_ 81