OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 PPAPI_SHARED_IMPL_MEDIA_STREAM_BUFFER_H_ | 5 #ifndef PPAPI_SHARED_IMPL_MEDIA_STREAM_BUFFER_H_ |
6 #define PPAPI_SHARED_IMPL_MEDIA_STREAM_BUFFER_H_ | 6 #define PPAPI_SHARED_IMPL_MEDIA_STREAM_BUFFER_H_ |
7 | 7 |
8 #include "ppapi/c/ppb_audio_buffer.h" | 8 #include "ppapi/c/ppb_audio_buffer.h" |
9 #include "ppapi/c/ppb_video_frame.h" | 9 #include "ppapi/c/ppb_video_frame.h" |
10 | 10 |
11 namespace ppapi { | 11 namespace ppapi { |
12 | 12 |
13 union MediaStreamBuffer { | 13 union MediaStreamBuffer { |
14 enum Type { TYPE_UNKNOWN = 0, TYPE_AUDIO = 1, TYPE_VIDEO = 2, }; | 14 enum Type { |
| 15 TYPE_UNKNOWN = 0, |
| 16 TYPE_AUDIO = 1, |
| 17 TYPE_VIDEO = 2, |
| 18 TYPE_BITSTREAM = 3 |
| 19 }; |
15 | 20 |
16 struct Header { | 21 struct Header { |
17 Type type; | 22 Type type; |
18 uint32_t size; | 23 uint32_t size; |
19 }; | 24 }; |
20 | 25 |
21 struct Audio { | 26 struct Audio { |
22 Header header; | 27 Header header; |
23 PP_TimeDelta timestamp; | 28 PP_TimeDelta timestamp; |
24 PP_AudioBuffer_SampleRate sample_rate; | 29 PP_AudioBuffer_SampleRate sample_rate; |
25 uint32_t number_of_channels; | 30 uint32_t number_of_channels; |
26 uint32_t number_of_samples; | 31 uint32_t number_of_samples; |
27 uint32_t data_size; | 32 uint32_t data_size; |
28 // Uses 8 bytes to make sure the Audio struct has consistent size between | 33 // Uses 8 bytes to make sure the Audio struct has consistent size between |
29 // NaCl code and renderer code. | 34 // NaCl code and renderer code. |
30 uint8_t data[8]; | 35 uint8_t data[8]; |
31 }; | 36 }; |
32 | 37 |
33 struct Video { | 38 struct Video { |
34 Header header; | 39 Header header; |
35 PP_TimeDelta timestamp; | 40 PP_TimeDelta timestamp; |
36 PP_VideoFrame_Format format; | 41 PP_VideoFrame_Format format; |
37 PP_Size size; | 42 PP_Size size; |
38 uint32_t data_size; | 43 uint32_t data_size; |
39 // Uses 8 bytes to make sure the Video struct has consistent size between | 44 // Uses 8 bytes to make sure the Video struct has consistent size between |
40 // NaCl code and renderer code. | 45 // NaCl code and renderer code. |
41 uint8_t data[8]; | 46 uint8_t data[8]; |
42 }; | 47 }; |
43 | 48 |
| 49 struct Bitstream { |
| 50 Header header; |
| 51 uint32_t data_size; |
| 52 // Uses 8 bytes to make sure the Bitstream struct has consistent size |
| 53 // between NaCl code and renderer code. |
| 54 uint8_t data[8]; |
| 55 }; |
| 56 |
44 // Because these structs are written and read in shared memory, we need | 57 // Because these structs are written and read in shared memory, we need |
45 // the size and alighment to be consistent between NaCl and its host trusted | 58 // the size and alighment to be consistent between NaCl and its host trusted |
46 // platform. | 59 // platform. |
47 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Header, 8); | 60 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Header, 8); |
48 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Audio, 40); | 61 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Audio, 40); |
49 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Video, 40); | 62 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Video, 40); |
| 63 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Bitstream, 20); |
50 | 64 |
51 Header header; | 65 Header header; |
52 Video video; | 66 Video video; |
53 Audio audio; | 67 Audio audio; |
| 68 Bitstream bitstream; |
54 }; | 69 }; |
55 | 70 |
56 } // namespace ppapi | 71 } // namespace ppapi |
57 | 72 |
58 #endif // PPAPI_SHARED_IMPL_MEDIA_STREAM_BUFFER_H_ | 73 #endif // PPAPI_SHARED_IMPL_MEDIA_STREAM_BUFFER_H_ |
OLD | NEW |