Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h

Issue 1430013003: rtcp::Bye packet moved to own file and got a Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2015 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
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_BYE_H_
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_BYE_H_
14
15 #include <string>
16 #include <vector>
17
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
20 #include "webrtc/typedefs.h"
21
22 namespace webrtc {
23 namespace rtcp {
24
25 class Bye : public RtcpPacket {
26 public:
27 static const uint8_t kPacketType = 203;
28
29 Bye();
30 virtual ~Bye() {}
31
32 // Parse assumes header is already parsed and validated.
33 bool Parse(const RTCPUtility::RtcpCommonHeader& header,
34 const uint8_t* payload); // Size of the payload is in the header.
35
36 void From(uint32_t ssrc) { sender_ssrc_ = ssrc; }
37 bool WithCsrc(uint32_t csrc);
38 bool WithReason(const std::string& reason);
39
40 uint32_t sender_ssrc() const { return sender_ssrc_; }
41 size_t csrcs_count() const { return csrcs_.size(); }
42 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
43 const std::string& reason() const { return reason_; }
44
45 protected:
46 bool Create(uint8_t* packet,
47 size_t* index,
48 size_t max_length,
49 RtcpPacket::PacketReadyCallback* callback) const override;
50
51 private:
52 static const int kMaxNumberOfCsrcs = 0x1f - 1; // First item is sender SSRC.
53
54 size_t BlockLength() const {
55 size_t source_count = (1 + csrcs_.size());
56 size_t reason_size_in_32bits =
57 reason_.empty() ? 0 : (reason_.size() / 4 + 1);
58 return kHeaderLength + 4 * (source_count + reason_size_in_32bits);
59 }
sprang_webrtc 2015/11/12 16:28:31 Would prefer not to inline
danilchap 2015/11/13 09:05:42 Done.
60
61 uint32_t sender_ssrc_;
62 std::vector<uint32_t> csrcs_;
63 std::string reason_;
64
65 RTC_DISALLOW_COPY_AND_ASSIGN(Bye);
66 };
67
68 } // namespace rtcp
69 } // namespace webrtc
70 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_BYE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698