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" */ 50d4d27facSStephan Aßmus B_MEDIA_FLAVORS_CHANGED /* "be:addon_id", "be:new_count", */ 51d4d27facSStephan Aßmus /* "be:gone_count" */ 5252a38012Sejakowatz }; 5352a38012Sejakowatz 54d4d27facSStephan Aßmus 5552a38012Sejakowatz enum media_type { 5652a38012Sejakowatz B_MEDIA_NO_TYPE = -1, 5752a38012Sejakowatz B_MEDIA_UNKNOWN_TYPE = 0, 58d4d27facSStephan Aßmus B_MEDIA_RAW_AUDIO = 1, /* uncompressed raw_audio */ 59d4d27facSStephan Aßmus B_MEDIA_RAW_VIDEO, /* uncompressed raw_video */ 6052a38012Sejakowatz B_MEDIA_VBL, /* raw data from VBL area, 1600/line */ 6152a38012Sejakowatz B_MEDIA_TIMECODE, /* data format TBD */ 6252a38012Sejakowatz B_MEDIA_MIDI, 6352a38012Sejakowatz B_MEDIA_TEXT, /* typically closed captioning */ 6452a38012Sejakowatz B_MEDIA_HTML, 6552a38012Sejakowatz B_MEDIA_MULTISTREAM, /* AVI, etc */ 6652a38012Sejakowatz B_MEDIA_PARAMETERS, /* BControllable change data */ 67d4d27facSStephan Aßmus B_MEDIA_ENCODED_AUDIO, /* MP3, AC-3, ... */ 68d4d27facSStephan Aßmus B_MEDIA_ENCODED_VIDEO, /* H.264, Theora, ... */ 69d4d27facSStephan Aßmus B_MEDIA_PRIVATE = 90000, 70d4d27facSStephan Aßmus /* This are reserved. */ 71d4d27facSStephan Aßmus B_MEDIA_FIRST_USER_TYPE = 100000 72d4d27facSStephan Aßmus /* Use something bigger than this for */ 73d4d27facSStephan Aßmus /* experimentation with your own media */ 74d4d27facSStephan Aßmus /* formats. */ 7552a38012Sejakowatz }; 7652a38012Sejakowatz 77d4d27facSStephan Aßmus 7852a38012Sejakowatz enum node_kind { 7952a38012Sejakowatz B_BUFFER_PRODUCER = 0x1, 8052a38012Sejakowatz B_BUFFER_CONSUMER = 0x2, 8152a38012Sejakowatz B_TIME_SOURCE = 0x4, 8252a38012Sejakowatz B_CONTROLLABLE = 0x8, 8352a38012Sejakowatz B_FILE_INTERFACE = 0x10, 8452a38012Sejakowatz B_ENTITY_INTERFACE = 0x20, 85d4d27facSStephan Aßmus 86d4d27facSStephan Aßmus /* Set these flags for nodes that are suitable as default system nodes. */ 8752a38012Sejakowatz B_PHYSICAL_INPUT = 0x10000, 8852a38012Sejakowatz B_PHYSICAL_OUTPUT = 0x20000, 8952a38012Sejakowatz B_SYSTEM_MIXER = 0x40000 9052a38012Sejakowatz }; 9152a38012Sejakowatz 92d4d27facSStephan Aßmus 93d4d27facSStephan Aßmus enum video_orientation { 94d4d27facSStephan Aßmus /* Which pixel is first and how do we scan each "line"? */ 95d4d27facSStephan Aßmus B_VIDEO_TOP_LEFT_RIGHT = 1, /* This is the typical progressive scan */ 96d4d27facSStephan Aßmus /* format */ 9752a38012Sejakowatz B_VIDEO_BOTTOM_LEFT_RIGHT /* This is how BMP and TGA might scan */ 9852a38012Sejakowatz }; 9952a38012Sejakowatz 10052a38012Sejakowatz 101d4d27facSStephan Aßmus /* data */ 102d4d27facSStephan Aßmus enum media_flags 10352a38012Sejakowatz { 104d4d27facSStephan Aßmus B_MEDIA_FLAGS_VERSION = 1, 105d4d27facSStephan Aßmus /* uint32, greater for newer versions */ 106d4d27facSStephan Aßmus B_MEDIA_FLAGS_PRIVATE = 0x40000000 107d4d27facSStephan Aßmus /* private to Haiku */ 10852a38012Sejakowatz }; 10952a38012Sejakowatz 11052a38012Sejakowatz 111d4d27facSStephan Aßmus /* for producer status */ 112d4d27facSStephan Aßmus enum media_producer_status { 11352a38012Sejakowatz B_DATA_NOT_AVAILABLE = 1, 11452a38012Sejakowatz B_DATA_AVAILABLE = 2, 11552a38012Sejakowatz B_PRODUCER_STOPPED = 3 11652a38012Sejakowatz }; 11752a38012Sejakowatz 118d4d27facSStephan Aßmus 119d4d27facSStephan Aßmus /* realtime flags */ 12052a38012Sejakowatz enum media_realtime_flags { 12152a38012Sejakowatz B_MEDIA_REALTIME_ALLOCATOR = 0x1, 12252a38012Sejakowatz B_MEDIA_REALTIME_AUDIO = 0x2, 12352a38012Sejakowatz B_MEDIA_REALTIME_VIDEO = 0x4, 12452a38012Sejakowatz B_MEDIA_REALTIME_ANYKIND = 0xffff 12552a38012Sejakowatz }; 12652a38012Sejakowatz 12752a38012Sejakowatz enum media_frame_flags { 12852a38012Sejakowatz B_MEDIA_KEY_FRAME = 0x1 12952a38012Sejakowatz }; 13052a38012Sejakowatz 13152a38012Sejakowatz #define B_MEDIA_ANY_QUALITY 0.0f 13252a38012Sejakowatz #define B_MEDIA_LOW_QUALITY 0.1f 13352a38012Sejakowatz #define B_MEDIA_MEDIUM_QUALITY 0.5f 13452a38012Sejakowatz #define B_MEDIA_HIGH_QUALITY 1.0f 13552a38012Sejakowatz 13652a38012Sejakowatz 137d4d27facSStephan Aßmus #ifndef _MULTI_AUDIO_H /* #define in protocol header */ 13852a38012Sejakowatz enum media_multi_channels { 139d4d27facSStephan Aßmus B_CHANNEL_LEFT = 0x00001, 140d4d27facSStephan Aßmus B_CHANNEL_RIGHT = 0x00002, 141d4d27facSStephan Aßmus B_CHANNEL_CENTER = 0x00004, /* 5.1+ or fake surround */ 142d4d27facSStephan Aßmus B_CHANNEL_SUB = 0x00008, /* 5.1+ */ 143d4d27facSStephan Aßmus B_CHANNEL_REARLEFT = 0x00010, /* quad surround or 5.1+ */ 144d4d27facSStephan Aßmus B_CHANNEL_REARRIGHT = 0x00020, /* quad surround or 5.1+ */ 145d4d27facSStephan Aßmus B_CHANNEL_FRONT_LEFT_CENTER = 0x00040, 146d4d27facSStephan Aßmus B_CHANNEL_FRONT_RIGHT_CENTER = 0x00080, 147d4d27facSStephan Aßmus B_CHANNEL_BACK_CENTER = 0x00100, /* 6.1 or fake surround */ 148d4d27facSStephan Aßmus B_CHANNEL_SIDE_LEFT = 0x00200, 149d4d27facSStephan Aßmus B_CHANNEL_SIDE_RIGHT = 0x00400, 150d4d27facSStephan Aßmus B_CHANNEL_TOP_CENTER = 0x00800, 151d4d27facSStephan Aßmus B_CHANNEL_TOP_FRONT_LEFT = 0x01000, 152d4d27facSStephan Aßmus B_CHANNEL_TOP_FRONT_CENTER = 0x02000, 153d4d27facSStephan Aßmus B_CHANNEL_TOP_FRONT_RIGHT = 0x04000, 154d4d27facSStephan Aßmus B_CHANNEL_TOP_BACK_LEFT = 0x08000, 15552a38012Sejakowatz B_CHANNEL_TOP_BACK_CENTER = 0x10000, 15652a38012Sejakowatz B_CHANNEL_TOP_BACK_RIGHT = 0x20000 15752a38012Sejakowatz }; 158d4d27facSStephan Aßmus 159d4d27facSStephan Aßmus 16052a38012Sejakowatz enum media_multi_matrix { 16152a38012Sejakowatz B_MATRIX_PROLOGIC_LR = 0x1, 16252a38012Sejakowatz B_MATRIX_AMBISONIC_WXYZ = 0x4 16352a38012Sejakowatz }; 164d4d27facSStephan Aßmus #endif // !_MULTI_AUDIO_H 16552a38012Sejakowatz 16652a38012Sejakowatz 16752a38012Sejakowatz typedef int32 media_node_id; 16852a38012Sejakowatz typedef int32 media_buffer_id; 16952a38012Sejakowatz typedef int32 media_addon_id; 17052a38012Sejakowatz 17152a38012Sejakowatz 17252a38012Sejakowatz #if defined(__cplusplus) 17352a38012Sejakowatz struct media_destination { 17452a38012Sejakowatz media_destination(); 175d4d27facSStephan Aßmus media_destination(port_id, int32); 176d4d27facSStephan Aßmus media_destination( 177d4d27facSStephan Aßmus const media_destination& other); 17852a38012Sejakowatz ~media_destination(); 179d4d27facSStephan Aßmus 180d4d27facSStephan Aßmus media_destination& operator=(const media_destination& other); 181d4d27facSStephan Aßmus 182d4d27facSStephan Aßmus port_id port; /* can be different from */ 183d4d27facSStephan Aßmus /* media_node.port */ 18452a38012Sejakowatz int32 id; 18552a38012Sejakowatz static media_destination null; 186d4d27facSStephan Aßmus 18752a38012Sejakowatz private: 18852a38012Sejakowatz uint32 _reserved_media_destination_[2]; 18952a38012Sejakowatz }; 19052a38012Sejakowatz 191d4d27facSStephan Aßmus 19252a38012Sejakowatz struct media_source { 19352a38012Sejakowatz media_source(); 194d4d27facSStephan Aßmus media_source(port_id, int32); 195d4d27facSStephan Aßmus media_source(const media_source& other); 19652a38012Sejakowatz ~media_source(); 197d4d27facSStephan Aßmus 198d4d27facSStephan Aßmus media_source& operator=(const media_source& other); 199d4d27facSStephan Aßmus port_id port; /* must be the same as */ 200d4d27facSStephan Aßmus /* media_node.port for owner */ 20152a38012Sejakowatz int32 id; 20252a38012Sejakowatz static media_source null; 203d4d27facSStephan Aßmus 20452a38012Sejakowatz private: 20552a38012Sejakowatz uint32 _reserved_media_source_[2]; 20652a38012Sejakowatz }; 20752a38012Sejakowatz 208d4d27facSStephan Aßmus 209f6e4cbb9SAxel Dörfler bool operator==(const media_destination& a, const media_destination& b); 210f6e4cbb9SAxel Dörfler bool operator!=(const media_destination& a, const media_destination& b); 211f6e4cbb9SAxel Dörfler bool operator<(const media_destination& a, const media_destination& b); 212f6e4cbb9SAxel Dörfler bool operator==(const media_source& a, const media_source& b); 213f6e4cbb9SAxel Dörfler bool operator!=(const media_source& a, const media_source& b); 214f6e4cbb9SAxel Dörfler bool operator<(const media_source& a, const media_source& b); 215f6e4cbb9SAxel Dörfler bool operator==(const media_node& a, const media_node& b); 216f6e4cbb9SAxel Dörfler bool operator!=(const media_node& a, const media_node& b); 217f6e4cbb9SAxel Dörfler bool operator<(const media_node& a, const media_node& b); 21852a38012Sejakowatz 21952a38012Sejakowatz 22052a38012Sejakowatz 22152a38012Sejakowatz /* Buffers are low-level constructs identified by an ID. */ 22252a38012Sejakowatz /* Buffers consist of the actual data area, plus a 64-byte */ 22352a38012Sejakowatz /* header area that is different for each type. */ 22452a38012Sejakowatz /* Buffers contain typed data. Type is not part of the */ 22552a38012Sejakowatz /* buffer header; it's negotiated out-of-bounds by nodes. */ 22652a38012Sejakowatz 22752a38012Sejakowatz enum { 22852a38012Sejakowatz B_MEDIA_BIG_ENDIAN = 1, 22952a38012Sejakowatz B_MEDIA_LITTLE_ENDIAN = 2, 23052a38012Sejakowatz #if B_HOST_IS_BENDIAN 23152a38012Sejakowatz B_MEDIA_HOST_ENDIAN = B_MEDIA_BIG_ENDIAN 23252a38012Sejakowatz #else 23352a38012Sejakowatz B_MEDIA_HOST_ENDIAN = B_MEDIA_LITTLE_ENDIAN 23452a38012Sejakowatz #endif 23552a38012Sejakowatz }; 23652a38012Sejakowatz 237d4d27facSStephan Aßmus 23852a38012Sejakowatz struct media_multi_audio_format; 23952a38012Sejakowatz 240d4d27facSStephan Aßmus 24152a38012Sejakowatz struct media_raw_audio_format { 242d4d27facSStephan Aßmus // possible values for "format" 243d4d27facSStephan Aßmus enum { 244d4d27facSStephan Aßmus B_AUDIO_FLOAT = 0x24, 245d4d27facSStephan Aßmus // 0 == mid, -1.0 == bottom, 1.0 == top 246d4d27facSStephan Aßmus // (the preferred format for non-game audio) 247d4d27facSStephan Aßmus 248d4d27facSStephan Aßmus B_AUDIO_DOUBLE = 0x28, 249d4d27facSStephan Aßmus // 0 == mid, -1.0 == bottom, 1.0 == top 250d4d27facSStephan Aßmus // (only useful for pro audio) 251d4d27facSStephan Aßmus 252d4d27facSStephan Aßmus B_AUDIO_INT = 0x4, 253d4d27facSStephan Aßmus // 0 == mid, 0x80000001 == bottom, 0x7fffffff == top 254d4d27facSStephan Aßmus // (all >16-bit formats, left-adjusted) 255d4d27facSStephan Aßmus 256d4d27facSStephan Aßmus B_AUDIO_SHORT = 0x2, 257d4d27facSStephan Aßmus // 0 == mid, -32767 == bottom, +32767 == top 258d4d27facSStephan Aßmus 259d4d27facSStephan Aßmus B_AUDIO_UCHAR = 0x11, 260d4d27facSStephan Aßmus // 128 == mid, 1 == bottom, 255 == top 261d4d27facSStephan Aßmus // (discouraged but supported format) 262d4d27facSStephan Aßmus 263d4d27facSStephan Aßmus B_AUDIO_CHAR = 0x1, 264d4d27facSStephan Aßmus // 0 == mid, -127 == bottom, +127 == top 265d4d27facSStephan Aßmus // (not officially supported format) 266d4d27facSStephan Aßmus 26752a38012Sejakowatz B_AUDIO_SIZE_MASK = 0xf 268d4d27facSStephan Aßmus // This mask can be used to obtain the sample size 269d4d27facSStephan Aßmus // for raw formats: (format & 0xf) == sizeof(sample) 270d4d27facSStephan Aßmus }; 27152a38012Sejakowatz 27252a38012Sejakowatz float frame_rate; 273d4d27facSStephan Aßmus uint32 channel_count; 274d4d27facSStephan Aßmus uint32 format; // see possible values above 275d4d27facSStephan Aßmus uint32 byte_order; // B_MEDIA_LITTLE_ENDIAN or B_MEDIA_BIG_ENDIAN 27652a38012Sejakowatz size_t buffer_size; // size of each buffer 27752a38012Sejakowatz 27852a38012Sejakowatz static media_multi_audio_format wildcard; 27952a38012Sejakowatz }; 28052a38012Sejakowatz 281d4d27facSStephan Aßmus 28252a38012Sejakowatz struct media_audio_header { 283*22ea661bSColin Günther // TODO: Refine this structure and put actual data at the end 284*22ea661bSColin Günther int32 _reserved_[14]; 285*22ea661bSColin Günther float frame_rate; 286*22ea661bSColin Günther uint32 channel_count; 287*22ea661bSColin Günther 28852a38012Sejakowatz }; 28952a38012Sejakowatz 290d4d27facSStephan Aßmus 29152a38012Sejakowatz struct media_multi_audio_info { 29252a38012Sejakowatz uint32 channel_mask; // bitmask 29352a38012Sejakowatz int16 valid_bits; // if < 32, for B_AUDIO_INT 294d4d27facSStephan Aßmus uint16 matrix_mask; // each of these bits may mean more than one 295d4d27facSStephan Aßmus // channel 29652a38012Sejakowatz 29752a38012Sejakowatz uint32 _reserved_b[3]; 29852a38012Sejakowatz }; 29952a38012Sejakowatz 300d4d27facSStephan Aßmus 301d4d27facSStephan Aßmus struct media_multi_audio_format : public media_raw_audio_format, 302d4d27facSStephan Aßmus public media_multi_audio_info { 303d4d27facSStephan Aßmus 30452a38012Sejakowatz static media_multi_audio_format wildcard; 30552a38012Sejakowatz }; 30652a38012Sejakowatz 30752a38012Sejakowatz 30852a38012Sejakowatz struct media_encoded_audio_format { 30952a38012Sejakowatz enum audio_encoding { 31052a38012Sejakowatz B_ANY 31152a38012Sejakowatz }; 312d4d27facSStephan Aßmus 31352a38012Sejakowatz media_raw_audio_format output; 31452a38012Sejakowatz audio_encoding encoding; 31552a38012Sejakowatz 316d4d27facSStephan Aßmus float bit_rate; 31752a38012Sejakowatz size_t frame_size; 31852a38012Sejakowatz 31952a38012Sejakowatz media_multi_audio_info multi_info; 32052a38012Sejakowatz 32152a38012Sejakowatz uint32 _reserved_[3]; 32252a38012Sejakowatz 32352a38012Sejakowatz static media_encoded_audio_format wildcard; 32452a38012Sejakowatz }; 32552a38012Sejakowatz 326d4d27facSStephan Aßmus 32752a38012Sejakowatz struct media_encoded_audio_header { 328d4d27facSStephan Aßmus // NOTE: More data fields need to go to the end 329d4d27facSStephan Aßmus int32 _reserved_0[14]; 330d4d27facSStephan Aßmus 331d4d27facSStephan Aßmus uint32 buffer_flags; 332d4d27facSStephan Aßmus // B_MEDIA_KEY_FRAME for key frame chunks 333d4d27facSStephan Aßmus uchar unused_mask; 334d4d27facSStephan Aßmus // mask of unused bits for the last byte of data 33552a38012Sejakowatz uchar _reserved_2[3]; 33652a38012Sejakowatz 33752a38012Sejakowatz }; 33852a38012Sejakowatz 33952a38012Sejakowatz enum media_display_flags { 340d4d27facSStephan Aßmus B_F1_DOMINANT = 0x1, // The first buffer sent (temporally) will 341d4d27facSStephan Aßmus // be an F1 field. 342d4d27facSStephan Aßmus B_F2_DOMINANT = 0x2, // The first buffer sent (temporally) will 343d4d27facSStephan Aßmus // be an F2 field. 344d4d27facSStephan Aßmus B_TOP_SCANLINE_F1 = 0x4, // The topmost scanline of the output buffer 345d4d27facSStephan Aßmus // belongs to F1. 346d4d27facSStephan Aßmus B_TOP_SCANLINE_F2 = 0x8 // The topmost scanline of the output buffer 347d4d27facSStephan Aßmus // belongs to F2. 34852a38012Sejakowatz }; 349d4d27facSStephan Aßmus 350d4d27facSStephan Aßmus 35152a38012Sejakowatz struct media_video_display_info { 35252a38012Sejakowatz color_space format; 35352a38012Sejakowatz uint32 line_width; 354d4d27facSStephan Aßmus uint32 line_count; // sum of all interlace fields lines 355d4d27facSStephan Aßmus uint32 bytes_per_row; // bytes_per_row is in format, not header, 356d4d27facSStephan Aßmus // because it's part of SetBuffers 357d4d27facSStephan Aßmus uint32 pixel_offset; // (in pixels) Offset from the start of the 358d4d27facSStephan Aßmus // buffer (see below). 359d4d27facSStephan Aßmus uint32 line_offset; // (in lines) Offset to the start of the field. 360d4d27facSStephan Aßmus // Think "buffer == framebuffer" when the 361d4d27facSStephan Aßmus // window displaying the active field moves 362d4d27facSStephan Aßmus // on screen. 36352a38012Sejakowatz uint32 flags; 36452a38012Sejakowatz uint32 _reserved_[3]; 365d4d27facSStephan Aßmus 36652a38012Sejakowatz static media_video_display_info wildcard; 36752a38012Sejakowatz }; 36852a38012Sejakowatz 369d4d27facSStephan Aßmus 37052a38012Sejakowatz struct media_raw_video_format { 37152a38012Sejakowatz float field_rate; 372d4d27facSStephan Aßmus uint32 interlace; // Number of fields per frame: 1 means 373d4d27facSStephan Aßmus // progressive (non-interlaced) frames. 374d4d27facSStephan Aßmus uint32 first_active; // Index of first active line. 0, typically 375d4d27facSStephan Aßmus // (wildcard, or "don't care") 376d4d27facSStephan Aßmus uint32 last_active; // Index of last active line (typically 377d4d27facSStephan Aßmus // line_count - 1, if first_active is 0. 378d4d27facSStephan Aßmus uint32 orientation; // B_VIDEO_TOP_LEFT_RIGHT is preferred. 379d4d27facSStephan Aßmus 380d4d27facSStephan Aßmus // This is the display aspect ratio (DAR). Usually, you would reduce the 381d4d27facSStephan Aßmus // width and height of the intended output frame size as far as possible 382d4d27facSStephan Aßmus // without changing their ratio. Note that you should not put 1 in both 383d4d27facSStephan Aßmus // fields to mean "undistorted pixels", unless you really intend square 384d4d27facSStephan Aßmus // video output! 38552a38012Sejakowatz uint16 pixel_width_aspect; // 1:1 has 1 here, 4:3 has 4 here 386d4d27facSStephan Aßmus // 16:9 has 16 here! 38752a38012Sejakowatz uint16 pixel_height_aspect; // 1:1 has 1 here, 4:3 has 3 here 388d4d27facSStephan Aßmus // 16:9 has 9 here! 38952a38012Sejakowatz 39052a38012Sejakowatz media_video_display_info display; 39152a38012Sejakowatz 39252a38012Sejakowatz static media_raw_video_format wildcard; 39352a38012Sejakowatz }; 39452a38012Sejakowatz 395d4d27facSStephan Aßmus 39652a38012Sejakowatz struct media_video_header { 397*22ea661bSColin Günther uint32 _reserved_[8]; // NOTE: Keep reserved data at the top! 398d4d27facSStephan Aßmus 399*22ea661bSColin Günther uint32 display_line_width; // Number of pixels per display_line 400*22ea661bSColin Günther uint32 display_line_count; // Sum of all interlace fields lines 401*22ea661bSColin Günther uint32 bytes_per_row; // Number of bytes in a display_line 402*22ea661bSColin Günther // (padding bytes excluded) 403*22ea661bSColin Günther uint16 pixel_width_aspect; // 1:1 has 1 here, 4:3 has 4 here 404*22ea661bSColin Günther // 16:9 has 16 here! 405*22ea661bSColin Günther uint16 pixel_height_aspect;// 1:1 has 1 here, 4:3 has 3 here 406*22ea661bSColin Günther // 16:9 has 9 here! 40752a38012Sejakowatz float field_gamma; 408d4d27facSStephan Aßmus uint32 field_sequence; // Sequence number since start of capture 409d4d27facSStephan Aßmus // May roll over if machine is on for a 410d4d27facSStephan Aßmus // LONG time. 411d4d27facSStephan Aßmus uint16 field_number; // 0 .. {interlace-1}; F1 == 0 ("odd"), 412d4d27facSStephan Aßmus // F2 == 1 ("even") 41352a38012Sejakowatz uint16 pulldown_number; // 0..2 for pulldown duplicated sequence 414d4d27facSStephan Aßmus uint16 first_active_line; // The NTSC/PAL line number (1-based) of 415d4d27facSStephan Aßmus // the first line in this field 416d4d27facSStephan Aßmus uint16 line_count; // The number of active lines in buffer. 41752a38012Sejakowatz }; 41852a38012Sejakowatz 419d4d27facSStephan Aßmus 42052a38012Sejakowatz struct media_encoded_video_format { 42152a38012Sejakowatz enum video_encoding { 42252a38012Sejakowatz B_ANY 42352a38012Sejakowatz }; 424d4d27facSStephan Aßmus 42552a38012Sejakowatz media_raw_video_format output; // set unknowns to wildcard 426d4d27facSStephan Aßmus 42752a38012Sejakowatz float avg_bit_rate; 42852a38012Sejakowatz float max_bit_rate; 429d4d27facSStephan Aßmus 43052a38012Sejakowatz video_encoding encoding; 43152a38012Sejakowatz size_t frame_size; 43252a38012Sejakowatz 433d4d27facSStephan Aßmus int16 forward_history; // maximum forward memory 434d4d27facSStephan Aßmus // required by codec 435d4d27facSStephan Aßmus 436d4d27facSStephan Aßmus int16 backward_history; // maximum backward memory 437d4d27facSStephan Aßmus // required by codec 438d4d27facSStephan Aßmus 439d4d27facSStephan Aßmus uint32 _reserved_[3]; // This structure cannot grow 440d4d27facSStephan Aßmus // more than this (embedded) 441d4d27facSStephan Aßmus // in media_format union 44252a38012Sejakowatz 44352a38012Sejakowatz static media_encoded_video_format wildcard; 44452a38012Sejakowatz }; 44552a38012Sejakowatz 446d4d27facSStephan Aßmus 44752a38012Sejakowatz struct media_encoded_video_header { 448d4d27facSStephan Aßmus // NOTE: More data fields need to go at the end of this structure. 449d4d27facSStephan Aßmus int32 _reserved_1[9]; 45052a38012Sejakowatz 45152a38012Sejakowatz uint32 field_flags; // B_MEDIA_KEY_FRAME 45252a38012Sejakowatz 453d4d27facSStephan Aßmus int16 forward_history; // forward memory required by this buffer 454d4d27facSStephan Aßmus // (0 for key frames) 455d4d27facSStephan Aßmus 456d4d27facSStephan Aßmus int16 backward_history; // backward memory required by this buffer 457d4d27facSStephan Aßmus // (0 for key frames) 458d4d27facSStephan Aßmus 459d4d27facSStephan Aßmus uchar unused_mask; // mask of unused bits for the last byte 460d4d27facSStephan Aßmus // of data 46152a38012Sejakowatz uchar _reserved_2[3]; 46252a38012Sejakowatz float field_gamma; 46352a38012Sejakowatz uint32 field_sequence; // sequence since start of capture 46452a38012Sejakowatz uint16 field_number; // 0 .. {interlace-1}; F1 == 0, F2 == 1 46552a38012Sejakowatz uint16 pulldown_number; // 0..2 for pulldown duplicated sequence 466d4d27facSStephan Aßmus uint16 first_active_line; // 0 or 1, typically, but could be 10 or 467d4d27facSStephan Aßmus // 11 for full-NTSC formats 46852a38012Sejakowatz uint16 line_count; // number of actual lines in buffer 46952a38012Sejakowatz }; 47052a38012Sejakowatz 47152a38012Sejakowatz struct media_multistream_format { 47252a38012Sejakowatz enum { 47352a38012Sejakowatz B_ANY = 0, 47452a38012Sejakowatz B_VID = 1, // raw raw_video/raw_audio buffers 47552a38012Sejakowatz B_AVI, 47652a38012Sejakowatz B_MPEG1, 47752a38012Sejakowatz B_MPEG2, 47852a38012Sejakowatz B_QUICKTIME, 47952a38012Sejakowatz B_PRIVATE = 90000, 480d4d27facSStephan Aßmus B_FIRST_USER_TYPE = 100000 48152a38012Sejakowatz }; 48252a38012Sejakowatz float avg_bit_rate; // 8 * byte rate, on average 48352a38012Sejakowatz float max_bit_rate; // 8 * byte rate, tops 484d4d27facSStephan Aßmus uint32 avg_chunk_size; // == max_chunk_size for fixed-size 485d4d27facSStephan Aßmus // chunks 48652a38012Sejakowatz uint32 max_chunk_size; // max buffer size 48752a38012Sejakowatz enum { 48852a38012Sejakowatz B_HEADER_HAS_FLAGS = 0x1, // are flags important? 489d4d27facSStephan Aßmus B_CLEAN_BUFFERS = 0x2, // each buffer represents an integral 490d4d27facSStephan Aßmus // number of "frames" 49152a38012Sejakowatz B_HOMOGENOUS_BUFFERS = 0x4 // a buffer has only one format in it 49252a38012Sejakowatz }; 49352a38012Sejakowatz uint32 flags; 49452a38012Sejakowatz int32 format; 49552a38012Sejakowatz uint32 _reserved_[2]; 49652a38012Sejakowatz 49752a38012Sejakowatz struct vid_info { 49852a38012Sejakowatz float frame_rate; 49952a38012Sejakowatz uint16 width; 50052a38012Sejakowatz uint16 height; 50152a38012Sejakowatz color_space space; 50252a38012Sejakowatz 50352a38012Sejakowatz float sampling_rate; 50452a38012Sejakowatz uint32 sample_format; 50552a38012Sejakowatz uint16 byte_order; 50652a38012Sejakowatz uint16 channel_count; 50752a38012Sejakowatz }; 50852a38012Sejakowatz struct avi_info { 50952a38012Sejakowatz uint32 us_per_frame; 51052a38012Sejakowatz uint16 width; 51152a38012Sejakowatz uint16 height; 51252a38012Sejakowatz uint16 _reserved_; 51352a38012Sejakowatz uint16 type_count; 51452a38012Sejakowatz media_type types[5]; 51552a38012Sejakowatz }; 51652a38012Sejakowatz 51752a38012Sejakowatz union { 51852a38012Sejakowatz vid_info vid; 51952a38012Sejakowatz avi_info avi; 52052a38012Sejakowatz } u; 52152a38012Sejakowatz 52252a38012Sejakowatz static media_multistream_format wildcard; 52352a38012Sejakowatz }; 52452a38012Sejakowatz 525d4d27facSStephan Aßmus 52652a38012Sejakowatz struct media_multistream_header { 52752a38012Sejakowatz uint32 _reserved_[14]; 528d4d27facSStephan Aßmus uchar unused_mask; // mask of unused bits for the last byte 529d4d27facSStephan Aßmus // of data 53052a38012Sejakowatz uchar _reserved_2[3]; 53152a38012Sejakowatz enum { 53252a38012Sejakowatz B_MASTER_HEADER = 0x1, // for master stream header data in buffer 53352a38012Sejakowatz B_SUBSTREAM_HEADER = 0x2, // for sub-stream header data in buffer 53452a38012Sejakowatz B_COMPLETE_BUFFER = 0x4 // data is an integral number of "frames" 53552a38012Sejakowatz }; 53652a38012Sejakowatz uint32 flags; 53752a38012Sejakowatz }; 53852a38012Sejakowatz 539d4d27facSStephan Aßmus 54052a38012Sejakowatz extern const type_code B_CODEC_TYPE_INFO; 54152a38012Sejakowatz 542d4d27facSStephan Aßmus 54352a38012Sejakowatz enum media_format_flags { 54452a38012Sejakowatz B_MEDIA_RETAINED_DATA = 0x1, 54552a38012Sejakowatz B_MEDIA_MULTIPLE_BUFFERS = 0x2, 54652a38012Sejakowatz B_MEDIA_CONTIGUOUS_BUFFER = 0x4, 54752a38012Sejakowatz B_MEDIA_LINEAR_UPDATES = 0x8, 548d4d27facSStephan Aßmus B_MEDIA_MAUI_UNDEFINED_FLAGS = ~0xf // NOTE: Always deny these flags 549d4d27facSStephan Aßmus // in new code. 55052a38012Sejakowatz }; 55152a38012Sejakowatz 552d4d27facSStephan Aßmus // NOTE: A field of 0 typically means "anything" or "wildcard". 553d4d27facSStephan Aßmus // NOTE: This structure should not be bigger than 192 bytes! 554d4d27facSStephan Aßmus struct media_format { 55552a38012Sejakowatz media_type type; 55652a38012Sejakowatz type_code user_data_type; 55752a38012Sejakowatz uchar user_data[48]; 55852a38012Sejakowatz uint32 _reserved_[3]; 55952a38012Sejakowatz uint16 require_flags; // media_format_flags 56052a38012Sejakowatz uint16 deny_flags; // media_format_flags 56152a38012Sejakowatz 56252a38012Sejakowatz private: 563bacf4b5eSshatty void* meta_data; 56452a38012Sejakowatz int32 meta_data_size; 56552a38012Sejakowatz area_id meta_data_area; 5660a00d23fSMarcus Overhagen area_id __unused_was_use_area; 5670a00d23fSMarcus Overhagen team_id __unused_was_team; 5680a00d23fSMarcus Overhagen void* __unused_was_thisPtr; 56952a38012Sejakowatz 57052a38012Sejakowatz public: 57152a38012Sejakowatz union { 57252a38012Sejakowatz media_multi_audio_format raw_audio; 57352a38012Sejakowatz media_raw_video_format raw_video; 57452a38012Sejakowatz media_multistream_format multistream; 57552a38012Sejakowatz media_encoded_audio_format encoded_audio; 57652a38012Sejakowatz media_encoded_video_format encoded_video; 57752a38012Sejakowatz char _reserved_[96]; // pad to 96 bytes 57852a38012Sejakowatz } u; 57952a38012Sejakowatz 580d4d27facSStephan Aßmus bool IsVideo() const; 58152a38012Sejakowatz 582d4d27facSStephan Aßmus uint32 Width() const; 583d4d27facSStephan Aßmus uint32 Height() const; 584d4d27facSStephan Aßmus color_space ColorSpace() const; 58552a38012Sejakowatz 586d4d27facSStephan Aßmus uint32& Width(); 587d4d27facSStephan Aßmus uint32& Height(); 588d4d27facSStephan Aßmus color_space& ColorSpace(); 58952a38012Sejakowatz 590d4d27facSStephan Aßmus bool IsAudio() const; 591d4d27facSStephan Aßmus uint32 AudioFormat() const; 592d4d27facSStephan Aßmus uint32& AudioFormat(); 593d4d27facSStephan Aßmus uint32 AudioFrameSize() const; 594d4d27facSStephan Aßmus 595d4d27facSStephan Aßmus uint32 Encoding() const; 596d4d27facSStephan Aßmus 597d4d27facSStephan Aßmus bool Matches(const media_format* other) const; 598d4d27facSStephan Aßmus void SpecializeTo(const media_format* other); 59952a38012Sejakowatz 60052a38012Sejakowatz status_t SetMetaData(const void* data, size_t size); 60152a38012Sejakowatz const void* MetaData() const; 60252a38012Sejakowatz int32 MetaDataSize() const; 60352a38012Sejakowatz 60452a38012Sejakowatz media_format(); 60552a38012Sejakowatz media_format(const media_format& other); 60652a38012Sejakowatz ~media_format(); 607d4d27facSStephan Aßmus 608d4d27facSStephan Aßmus media_format& operator=(const media_format& other); 60952a38012Sejakowatz }; 61052a38012Sejakowatz 611d4d27facSStephan Aßmus 612d4d27facSStephan Aßmus bool operator==(const media_raw_audio_format& a, 613d4d27facSStephan Aßmus const media_raw_audio_format& b); 614d4d27facSStephan Aßmus 615d4d27facSStephan Aßmus bool operator==(const media_multi_audio_info& a, 616d4d27facSStephan Aßmus const media_multi_audio_info& b); 617d4d27facSStephan Aßmus 618d4d27facSStephan Aßmus bool operator==(const media_multi_audio_format& a, 619d4d27facSStephan Aßmus const media_multi_audio_format& b); 620d4d27facSStephan Aßmus 621d4d27facSStephan Aßmus bool operator==(const media_encoded_audio_format& a, 622d4d27facSStephan Aßmus const media_encoded_audio_format& b); 623d4d27facSStephan Aßmus 624d4d27facSStephan Aßmus bool operator==(const media_video_display_info& a, 625d4d27facSStephan Aßmus const media_video_display_info& b); 626d4d27facSStephan Aßmus 627d4d27facSStephan Aßmus bool operator==(const media_raw_video_format& a, 628d4d27facSStephan Aßmus const media_raw_video_format& b); 629d4d27facSStephan Aßmus 630d4d27facSStephan Aßmus bool operator==(const media_encoded_video_format& a, 631d4d27facSStephan Aßmus const media_encoded_video_format& b); 632d4d27facSStephan Aßmus 633d4d27facSStephan Aßmus bool operator==(const media_multistream_format::vid_info& a, 634d4d27facSStephan Aßmus const media_multistream_format::vid_info& b); 635d4d27facSStephan Aßmus 636d4d27facSStephan Aßmus bool operator==(const media_multistream_format::avi_info& a, 637d4d27facSStephan Aßmus const media_multistream_format::avi_info & b); 638d4d27facSStephan Aßmus 639d4d27facSStephan Aßmus bool operator==(const media_multistream_format& a, 640d4d27facSStephan Aßmus const media_multistream_format& b); 641d4d27facSStephan Aßmus 642f6e4cbb9SAxel Dörfler bool operator==(const media_format& a, const media_format& b); 64352a38012Sejakowatz 644d4d27facSStephan Aßmus 645d4d27facSStephan Aßmus bool format_is_compatible(const media_format & a, const media_format & b); 646d4d27facSStephan Aßmus // Returns true if a and b are compatible (accounting for wildcards) 647d4d27facSStephan Aßmus // (a is the format you want to feed to something accepting b 648d4d27facSStephan Aßmus 649f6e4cbb9SAxel Dörfler bool string_for_format(const media_format & f, char * buf, size_t size); 65052a38012Sejakowatz 651d4d27facSStephan Aßmus 65252a38012Sejakowatz struct media_seek_tag { 65352a38012Sejakowatz char data[16]; 65452a38012Sejakowatz }; 65552a38012Sejakowatz 656d4d27facSStephan Aßmus 65752a38012Sejakowatz struct media_header_time_code { 65852a38012Sejakowatz int8 type; // See TimeCode.h; don't use the "DEFAULT" value 65952a38012Sejakowatz int8 _reserved; 66052a38012Sejakowatz int8 hours; 66152a38012Sejakowatz int8 minutes; 66252a38012Sejakowatz int8 seconds; 66352a38012Sejakowatz int8 frames; 664d4d27facSStephan Aßmus int16 subframes; // Set to -1 if not available 66552a38012Sejakowatz }; 66652a38012Sejakowatz 667d4d27facSStephan Aßmus 668d4d27facSStephan Aßmus // Broadcast() fills in fields marked with "//+" 669d4d27facSStephan Aßmus struct media_header { 67052a38012Sejakowatz media_type type; // what kind of data (for union) 67152a38012Sejakowatz media_buffer_id buffer; //+ what buffer does this header go with? 67252a38012Sejakowatz int32 destination; //+ what 'socket' is this intended for? 67352a38012Sejakowatz media_node_id time_source; // node that encoded start_time 67452a38012Sejakowatz uint32 _deprecated_; // used to be change_tag 67552a38012Sejakowatz uint32 size_used; // size within buffer that is used 67652a38012Sejakowatz bigtime_t start_time; // performance time 67752a38012Sejakowatz area_id owner; //+ buffer owner info area 67852a38012Sejakowatz enum { 67952a38012Sejakowatz B_SEEK_TAG = 'TRST', // user data type of the codec seek 68052a38012Sejakowatz // protocol. size of seek tag is 16 bytes 68152a38012Sejakowatz B_TIME_CODE = 'TRTC' // user data is media_header_time_code 68252a38012Sejakowatz }; 68352a38012Sejakowatz type_code user_data_type; 68452a38012Sejakowatz uchar user_data[64]; // user_data_type indicates what this is 685b289aaf6SAxel Dörfler int32 source; 686b289aaf6SAxel Dörfler port_id source_port; 68752a38012Sejakowatz 68852a38012Sejakowatz off_t file_pos; // where in a file this data came from 68952a38012Sejakowatz size_t orig_size; // and how big it was. if unused, zero out 69052a38012Sejakowatz 69152a38012Sejakowatz uint32 data_offset; // offset within buffer (already reflected in Data()) 69252a38012Sejakowatz 69352a38012Sejakowatz union { 69452a38012Sejakowatz media_audio_header raw_audio; 69552a38012Sejakowatz media_video_header raw_video; 69652a38012Sejakowatz media_multistream_header multistream; 69752a38012Sejakowatz media_encoded_audio_header encoded_audio; 69852a38012Sejakowatz media_encoded_video_header encoded_video; 69952a38012Sejakowatz char _reserved_[64]; // pad to 64 bytes 70052a38012Sejakowatz } u; 70152a38012Sejakowatz }; 70252a38012Sejakowatz 70352a38012Sejakowatz 70452a38012Sejakowatz struct media_file_format_id { 70552a38012Sejakowatz ino_t node; 70652a38012Sejakowatz dev_t device; 70752a38012Sejakowatz uint32 internal_id; 70852a38012Sejakowatz }; 709d4d27facSStephan Aßmus 710d4d27facSStephan Aßmus 711f6e4cbb9SAxel Dörfler bool operator==(const media_file_format_id& a, const media_file_format_id& b); 712f6e4cbb9SAxel Dörfler bool operator<(const media_file_format_id& a, const media_file_format_id& b); 71352a38012Sejakowatz 714d4d27facSStephan Aßmus 71552a38012Sejakowatz typedef enum { 71652a38012Sejakowatz B_ANY_FORMAT_FAMILY = 0, 71752a38012Sejakowatz B_BEOS_FORMAT_FAMILY = 1, 718d4d27facSStephan Aßmus B_QUICKTIME_FORMAT_FAMILY = 2, // QuickTime is a registered 719d4d27facSStephan Aßmus // trademark of Apple Computer. 72052a38012Sejakowatz B_AVI_FORMAT_FAMILY = 3, 72152a38012Sejakowatz B_ASF_FORMAT_FAMILY = 4, 72252a38012Sejakowatz B_MPEG_FORMAT_FAMILY = 5, 72352a38012Sejakowatz B_WAV_FORMAT_FAMILY = 6, 72452a38012Sejakowatz B_AIFF_FORMAT_FAMILY = 7, 72552a38012Sejakowatz B_AVR_FORMAT_FAMILY = 8, 726d4d27facSStephan Aßmus 727da87cefeSbeveloper B_MISC_FORMAT_FAMILY = 99999, 72852a38012Sejakowatz } media_format_family; 72952a38012Sejakowatz 730d4d27facSStephan Aßmus 73152a38012Sejakowatz struct media_file_format { 732d4d27facSStephan Aßmus // Possible flags for capabilities bitmask 733d4d27facSStephan Aßmus enum { 73452a38012Sejakowatz B_READABLE = 0x1, 73552a38012Sejakowatz B_WRITABLE = 0x2, 73652a38012Sejakowatz B_PERFECTLY_SEEKABLE = 0x4, 73752a38012Sejakowatz B_IMPERFECTLY_SEEKABLE = 0x8, 73852a38012Sejakowatz B_KNOWS_RAW_VIDEO = 0x10, 73952a38012Sejakowatz B_KNOWS_RAW_AUDIO = 0x20, 74052a38012Sejakowatz B_KNOWS_MIDI = 0x40, 74152a38012Sejakowatz B_KNOWS_ENCODED_VIDEO = 0x80, 74252a38012Sejakowatz B_KNOWS_ENCODED_AUDIO = 0x100, 743d4d27facSStephan Aßmus B_KNOWS_OTHER = 0x1000000, // For example sub-title streams 74452a38012Sejakowatz B_KNOWS_ANYTHING = 0x2000000 74552a38012Sejakowatz }; 746d4d27facSStephan Aßmus uint32 capabilities; // Bitmask, see flags above 747d4d27facSStephan Aßmus media_file_format_id id; // Opaque id used to construct a 748d4d27facSStephan Aßmus // BMediaFile 749d4d27facSStephan Aßmus media_format_family family; // One of the family enums 75052a38012Sejakowatz int32 version; // 100 for 1.0 75152a38012Sejakowatz 75252a38012Sejakowatz uint32 _reserved_[25]; 75352a38012Sejakowatz 754d4d27facSStephan Aßmus char mime_type[64]; 755d4d27facSStephan Aßmus char pretty_name[64]; // "QuickTime File Format" 756d4d27facSStephan Aßmus char short_name[32]; // "quicktime", "avi", "mpeg" 757d4d27facSStephan Aßmus char file_extension[8]; // "mov", "avi", "mpg" 758d4d27facSStephan Aßmus 75952a38012Sejakowatz char reserved[88]; 76052a38012Sejakowatz }; 76152a38012Sejakowatz 76252a38012Sejakowatz 763d4d27facSStephan Aßmus // Initialize the cookie to 0 and keep calling this function to iterate 764d4d27facSStephan Aßmus // over all available media file format writers. 76552a38012Sejakowatz status_t get_next_file_format(int32* cookie, media_file_format* mfi); 76652a38012Sejakowatz 76752a38012Sejakowatz 768d4d27facSStephan Aßmus // A buffer of this size is guaranteed to be large enough to hold any 769d4d27facSStephan Aßmus // message, which your service thread can read from read_port() and 770d4d27facSStephan Aßmus // passes on to HandleMessage(). 77152a38012Sejakowatz const size_t B_MEDIA_MESSAGE_SIZE = 16384; 77252a38012Sejakowatz 773d4d27facSStephan Aßmus 774f6e4cbb9SAxel Dörfler extern const char* B_MEDIA_SERVER_SIGNATURE; 77552a38012Sejakowatz 776d4d27facSStephan Aßmus class media_node; 77752a38012Sejakowatz struct media_input; 77852a38012Sejakowatz struct media_output; 77952a38012Sejakowatz struct live_node_info; 78052a38012Sejakowatz struct dormant_node_info; 78152a38012Sejakowatz struct buffer_clone_info; 78252a38012Sejakowatz 78352a38012Sejakowatz 784d4d27facSStephan Aßmus // Functions which control the shutdown and launching process of the 785d4d27facSStephan Aßmus // media_server and it's friends. You can provide a call back hook which 786d4d27facSStephan Aßmus // will be called during various steps of the process. This callback should 787d4d27facSStephan Aßmus // currently always return TRUE. A 'stage' value of 100 means the process is 788d4d27facSStephan Aßmus // completely finished. 789d4d27facSStephan Aßmus status_t shutdown_media_server(bigtime_t timeout = B_INFINITE_TIMEOUT, 790d4d27facSStephan Aßmus bool (*progress)(int stage, const char* message, void* cookie) = NULL, 791d4d27facSStephan Aßmus void* cookie = NULL); 79252a38012Sejakowatz status_t launch_media_server(uint32 flags = 0); 79352a38012Sejakowatz 794d4d27facSStephan Aßmus 79552a38012Sejakowatz // Given an image_id, prepare that image_id for realtime media 796d4d27facSStephan Aßmus // If the kind of media indicated by 'flags' is not enabled for real-time, 79752a38012Sejakowatz // B_MEDIA_REALTIME_DISABLED is returned. 79852a38012Sejakowatz // If there are not enough system resources to enable real-time performance, 79952a38012Sejakowatz // B_MEDIA_REALTIME_UNAVAILABLE is returned. 80052a38012Sejakowatz status_t media_realtime_init_image(image_id image, uint32 flags); 80152a38012Sejakowatz 802d4d27facSStephan Aßmus 80352a38012Sejakowatz // Given a thread ID, and an optional indication of what the thread is 80452a38012Sejakowatz // doing in "flags", prepare the thread for real-time media performance. 80552a38012Sejakowatz // Currently, this means locking the thread stack, up to size_used bytes, 80652a38012Sejakowatz // or all of it if 0 is passed. Typically, you will not be using all 80752a38012Sejakowatz // 256 kB of the stack, so you should pass some smaller value you determine 80852a38012Sejakowatz // from profiling the thread; typically in the 32-64kB range. 80952a38012Sejakowatz // Return values are the same as for media_prepare_realtime_image(). 810d4d27facSStephan Aßmus status_t media_realtime_init_thread(thread_id thread, size_t stack_used, 811d4d27facSStephan Aßmus uint32 flags); 812d4d27facSStephan Aßmus 81352a38012Sejakowatz 81452a38012Sejakowatz // A teeny bit of legacy preserved for BSoundFile from R3. 81552a38012Sejakowatz // These came from the old MediaDefs.h; don't use them 81652a38012Sejakowatz // unless you get them from BSoundFile. 81752a38012Sejakowatz 81852a38012Sejakowatz 819d4d27facSStephan Aßmus // values for byte_ordering 820d4d27facSStephan Aßmus enum { 821d4d27facSStephan Aßmus B_BIG_ENDIAN, 822d4d27facSStephan Aßmus B_LITTLE_ENDIAN 823d4d27facSStephan Aßmus }; 824d4d27facSStephan Aßmus 825d4d27facSStephan Aßmus 826d4d27facSStephan Aßmus // values for sample_format 82752a38012Sejakowatz enum { 82852a38012Sejakowatz B_UNDEFINED_SAMPLES, 82952a38012Sejakowatz B_LINEAR_SAMPLES, 83052a38012Sejakowatz B_FLOAT_SAMPLES, 83152a38012Sejakowatz B_MULAW_SAMPLES 83252a38012Sejakowatz }; 83352a38012Sejakowatz 83452a38012Sejakowatz 835d4d27facSStephan Aßmus // #pragma mark - encoders and file writers 836d4d27facSStephan Aßmus 83752a38012Sejakowatz 83852a38012Sejakowatz struct media_encode_info { 839d4d27facSStephan Aßmus uint32 flags; // B_MEDIA_KEY_FRAME, set before every 840d4d27facSStephan Aßmus // use 841d4d27facSStephan Aßmus 842d4d27facSStephan Aßmus int32 used_data_size; // data size used by other tracks 843d4d27facSStephan Aßmus // add output size used by this encoder 844d4d27facSStephan Aßmus 845d4d27facSStephan Aßmus bigtime_t start_time; // us from start of file 846d4d27facSStephan Aßmus bigtime_t time_to_encode; // 0 - hurry up, B_INFINITE_TIMEOUT 847d4d27facSStephan Aßmus // - don't care 84852a38012Sejakowatz int32 _pad[22]; 849d4d27facSStephan Aßmus 850d4d27facSStephan Aßmus void* file_format_data; // file format specific info 85152a38012Sejakowatz size_t file_format_data_size; 852d4d27facSStephan Aßmus 853d4d27facSStephan Aßmus void* codec_data; // codec specific info 85452a38012Sejakowatz size_t codec_data_size; 85552a38012Sejakowatz 85652a38012Sejakowatz media_encode_info(); 85752a38012Sejakowatz }; 85852a38012Sejakowatz 859d4d27facSStephan Aßmus 86052a38012Sejakowatz struct encode_parameters { 86152a38012Sejakowatz float quality; // 0.0-1.0 , 1.0 is high quality 862d4d27facSStephan Aßmus 86352a38012Sejakowatz int32 avg_field_size; // in bytes 86452a38012Sejakowatz int32 max_field_size; // in bytes 865d4d27facSStephan Aßmus 86652a38012Sejakowatz int32 _pad[27]; 867d4d27facSStephan Aßmus 86852a38012Sejakowatz void* user_data; // codec specific info 86952a38012Sejakowatz size_t user_data_size; 87052a38012Sejakowatz }; 87152a38012Sejakowatz 872d4d27facSStephan Aßmus 87352a38012Sejakowatz struct media_decode_info { 874d4d27facSStephan Aßmus bigtime_t time_to_decode; // 0 - hurry up, B_INFINITE_TIMEOUT 875d4d27facSStephan Aßmus // - don't care 876d4d27facSStephan Aßmus 87752a38012Sejakowatz int32 _pad[26]; 878d4d27facSStephan Aßmus 879d4d27facSStephan Aßmus void* file_format_data; // file format specific info 88052a38012Sejakowatz size_t file_format_data_size; 881d4d27facSStephan Aßmus 882d4d27facSStephan Aßmus void* codec_data; // codec specific info 88352a38012Sejakowatz size_t codec_data_size; 88452a38012Sejakowatz 88552a38012Sejakowatz media_decode_info(); 88652a38012Sejakowatz }; 88752a38012Sejakowatz 88852a38012Sejakowatz 889d4d27facSStephan Aßmus // #pragma mark - inline implementations 890d4d27facSStephan Aßmus 891d4d27facSStephan Aßmus 892d4d27facSStephan Aßmus inline bool 893d4d27facSStephan Aßmus media_format::IsVideo() const 894d4d27facSStephan Aßmus { 895d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO || type == B_MEDIA_RAW_VIDEO; 896d4d27facSStephan Aßmus } 897d4d27facSStephan Aßmus 898d4d27facSStephan Aßmus 899d4d27facSStephan Aßmus inline uint32 900d4d27facSStephan Aßmus media_format::Width() const 901d4d27facSStephan Aßmus { 902d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 903d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_width 904d4d27facSStephan Aßmus : u.raw_video.display.line_width; 905d4d27facSStephan Aßmus } 906d4d27facSStephan Aßmus 907d4d27facSStephan Aßmus 908d4d27facSStephan Aßmus inline uint32 909d4d27facSStephan Aßmus media_format::Height() const 910d4d27facSStephan Aßmus { 911d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 912d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_count 913d4d27facSStephan Aßmus : u.raw_video.display.line_count; 914d4d27facSStephan Aßmus } 915d4d27facSStephan Aßmus 916d4d27facSStephan Aßmus 917d4d27facSStephan Aßmus inline color_space 918d4d27facSStephan Aßmus media_format::ColorSpace() const 919d4d27facSStephan Aßmus { 920d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 921d4d27facSStephan Aßmus ? u.encoded_video.output.display.format 922d4d27facSStephan Aßmus : u.raw_video.display.format; 923d4d27facSStephan Aßmus } 924d4d27facSStephan Aßmus 925d4d27facSStephan Aßmus 926d4d27facSStephan Aßmus inline uint32& 927d4d27facSStephan Aßmus media_format::Width() 928d4d27facSStephan Aßmus { 929d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 930d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_width 931d4d27facSStephan Aßmus : u.raw_video.display.line_width; 932d4d27facSStephan Aßmus } 933d4d27facSStephan Aßmus 934d4d27facSStephan Aßmus 935d4d27facSStephan Aßmus inline uint32& 936d4d27facSStephan Aßmus media_format::Height() 937d4d27facSStephan Aßmus { 938d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 939d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_count 940d4d27facSStephan Aßmus : u.raw_video.display.line_count; 941d4d27facSStephan Aßmus } 942d4d27facSStephan Aßmus 943d4d27facSStephan Aßmus 944d4d27facSStephan Aßmus inline color_space& 945d4d27facSStephan Aßmus media_format::ColorSpace() 946d4d27facSStephan Aßmus { 947d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 948d4d27facSStephan Aßmus ? u.encoded_video.output.display.format 949d4d27facSStephan Aßmus : u.raw_video.display.format; 950d4d27facSStephan Aßmus } 951d4d27facSStephan Aßmus 952d4d27facSStephan Aßmus 953d4d27facSStephan Aßmus inline bool 954d4d27facSStephan Aßmus media_format::IsAudio() const 955d4d27facSStephan Aßmus { 956d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO || type == B_MEDIA_RAW_AUDIO; 957d4d27facSStephan Aßmus } 958d4d27facSStephan Aßmus 959d4d27facSStephan Aßmus 960d4d27facSStephan Aßmus inline uint32 961d4d27facSStephan Aßmus media_format::AudioFormat() const 962d4d27facSStephan Aßmus { 963d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO 964d4d27facSStephan Aßmus ? u.encoded_audio.output.format : u.raw_audio.format; 965d4d27facSStephan Aßmus } 966d4d27facSStephan Aßmus 967d4d27facSStephan Aßmus 968d4d27facSStephan Aßmus inline uint32& 969d4d27facSStephan Aßmus media_format::AudioFormat() 970d4d27facSStephan Aßmus { 971d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO 972d4d27facSStephan Aßmus ? u.encoded_audio.output.format : u.raw_audio.format; 973d4d27facSStephan Aßmus } 974d4d27facSStephan Aßmus 975d4d27facSStephan Aßmus 976d4d27facSStephan Aßmus inline uint32 977d4d27facSStephan Aßmus media_format::AudioFrameSize() const 978d4d27facSStephan Aßmus { 979d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO 980d4d27facSStephan Aßmus ? (u.encoded_audio.output.format 981d4d27facSStephan Aßmus & media_raw_audio_format::B_AUDIO_SIZE_MASK) 982d4d27facSStephan Aßmus * u.encoded_audio.output.channel_count 983d4d27facSStephan Aßmus : (u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK) 984d4d27facSStephan Aßmus * u.raw_audio.channel_count; 985d4d27facSStephan Aßmus } 986d4d27facSStephan Aßmus 987d4d27facSStephan Aßmus 988d4d27facSStephan Aßmus inline uint32 989d4d27facSStephan Aßmus media_format::Encoding() const 990d4d27facSStephan Aßmus { 991d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO 992d4d27facSStephan Aßmus ? u.encoded_video.encoding : type == B_MEDIA_ENCODED_AUDIO 993d4d27facSStephan Aßmus ? u.encoded_audio.encoding : type == B_MEDIA_MULTISTREAM 994d4d27facSStephan Aßmus ? u.multistream.format : 0UL; 995d4d27facSStephan Aßmus } 996d4d27facSStephan Aßmus 997d4d27facSStephan Aßmus 998d4d27facSStephan Aßmus #endif /* end of __cplusplus section */ 999d4d27facSStephan Aßmus 100052a38012Sejakowatz 100152a38012Sejakowatz #endif /* MEDIA_DEFS_H */ 1002