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 // Vp8Descriptor struct used to store values of the VP8 RTP descriptor |
| 28 // fields. Meaning of each field is documented in the RTP Payload |
| 29 // Format for VP8 spec: http://www.webmproject.org/code/specs/rtp/ . |
| 30 struct Vp8Descriptor { |
| 31 enum FragmentationInfo { |
| 32 NOT_FRAGMENTED = 0, |
| 33 FIRST_FRAGMENT = 1, |
| 34 MIDDLE_FRAGMENT = 2, |
| 35 LAST_FRAGMENT = 3, |
| 36 }; |
| 37 |
| 38 bool non_reference_frame; |
| 39 uint8 fragmentation_info; |
| 40 bool frame_beginning; |
| 41 |
| 42 // PictureID is considered to be absent if |picture_id| is set to kuint32max. |
| 43 uint32 picture_id; |
| 44 }; |
| 45 |
27 // Returns size of RTP header for the specified number of sources. | 46 // Returns size of RTP header for the specified number of sources. |
28 int GetRtpHeaderSize(int sources); | 47 int GetRtpHeaderSize(const RtpHeader& header); |
29 | 48 |
30 // Packs RTP header into the buffer. | 49 // Packs RTP header into the buffer. |
31 void PackRtpHeader(uint8* buffer, int buffer_size, | 50 void PackRtpHeader(const RtpHeader& header, uint8* buffer, int buffer_size); |
32 const RtpHeader& header); | |
33 | 51 |
34 // Unpacks RTP header and stores unpacked values in |header|. If the header | 52 // Unpacks RTP header and stores unpacked values in |header|. If the header |
35 // is not valid returns -1, otherwise returns size of the header. | 53 // is not valid returns -1, otherwise returns size of the header. |
36 int UnpackRtpHeader(const uint8* buffer, int buffer_size, | 54 int UnpackRtpHeader(const uint8* buffer, int buffer_size, RtpHeader* header); |
37 RtpHeader* header); | 55 |
| 56 int GetVp8DescriptorSize(const Vp8Descriptor& descriptor); |
| 57 |
| 58 void PackVp8Descriptor(const Vp8Descriptor& descriptor, uint8* buffer, |
| 59 int buffer_size); |
| 60 |
| 61 int UnpackVp8Descriptor(const uint8* buffer, int buffer_size, |
| 62 Vp8Descriptor* descriptor); |
38 | 63 |
39 } // namespace protocol | 64 } // namespace protocol |
40 } // namespace remoting | 65 } // namespace remoting |
41 | 66 |
42 #endif // REMOTING_PROTOCOL_RTP_UTILS_H_ | 67 #endif // REMOTING_PROTOCOL_RTP_UTILS_H_ |
OLD | NEW |