Chromium Code Reviews| 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 * | |
| 10 */ | 9 */ |
| 11 | 10 |
| 12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_ |
| 13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_ |
| 14 | 13 |
| 14 #include <vector> | |
| 15 | |
| 15 #include "webrtc/base/basictypes.h" | 16 #include "webrtc/base/basictypes.h" |
| 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| 18 | 19 |
| 19 namespace webrtc { | 20 namespace webrtc { |
| 20 namespace rtcp { | 21 namespace rtcp { |
| 22 // Full intra request (FIR) (RFC 5104). | |
| 23 class Fir : public Psfb { | |
| 24 public: | |
| 25 static const uint8_t kFeedbackMessageType = 4; | |
| 26 struct Request { | |
| 27 Request() : ssrc(0), seq_nr(0) {} | |
| 28 Request(uint32_t ssrc, uint8_t seq_nr) : ssrc(ssrc), seq_nr(seq_nr) {} | |
| 29 uint32_t ssrc; | |
| 30 uint8_t seq_nr; | |
| 31 }; | |
| 21 | 32 |
| 22 // Full intra request (FIR) (RFC 5104). | 33 Fir() {} |
| 23 class Fir : public RtcpPacket { | 34 ~Fir() override {} |
| 24 public: | 35 |
| 25 Fir() : RtcpPacket() { | 36 // Parse assumes header is already parsed and validated. |
| 26 memset(&fir_, 0, sizeof(fir_)); | 37 bool Parse(const RTCPUtility::RtcpCommonHeader& header, |
| 27 memset(&fir_item_, 0, sizeof(fir_item_)); | 38 const uint8_t* payload); // Size of the payload is in the header. |
| 39 | |
| 40 void WithRequestTo(uint32_t ssrc, uint8_t seq_num) { | |
| 41 items_.push_back(Request(ssrc, seq_num)); | |
| 28 } | 42 } |
| 29 | 43 const std::vector<Request>& requests() const { return items_; } |
| 30 virtual ~Fir() {} | |
| 31 | |
| 32 void From(uint32_t ssrc) { | |
| 33 fir_.SenderSSRC = ssrc; | |
| 34 } | |
| 35 void To(uint32_t ssrc) { | |
| 36 fir_item_.SSRC = ssrc; | |
| 37 } | |
| 38 void WithCommandSeqNum(uint8_t seq_num) { | |
| 39 fir_item_.CommandSequenceNumber = seq_num; | |
| 40 } | |
| 41 | 44 |
| 42 protected: | 45 protected: |
| 43 bool Create(uint8_t* packet, | 46 bool Create(uint8_t* packet, |
| 44 size_t* index, | 47 size_t* index, |
| 45 size_t max_length, | 48 size_t max_length, |
| 46 RtcpPacket::PacketReadyCallback* callback) const override; | 49 RtcpPacket::PacketReadyCallback* callback) const override; |
| 47 | 50 |
| 48 private: | 51 private: |
| 49 size_t BlockLength() const { | 52 static const size_t kFciLength = 8; |
| 50 const size_t kFciLength = 8; | 53 size_t BlockLength() const override { |
| 51 return kCommonFbFmtLength + kFciLength; | 54 return kHeaderLength + kCommonFeedbackLength + kFciLength * items_.size(); |
| 52 } | 55 } |
| 56 // SSRC of media source is not used in FIR packet. Shadow base functions. | |
| 57 void To(size_t ssrc); | |
|
åsapersson
2016/01/21 16:04:35
size_t->uint32
danilchap
2016/01/21 16:48:12
Oops.
| |
| 58 uint32_t media_ssrc() const; | |
| 53 | 59 |
| 54 RTCPUtility::RTCPPacketPSFBFIR fir_; | 60 std::vector<Request> items_; |
| 55 RTCPUtility::RTCPPacketPSFBFIRItem fir_item_; | |
| 56 }; | 61 }; |
| 57 | |
| 58 } // namespace rtcp | 62 } // namespace rtcp |
| 59 } // namespace webrtc | 63 } // namespace webrtc |
| 60 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_ | 64 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_ |
| OLD | NEW |