OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_PROTOCOL_RTP_UTILS_H_ | 5 #ifndef REMOTING_PROTOCOL_RTP_UTILS_H_ |
6 #define REMOTING_PROTOCOL_RTP_UTILS_H_ | 6 #define REMOTING_PROTOCOL_RTP_UTILS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 | 9 |
10 namespace remoting { | 10 namespace remoting { |
11 namespace protocol { | 11 namespace protocol { |
12 | 12 |
13 struct RtpHeader { | 13 struct RtpHeader { |
14 // RTP version is always set to 2. | 14 // RTP version is always set to 2. |
15 // version = 2 | 15 // version = 2 |
16 bool padding; | 16 bool padding; |
17 bool extension; | 17 bool extension; |
18 uint8 sources; | 18 uint8 sources; |
19 bool marker; | 19 bool marker; |
20 uint8 payload_type; | 20 uint8 payload_type; |
21 uint16 sequence_number; | 21 uint16 sequence_number; |
22 uint32 timestamp; | 22 uint32 timestamp; |
23 uint32 sync_source_id; | 23 uint32 sync_source_id; |
24 uint32 source_id[15]; | 24 uint32 source_id[15]; |
25 }; | 25 }; |
26 | 26 |
27 struct Vp8Descriptor { | |
28 enum FragmentationInfo { | |
Alpha Left Google
2010/11/15 23:46:35
Need explanation for these values
Sergey Ulanov
2010/11/16 00:22:55
These are documented in the spec. Added comment wi
| |
29 NOT_FRAGMENTED = 0, | |
30 FIRST_FRAGMENT = 1, | |
31 MIDDLE_FRAGMENT = 2, | |
32 LAST_FRAGMENT = 3, | |
33 }; | |
34 | |
35 bool non_reference_frame; | |
36 uint8 fragmentation_info; | |
37 bool frame_beginning; | |
38 | |
39 // PictureID is considered to be absent if |picture_id| is set to kuint32max. | |
40 uint32 picture_id; | |
41 }; | |
42 | |
27 // Returns size of RTP header for the specified number of sources. | 43 // Returns size of RTP header for the specified number of sources. |
28 int GetRtpHeaderSize(int sources); | 44 int GetRtpHeaderSize(const RtpHeader& header); |
29 | 45 |
30 // Packs RTP header into the buffer. | 46 // Packs RTP header into the buffer. |
31 void PackRtpHeader(uint8* buffer, int buffer_size, | 47 void PackRtpHeader(const RtpHeader& header, uint8* buffer, int buffer_size); |
32 const RtpHeader& header); | |
33 | 48 |
34 // Unpacks RTP header and stores unpacked values in |header|. If the header | 49 // Unpacks RTP header and stores unpacked values in |header|. If the header |
35 // is not valid returns -1, otherwise returns size of the header. | 50 // is not valid returns -1, otherwise returns size of the header. |
36 int UnpackRtpHeader(const uint8* buffer, int buffer_size, | 51 int UnpackRtpHeader(const uint8* buffer, int buffer_size, RtpHeader* header); |
37 RtpHeader* header); | 52 |
53 int GetVp8DescriptorSize(const Vp8Descriptor& descriptor); | |
54 | |
55 void PackVp8Descriptor(const Vp8Descriptor& descriptor, uint8* buffer, | |
56 int buffer_size); | |
57 | |
58 int UnpackVp8Descriptor(const uint8* buffer, int buffer_size, | |
59 Vp8Descriptor* descriptor); | |
38 | 60 |
39 } // namespace protocol | 61 } // namespace protocol |
40 } // namespace remoting | 62 } // namespace remoting |
41 | 63 |
42 #endif // REMOTING_PROTOCOL_RTP_UTILS_H_ | 64 #endif // REMOTING_PROTOCOL_RTP_UTILS_H_ |
OLD | NEW |