Chromium Code Reviews| Index: webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h |
| diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h b/webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bdb10f83a7f40f0fb7b54741699a51674252324b |
| --- /dev/null |
| +++ b/webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h |
| @@ -0,0 +1,70 @@ |
| +/* |
| + * Copyright (c) 2015 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 |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + * |
| + */ |
| + |
| +#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_BYE_H_ |
| +#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_BYE_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
| +#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| +#include "webrtc/typedefs.h" |
| + |
| +namespace webrtc { |
| +namespace rtcp { |
| + |
| +class Bye : public RtcpPacket { |
| + public: |
| + static const uint8_t kPacketType = 203; |
| + |
| + Bye(); |
| + virtual ~Bye() {} |
| + |
| + // Parse assumes header is already parsed and validated. |
| + bool Parse(const RTCPUtility::RtcpCommonHeader& header, |
| + const uint8_t* payload); // Size of the payload is in the header. |
| + |
| + void From(uint32_t ssrc) { sender_ssrc_ = ssrc; } |
| + bool WithCsrc(uint32_t csrc); |
| + bool WithReason(const std::string& reason); |
| + |
| + uint32_t sender_ssrc() const { return sender_ssrc_; } |
| + size_t csrcs_count() const { return csrcs_.size(); } |
| + uint32_t csrc(size_t index) const { return csrcs_[index]; } |
|
sprang_webrtc
2015/11/12 16:28:31
I'd rather get a const std::vector<uint32_t>&
danilchap
2015/11/13 09:05:42
Do not want expose to user that vector is used for
|
| + const std::string& reason() const { return reason_; } |
| + |
| + protected: |
| + bool Create(uint8_t* packet, |
| + size_t* index, |
| + size_t max_length, |
| + RtcpPacket::PacketReadyCallback* callback) const override; |
| + |
| + private: |
| + static const int kMaxNumberOfCsrcs = 0x1f - 1; // First item is sender SSRC. |
| + |
| + size_t BlockLength() const { |
| + size_t source_count = (1 + csrcs_.size()); |
| + size_t reason_size_in_32bits = |
| + reason_.empty() ? 0 : (reason_.size() / 4 + 1); |
| + return kHeaderLength + 4 * (source_count + reason_size_in_32bits); |
| + } |
|
sprang_webrtc
2015/11/12 16:28:31
Would prefer not to inline
danilchap
2015/11/13 09:05:42
Done.
|
| + |
| + uint32_t sender_ssrc_; |
| + std::vector<uint32_t> csrcs_; |
| + std::string reason_; |
| + |
| + RTC_DISALLOW_COPY_AND_ASSIGN(Bye); |
| +}; |
| + |
| +} // namespace rtcp |
| +} // namespace webrtc |
| +#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_BYE_H_ |