1d4d27facSStephan Aßmus /* 2d4d27facSStephan Aßmus * Copyright 2009, Haiku, Inc. All rights reserved. 3d4d27facSStephan Aßmus * Distributed under the terms of the MIT License. 4d4d27facSStephan Aßmus */ 5d4d27facSStephan Aßmus #ifndef _MEDIA_DEFS_H 652a38012Sejakowatz #define _MEDIA_DEFS_H 752a38012Sejakowatz 8d4d27facSStephan Aßmus 9d4d27facSStephan Aßmus /*! Basic data types and defines for the Media Kit. */ 10d4d27facSStephan Aßmus 11d4d27facSStephan Aßmus 1252a38012Sejakowatz #include <OS.h> 1352a38012Sejakowatz #include <ByteOrder.h> 1452a38012Sejakowatz 1552a38012Sejakowatz #if defined(__cplusplus) 1652a38012Sejakowatz # include <GraphicsDefs.h> 1752a38012Sejakowatz # include <Looper.h> 1852a38012Sejakowatz #endif 1952a38012Sejakowatz 20d4d27facSStephan Aßmus 21f6e4cbb9SAxel Dörfler struct media_node; 2252a38012Sejakowatz 2352a38012Sejakowatz #define B_MEDIA_NAME_LENGTH 64 2452a38012Sejakowatz 2552a38012Sejakowatz 26d4d27facSStephan Aßmus /* Notification messages 'what' fields */ 2752a38012Sejakowatz enum { 28d4d27facSStephan Aßmus /* Note that BMediaNode::node_error also belongs in here! */ 29d4d27facSStephan Aßmus B_MEDIA_WILDCARD = 'TRWC', 30d4d27facSStephan Aßmus /* Used to match any notification in */ 31d4d27facSStephan Aßmus /* Start/StopWatching */ 32d4d27facSStephan Aßmus B_MEDIA_NODE_CREATED = 'TRIA', 33d4d27facSStephan Aßmus /* "media_node_id" (multiple items) */ 3452a38012Sejakowatz B_MEDIA_NODE_DELETED, /* "media_node_id" (multiple items) */ 3552a38012Sejakowatz B_MEDIA_CONNECTION_MADE, /* "output", "input", "format" */ 3652a38012Sejakowatz B_MEDIA_CONNECTION_BROKEN, /* "source", "destination" */ 37d4d27facSStephan Aßmus B_MEDIA_BUFFER_CREATED, /* "clone_info" -- handled by */ 38d4d27facSStephan Aßmus /* BMediaRoster */ 39d4d27facSStephan Aßmus B_MEDIA_BUFFER_DELETED, /* "media_buffer_id" -- handled by */ 40d4d27facSStephan Aßmus /* BMediaRoster */ 4152a38012Sejakowatz B_MEDIA_TRANSPORT_STATE, /* "state", "location", "realtime" */ 4252a38012Sejakowatz B_MEDIA_PARAMETER_CHANGED, /* N "node", "parameter" */ 4352a38012Sejakowatz B_MEDIA_FORMAT_CHANGED, /* N "source", "destination", "format" */ 4452a38012Sejakowatz B_MEDIA_WEB_CHANGED, /* N "node" */ 45d4d27facSStephan Aßmus B_MEDIA_DEFAULT_CHANGED, /* "default", "node" -- handled by */ 46d4d27facSStephan Aßmus /* BMediaRoster */ 47d4d27facSStephan Aßmus B_MEDIA_NEW_PARAMETER_VALUE, /* N "node", "parameter", "when", */ 48d4d27facSStephan Aßmus /* "value" */ 4952a38012Sejakowatz B_MEDIA_NODE_STOPPED, /* N "node", "when" */ 5032afe10aSDario Casalinuovo B_MEDIA_FLAVORS_CHANGED, /* "be:addon_id", "be:new_count", */ 51d4d27facSStephan Aßmus /* "be:gone_count" */ 5232afe10aSDario Casalinuovo B_MEDIA_SERVER_STARTED, 5332afe10aSDario Casalinuovo B_MEDIA_SERVER_QUIT 5452a38012Sejakowatz }; 5552a38012Sejakowatz 56d4d27facSStephan Aßmus 5752a38012Sejakowatz enum media_type { 5852a38012Sejakowatz B_MEDIA_NO_TYPE = -1, 5952a38012Sejakowatz B_MEDIA_UNKNOWN_TYPE = 0, 60d4d27facSStephan Aßmus B_MEDIA_RAW_AUDIO = 1, /* uncompressed raw_audio */ 61d4d27facSStephan Aßmus B_MEDIA_RAW_VIDEO, /* uncompressed raw_video */ 6252a38012Sejakowatz B_MEDIA_VBL, /* raw data from VBL area, 1600/line */ 6352a38012Sejakowatz B_MEDIA_TIMECODE, /* data format TBD */ 6452a38012Sejakowatz B_MEDIA_MIDI, 6552a38012Sejakowatz B_MEDIA_TEXT, /* typically closed captioning */ 6652a38012Sejakowatz B_MEDIA_HTML, 6752a38012Sejakowatz B_MEDIA_MULTISTREAM, /* AVI, etc */ 6852a38012Sejakowatz B_MEDIA_PARAMETERS, /* BControllable change data */ 69d4d27facSStephan Aßmus B_MEDIA_ENCODED_AUDIO, /* MP3, AC-3, ... */ 70d4d27facSStephan Aßmus B_MEDIA_ENCODED_VIDEO, /* H.264, Theora, ... */ 71d4d27facSStephan Aßmus B_MEDIA_PRIVATE = 90000, 72d4d27facSStephan Aßmus /* This are reserved. */ 73d4d27facSStephan Aßmus B_MEDIA_FIRST_USER_TYPE = 100000 74d4d27facSStephan Aßmus /* Use something bigger than this for */ 75d4d27facSStephan Aßmus /* experimentation with your own media */ 76d4d27facSStephan Aßmus /* formats. */ 7752a38012Sejakowatz }; 7852a38012Sejakowatz 79d4d27facSStephan Aßmus 8052a38012Sejakowatz enum node_kind { 8152a38012Sejakowatz B_BUFFER_PRODUCER = 0x1, 8252a38012Sejakowatz B_BUFFER_CONSUMER = 0x2, 8352a38012Sejakowatz B_TIME_SOURCE = 0x4, 8452a38012Sejakowatz B_CONTROLLABLE = 0x8, 8552a38012Sejakowatz B_FILE_INTERFACE = 0x10, 8652a38012Sejakowatz B_ENTITY_INTERFACE = 0x20, 87d4d27facSStephan Aßmus 88d4d27facSStephan Aßmus /* Set these flags for nodes that are suitable as default system nodes. */ 8952a38012Sejakowatz B_PHYSICAL_INPUT = 0x10000, 9052a38012Sejakowatz B_PHYSICAL_OUTPUT = 0x20000, 9152a38012Sejakowatz B_SYSTEM_MIXER = 0x40000 9252a38012Sejakowatz }; 9352a38012Sejakowatz 94d4d27facSStephan Aßmus 95d4d27facSStephan Aßmus enum video_orientation { 96d4d27facSStephan Aßmus /* Which pixel is first and how do we scan each "line"? */ 97d4d27facSStephan Aßmus B_VIDEO_TOP_LEFT_RIGHT = 1, /* This is the typical progressive scan */ 98d4d27facSStephan Aßmus /* format */ 9952a38012Sejakowatz B_VIDEO_BOTTOM_LEFT_RIGHT /* This is how BMP and TGA might scan */ 10052a38012Sejakowatz }; 10152a38012Sejakowatz 10252a38012Sejakowatz 103d4d27facSStephan Aßmus /* data */ 104d4d27facSStephan Aßmus enum media_flags 10552a38012Sejakowatz { 106d4d27facSStephan Aßmus B_MEDIA_FLAGS_VERSION = 1, 107d4d27facSStephan Aßmus /* uint32, greater for newer versions */ 108d4d27facSStephan Aßmus B_MEDIA_FLAGS_PRIVATE = 0x40000000 109d4d27facSStephan Aßmus /* private to Haiku */ 11052a38012Sejakowatz }; 11152a38012Sejakowatz 11252a38012Sejakowatz 113d4d27facSStephan Aßmus /* for producer status */ 114d4d27facSStephan Aßmus enum media_producer_status { 11552a38012Sejakowatz B_DATA_NOT_AVAILABLE = 1, 11652a38012Sejakowatz B_DATA_AVAILABLE = 2, 11752a38012Sejakowatz B_PRODUCER_STOPPED = 3 11852a38012Sejakowatz }; 11952a38012Sejakowatz 120d4d27facSStephan Aßmus 121d4d27facSStephan Aßmus /* realtime flags */ 12252a38012Sejakowatz enum media_realtime_flags { 12352a38012Sejakowatz B_MEDIA_REALTIME_ALLOCATOR = 0x1, 12452a38012Sejakowatz B_MEDIA_REALTIME_AUDIO = 0x2, 12552a38012Sejakowatz B_MEDIA_REALTIME_VIDEO = 0x4, 12652a38012Sejakowatz B_MEDIA_REALTIME_ANYKIND = 0xffff 12752a38012Sejakowatz }; 12852a38012Sejakowatz 12952a38012Sejakowatz enum media_frame_flags { 13052a38012Sejakowatz B_MEDIA_KEY_FRAME = 0x1 13152a38012Sejakowatz }; 13252a38012Sejakowatz 13352a38012Sejakowatz #define B_MEDIA_ANY_QUALITY 0.0f 13452a38012Sejakowatz #define B_MEDIA_LOW_QUALITY 0.1f 13552a38012Sejakowatz #define B_MEDIA_MEDIUM_QUALITY 0.5f 13652a38012Sejakowatz #define B_MEDIA_HIGH_QUALITY 1.0f 13752a38012Sejakowatz 13852a38012Sejakowatz 139d4d27facSStephan Aßmus #ifndef _MULTI_AUDIO_H /* #define in protocol header */ 14052a38012Sejakowatz enum media_multi_channels { 141d4d27facSStephan Aßmus B_CHANNEL_LEFT = 0x00001, 142d4d27facSStephan Aßmus B_CHANNEL_RIGHT = 0x00002, 143d4d27facSStephan Aßmus B_CHANNEL_CENTER = 0x00004, /* 5.1+ or fake surround */ 144d4d27facSStephan Aßmus B_CHANNEL_SUB = 0x00008, /* 5.1+ */ 145d4d27facSStephan Aßmus B_CHANNEL_REARLEFT = 0x00010, /* quad surround or 5.1+ */ 146d4d27facSStephan Aßmus B_CHANNEL_REARRIGHT = 0x00020, /* quad surround or 5.1+ */ 147d4d27facSStephan Aßmus B_CHANNEL_FRONT_LEFT_CENTER = 0x00040, 148d4d27facSStephan Aßmus B_CHANNEL_FRONT_RIGHT_CENTER = 0x00080, 149d4d27facSStephan Aßmus B_CHANNEL_BACK_CENTER = 0x00100, /* 6.1 or fake surround */ 150d4d27facSStephan Aßmus B_CHANNEL_SIDE_LEFT = 0x00200, 151d4d27facSStephan Aßmus B_CHANNEL_SIDE_RIGHT = 0x00400, 152d4d27facSStephan Aßmus B_CHANNEL_TOP_CENTER = 0x00800, 153d4d27facSStephan Aßmus B_CHANNEL_TOP_FRONT_LEFT = 0x01000, 154d4d27facSStephan Aßmus B_CHANNEL_TOP_FRONT_CENTER = 0x02000, 155d4d27facSStephan Aßmus B_CHANNEL_TOP_FRONT_RIGHT = 0x04000, 156d4d27facSStephan Aßmus B_CHANNEL_TOP_BACK_LEFT = 0x08000, 15752a38012Sejakowatz B_CHANNEL_TOP_BACK_CENTER = 0x10000, 15852a38012Sejakowatz B_CHANNEL_TOP_BACK_RIGHT = 0x20000 15952a38012Sejakowatz }; 160d4d27facSStephan Aßmus 161d4d27facSStephan Aßmus 16252a38012Sejakowatz enum media_multi_matrix { 16352a38012Sejakowatz B_MATRIX_PROLOGIC_LR = 0x1, 16452a38012Sejakowatz B_MATRIX_AMBISONIC_WXYZ = 0x4 16552a38012Sejakowatz }; 166d4d27facSStephan Aßmus #endif // !_MULTI_AUDIO_H 16752a38012Sejakowatz 16852a38012Sejakowatz 16952a38012Sejakowatz typedef int32 media_node_id; 17052a38012Sejakowatz typedef int32 media_buffer_id; 17152a38012Sejakowatz typedef int32 media_addon_id; 17252a38012Sejakowatz 17352a38012Sejakowatz 17452a38012Sejakowatz #if defined(__cplusplus) 17552a38012Sejakowatz struct media_destination { 17652a38012Sejakowatz media_destination(); 177d4d27facSStephan Aßmus media_destination(port_id, int32); 178d4d27facSStephan Aßmus media_destination( 179d4d27facSStephan Aßmus const media_destination& other); 18052a38012Sejakowatz ~media_destination(); 181d4d27facSStephan Aßmus 182d4d27facSStephan Aßmus media_destination& operator=(const media_destination& other); 183d4d27facSStephan Aßmus 184d4d27facSStephan Aßmus port_id port; /* can be different from */ 185d4d27facSStephan Aßmus /* media_node.port */ 18652a38012Sejakowatz int32 id; 18752a38012Sejakowatz static media_destination null; 188d4d27facSStephan Aßmus 18952a38012Sejakowatz private: 19052a38012Sejakowatz uint32 _reserved_media_destination_[2]; 19152a38012Sejakowatz }; 19252a38012Sejakowatz 193d4d27facSStephan Aßmus 19452a38012Sejakowatz struct media_source { 19552a38012Sejakowatz media_source(); 196d4d27facSStephan Aßmus media_source(port_id, int32); 197d4d27facSStephan Aßmus media_source(const media_source& other); 19852a38012Sejakowatz ~media_source(); 199d4d27facSStephan Aßmus 200d4d27facSStephan Aßmus media_source& operator=(const media_source& other); 201d4d27facSStephan Aßmus port_id port; /* must be the same as */ 202d4d27facSStephan Aßmus /* media_node.port for owner */ 20352a38012Sejakowatz int32 id; 20452a38012Sejakowatz static media_source null; 205d4d27facSStephan Aßmus 20652a38012Sejakowatz private: 20752a38012Sejakowatz uint32 _reserved_media_source_[2]; 20852a38012Sejakowatz }; 20952a38012Sejakowatz 210d4d27facSStephan Aßmus 211f6e4cbb9SAxel Dörfler bool operator==(const media_destination& a, const media_destination& b); 212f6e4cbb9SAxel Dörfler bool operator!=(const media_destination& a, const media_destination& b); 213f6e4cbb9SAxel Dörfler bool operator<(const media_destination& a, const media_destination& b); 214f6e4cbb9SAxel Dörfler bool operator==(const media_source& a, const media_source& b); 215f6e4cbb9SAxel Dörfler bool operator!=(const media_source& a, const media_source& b); 216f6e4cbb9SAxel Dörfler bool operator<(const media_source& a, const media_source& b); 217f6e4cbb9SAxel Dörfler bool operator==(const media_node& a, const media_node& b); 218f6e4cbb9SAxel Dörfler bool operator!=(const media_node& a, const media_node& b); 219f6e4cbb9SAxel Dörfler bool operator<(const media_node& a, const media_node& b); 22052a38012Sejakowatz 22152a38012Sejakowatz 22252a38012Sejakowatz 22352a38012Sejakowatz /* Buffers are low-level constructs identified by an ID. */ 22452a38012Sejakowatz /* Buffers consist of the actual data area, plus a 64-byte */ 22552a38012Sejakowatz /* header area that is different for each type. */ 22652a38012Sejakowatz /* Buffers contain typed data. Type is not part of the */ 22752a38012Sejakowatz /* buffer header; it's negotiated out-of-bounds by nodes. */ 22852a38012Sejakowatz 22952a38012Sejakowatz enum { 23052a38012Sejakowatz B_MEDIA_BIG_ENDIAN = 1, 23152a38012Sejakowatz B_MEDIA_LITTLE_ENDIAN = 2, 23252a38012Sejakowatz #if B_HOST_IS_BENDIAN 23352a38012Sejakowatz B_MEDIA_HOST_ENDIAN = B_MEDIA_BIG_ENDIAN 23452a38012Sejakowatz #else 23552a38012Sejakowatz B_MEDIA_HOST_ENDIAN = B_MEDIA_LITTLE_ENDIAN 23652a38012Sejakowatz #endif 23752a38012Sejakowatz }; 23852a38012Sejakowatz 239d4d27facSStephan Aßmus 24052a38012Sejakowatz struct media_multi_audio_format; 24152a38012Sejakowatz 242d4d27facSStephan Aßmus 24352a38012Sejakowatz struct media_raw_audio_format { 244d4d27facSStephan Aßmus // possible values for "format" 245d4d27facSStephan Aßmus enum { 246d4d27facSStephan Aßmus B_AUDIO_FLOAT = 0x24, 247d4d27facSStephan Aßmus // 0 == mid, -1.0 == bottom, 1.0 == top 248d4d27facSStephan Aßmus // (the preferred format for non-game audio) 249d4d27facSStephan Aßmus 250d4d27facSStephan Aßmus B_AUDIO_DOUBLE = 0x28, 251d4d27facSStephan Aßmus // 0 == mid, -1.0 == bottom, 1.0 == top 252d4d27facSStephan Aßmus // (only useful for pro audio) 253d4d27facSStephan Aßmus 254d4d27facSStephan Aßmus B_AUDIO_INT = 0x4, 255d4d27facSStephan Aßmus // 0 == mid, 0x80000001 == bottom, 0x7fffffff == top 256d4d27facSStephan Aßmus // (all >16-bit formats, left-adjusted) 257d4d27facSStephan Aßmus 258d4d27facSStephan Aßmus B_AUDIO_SHORT = 0x2, 259d4d27facSStephan Aßmus // 0 == mid, -32767 == bottom, +32767 == top 260d4d27facSStephan Aßmus 261d4d27facSStephan Aßmus B_AUDIO_UCHAR = 0x11, 262d4d27facSStephan Aßmus // 128 == mid, 1 == bottom, 255 == top 263d4d27facSStephan Aßmus // (discouraged but supported format) 264d4d27facSStephan Aßmus 265d4d27facSStephan Aßmus B_AUDIO_CHAR = 0x1, 266d4d27facSStephan Aßmus // 0 == mid, -127 == bottom, +127 == top 267d4d27facSStephan Aßmus // (not officially supported format) 268d4d27facSStephan Aßmus 26952a38012Sejakowatz B_AUDIO_SIZE_MASK = 0xf 270d4d27facSStephan Aßmus // This mask can be used to obtain the sample size 271d4d27facSStephan Aßmus // for raw formats: (format & 0xf) == sizeof(sample) 272d4d27facSStephan Aßmus }; 27352a38012Sejakowatz 27452a38012Sejakowatz float frame_rate; 275d4d27facSStephan Aßmus uint32 channel_count; 276d4d27facSStephan Aßmus uint32 format; // see possible values above 277d4d27facSStephan Aßmus uint32 byte_order; // B_MEDIA_LITTLE_ENDIAN or B_MEDIA_BIG_ENDIAN 27852a38012Sejakowatz size_t buffer_size; // size of each buffer 27952a38012Sejakowatz 28052a38012Sejakowatz static media_multi_audio_format wildcard; 28152a38012Sejakowatz }; 28252a38012Sejakowatz 283d4d27facSStephan Aßmus 28452a38012Sejakowatz struct media_audio_header { 28522ea661bSColin Günther // TODO: Refine this structure and put actual data at the end 28622ea661bSColin Günther int32 _reserved_[14]; 28722ea661bSColin Günther float frame_rate; 28822ea661bSColin Günther uint32 channel_count; 28922ea661bSColin Günther 29052a38012Sejakowatz }; 29152a38012Sejakowatz 292d4d27facSStephan Aßmus 29352a38012Sejakowatz struct media_multi_audio_info { 29452a38012Sejakowatz uint32 channel_mask; // bitmask 29552a38012Sejakowatz int16 valid_bits; // if < 32, for B_AUDIO_INT 296d4d27facSStephan Aßmus uint16 matrix_mask; // each of these bits may mean more than one 297d4d27facSStephan Aßmus // channel 29852a38012Sejakowatz 29952a38012Sejakowatz uint32 _reserved_b[3]; 30052a38012Sejakowatz }; 30152a38012Sejakowatz 302d4d27facSStephan Aßmus 303d4d27facSStephan Aßmus struct media_multi_audio_format : public media_raw_audio_format, 304d4d27facSStephan Aßmus public media_multi_audio_info { 305d4d27facSStephan Aßmus 30652a38012Sejakowatz static media_multi_audio_format wildcard; 30752a38012Sejakowatz }; 30852a38012Sejakowatz 30952a38012Sejakowatz 31052a38012Sejakowatz struct media_encoded_audio_format { 31152a38012Sejakowatz enum audio_encoding { 31252a38012Sejakowatz B_ANY 31352a38012Sejakowatz }; 314d4d27facSStephan Aßmus 31552a38012Sejakowatz media_raw_audio_format output; 31652a38012Sejakowatz audio_encoding encoding; 31752a38012Sejakowatz 318d4d27facSStephan Aßmus float bit_rate; 31952a38012Sejakowatz size_t frame_size; 32052a38012Sejakowatz 32152a38012Sejakowatz media_multi_audio_info multi_info; 32252a38012Sejakowatz 32352a38012Sejakowatz uint32 _reserved_[3]; 32452a38012Sejakowatz 32552a38012Sejakowatz static media_encoded_audio_format wildcard; 32652a38012Sejakowatz }; 32752a38012Sejakowatz 328d4d27facSStephan Aßmus 32952a38012Sejakowatz struct media_encoded_audio_header { 330d4d27facSStephan Aßmus // NOTE: More data fields need to go to the end 331d4d27facSStephan Aßmus int32 _reserved_0[14]; 332d4d27facSStephan Aßmus 333d4d27facSStephan Aßmus uint32 buffer_flags; 334d4d27facSStephan Aßmus // B_MEDIA_KEY_FRAME for key frame chunks 335d4d27facSStephan Aßmus uchar unused_mask; 336d4d27facSStephan Aßmus // mask of unused bits for the last byte of data 33752a38012Sejakowatz uchar _reserved_2[3]; 33852a38012Sejakowatz 33952a38012Sejakowatz }; 34052a38012Sejakowatz 34152a38012Sejakowatz enum media_display_flags { 342d4d27facSStephan Aßmus B_F1_DOMINANT = 0x1, // The first buffer sent (temporally) will 343d4d27facSStephan Aßmus // be an F1 field. 344d4d27facSStephan Aßmus B_F2_DOMINANT = 0x2, // The first buffer sent (temporally) will 345d4d27facSStephan Aßmus // be an F2 field. 346d4d27facSStephan Aßmus B_TOP_SCANLINE_F1 = 0x4, // The topmost scanline of the output buffer 347d4d27facSStephan Aßmus // belongs to F1. 348d4d27facSStephan Aßmus B_TOP_SCANLINE_F2 = 0x8 // The topmost scanline of the output buffer 349d4d27facSStephan Aßmus // belongs to F2. 35052a38012Sejakowatz }; 351d4d27facSStephan Aßmus 352d4d27facSStephan Aßmus 35352a38012Sejakowatz struct media_video_display_info { 35452a38012Sejakowatz color_space format; 35552a38012Sejakowatz uint32 line_width; 356d4d27facSStephan Aßmus uint32 line_count; // sum of all interlace fields lines 357d4d27facSStephan Aßmus uint32 bytes_per_row; // bytes_per_row is in format, not header, 358d4d27facSStephan Aßmus // because it's part of SetBuffers 359d4d27facSStephan Aßmus uint32 pixel_offset; // (in pixels) Offset from the start of the 360d4d27facSStephan Aßmus // buffer (see below). 361d4d27facSStephan Aßmus uint32 line_offset; // (in lines) Offset to the start of the field. 362d4d27facSStephan Aßmus // Think "buffer == framebuffer" when the 363d4d27facSStephan Aßmus // window displaying the active field moves 364d4d27facSStephan Aßmus // on screen. 36552a38012Sejakowatz uint32 flags; 36652a38012Sejakowatz uint32 _reserved_[3]; 367d4d27facSStephan Aßmus 36852a38012Sejakowatz static media_video_display_info wildcard; 36952a38012Sejakowatz }; 37052a38012Sejakowatz 371d4d27facSStephan Aßmus 37252a38012Sejakowatz struct media_raw_video_format { 37352a38012Sejakowatz float field_rate; 374d4d27facSStephan Aßmus uint32 interlace; // Number of fields per frame: 1 means 375d4d27facSStephan Aßmus // progressive (non-interlaced) frames. 376d4d27facSStephan Aßmus uint32 first_active; // Index of first active line. 0, typically 377d4d27facSStephan Aßmus // (wildcard, or "don't care") 378d4d27facSStephan Aßmus uint32 last_active; // Index of last active line (typically 379d4d27facSStephan Aßmus // line_count - 1, if first_active is 0. 380d4d27facSStephan Aßmus uint32 orientation; // B_VIDEO_TOP_LEFT_RIGHT is preferred. 381d4d27facSStephan Aßmus 382d4d27facSStephan Aßmus // This is the display aspect ratio (DAR). Usually, you would reduce the 383d4d27facSStephan Aßmus // width and height of the intended output frame size as far as possible 384d4d27facSStephan Aßmus // without changing their ratio. Note that you should not put 1 in both 385d4d27facSStephan Aßmus // fields to mean "undistorted pixels", unless you really intend square 386d4d27facSStephan Aßmus // video output! 38752a38012Sejakowatz uint16 pixel_width_aspect; // 1:1 has 1 here, 4:3 has 4 here 388d4d27facSStephan Aßmus // 16:9 has 16 here! 38952a38012Sejakowatz uint16 pixel_height_aspect; // 1:1 has 1 here, 4:3 has 3 here 390d4d27facSStephan Aßmus // 16:9 has 9 here! 39152a38012Sejakowatz 39252a38012Sejakowatz media_video_display_info display; 39352a38012Sejakowatz 39452a38012Sejakowatz static media_raw_video_format wildcard; 39552a38012Sejakowatz }; 39652a38012Sejakowatz 397d4d27facSStephan Aßmus 39852a38012Sejakowatz struct media_video_header { 39922ea661bSColin Günther uint32 _reserved_[8]; // NOTE: Keep reserved data at the top! 400d4d27facSStephan Aßmus 40122ea661bSColin Günther uint32 display_line_width; // Number of pixels per display_line 40222ea661bSColin Günther uint32 display_line_count; // Sum of all interlace fields lines 40322ea661bSColin Günther uint32 bytes_per_row; // Number of bytes in a display_line 40422ea661bSColin Günther // (padding bytes excluded) 40522ea661bSColin Günther uint16 pixel_width_aspect; // 1:1 has 1 here, 4:3 has 4 here 40622ea661bSColin Günther // 16:9 has 16 here! 40722ea661bSColin Günther uint16 pixel_height_aspect;// 1:1 has 1 here, 4:3 has 3 here 40822ea661bSColin Günther // 16:9 has 9 here! 40952a38012Sejakowatz float field_gamma; 410d4d27facSStephan Aßmus uint32 field_sequence; // Sequence number since start of capture 411d4d27facSStephan Aßmus // May roll over if machine is on for a 412d4d27facSStephan Aßmus // LONG time. 413d4d27facSStephan Aßmus uint16 field_number; // 0 .. {interlace-1}; F1 == 0 ("odd"), 414d4d27facSStephan Aßmus // F2 == 1 ("even") 41552a38012Sejakowatz uint16 pulldown_number; // 0..2 for pulldown duplicated sequence 416d4d27facSStephan Aßmus uint16 first_active_line; // The NTSC/PAL line number (1-based) of 417d4d27facSStephan Aßmus // the first line in this field 418d4d27facSStephan Aßmus uint16 line_count; // The number of active lines in buffer. 41952a38012Sejakowatz }; 42052a38012Sejakowatz 421d4d27facSStephan Aßmus 42252a38012Sejakowatz struct media_encoded_video_format { 42352a38012Sejakowatz enum video_encoding { 42452a38012Sejakowatz B_ANY 42552a38012Sejakowatz }; 426d4d27facSStephan Aßmus 42752a38012Sejakowatz media_raw_video_format output; // set unknowns to wildcard 428d4d27facSStephan Aßmus 42952a38012Sejakowatz float avg_bit_rate; 43052a38012Sejakowatz float max_bit_rate; 431d4d27facSStephan Aßmus 43252a38012Sejakowatz video_encoding encoding; 43352a38012Sejakowatz size_t frame_size; 43452a38012Sejakowatz 435d4d27facSStephan Aßmus int16 forward_history; // maximum forward memory 436d4d27facSStephan Aßmus // required by codec 437d4d27facSStephan Aßmus 438d4d27facSStephan Aßmus int16 backward_history; // maximum backward memory 439d4d27facSStephan Aßmus // required by codec 440d4d27facSStephan Aßmus 441d4d27facSStephan Aßmus uint32 _reserved_[3]; // This structure cannot grow 442d4d27facSStephan Aßmus // more than this (embedded) 443d4d27facSStephan Aßmus // in media_format union 44452a38012Sejakowatz 44552a38012Sejakowatz static media_encoded_video_format wildcard; 44652a38012Sejakowatz }; 44752a38012Sejakowatz 448d4d27facSStephan Aßmus 44952a38012Sejakowatz struct media_encoded_video_header { 450d4d27facSStephan Aßmus // NOTE: More data fields need to go at the end of this structure. 451d4d27facSStephan Aßmus int32 _reserved_1[9]; 45252a38012Sejakowatz 45352a38012Sejakowatz uint32 field_flags; // B_MEDIA_KEY_FRAME 45452a38012Sejakowatz 455d4d27facSStephan Aßmus int16 forward_history; // forward memory required by this buffer 456d4d27facSStephan Aßmus // (0 for key frames) 457d4d27facSStephan Aßmus 458d4d27facSStephan Aßmus int16 backward_history; // backward memory required by this buffer 459d4d27facSStephan Aßmus // (0 for key frames) 460d4d27facSStephan Aßmus 461d4d27facSStephan Aßmus uchar unused_mask; // mask of unused bits for the last byte 462d4d27facSStephan Aßmus // of data 46352a38012Sejakowatz uchar _reserved_2[3]; 46452a38012Sejakowatz float field_gamma; 46552a38012Sejakowatz uint32 field_sequence; // sequence since start of capture 46652a38012Sejakowatz uint16 field_number; // 0 .. {interlace-1}; F1 == 0, F2 == 1 46752a38012Sejakowatz uint16 pulldown_number; // 0..2 for pulldown duplicated sequence 468d4d27facSStephan Aßmus uint16 first_active_line; // 0 or 1, typically, but could be 10 or 469d4d27facSStephan Aßmus // 11 for full-NTSC formats 47052a38012Sejakowatz uint16 line_count; // number of actual lines in buffer 47152a38012Sejakowatz }; 47252a38012Sejakowatz 47352a38012Sejakowatz struct media_multistream_format { 47452a38012Sejakowatz enum { 47552a38012Sejakowatz B_ANY = 0, 47652a38012Sejakowatz B_VID = 1, // raw raw_video/raw_audio buffers 47752a38012Sejakowatz B_AVI, 47852a38012Sejakowatz B_MPEG1, 47952a38012Sejakowatz B_MPEG2, 48052a38012Sejakowatz B_QUICKTIME, 48152a38012Sejakowatz B_PRIVATE = 90000, 482d4d27facSStephan Aßmus B_FIRST_USER_TYPE = 100000 48352a38012Sejakowatz }; 48452a38012Sejakowatz float avg_bit_rate; // 8 * byte rate, on average 48552a38012Sejakowatz float max_bit_rate; // 8 * byte rate, tops 486d4d27facSStephan Aßmus uint32 avg_chunk_size; // == max_chunk_size for fixed-size 487d4d27facSStephan Aßmus // chunks 48852a38012Sejakowatz uint32 max_chunk_size; // max buffer size 48952a38012Sejakowatz enum { 49052a38012Sejakowatz B_HEADER_HAS_FLAGS = 0x1, // are flags important? 491d4d27facSStephan Aßmus B_CLEAN_BUFFERS = 0x2, // each buffer represents an integral 492d4d27facSStephan Aßmus // number of "frames" 49352a38012Sejakowatz B_HOMOGENOUS_BUFFERS = 0x4 // a buffer has only one format in it 49452a38012Sejakowatz }; 49552a38012Sejakowatz uint32 flags; 49652a38012Sejakowatz int32 format; 49752a38012Sejakowatz uint32 _reserved_[2]; 49852a38012Sejakowatz 49952a38012Sejakowatz struct vid_info { 50052a38012Sejakowatz float frame_rate; 50152a38012Sejakowatz uint16 width; 50252a38012Sejakowatz uint16 height; 50352a38012Sejakowatz color_space space; 50452a38012Sejakowatz 50552a38012Sejakowatz float sampling_rate; 50652a38012Sejakowatz uint32 sample_format; 50752a38012Sejakowatz uint16 byte_order; 50852a38012Sejakowatz uint16 channel_count; 50952a38012Sejakowatz }; 51052a38012Sejakowatz struct avi_info { 51152a38012Sejakowatz uint32 us_per_frame; 51252a38012Sejakowatz uint16 width; 51352a38012Sejakowatz uint16 height; 51452a38012Sejakowatz uint16 _reserved_; 51552a38012Sejakowatz uint16 type_count; 51652a38012Sejakowatz media_type types[5]; 51752a38012Sejakowatz }; 51852a38012Sejakowatz 51952a38012Sejakowatz union { 52052a38012Sejakowatz vid_info vid; 52152a38012Sejakowatz avi_info avi; 52252a38012Sejakowatz } u; 52352a38012Sejakowatz 52452a38012Sejakowatz static media_multistream_format wildcard; 52552a38012Sejakowatz }; 52652a38012Sejakowatz 527d4d27facSStephan Aßmus 52852a38012Sejakowatz struct media_multistream_header { 52952a38012Sejakowatz uint32 _reserved_[14]; 530d4d27facSStephan Aßmus uchar unused_mask; // mask of unused bits for the last byte 531d4d27facSStephan Aßmus // of data 53252a38012Sejakowatz uchar _reserved_2[3]; 53352a38012Sejakowatz enum { 53452a38012Sejakowatz B_MASTER_HEADER = 0x1, // for master stream header data in buffer 53552a38012Sejakowatz B_SUBSTREAM_HEADER = 0x2, // for sub-stream header data in buffer 53652a38012Sejakowatz B_COMPLETE_BUFFER = 0x4 // data is an integral number of "frames" 53752a38012Sejakowatz }; 53852a38012Sejakowatz uint32 flags; 53952a38012Sejakowatz }; 54052a38012Sejakowatz 541d4d27facSStephan Aßmus 54252a38012Sejakowatz extern const type_code B_CODEC_TYPE_INFO; 54352a38012Sejakowatz 544d4d27facSStephan Aßmus 54552a38012Sejakowatz enum media_format_flags { 54652a38012Sejakowatz B_MEDIA_RETAINED_DATA = 0x1, 54752a38012Sejakowatz B_MEDIA_MULTIPLE_BUFFERS = 0x2, 54852a38012Sejakowatz B_MEDIA_CONTIGUOUS_BUFFER = 0x4, 54952a38012Sejakowatz B_MEDIA_LINEAR_UPDATES = 0x8, 550d4d27facSStephan Aßmus B_MEDIA_MAUI_UNDEFINED_FLAGS = ~0xf // NOTE: Always deny these flags 551d4d27facSStephan Aßmus // in new code. 55252a38012Sejakowatz }; 55352a38012Sejakowatz 554d4d27facSStephan Aßmus // NOTE: A field of 0 typically means "anything" or "wildcard". 555d4d27facSStephan Aßmus // NOTE: This structure should not be bigger than 192 bytes! 556d4d27facSStephan Aßmus struct media_format { 55752a38012Sejakowatz media_type type; 55852a38012Sejakowatz type_code user_data_type; 55952a38012Sejakowatz uchar user_data[48]; 56052a38012Sejakowatz uint32 _reserved_[3]; 56152a38012Sejakowatz uint16 require_flags; // media_format_flags 56252a38012Sejakowatz uint16 deny_flags; // media_format_flags 56352a38012Sejakowatz 56452a38012Sejakowatz private: 565bacf4b5eSshatty void* meta_data; 56652a38012Sejakowatz int32 meta_data_size; 56752a38012Sejakowatz area_id meta_data_area; 5680a00d23fSMarcus Overhagen area_id __unused_was_use_area; 5690a00d23fSMarcus Overhagen team_id __unused_was_team; 5700a00d23fSMarcus Overhagen void* __unused_was_thisPtr; 57152a38012Sejakowatz 57252a38012Sejakowatz public: 57352a38012Sejakowatz union { 57452a38012Sejakowatz media_multi_audio_format raw_audio; 57552a38012Sejakowatz media_raw_video_format raw_video; 57652a38012Sejakowatz media_multistream_format multistream; 57752a38012Sejakowatz media_encoded_audio_format encoded_audio; 57852a38012Sejakowatz media_encoded_video_format encoded_video; 57952a38012Sejakowatz char _reserved_[96]; // pad to 96 bytes 58052a38012Sejakowatz } u; 58152a38012Sejakowatz 582d4d27facSStephan Aßmus bool IsVideo() const; 58352a38012Sejakowatz 584d4d27facSStephan Aßmus uint32 Width() const; 585d4d27facSStephan Aßmus uint32 Height() const; 586d4d27facSStephan Aßmus color_space ColorSpace() const; 58752a38012Sejakowatz 588d4d27facSStephan Aßmus uint32& Width(); 589d4d27facSStephan Aßmus uint32& Height(); 590d4d27facSStephan Aßmus color_space& ColorSpace(); 59152a38012Sejakowatz 592d4d27facSStephan Aßmus bool IsAudio() const; 593d4d27facSStephan Aßmus uint32 AudioFormat() const; 594d4d27facSStephan Aßmus uint32& AudioFormat(); 595d4d27facSStephan Aßmus uint32 AudioFrameSize() const; 596d4d27facSStephan Aßmus 597d4d27facSStephan Aßmus uint32 Encoding() const; 598d4d27facSStephan Aßmus 599d4d27facSStephan Aßmus bool Matches(const media_format* other) const; 600d4d27facSStephan Aßmus void SpecializeTo(const media_format* other); 60152a38012Sejakowatz 60252a38012Sejakowatz status_t SetMetaData(const void* data, size_t size); 60352a38012Sejakowatz const void* MetaData() const; 60452a38012Sejakowatz int32 MetaDataSize() const; 60552a38012Sejakowatz 60652a38012Sejakowatz media_format(); 60752a38012Sejakowatz media_format(const media_format& other); 60852a38012Sejakowatz ~media_format(); 609d4d27facSStephan Aßmus 610d4d27facSStephan Aßmus media_format& operator=(const media_format& other); 61152a38012Sejakowatz }; 61252a38012Sejakowatz 613d4d27facSStephan Aßmus 614d4d27facSStephan Aßmus bool operator==(const media_raw_audio_format& a, 615d4d27facSStephan Aßmus const media_raw_audio_format& b); 616d4d27facSStephan Aßmus 617d4d27facSStephan Aßmus bool operator==(const media_multi_audio_info& a, 618d4d27facSStephan Aßmus const media_multi_audio_info& b); 619d4d27facSStephan Aßmus 620d4d27facSStephan Aßmus bool operator==(const media_multi_audio_format& a, 621d4d27facSStephan Aßmus const media_multi_audio_format& b); 622d4d27facSStephan Aßmus 623d4d27facSStephan Aßmus bool operator==(const media_encoded_audio_format& a, 624d4d27facSStephan Aßmus const media_encoded_audio_format& b); 625d4d27facSStephan Aßmus 626d4d27facSStephan Aßmus bool operator==(const media_video_display_info& a, 627d4d27facSStephan Aßmus const media_video_display_info& b); 628d4d27facSStephan Aßmus 629d4d27facSStephan Aßmus bool operator==(const media_raw_video_format& a, 630d4d27facSStephan Aßmus const media_raw_video_format& b); 631d4d27facSStephan Aßmus 632d4d27facSStephan Aßmus bool operator==(const media_encoded_video_format& a, 633d4d27facSStephan Aßmus const media_encoded_video_format& b); 634d4d27facSStephan Aßmus 635d4d27facSStephan Aßmus bool operator==(const media_multistream_format::vid_info& a, 636d4d27facSStephan Aßmus const media_multistream_format::vid_info& b); 637d4d27facSStephan Aßmus 638d4d27facSStephan Aßmus bool operator==(const media_multistream_format::avi_info& a, 639d4d27facSStephan Aßmus const media_multistream_format::avi_info & b); 640d4d27facSStephan Aßmus 641d4d27facSStephan Aßmus bool operator==(const media_multistream_format& a, 642d4d27facSStephan Aßmus const media_multistream_format& b); 643d4d27facSStephan Aßmus 644f6e4cbb9SAxel Dörfler bool operator==(const media_format& a, const media_format& b); 64552a38012Sejakowatz 646d4d27facSStephan Aßmus 647d4d27facSStephan Aßmus bool format_is_compatible(const media_format & a, const media_format & b); 648d4d27facSStephan Aßmus // Returns true if a and b are compatible (accounting for wildcards) 649d4d27facSStephan Aßmus // (a is the format you want to feed to something accepting b 650d4d27facSStephan Aßmus 651f6e4cbb9SAxel Dörfler bool string_for_format(const media_format & f, char * buf, size_t size); 65252a38012Sejakowatz 653d4d27facSStephan Aßmus 65452a38012Sejakowatz struct media_seek_tag { 65552a38012Sejakowatz char data[16]; 65652a38012Sejakowatz }; 65752a38012Sejakowatz 658d4d27facSStephan Aßmus 65952a38012Sejakowatz struct media_header_time_code { 66052a38012Sejakowatz int8 type; // See TimeCode.h; don't use the "DEFAULT" value 66152a38012Sejakowatz int8 _reserved; 66252a38012Sejakowatz int8 hours; 66352a38012Sejakowatz int8 minutes; 66452a38012Sejakowatz int8 seconds; 66552a38012Sejakowatz int8 frames; 666d4d27facSStephan Aßmus int16 subframes; // Set to -1 if not available 66752a38012Sejakowatz }; 66852a38012Sejakowatz 669d4d27facSStephan Aßmus 670d4d27facSStephan Aßmus // Broadcast() fills in fields marked with "//+" 671d4d27facSStephan Aßmus struct media_header { 67252a38012Sejakowatz media_type type; // what kind of data (for union) 67352a38012Sejakowatz media_buffer_id buffer; //+ what buffer does this header go with? 67452a38012Sejakowatz int32 destination; //+ what 'socket' is this intended for? 67552a38012Sejakowatz media_node_id time_source; // node that encoded start_time 67652a38012Sejakowatz uint32 _deprecated_; // used to be change_tag 67752a38012Sejakowatz uint32 size_used; // size within buffer that is used 67852a38012Sejakowatz bigtime_t start_time; // performance time 67952a38012Sejakowatz area_id owner; //+ buffer owner info area 68052a38012Sejakowatz enum { 68152a38012Sejakowatz B_SEEK_TAG = 'TRST', // user data type of the codec seek 68252a38012Sejakowatz // protocol. size of seek tag is 16 bytes 68352a38012Sejakowatz B_TIME_CODE = 'TRTC' // user data is media_header_time_code 68452a38012Sejakowatz }; 68552a38012Sejakowatz type_code user_data_type; 68652a38012Sejakowatz uchar user_data[64]; // user_data_type indicates what this is 687b289aaf6SAxel Dörfler int32 source; 688b289aaf6SAxel Dörfler port_id source_port; 68952a38012Sejakowatz 69052a38012Sejakowatz off_t file_pos; // where in a file this data came from 69152a38012Sejakowatz size_t orig_size; // and how big it was. if unused, zero out 69252a38012Sejakowatz 69352a38012Sejakowatz uint32 data_offset; // offset within buffer (already reflected in Data()) 69452a38012Sejakowatz 69552a38012Sejakowatz union { 69652a38012Sejakowatz media_audio_header raw_audio; 69752a38012Sejakowatz media_video_header raw_video; 69852a38012Sejakowatz media_multistream_header multistream; 69952a38012Sejakowatz media_encoded_audio_header encoded_audio; 70052a38012Sejakowatz media_encoded_video_header encoded_video; 70152a38012Sejakowatz char _reserved_[64]; // pad to 64 bytes 70252a38012Sejakowatz } u; 70352a38012Sejakowatz }; 70452a38012Sejakowatz 70552a38012Sejakowatz 70652a38012Sejakowatz struct media_file_format_id { 70752a38012Sejakowatz ino_t node; 70852a38012Sejakowatz dev_t device; 70952a38012Sejakowatz uint32 internal_id; 71052a38012Sejakowatz }; 711d4d27facSStephan Aßmus 712d4d27facSStephan Aßmus 713f6e4cbb9SAxel Dörfler bool operator==(const media_file_format_id& a, const media_file_format_id& b); 714f6e4cbb9SAxel Dörfler bool operator<(const media_file_format_id& a, const media_file_format_id& b); 71552a38012Sejakowatz 716d4d27facSStephan Aßmus 71752a38012Sejakowatz typedef enum { 71852a38012Sejakowatz B_ANY_FORMAT_FAMILY = 0, 71952a38012Sejakowatz B_BEOS_FORMAT_FAMILY = 1, 720d4d27facSStephan Aßmus B_QUICKTIME_FORMAT_FAMILY = 2, // QuickTime is a registered 721d4d27facSStephan Aßmus // trademark of Apple Computer. 72252a38012Sejakowatz B_AVI_FORMAT_FAMILY = 3, 72352a38012Sejakowatz B_ASF_FORMAT_FAMILY = 4, 72452a38012Sejakowatz B_MPEG_FORMAT_FAMILY = 5, 72552a38012Sejakowatz B_WAV_FORMAT_FAMILY = 6, 72652a38012Sejakowatz B_AIFF_FORMAT_FAMILY = 7, 72752a38012Sejakowatz B_AVR_FORMAT_FAMILY = 8, 728d4d27facSStephan Aßmus 729da87cefeSbeveloper B_MISC_FORMAT_FAMILY = 99999, 73052a38012Sejakowatz } media_format_family; 73152a38012Sejakowatz 732d4d27facSStephan Aßmus 73352a38012Sejakowatz struct media_file_format { 734d4d27facSStephan Aßmus // Possible flags for capabilities bitmask 735d4d27facSStephan Aßmus enum { 73652a38012Sejakowatz B_READABLE = 0x1, 73752a38012Sejakowatz B_WRITABLE = 0x2, 73852a38012Sejakowatz B_PERFECTLY_SEEKABLE = 0x4, 73952a38012Sejakowatz B_IMPERFECTLY_SEEKABLE = 0x8, 74052a38012Sejakowatz B_KNOWS_RAW_VIDEO = 0x10, 74152a38012Sejakowatz B_KNOWS_RAW_AUDIO = 0x20, 74252a38012Sejakowatz B_KNOWS_MIDI = 0x40, 74352a38012Sejakowatz B_KNOWS_ENCODED_VIDEO = 0x80, 74452a38012Sejakowatz B_KNOWS_ENCODED_AUDIO = 0x100, 745d4d27facSStephan Aßmus B_KNOWS_OTHER = 0x1000000, // For example sub-title streams 74652a38012Sejakowatz B_KNOWS_ANYTHING = 0x2000000 74752a38012Sejakowatz }; 748d4d27facSStephan Aßmus uint32 capabilities; // Bitmask, see flags above 749d4d27facSStephan Aßmus media_file_format_id id; // Opaque id used to construct a 750d4d27facSStephan Aßmus // BMediaFile 751d4d27facSStephan Aßmus media_format_family family; // One of the family enums 75252a38012Sejakowatz int32 version; // 100 for 1.0 75352a38012Sejakowatz 75452a38012Sejakowatz uint32 _reserved_[25]; 75552a38012Sejakowatz 756d4d27facSStephan Aßmus char mime_type[64]; 757d4d27facSStephan Aßmus char pretty_name[64]; // "QuickTime File Format" 758d4d27facSStephan Aßmus char short_name[32]; // "quicktime", "avi", "mpeg" 759d4d27facSStephan Aßmus char file_extension[8]; // "mov", "avi", "mpg" 760d4d27facSStephan Aßmus 76152a38012Sejakowatz char reserved[88]; 76252a38012Sejakowatz }; 76352a38012Sejakowatz 76452a38012Sejakowatz 765d4d27facSStephan Aßmus // Initialize the cookie to 0 and keep calling this function to iterate 766d4d27facSStephan Aßmus // over all available media file format writers. 76752a38012Sejakowatz status_t get_next_file_format(int32* cookie, media_file_format* mfi); 76852a38012Sejakowatz 76952a38012Sejakowatz 770d4d27facSStephan Aßmus // A buffer of this size is guaranteed to be large enough to hold any 771d4d27facSStephan Aßmus // message, which your service thread can read from read_port() and 772d4d27facSStephan Aßmus // passes on to HandleMessage(). 77352a38012Sejakowatz const size_t B_MEDIA_MESSAGE_SIZE = 16384; 77452a38012Sejakowatz 775d4d27facSStephan Aßmus 776f6e4cbb9SAxel Dörfler extern const char* B_MEDIA_SERVER_SIGNATURE; 77752a38012Sejakowatz 778d4d27facSStephan Aßmus class media_node; 77952a38012Sejakowatz struct media_input; 78052a38012Sejakowatz struct media_output; 78152a38012Sejakowatz struct live_node_info; 78252a38012Sejakowatz struct dormant_node_info; 78352a38012Sejakowatz struct buffer_clone_info; 78452a38012Sejakowatz 78552a38012Sejakowatz 786d4d27facSStephan Aßmus // Functions which control the shutdown and launching process of the 787d4d27facSStephan Aßmus // media_server and it's friends. You can provide a call back hook which 788d4d27facSStephan Aßmus // will be called during various steps of the process. This callback should 789d4d27facSStephan Aßmus // currently always return TRUE. A 'stage' value of 100 means the process is 790*8acd164fSDario Casalinuovo // completely finished. Differently from BeOS the functions automatically 791*8acd164fSDario Casalinuovo // send notifications to the Deskbar if not differently specified. 792*8acd164fSDario Casalinuovo // It's also provided a new version of launch_media_server allowing 793*8acd164fSDario Casalinuovo // to specify a custom callback for notifications. 794*8acd164fSDario Casalinuovo 795*8acd164fSDario Casalinuovo // Deprecated 796*8acd164fSDario Casalinuovo status_t launch_media_server(uint32 flags); 797*8acd164fSDario Casalinuovo 798*8acd164fSDario Casalinuovo status_t launch_media_server(bigtime_t timeout = B_INFINITE_TIMEOUT, 799*8acd164fSDario Casalinuovo bool (*progress)(int stage, const char* message, void* cookie) = NULL, 800*8acd164fSDario Casalinuovo void* cookie = NULL, uint32 flags = 0); 801*8acd164fSDario Casalinuovo 802d4d27facSStephan Aßmus status_t shutdown_media_server(bigtime_t timeout = B_INFINITE_TIMEOUT, 803d4d27facSStephan Aßmus bool (*progress)(int stage, const char* message, void* cookie) = NULL, 804d4d27facSStephan Aßmus void* cookie = NULL); 80552a38012Sejakowatz 806d4d27facSStephan Aßmus 80752a38012Sejakowatz // Given an image_id, prepare that image_id for realtime media 808d4d27facSStephan Aßmus // If the kind of media indicated by 'flags' is not enabled for real-time, 80952a38012Sejakowatz // B_MEDIA_REALTIME_DISABLED is returned. 81052a38012Sejakowatz // If there are not enough system resources to enable real-time performance, 81152a38012Sejakowatz // B_MEDIA_REALTIME_UNAVAILABLE is returned. 81252a38012Sejakowatz status_t media_realtime_init_image(image_id image, uint32 flags); 81352a38012Sejakowatz 814d4d27facSStephan Aßmus 81552a38012Sejakowatz // Given a thread ID, and an optional indication of what the thread is 81652a38012Sejakowatz // doing in "flags", prepare the thread for real-time media performance. 81752a38012Sejakowatz // Currently, this means locking the thread stack, up to size_used bytes, 81852a38012Sejakowatz // or all of it if 0 is passed. Typically, you will not be using all 81952a38012Sejakowatz // 256 kB of the stack, so you should pass some smaller value you determine 82052a38012Sejakowatz // from profiling the thread; typically in the 32-64kB range. 82152a38012Sejakowatz // Return values are the same as for media_prepare_realtime_image(). 822d4d27facSStephan Aßmus status_t media_realtime_init_thread(thread_id thread, size_t stack_used, 823d4d27facSStephan Aßmus uint32 flags); 824d4d27facSStephan Aßmus 82552a38012Sejakowatz 82652a38012Sejakowatz // A teeny bit of legacy preserved for BSoundFile from R3. 82752a38012Sejakowatz // These came from the old MediaDefs.h; don't use them 82852a38012Sejakowatz // unless you get them from BSoundFile. 82952a38012Sejakowatz 83052a38012Sejakowatz 831d4d27facSStephan Aßmus // values for byte_ordering 832d4d27facSStephan Aßmus enum { 833d4d27facSStephan Aßmus B_BIG_ENDIAN, 834d4d27facSStephan Aßmus B_LITTLE_ENDIAN 835d4d27facSStephan Aßmus }; 836d4d27facSStephan Aßmus 837d4d27facSStephan Aßmus 838d4d27facSStephan Aßmus // values for sample_format 83952a38012Sejakowatz enum { 84052a38012Sejakowatz B_UNDEFINED_SAMPLES, 84152a38012Sejakowatz B_LINEAR_SAMPLES, 84252a38012Sejakowatz B_FLOAT_SAMPLES, 84352a38012Sejakowatz B_MULAW_SAMPLES 84452a38012Sejakowatz }; 84552a38012Sejakowatz 84652a38012Sejakowatz 847d4d27facSStephan Aßmus // #pragma mark - encoders and file writers 848d4d27facSStephan Aßmus 84952a38012Sejakowatz 85052a38012Sejakowatz struct media_encode_info { 851d4d27facSStephan Aßmus uint32 flags; // B_MEDIA_KEY_FRAME, set before every 852d4d27facSStephan Aßmus // use 853d4d27facSStephan Aßmus 854d4d27facSStephan Aßmus int32 used_data_size; // data size used by other tracks 855d4d27facSStephan Aßmus // add output size used by this encoder 856d4d27facSStephan Aßmus 857d4d27facSStephan Aßmus bigtime_t start_time; // us from start of file 858d4d27facSStephan Aßmus bigtime_t time_to_encode; // 0 - hurry up, B_INFINITE_TIMEOUT 859d4d27facSStephan Aßmus // - don't care 86052a38012Sejakowatz int32 _pad[22]; 861d4d27facSStephan Aßmus 862d4d27facSStephan Aßmus void* file_format_data; // file format specific info 86352a38012Sejakowatz size_t file_format_data_size; 864d4d27facSStephan Aßmus 865d4d27facSStephan Aßmus void* codec_data; // codec specific info 86652a38012Sejakowatz size_t codec_data_size; 86752a38012Sejakowatz 86852a38012Sejakowatz media_encode_info(); 86952a38012Sejakowatz }; 87052a38012Sejakowatz 871d4d27facSStephan Aßmus 87252a38012Sejakowatz struct encode_parameters { 87352a38012Sejakowatz float quality; // 0.0-1.0 , 1.0 is high quality 874d4d27facSStephan Aßmus 87552a38012Sejakowatz int32 avg_field_size; // in bytes 87652a38012Sejakowatz int32 max_field_size; // in bytes 877d4d27facSStephan Aßmus 87852a38012Sejakowatz int32 _pad[27]; 879d4d27facSStephan Aßmus 88052a38012Sejakowatz void* user_data; // codec specific info 88152a38012Sejakowatz size_t user_data_size; 88252a38012Sejakowatz }; 88352a38012Sejakowatz 884d4d27facSStephan Aßmus 88552a38012Sejakowatz struct media_decode_info { 886d4d27facSStephan Aßmus bigtime_t time_to_decode; // 0 - hurry up, B_INFINITE_TIMEOUT 887d4d27facSStephan Aßmus // - don't care 888d4d27facSStephan Aßmus 88952a38012Sejakowatz int32 _pad[26]; 890d4d27facSStephan Aßmus 891d4d27facSStephan Aßmus void* file_format_data; // file format specific info 89252a38012Sejakowatz size_t file_format_data_size; 893d4d27facSStephan Aßmus 894d4d27facSStephan Aßmus void* codec_data; // codec specific info 89552a38012Sejakowatz size_t codec_data_size; 89652a38012Sejakowatz 89752a38012Sejakowatz media_decode_info(); 89852a38012Sejakowatz }; 89952a38012Sejakowatz 90052a38012Sejakowatz 901d4d27facSStephan Aßmus // #pragma mark - inline implementations 902d4d27facSStephan Aßmus 903d4d27facSStephan Aßmus 904d4d27facSStephan Aßmus inline bool 905d4d27facSStephan Aßmus media_format::IsVideo() const 906d4d27facSStephan Aßmus { 907d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO || type == B_MEDIA_RAW_VIDEO; 908d4d27facSStephan Aßmus } 909d4d27facSStephan Aßmus 910d4d27facSStephan Aßmus 911d4d27facSStephan Aßmus inline uint32 912d4d27facSStephan Aßmus media_format::Width() const 913d4d27facSStephan Aßmus { 914d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 915d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_width 916d4d27facSStephan Aßmus : u.raw_video.display.line_width; 917d4d27facSStephan Aßmus } 918d4d27facSStephan Aßmus 919d4d27facSStephan Aßmus 920d4d27facSStephan Aßmus inline uint32 921d4d27facSStephan Aßmus media_format::Height() const 922d4d27facSStephan Aßmus { 923d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 924d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_count 925d4d27facSStephan Aßmus : u.raw_video.display.line_count; 926d4d27facSStephan Aßmus } 927d4d27facSStephan Aßmus 928d4d27facSStephan Aßmus 929d4d27facSStephan Aßmus inline color_space 930d4d27facSStephan Aßmus media_format::ColorSpace() const 931d4d27facSStephan Aßmus { 932d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 933d4d27facSStephan Aßmus ? u.encoded_video.output.display.format 934d4d27facSStephan Aßmus : u.raw_video.display.format; 935d4d27facSStephan Aßmus } 936d4d27facSStephan Aßmus 937d4d27facSStephan Aßmus 938d4d27facSStephan Aßmus inline uint32& 939d4d27facSStephan Aßmus media_format::Width() 940d4d27facSStephan Aßmus { 941d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 942d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_width 943d4d27facSStephan Aßmus : u.raw_video.display.line_width; 944d4d27facSStephan Aßmus } 945d4d27facSStephan Aßmus 946d4d27facSStephan Aßmus 947d4d27facSStephan Aßmus inline uint32& 948d4d27facSStephan Aßmus media_format::Height() 949d4d27facSStephan Aßmus { 950d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 951d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_count 952d4d27facSStephan Aßmus : u.raw_video.display.line_count; 953d4d27facSStephan Aßmus } 954d4d27facSStephan Aßmus 955d4d27facSStephan Aßmus 956d4d27facSStephan Aßmus inline color_space& 957d4d27facSStephan Aßmus media_format::ColorSpace() 958d4d27facSStephan Aßmus { 959d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 960d4d27facSStephan Aßmus ? u.encoded_video.output.display.format 961d4d27facSStephan Aßmus : u.raw_video.display.format; 962d4d27facSStephan Aßmus } 963d4d27facSStephan Aßmus 964d4d27facSStephan Aßmus 965d4d27facSStephan Aßmus inline bool 966d4d27facSStephan Aßmus media_format::IsAudio() const 967d4d27facSStephan Aßmus { 968d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO || type == B_MEDIA_RAW_AUDIO; 969d4d27facSStephan Aßmus } 970d4d27facSStephan Aßmus 971d4d27facSStephan Aßmus 972d4d27facSStephan Aßmus inline uint32 973d4d27facSStephan Aßmus media_format::AudioFormat() const 974d4d27facSStephan Aßmus { 975d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO 976d4d27facSStephan Aßmus ? u.encoded_audio.output.format : u.raw_audio.format; 977d4d27facSStephan Aßmus } 978d4d27facSStephan Aßmus 979d4d27facSStephan Aßmus 980d4d27facSStephan Aßmus inline uint32& 981d4d27facSStephan Aßmus media_format::AudioFormat() 982d4d27facSStephan Aßmus { 983d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO 984d4d27facSStephan Aßmus ? u.encoded_audio.output.format : u.raw_audio.format; 985d4d27facSStephan Aßmus } 986d4d27facSStephan Aßmus 987d4d27facSStephan Aßmus 988d4d27facSStephan Aßmus inline uint32 989d4d27facSStephan Aßmus media_format::AudioFrameSize() const 990d4d27facSStephan Aßmus { 991d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO 992d4d27facSStephan Aßmus ? (u.encoded_audio.output.format 993d4d27facSStephan Aßmus & media_raw_audio_format::B_AUDIO_SIZE_MASK) 994d4d27facSStephan Aßmus * u.encoded_audio.output.channel_count 995d4d27facSStephan Aßmus : (u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK) 996d4d27facSStephan Aßmus * u.raw_audio.channel_count; 997d4d27facSStephan Aßmus } 998d4d27facSStephan Aßmus 999d4d27facSStephan Aßmus 1000d4d27facSStephan Aßmus inline uint32 1001d4d27facSStephan Aßmus media_format::Encoding() const 1002d4d27facSStephan Aßmus { 1003d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 1004d4d27facSStephan Aßmus ? u.encoded_video.encoding : type == B_MEDIA_ENCODED_AUDIO 1005d4d27facSStephan Aßmus ? u.encoded_audio.encoding : type == B_MEDIA_MULTISTREAM 1006d4d27facSStephan Aßmus ? u.multistream.format : 0UL; 1007d4d27facSStephan Aßmus } 1008d4d27facSStephan Aßmus 1009d4d27facSStephan Aßmus 1010d4d27facSStephan Aßmus #endif /* end of __cplusplus section */ 1011d4d27facSStephan Aßmus 101252a38012Sejakowatz 101352a38012Sejakowatz #endif /* MEDIA_DEFS_H */ 1014