OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_ |
13 | 13 |
14 #include "webrtc/base/basictypes.h" | 14 #include "webrtc/base/basictypes.h" |
15 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 15 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" |
16 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 namespace rtcp { | 19 namespace rtcp { |
20 // Reference picture selection indication (RPSI) (RFC 4585). | 20 // Reference picture selection indication (RPSI) (RFC 4585). |
21 class Rpsi : public RtcpPacket { | 21 // Assumes native bit string stores PictureId (VP8, VP9). |
| 22 class Rpsi : public Psfb { |
22 public: | 23 public: |
23 Rpsi() | 24 static const uint8_t kFeedbackMessageType = 3; |
24 : RtcpPacket(), | 25 Rpsi(); |
25 padding_bytes_(0) { | 26 ~Rpsi() override {} |
26 memset(&rpsi_, 0, sizeof(rpsi_)); | |
27 } | |
28 | 27 |
29 virtual ~Rpsi() {} | 28 // Parse assumes header is already parsed and validated. |
| 29 bool Parse(const RTCPUtility::RtcpCommonHeader& header, |
| 30 const uint8_t* payload); // Size of the payload is in the header. |
30 | 31 |
31 void From(uint32_t ssrc) { | 32 void WithPayloadType(uint8_t payload); |
32 rpsi_.SenderSSRC = ssrc; | |
33 } | |
34 void To(uint32_t ssrc) { | |
35 rpsi_.MediaSSRC = ssrc; | |
36 } | |
37 void WithPayloadType(uint8_t payload) { | |
38 assert(payload <= 0x7f); | |
39 rpsi_.PayloadType = payload; | |
40 } | |
41 void WithPictureId(uint64_t picture_id); | 33 void WithPictureId(uint64_t picture_id); |
42 | 34 |
| 35 uint8_t payload_type() const { return payload_type_; } |
| 36 uint64_t picture_id() const { return picture_id_; } |
| 37 |
43 protected: | 38 protected: |
44 bool Create(uint8_t* packet, | 39 bool Create(uint8_t* packet, |
45 size_t* index, | 40 size_t* index, |
46 size_t max_length, | 41 size_t max_length, |
47 RtcpPacket::PacketReadyCallback* callback) const override; | 42 RtcpPacket::PacketReadyCallback* callback) const override; |
48 | 43 |
49 private: | 44 private: |
50 size_t BlockLength() const { | 45 size_t BlockLength() const override { return block_length_; } |
51 size_t fci_length = 2 + (rpsi_.NumberOfValidBits / 8) + padding_bytes_; | 46 static size_t CalculateBlockLength(uint8_t bitstring_size_bytes); |
52 return kCommonFbFmtLength + fci_length; | |
53 } | |
54 | 47 |
55 uint8_t padding_bytes_; | 48 uint8_t payload_type_; |
56 RTCPUtility::RTCPPacketPSFBRPSI rpsi_; | 49 uint64_t picture_id_; |
| 50 size_t block_length_; |
57 | 51 |
58 RTC_DISALLOW_COPY_AND_ASSIGN(Rpsi); | 52 RTC_DISALLOW_COPY_AND_ASSIGN(Rpsi); |
59 }; | 53 }; |
60 } // namespace rtcp | 54 } // namespace rtcp |
61 } // namespace webrtc | 55 } // namespace webrtc |
62 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_ | 56 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RPSI_H_ |
OLD | NEW |