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 3 // found in the LICENSE file. 4 5 #ifndef PPAPI_SHARED_IMPL_MEDIA_STREAM_BUFFER_H_ 6 #define PPAPI_SHARED_IMPL_MEDIA_STREAM_BUFFER_H_ 7 8 #include "ppapi/c/ppb_audio_buffer.h" 9 #include "ppapi/c/ppb_video_frame.h" 10 11 namespace ppapi { 12 13 union MediaStreamBuffer { 14 enum Type { TYPE_UNKNOWN = 0, TYPE_AUDIO = 1, TYPE_VIDEO = 2, }; 15 16 struct Header { 17 Type type; 18 uint32_t size; 19 }; 20 21 struct Audio { 22 Header header; 23 PP_TimeDelta timestamp; 24 PP_AudioBuffer_SampleRate sample_rate; 25 uint32_t number_of_channels; 26 uint32_t number_of_samples; 27 uint32_t data_size; 28 // Uses 8 bytes to make sure the Audio struct has consistent size between 29 // NaCl code and renderer code. 30 uint8_t data[8]; 31 }; 32 33 struct Video { 34 Header header; 35 PP_TimeDelta timestamp; 36 PP_VideoFrame_Format format; 37 PP_Size size; 38 uint32_t data_size; 39 // Uses 8 bytes to make sure the Video struct has consistent size between 40 // NaCl code and renderer code. 41 uint8_t data[8]; 42 }; 43 44 // 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 46 // platform. 47 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Header, 8); 48 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Audio, 40); 49 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Video, 40); 50 51 Header header; 52 Video video; 53 Audio audio; 54 }; 55 56 } // namespace ppapi 57 58 #endif // PPAPI_SHARED_IMPL_MEDIA_STREAM_BUFFER_H_ 59