OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 */ |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 PacketReadyCallback() {} | 74 PacketReadyCallback() {} |
75 virtual ~PacketReadyCallback() {} | 75 virtual ~PacketReadyCallback() {} |
76 | 76 |
77 virtual void OnPacketReady(uint8_t* data, size_t length) = 0; | 77 virtual void OnPacketReady(uint8_t* data, size_t length) = 0; |
78 }; | 78 }; |
79 | 79 |
80 // Convenience method mostly used for test. Max length of IP_PACKET_SIZE is | 80 // Convenience method mostly used for test. Max length of IP_PACKET_SIZE is |
81 // used, will cause assertion error if fragmentation occurs. | 81 // used, will cause assertion error if fragmentation occurs. |
82 rtc::scoped_ptr<RawPacket> Build() const; | 82 rtc::scoped_ptr<RawPacket> Build() const; |
83 | 83 |
84 // Returns true if all calls to Create succeeded. A buffer of size | |
85 // IP_PACKET_SIZE will be allocated and reused between calls to callback. | |
86 bool Build(PacketReadyCallback* callback) const; | |
87 | |
88 // Returns true if all calls to Create succeeded. Provided buffer reference | 84 // Returns true if all calls to Create succeeded. Provided buffer reference |
89 // will be used for all calls to callback. | 85 // will be used for all calls to callback. |
90 bool BuildExternalBuffer(uint8_t* buffer, | 86 bool BuildExternalBuffer(uint8_t* buffer, |
91 size_t max_length, | 87 size_t max_length, |
92 PacketReadyCallback* callback) const; | 88 PacketReadyCallback* callback) const; |
93 | 89 |
| 90 // Same as BuildExternalBuffer, but index pointer is explicitly exposed and |
| 91 // the PacketReadyCallback will not be called prior to returning (so index |
| 92 // must be checked to see if there is something left in the buffer unsent). |
| 93 bool CreateAndAddAppended(uint8_t* packet, |
| 94 size_t* index, |
| 95 size_t max_length, |
| 96 PacketReadyCallback* callback) const; |
| 97 |
94 // Size of this packet in bytes (including headers, excluding nested packets). | 98 // Size of this packet in bytes (including headers, excluding nested packets). |
95 virtual size_t BlockLength() const = 0; | 99 virtual size_t BlockLength() const = 0; |
96 | 100 |
97 protected: | 101 protected: |
98 RtcpPacket() {} | 102 RtcpPacket() {} |
99 | 103 |
100 virtual bool Create(uint8_t* packet, | 104 virtual bool Create(uint8_t* packet, |
101 size_t* index, | 105 size_t* index, |
102 size_t max_length, | 106 size_t max_length, |
103 PacketReadyCallback* callback) const = 0; | 107 PacketReadyCallback* callback) const = 0; |
104 | 108 |
105 static void CreateHeader(uint8_t count_or_format, | 109 static void CreateHeader(uint8_t count_or_format, |
106 uint8_t packet_type, | 110 uint8_t packet_type, |
107 size_t block_length, // Size in 32bit words - 1. | 111 size_t block_length, // Size in 32bit words - 1. |
108 uint8_t* buffer, | 112 uint8_t* buffer, |
109 size_t* pos); | 113 size_t* pos); |
110 | 114 |
111 bool OnBufferFull(uint8_t* packet, | 115 bool OnBufferFull(uint8_t* packet, |
112 size_t* index, | 116 size_t* index, |
113 RtcpPacket::PacketReadyCallback* callback) const; | 117 RtcpPacket::PacketReadyCallback* callback) const; |
114 | 118 |
115 size_t HeaderLength() const; | 119 size_t HeaderLength() const; |
116 | 120 |
117 static const size_t kHeaderLength = 4; | 121 static const size_t kHeaderLength = 4; |
118 | 122 |
119 private: | 123 private: |
120 bool CreateAndAddAppended(uint8_t* packet, | |
121 size_t* index, | |
122 size_t max_length, | |
123 PacketReadyCallback* callback) const; | |
124 | |
125 std::vector<RtcpPacket*> appended_packets_; | 124 std::vector<RtcpPacket*> appended_packets_; |
126 }; | 125 }; |
127 | 126 |
128 // TODO(sprang): Move RtcpPacket subclasses out to separate files. | 127 // TODO(sprang): Move RtcpPacket subclasses out to separate files. |
129 | 128 |
130 class Empty : public RtcpPacket { | 129 class Empty : public RtcpPacket { |
131 public: | 130 public: |
132 Empty() : RtcpPacket() {} | 131 Empty() : RtcpPacket() {} |
133 | 132 |
134 virtual ~Empty() {} | 133 virtual ~Empty() {} |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 | 1156 |
1158 private: | 1157 private: |
1159 const size_t buffer_length_; | 1158 const size_t buffer_length_; |
1160 size_t length_; | 1159 size_t length_; |
1161 rtc::scoped_ptr<uint8_t[]> buffer_; | 1160 rtc::scoped_ptr<uint8_t[]> buffer_; |
1162 }; | 1161 }; |
1163 | 1162 |
1164 } // namespace rtcp | 1163 } // namespace rtcp |
1165 } // namespace webrtc | 1164 } // namespace webrtc |
1166 #endif // WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ | 1165 #endif // WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ |
OLD | NEW |