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>
18841d719fSAugustin Cavalier class media_node;
19841d719fSAugustin Cavalier #else
20841d719fSAugustin Cavalier struct media_node;
2152a38012Sejakowatz #endif
2252a38012Sejakowatz
23d4d27facSStephan Aßmus
2452a38012Sejakowatz #define B_MEDIA_NAME_LENGTH 64
2552a38012Sejakowatz
2652a38012Sejakowatz
27d4d27facSStephan Aßmus /* Notification messages 'what' fields */
2852a38012Sejakowatz enum {
29d4d27facSStephan Aßmus /* Note that BMediaNode::node_error also belongs in here! */
30d4d27facSStephan Aßmus B_MEDIA_WILDCARD = 'TRWC',
31d4d27facSStephan Aßmus /* Used to match any notification in */
32d4d27facSStephan Aßmus /* Start/StopWatching */
33d4d27facSStephan Aßmus B_MEDIA_NODE_CREATED = 'TRIA',
34d4d27facSStephan Aßmus /* "media_node_id" (multiple items) */
3552a38012Sejakowatz B_MEDIA_NODE_DELETED, /* "media_node_id" (multiple items) */
3652a38012Sejakowatz B_MEDIA_CONNECTION_MADE, /* "output", "input", "format" */
3752a38012Sejakowatz B_MEDIA_CONNECTION_BROKEN, /* "source", "destination" */
38d4d27facSStephan Aßmus B_MEDIA_BUFFER_CREATED, /* "clone_info" -- handled by */
39d4d27facSStephan Aßmus /* BMediaRoster */
40d4d27facSStephan Aßmus B_MEDIA_BUFFER_DELETED, /* "media_buffer_id" -- handled by */
41d4d27facSStephan Aßmus /* BMediaRoster */
4252a38012Sejakowatz B_MEDIA_TRANSPORT_STATE, /* "state", "location", "realtime" */
4352a38012Sejakowatz B_MEDIA_PARAMETER_CHANGED, /* N "node", "parameter" */
4452a38012Sejakowatz B_MEDIA_FORMAT_CHANGED, /* N "source", "destination", "format" */
4552a38012Sejakowatz B_MEDIA_WEB_CHANGED, /* N "node" */
46d4d27facSStephan Aßmus B_MEDIA_DEFAULT_CHANGED, /* "default", "node" -- handled by */
47d4d27facSStephan Aßmus /* BMediaRoster */
48d4d27facSStephan Aßmus B_MEDIA_NEW_PARAMETER_VALUE, /* N "node", "parameter", "when", */
49d4d27facSStephan Aßmus /* "value" */
5052a38012Sejakowatz B_MEDIA_NODE_STOPPED, /* N "node", "when" */
5132afe10aSDario Casalinuovo B_MEDIA_FLAVORS_CHANGED, /* "be:addon_id", "be:new_count", */
52d4d27facSStephan Aßmus /* "be:gone_count" */
5332afe10aSDario Casalinuovo B_MEDIA_SERVER_STARTED,
5432afe10aSDario Casalinuovo B_MEDIA_SERVER_QUIT
5552a38012Sejakowatz };
5652a38012Sejakowatz
57d4d27facSStephan Aßmus
5852a38012Sejakowatz enum media_type {
5952a38012Sejakowatz B_MEDIA_NO_TYPE = -1,
6052a38012Sejakowatz B_MEDIA_UNKNOWN_TYPE = 0,
61d4d27facSStephan Aßmus B_MEDIA_RAW_AUDIO = 1, /* uncompressed raw_audio */
62d4d27facSStephan Aßmus B_MEDIA_RAW_VIDEO, /* uncompressed raw_video */
6352a38012Sejakowatz B_MEDIA_VBL, /* raw data from VBL area, 1600/line */
6452a38012Sejakowatz B_MEDIA_TIMECODE, /* data format TBD */
6552a38012Sejakowatz B_MEDIA_MIDI,
6652a38012Sejakowatz B_MEDIA_TEXT, /* typically closed captioning */
6752a38012Sejakowatz B_MEDIA_HTML,
6852a38012Sejakowatz B_MEDIA_MULTISTREAM, /* AVI, etc */
6952a38012Sejakowatz B_MEDIA_PARAMETERS, /* BControllable change data */
70d4d27facSStephan Aßmus B_MEDIA_ENCODED_AUDIO, /* MP3, AC-3, ... */
71d4d27facSStephan Aßmus B_MEDIA_ENCODED_VIDEO, /* H.264, Theora, ... */
72d4d27facSStephan Aßmus B_MEDIA_PRIVATE = 90000,
73d4d27facSStephan Aßmus /* This are reserved. */
74d4d27facSStephan Aßmus B_MEDIA_FIRST_USER_TYPE = 100000
75d4d27facSStephan Aßmus /* Use something bigger than this for */
76d4d27facSStephan Aßmus /* experimentation with your own media */
77d4d27facSStephan Aßmus /* formats. */
7852a38012Sejakowatz };
7952a38012Sejakowatz
80d4d27facSStephan Aßmus
8152a38012Sejakowatz enum node_kind {
8252a38012Sejakowatz B_BUFFER_PRODUCER = 0x1,
8352a38012Sejakowatz B_BUFFER_CONSUMER = 0x2,
8452a38012Sejakowatz B_TIME_SOURCE = 0x4,
8552a38012Sejakowatz B_CONTROLLABLE = 0x8,
8652a38012Sejakowatz B_FILE_INTERFACE = 0x10,
8752a38012Sejakowatz B_ENTITY_INTERFACE = 0x20,
88d4d27facSStephan Aßmus
89d4d27facSStephan Aßmus /* Set these flags for nodes that are suitable as default system nodes. */
9052a38012Sejakowatz B_PHYSICAL_INPUT = 0x10000,
9152a38012Sejakowatz B_PHYSICAL_OUTPUT = 0x20000,
9252a38012Sejakowatz B_SYSTEM_MIXER = 0x40000
9352a38012Sejakowatz };
9452a38012Sejakowatz
95d4d27facSStephan Aßmus
96d4d27facSStephan Aßmus enum video_orientation {
97d4d27facSStephan Aßmus /* Which pixel is first and how do we scan each "line"? */
98d4d27facSStephan Aßmus B_VIDEO_TOP_LEFT_RIGHT = 1, /* This is the typical progressive scan */
99d4d27facSStephan Aßmus /* format */
10052a38012Sejakowatz B_VIDEO_BOTTOM_LEFT_RIGHT /* This is how BMP and TGA might scan */
10152a38012Sejakowatz };
10252a38012Sejakowatz
10352a38012Sejakowatz
104d4d27facSStephan Aßmus /* data */
105d4d27facSStephan Aßmus enum media_flags
10652a38012Sejakowatz {
107d4d27facSStephan Aßmus B_MEDIA_FLAGS_VERSION = 1,
108d4d27facSStephan Aßmus /* uint32, greater for newer versions */
109d4d27facSStephan Aßmus B_MEDIA_FLAGS_PRIVATE = 0x40000000
110d4d27facSStephan Aßmus /* private to Haiku */
11152a38012Sejakowatz };
11252a38012Sejakowatz
11352a38012Sejakowatz
114d4d27facSStephan Aßmus /* for producer status */
115d4d27facSStephan Aßmus enum media_producer_status {
11652a38012Sejakowatz B_DATA_NOT_AVAILABLE = 1,
11752a38012Sejakowatz B_DATA_AVAILABLE = 2,
11852a38012Sejakowatz B_PRODUCER_STOPPED = 3
11952a38012Sejakowatz };
12052a38012Sejakowatz
121d4d27facSStephan Aßmus
122d4d27facSStephan Aßmus /* realtime flags */
12352a38012Sejakowatz enum media_realtime_flags {
12452a38012Sejakowatz B_MEDIA_REALTIME_ALLOCATOR = 0x1,
12552a38012Sejakowatz B_MEDIA_REALTIME_AUDIO = 0x2,
12652a38012Sejakowatz B_MEDIA_REALTIME_VIDEO = 0x4,
12752a38012Sejakowatz B_MEDIA_REALTIME_ANYKIND = 0xffff
12852a38012Sejakowatz };
12952a38012Sejakowatz
13052a38012Sejakowatz enum media_frame_flags {
13152a38012Sejakowatz B_MEDIA_KEY_FRAME = 0x1
13252a38012Sejakowatz };
13352a38012Sejakowatz
13452a38012Sejakowatz #define B_MEDIA_ANY_QUALITY 0.0f
13552a38012Sejakowatz #define B_MEDIA_LOW_QUALITY 0.1f
13652a38012Sejakowatz #define B_MEDIA_MEDIUM_QUALITY 0.5f
13752a38012Sejakowatz #define B_MEDIA_HIGH_QUALITY 1.0f
13852a38012Sejakowatz
13952a38012Sejakowatz
140d4d27facSStephan Aßmus #ifndef _MULTI_AUDIO_H /* #define in protocol header */
14152a38012Sejakowatz enum media_multi_channels {
142d4d27facSStephan Aßmus B_CHANNEL_LEFT = 0x00001,
143d4d27facSStephan Aßmus B_CHANNEL_RIGHT = 0x00002,
144d4d27facSStephan Aßmus B_CHANNEL_CENTER = 0x00004, /* 5.1+ or fake surround */
145d4d27facSStephan Aßmus B_CHANNEL_SUB = 0x00008, /* 5.1+ */
146d4d27facSStephan Aßmus B_CHANNEL_REARLEFT = 0x00010, /* quad surround or 5.1+ */
147d4d27facSStephan Aßmus B_CHANNEL_REARRIGHT = 0x00020, /* quad surround or 5.1+ */
148d4d27facSStephan Aßmus B_CHANNEL_FRONT_LEFT_CENTER = 0x00040,
149d4d27facSStephan Aßmus B_CHANNEL_FRONT_RIGHT_CENTER = 0x00080,
150d4d27facSStephan Aßmus B_CHANNEL_BACK_CENTER = 0x00100, /* 6.1 or fake surround */
151d4d27facSStephan Aßmus B_CHANNEL_SIDE_LEFT = 0x00200,
152d4d27facSStephan Aßmus B_CHANNEL_SIDE_RIGHT = 0x00400,
153d4d27facSStephan Aßmus B_CHANNEL_TOP_CENTER = 0x00800,
154d4d27facSStephan Aßmus B_CHANNEL_TOP_FRONT_LEFT = 0x01000,
155d4d27facSStephan Aßmus B_CHANNEL_TOP_FRONT_CENTER = 0x02000,
156d4d27facSStephan Aßmus B_CHANNEL_TOP_FRONT_RIGHT = 0x04000,
157d4d27facSStephan Aßmus B_CHANNEL_TOP_BACK_LEFT = 0x08000,
15852a38012Sejakowatz B_CHANNEL_TOP_BACK_CENTER = 0x10000,
15952a38012Sejakowatz B_CHANNEL_TOP_BACK_RIGHT = 0x20000
16052a38012Sejakowatz };
161d4d27facSStephan Aßmus
162d4d27facSStephan Aßmus
16352a38012Sejakowatz enum media_multi_matrix {
16452a38012Sejakowatz B_MATRIX_PROLOGIC_LR = 0x1,
16552a38012Sejakowatz B_MATRIX_AMBISONIC_WXYZ = 0x4
16652a38012Sejakowatz };
167d4d27facSStephan Aßmus #endif // !_MULTI_AUDIO_H
16852a38012Sejakowatz
16952a38012Sejakowatz
17052a38012Sejakowatz typedef int32 media_node_id;
17152a38012Sejakowatz typedef int32 media_buffer_id;
17252a38012Sejakowatz typedef int32 media_addon_id;
17352a38012Sejakowatz
17452a38012Sejakowatz
17552a38012Sejakowatz #if defined(__cplusplus)
17652a38012Sejakowatz struct media_destination {
17752a38012Sejakowatz media_destination();
178d4d27facSStephan Aßmus media_destination(port_id, int32);
179d4d27facSStephan Aßmus media_destination(
180d4d27facSStephan Aßmus const media_destination& other);
18152a38012Sejakowatz ~media_destination();
182d4d27facSStephan Aßmus
183d4d27facSStephan Aßmus media_destination& operator=(const media_destination& other);
184d4d27facSStephan Aßmus
185d4d27facSStephan Aßmus port_id port; /* can be different from */
186d4d27facSStephan Aßmus /* media_node.port */
18752a38012Sejakowatz int32 id;
18852a38012Sejakowatz static media_destination null;
189d4d27facSStephan Aßmus
19052a38012Sejakowatz private:
19152a38012Sejakowatz uint32 _reserved_media_destination_[2];
19252a38012Sejakowatz };
19352a38012Sejakowatz
194d4d27facSStephan Aßmus
19552a38012Sejakowatz struct media_source {
19652a38012Sejakowatz media_source();
197d4d27facSStephan Aßmus media_source(port_id, int32);
198d4d27facSStephan Aßmus media_source(const media_source& other);
19952a38012Sejakowatz ~media_source();
200d4d27facSStephan Aßmus
201d4d27facSStephan Aßmus media_source& operator=(const media_source& other);
202d4d27facSStephan Aßmus port_id port; /* must be the same as */
203d4d27facSStephan Aßmus /* media_node.port for owner */
20452a38012Sejakowatz int32 id;
20552a38012Sejakowatz static media_source null;
206d4d27facSStephan Aßmus
20752a38012Sejakowatz private:
20852a38012Sejakowatz uint32 _reserved_media_source_[2];
20952a38012Sejakowatz };
21052a38012Sejakowatz
211d4d27facSStephan Aßmus
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_destination& a, const media_destination& 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_source& a, const media_source& 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);
220f6e4cbb9SAxel Dörfler bool operator<(const media_node& a, const media_node& b);
22152a38012Sejakowatz
22252a38012Sejakowatz
22352a38012Sejakowatz
22452a38012Sejakowatz /* Buffers are low-level constructs identified by an ID. */
22552a38012Sejakowatz /* Buffers consist of the actual data area, plus a 64-byte */
22652a38012Sejakowatz /* header area that is different for each type. */
22752a38012Sejakowatz /* Buffers contain typed data. Type is not part of the */
22852a38012Sejakowatz /* buffer header; it's negotiated out-of-bounds by nodes. */
22952a38012Sejakowatz
23052a38012Sejakowatz enum {
23152a38012Sejakowatz B_MEDIA_BIG_ENDIAN = 1,
23252a38012Sejakowatz B_MEDIA_LITTLE_ENDIAN = 2,
23352a38012Sejakowatz #if B_HOST_IS_BENDIAN
23452a38012Sejakowatz B_MEDIA_HOST_ENDIAN = B_MEDIA_BIG_ENDIAN
23552a38012Sejakowatz #else
23652a38012Sejakowatz B_MEDIA_HOST_ENDIAN = B_MEDIA_LITTLE_ENDIAN
23752a38012Sejakowatz #endif
23852a38012Sejakowatz };
23952a38012Sejakowatz
240d4d27facSStephan Aßmus
24152a38012Sejakowatz struct media_multi_audio_format;
24252a38012Sejakowatz
243d4d27facSStephan Aßmus
24452a38012Sejakowatz struct media_raw_audio_format {
245d4d27facSStephan Aßmus // possible values for "format"
246d4d27facSStephan Aßmus enum {
247d4d27facSStephan Aßmus B_AUDIO_FLOAT = 0x24,
248d4d27facSStephan Aßmus // 0 == mid, -1.0 == bottom, 1.0 == top
249d4d27facSStephan Aßmus // (the preferred format for non-game audio)
250d4d27facSStephan Aßmus
251d4d27facSStephan Aßmus B_AUDIO_DOUBLE = 0x28,
252d4d27facSStephan Aßmus // 0 == mid, -1.0 == bottom, 1.0 == top
253d4d27facSStephan Aßmus // (only useful for pro audio)
254d4d27facSStephan Aßmus
255d4d27facSStephan Aßmus B_AUDIO_INT = 0x4,
256d4d27facSStephan Aßmus // 0 == mid, 0x80000001 == bottom, 0x7fffffff == top
257d4d27facSStephan Aßmus // (all >16-bit formats, left-adjusted)
258d4d27facSStephan Aßmus
259d4d27facSStephan Aßmus B_AUDIO_SHORT = 0x2,
260d4d27facSStephan Aßmus // 0 == mid, -32767 == bottom, +32767 == top
261d4d27facSStephan Aßmus
262d4d27facSStephan Aßmus B_AUDIO_UCHAR = 0x11,
263d4d27facSStephan Aßmus // 128 == mid, 1 == bottom, 255 == top
264d4d27facSStephan Aßmus // (discouraged but supported format)
265d4d27facSStephan Aßmus
266d4d27facSStephan Aßmus B_AUDIO_CHAR = 0x1,
267d4d27facSStephan Aßmus // 0 == mid, -127 == bottom, +127 == top
268d4d27facSStephan Aßmus // (not officially supported format)
269d4d27facSStephan Aßmus
27052a38012Sejakowatz B_AUDIO_SIZE_MASK = 0xf
271d4d27facSStephan Aßmus // This mask can be used to obtain the sample size
272d4d27facSStephan Aßmus // for raw formats: (format & 0xf) == sizeof(sample)
273d4d27facSStephan Aßmus };
27452a38012Sejakowatz
27552a38012Sejakowatz float frame_rate;
276d4d27facSStephan Aßmus uint32 channel_count;
277d4d27facSStephan Aßmus uint32 format; // see possible values above
278d4d27facSStephan Aßmus uint32 byte_order; // B_MEDIA_LITTLE_ENDIAN or B_MEDIA_BIG_ENDIAN
27952a38012Sejakowatz size_t buffer_size; // size of each buffer
28052a38012Sejakowatz
281*64e742deSAugustin Cavalier static const media_multi_audio_format wildcard;
28252a38012Sejakowatz };
28352a38012Sejakowatz
284d4d27facSStephan Aßmus
28552a38012Sejakowatz struct media_audio_header {
28622ea661bSColin Günther // TODO: Refine this structure and put actual data at the end
28722ea661bSColin Günther int32 _reserved_[14];
28822ea661bSColin Günther float frame_rate;
28922ea661bSColin Günther uint32 channel_count;
29022ea661bSColin Günther
29152a38012Sejakowatz };
29252a38012Sejakowatz
293d4d27facSStephan Aßmus
29452a38012Sejakowatz struct media_multi_audio_info {
29552a38012Sejakowatz uint32 channel_mask; // bitmask
29652a38012Sejakowatz int16 valid_bits; // if < 32, for B_AUDIO_INT
297d4d27facSStephan Aßmus uint16 matrix_mask; // each of these bits may mean more than one
298d4d27facSStephan Aßmus // channel
29952a38012Sejakowatz
30052a38012Sejakowatz uint32 _reserved_b[3];
30152a38012Sejakowatz };
30252a38012Sejakowatz
303d4d27facSStephan Aßmus
304d4d27facSStephan Aßmus struct media_multi_audio_format : public media_raw_audio_format,
305d4d27facSStephan Aßmus public media_multi_audio_info {
306d4d27facSStephan Aßmus
307*64e742deSAugustin Cavalier static const media_multi_audio_format wildcard;
30852a38012Sejakowatz };
30952a38012Sejakowatz
31052a38012Sejakowatz
31152a38012Sejakowatz struct media_encoded_audio_format {
31252a38012Sejakowatz enum audio_encoding {
31352a38012Sejakowatz B_ANY
31452a38012Sejakowatz };
315d4d27facSStephan Aßmus
31652a38012Sejakowatz media_raw_audio_format output;
31752a38012Sejakowatz audio_encoding encoding;
31852a38012Sejakowatz
319d4d27facSStephan Aßmus float bit_rate;
32052a38012Sejakowatz size_t frame_size;
32152a38012Sejakowatz
32252a38012Sejakowatz media_multi_audio_info multi_info;
32352a38012Sejakowatz
32452a38012Sejakowatz uint32 _reserved_[3];
32552a38012Sejakowatz
326*64e742deSAugustin Cavalier static const media_encoded_audio_format wildcard;
32752a38012Sejakowatz };
32852a38012Sejakowatz
329d4d27facSStephan Aßmus
33052a38012Sejakowatz struct media_encoded_audio_header {
331d4d27facSStephan Aßmus // NOTE: More data fields need to go to the end
332d4d27facSStephan Aßmus int32 _reserved_0[14];
333d4d27facSStephan Aßmus
334d4d27facSStephan Aßmus uint32 buffer_flags;
335d4d27facSStephan Aßmus // B_MEDIA_KEY_FRAME for key frame chunks
336d4d27facSStephan Aßmus uchar unused_mask;
337d4d27facSStephan Aßmus // mask of unused bits for the last byte of data
33852a38012Sejakowatz uchar _reserved_2[3];
33952a38012Sejakowatz
34052a38012Sejakowatz };
34152a38012Sejakowatz
34252a38012Sejakowatz enum media_display_flags {
343d4d27facSStephan Aßmus B_F1_DOMINANT = 0x1, // The first buffer sent (temporally) will
344d4d27facSStephan Aßmus // be an F1 field.
345d4d27facSStephan Aßmus B_F2_DOMINANT = 0x2, // The first buffer sent (temporally) will
346d4d27facSStephan Aßmus // be an F2 field.
347d4d27facSStephan Aßmus B_TOP_SCANLINE_F1 = 0x4, // The topmost scanline of the output buffer
348d4d27facSStephan Aßmus // belongs to F1.
349d4d27facSStephan Aßmus B_TOP_SCANLINE_F2 = 0x8 // The topmost scanline of the output buffer
350d4d27facSStephan Aßmus // belongs to F2.
35152a38012Sejakowatz };
352d4d27facSStephan Aßmus
353d4d27facSStephan Aßmus
35452a38012Sejakowatz struct media_video_display_info {
35552a38012Sejakowatz color_space format;
35652a38012Sejakowatz uint32 line_width;
357d4d27facSStephan Aßmus uint32 line_count; // sum of all interlace fields lines
358d4d27facSStephan Aßmus uint32 bytes_per_row; // bytes_per_row is in format, not header,
359d4d27facSStephan Aßmus // because it's part of SetBuffers
360d4d27facSStephan Aßmus uint32 pixel_offset; // (in pixels) Offset from the start of the
361d4d27facSStephan Aßmus // buffer (see below).
362d4d27facSStephan Aßmus uint32 line_offset; // (in lines) Offset to the start of the field.
363d4d27facSStephan Aßmus // Think "buffer == framebuffer" when the
364d4d27facSStephan Aßmus // window displaying the active field moves
365d4d27facSStephan Aßmus // on screen.
36652a38012Sejakowatz uint32 flags;
36752a38012Sejakowatz uint32 _reserved_[3];
368d4d27facSStephan Aßmus
369*64e742deSAugustin Cavalier static const media_video_display_info wildcard;
37052a38012Sejakowatz };
37152a38012Sejakowatz
372d4d27facSStephan Aßmus
37352a38012Sejakowatz struct media_raw_video_format {
37452a38012Sejakowatz float field_rate;
375d4d27facSStephan Aßmus uint32 interlace; // Number of fields per frame: 1 means
376d4d27facSStephan Aßmus // progressive (non-interlaced) frames.
377d4d27facSStephan Aßmus uint32 first_active; // Index of first active line. 0, typically
378d4d27facSStephan Aßmus // (wildcard, or "don't care")
379d4d27facSStephan Aßmus uint32 last_active; // Index of last active line (typically
380d4d27facSStephan Aßmus // line_count - 1, if first_active is 0.
381d4d27facSStephan Aßmus uint32 orientation; // B_VIDEO_TOP_LEFT_RIGHT is preferred.
382d4d27facSStephan Aßmus
383d4d27facSStephan Aßmus // This is the display aspect ratio (DAR). Usually, you would reduce the
384d4d27facSStephan Aßmus // width and height of the intended output frame size as far as possible
385d4d27facSStephan Aßmus // without changing their ratio. Note that you should not put 1 in both
386d4d27facSStephan Aßmus // fields to mean "undistorted pixels", unless you really intend square
387d4d27facSStephan Aßmus // video output!
38852a38012Sejakowatz uint16 pixel_width_aspect; // 1:1 has 1 here, 4:3 has 4 here
389d4d27facSStephan Aßmus // 16:9 has 16 here!
39052a38012Sejakowatz uint16 pixel_height_aspect; // 1:1 has 1 here, 4:3 has 3 here
391d4d27facSStephan Aßmus // 16:9 has 9 here!
39252a38012Sejakowatz
39352a38012Sejakowatz media_video_display_info display;
39452a38012Sejakowatz
395*64e742deSAugustin Cavalier static const media_raw_video_format wildcard;
39652a38012Sejakowatz };
39752a38012Sejakowatz
398d4d27facSStephan Aßmus
39952a38012Sejakowatz struct media_video_header {
40022ea661bSColin Günther uint32 _reserved_[8]; // NOTE: Keep reserved data at the top!
401d4d27facSStephan Aßmus
40222ea661bSColin Günther uint32 display_line_width; // Number of pixels per display_line
40322ea661bSColin Günther uint32 display_line_count; // Sum of all interlace fields lines
40422ea661bSColin Günther uint32 bytes_per_row; // Number of bytes in a display_line
40522ea661bSColin Günther // (padding bytes excluded)
40622ea661bSColin Günther uint16 pixel_width_aspect; // 1:1 has 1 here, 4:3 has 4 here
40722ea661bSColin Günther // 16:9 has 16 here!
40822ea661bSColin Günther uint16 pixel_height_aspect;// 1:1 has 1 here, 4:3 has 3 here
40922ea661bSColin Günther // 16:9 has 9 here!
41052a38012Sejakowatz float field_gamma;
411d4d27facSStephan Aßmus uint32 field_sequence; // Sequence number since start of capture
412d4d27facSStephan Aßmus // May roll over if machine is on for a
413d4d27facSStephan Aßmus // LONG time.
414d4d27facSStephan Aßmus uint16 field_number; // 0 .. {interlace-1}; F1 == 0 ("odd"),
415d4d27facSStephan Aßmus // F2 == 1 ("even")
41652a38012Sejakowatz uint16 pulldown_number; // 0..2 for pulldown duplicated sequence
417d4d27facSStephan Aßmus uint16 first_active_line; // The NTSC/PAL line number (1-based) of
418d4d27facSStephan Aßmus // the first line in this field
419d4d27facSStephan Aßmus uint16 line_count; // The number of active lines in buffer.
42052a38012Sejakowatz };
42152a38012Sejakowatz
422d4d27facSStephan Aßmus
42352a38012Sejakowatz struct media_encoded_video_format {
42452a38012Sejakowatz enum video_encoding {
42552a38012Sejakowatz B_ANY
42652a38012Sejakowatz };
427d4d27facSStephan Aßmus
42852a38012Sejakowatz media_raw_video_format output; // set unknowns to wildcard
429d4d27facSStephan Aßmus
43052a38012Sejakowatz float avg_bit_rate;
43152a38012Sejakowatz float max_bit_rate;
432d4d27facSStephan Aßmus
43352a38012Sejakowatz video_encoding encoding;
43452a38012Sejakowatz size_t frame_size;
43552a38012Sejakowatz
436d4d27facSStephan Aßmus int16 forward_history; // maximum forward memory
437d4d27facSStephan Aßmus // required by codec
438d4d27facSStephan Aßmus
439d4d27facSStephan Aßmus int16 backward_history; // maximum backward memory
440d4d27facSStephan Aßmus // required by codec
441d4d27facSStephan Aßmus
442d4d27facSStephan Aßmus uint32 _reserved_[3]; // This structure cannot grow
443d4d27facSStephan Aßmus // more than this (embedded)
444d4d27facSStephan Aßmus // in media_format union
44552a38012Sejakowatz
446*64e742deSAugustin Cavalier static const media_encoded_video_format wildcard;
44752a38012Sejakowatz };
44852a38012Sejakowatz
449d4d27facSStephan Aßmus
45052a38012Sejakowatz struct media_encoded_video_header {
451d4d27facSStephan Aßmus // NOTE: More data fields need to go at the end of this structure.
452d4d27facSStephan Aßmus int32 _reserved_1[9];
45352a38012Sejakowatz
45452a38012Sejakowatz uint32 field_flags; // B_MEDIA_KEY_FRAME
45552a38012Sejakowatz
456d4d27facSStephan Aßmus int16 forward_history; // forward memory required by this buffer
457d4d27facSStephan Aßmus // (0 for key frames)
458d4d27facSStephan Aßmus
459d4d27facSStephan Aßmus int16 backward_history; // backward memory required by this buffer
460d4d27facSStephan Aßmus // (0 for key frames)
461d4d27facSStephan Aßmus
462d4d27facSStephan Aßmus uchar unused_mask; // mask of unused bits for the last byte
463d4d27facSStephan Aßmus // of data
46452a38012Sejakowatz uchar _reserved_2[3];
46552a38012Sejakowatz float field_gamma;
46652a38012Sejakowatz uint32 field_sequence; // sequence since start of capture
46752a38012Sejakowatz uint16 field_number; // 0 .. {interlace-1}; F1 == 0, F2 == 1
46852a38012Sejakowatz uint16 pulldown_number; // 0..2 for pulldown duplicated sequence
469d4d27facSStephan Aßmus uint16 first_active_line; // 0 or 1, typically, but could be 10 or
470d4d27facSStephan Aßmus // 11 for full-NTSC formats
47152a38012Sejakowatz uint16 line_count; // number of actual lines in buffer
47252a38012Sejakowatz };
47352a38012Sejakowatz
47452a38012Sejakowatz struct media_multistream_format {
47552a38012Sejakowatz enum {
47652a38012Sejakowatz B_ANY = 0,
47752a38012Sejakowatz B_VID = 1, // raw raw_video/raw_audio buffers
47852a38012Sejakowatz B_AVI,
47952a38012Sejakowatz B_MPEG1,
48052a38012Sejakowatz B_MPEG2,
48152a38012Sejakowatz B_QUICKTIME,
48252a38012Sejakowatz B_PRIVATE = 90000,
483d4d27facSStephan Aßmus B_FIRST_USER_TYPE = 100000
48452a38012Sejakowatz };
48552a38012Sejakowatz float avg_bit_rate; // 8 * byte rate, on average
48652a38012Sejakowatz float max_bit_rate; // 8 * byte rate, tops
487d4d27facSStephan Aßmus uint32 avg_chunk_size; // == max_chunk_size for fixed-size
488d4d27facSStephan Aßmus // chunks
48952a38012Sejakowatz uint32 max_chunk_size; // max buffer size
49052a38012Sejakowatz enum {
49152a38012Sejakowatz B_HEADER_HAS_FLAGS = 0x1, // are flags important?
492d4d27facSStephan Aßmus B_CLEAN_BUFFERS = 0x2, // each buffer represents an integral
493d4d27facSStephan Aßmus // number of "frames"
49452a38012Sejakowatz B_HOMOGENOUS_BUFFERS = 0x4 // a buffer has only one format in it
49552a38012Sejakowatz };
49652a38012Sejakowatz uint32 flags;
49752a38012Sejakowatz int32 format;
49852a38012Sejakowatz uint32 _reserved_[2];
49952a38012Sejakowatz
50052a38012Sejakowatz struct vid_info {
50152a38012Sejakowatz float frame_rate;
50252a38012Sejakowatz uint16 width;
50352a38012Sejakowatz uint16 height;
50452a38012Sejakowatz color_space space;
50552a38012Sejakowatz
50652a38012Sejakowatz float sampling_rate;
50752a38012Sejakowatz uint32 sample_format;
50852a38012Sejakowatz uint16 byte_order;
50952a38012Sejakowatz uint16 channel_count;
51052a38012Sejakowatz };
51152a38012Sejakowatz struct avi_info {
51252a38012Sejakowatz uint32 us_per_frame;
51352a38012Sejakowatz uint16 width;
51452a38012Sejakowatz uint16 height;
51552a38012Sejakowatz uint16 _reserved_;
51652a38012Sejakowatz uint16 type_count;
51752a38012Sejakowatz media_type types[5];
51852a38012Sejakowatz };
51952a38012Sejakowatz
52052a38012Sejakowatz union {
52152a38012Sejakowatz vid_info vid;
52252a38012Sejakowatz avi_info avi;
52352a38012Sejakowatz } u;
52452a38012Sejakowatz
525*64e742deSAugustin Cavalier static const media_multistream_format wildcard;
52652a38012Sejakowatz };
52752a38012Sejakowatz
528d4d27facSStephan Aßmus
52952a38012Sejakowatz struct media_multistream_header {
53052a38012Sejakowatz uint32 _reserved_[14];
531d4d27facSStephan Aßmus uchar unused_mask; // mask of unused bits for the last byte
532d4d27facSStephan Aßmus // of data
53352a38012Sejakowatz uchar _reserved_2[3];
53452a38012Sejakowatz enum {
53552a38012Sejakowatz B_MASTER_HEADER = 0x1, // for master stream header data in buffer
53652a38012Sejakowatz B_SUBSTREAM_HEADER = 0x2, // for sub-stream header data in buffer
53752a38012Sejakowatz B_COMPLETE_BUFFER = 0x4 // data is an integral number of "frames"
53852a38012Sejakowatz };
53952a38012Sejakowatz uint32 flags;
54052a38012Sejakowatz };
54152a38012Sejakowatz
542d4d27facSStephan Aßmus
54352a38012Sejakowatz extern const type_code B_CODEC_TYPE_INFO;
54452a38012Sejakowatz
545d4d27facSStephan Aßmus
54652a38012Sejakowatz enum media_format_flags {
54752a38012Sejakowatz B_MEDIA_RETAINED_DATA = 0x1,
54852a38012Sejakowatz B_MEDIA_MULTIPLE_BUFFERS = 0x2,
54952a38012Sejakowatz B_MEDIA_CONTIGUOUS_BUFFER = 0x4,
55052a38012Sejakowatz B_MEDIA_LINEAR_UPDATES = 0x8,
551d4d27facSStephan Aßmus B_MEDIA_MAUI_UNDEFINED_FLAGS = ~0xf // NOTE: Always deny these flags
552d4d27facSStephan Aßmus // in new code.
55352a38012Sejakowatz };
55452a38012Sejakowatz
555d4d27facSStephan Aßmus // NOTE: A field of 0 typically means "anything" or "wildcard".
556d4d27facSStephan Aßmus // NOTE: This structure should not be bigger than 192 bytes!
557d4d27facSStephan Aßmus struct media_format {
55852a38012Sejakowatz media_type type;
55952a38012Sejakowatz type_code user_data_type;
56052a38012Sejakowatz uchar user_data[48];
56152a38012Sejakowatz uint32 _reserved_[3];
56252a38012Sejakowatz uint16 require_flags; // media_format_flags
56352a38012Sejakowatz uint16 deny_flags; // media_format_flags
56452a38012Sejakowatz
56552a38012Sejakowatz private:
566bacf4b5eSshatty void* meta_data;
56752a38012Sejakowatz int32 meta_data_size;
56852a38012Sejakowatz area_id meta_data_area;
5690a00d23fSMarcus Overhagen area_id __unused_was_use_area;
5700a00d23fSMarcus Overhagen team_id __unused_was_team;
5710a00d23fSMarcus Overhagen void* __unused_was_thisPtr;
57252a38012Sejakowatz
57352a38012Sejakowatz public:
57452a38012Sejakowatz union {
57552a38012Sejakowatz media_multi_audio_format raw_audio;
57652a38012Sejakowatz media_raw_video_format raw_video;
57752a38012Sejakowatz media_multistream_format multistream;
57852a38012Sejakowatz media_encoded_audio_format encoded_audio;
57952a38012Sejakowatz media_encoded_video_format encoded_video;
58052a38012Sejakowatz char _reserved_[96]; // pad to 96 bytes
58152a38012Sejakowatz } u;
58252a38012Sejakowatz
583d4d27facSStephan Aßmus bool IsVideo() const;
58452a38012Sejakowatz
585d4d27facSStephan Aßmus uint32 Width() const;
586d4d27facSStephan Aßmus uint32 Height() const;
587d4d27facSStephan Aßmus color_space ColorSpace() const;
58852a38012Sejakowatz
589d4d27facSStephan Aßmus uint32& Width();
590d4d27facSStephan Aßmus uint32& Height();
591d4d27facSStephan Aßmus color_space& ColorSpace();
59252a38012Sejakowatz
593d4d27facSStephan Aßmus bool IsAudio() const;
594d4d27facSStephan Aßmus uint32 AudioFormat() const;
595d4d27facSStephan Aßmus uint32& AudioFormat();
596d4d27facSStephan Aßmus uint32 AudioFrameSize() const;
597d4d27facSStephan Aßmus
598d4d27facSStephan Aßmus uint32 Encoding() const;
599d4d27facSStephan Aßmus
600d4d27facSStephan Aßmus bool Matches(const media_format* other) const;
601d4d27facSStephan Aßmus void SpecializeTo(const media_format* other);
60252a38012Sejakowatz
60352a38012Sejakowatz status_t SetMetaData(const void* data, size_t size);
60452a38012Sejakowatz const void* MetaData() const;
60552a38012Sejakowatz int32 MetaDataSize() const;
60652a38012Sejakowatz
60712ed45b6SMurai Takashi void Unflatten(const char *flatBuffer);
60812ed45b6SMurai Takashi void Clear();
60912ed45b6SMurai Takashi
61052a38012Sejakowatz media_format();
61152a38012Sejakowatz media_format(const media_format& other);
61252a38012Sejakowatz ~media_format();
613d4d27facSStephan Aßmus
614d4d27facSStephan Aßmus media_format& operator=(const media_format& other);
61552a38012Sejakowatz };
61652a38012Sejakowatz
617d4d27facSStephan Aßmus
618d4d27facSStephan Aßmus bool operator==(const media_raw_audio_format& a,
619d4d27facSStephan Aßmus const media_raw_audio_format& b);
620d4d27facSStephan Aßmus
621d4d27facSStephan Aßmus bool operator==(const media_multi_audio_info& a,
622d4d27facSStephan Aßmus const media_multi_audio_info& b);
623d4d27facSStephan Aßmus
624d4d27facSStephan Aßmus bool operator==(const media_multi_audio_format& a,
625d4d27facSStephan Aßmus const media_multi_audio_format& b);
626d4d27facSStephan Aßmus
627d4d27facSStephan Aßmus bool operator==(const media_encoded_audio_format& a,
628d4d27facSStephan Aßmus const media_encoded_audio_format& b);
629d4d27facSStephan Aßmus
630d4d27facSStephan Aßmus bool operator==(const media_video_display_info& a,
631d4d27facSStephan Aßmus const media_video_display_info& b);
632d4d27facSStephan Aßmus
633d4d27facSStephan Aßmus bool operator==(const media_raw_video_format& a,
634d4d27facSStephan Aßmus const media_raw_video_format& b);
635d4d27facSStephan Aßmus
636d4d27facSStephan Aßmus bool operator==(const media_encoded_video_format& a,
637d4d27facSStephan Aßmus const media_encoded_video_format& b);
638d4d27facSStephan Aßmus
639d4d27facSStephan Aßmus bool operator==(const media_multistream_format::vid_info& a,
640d4d27facSStephan Aßmus const media_multistream_format::vid_info& b);
641d4d27facSStephan Aßmus
642d4d27facSStephan Aßmus bool operator==(const media_multistream_format::avi_info& a,
643d4d27facSStephan Aßmus const media_multistream_format::avi_info & b);
644d4d27facSStephan Aßmus
645d4d27facSStephan Aßmus bool operator==(const media_multistream_format& a,
646d4d27facSStephan Aßmus const media_multistream_format& b);
647d4d27facSStephan Aßmus
648f6e4cbb9SAxel Dörfler bool operator==(const media_format& a, const media_format& b);
64952a38012Sejakowatz
650d4d27facSStephan Aßmus
651d4d27facSStephan Aßmus bool format_is_compatible(const media_format & a, const media_format & b);
652d4d27facSStephan Aßmus // Returns true if a and b are compatible (accounting for wildcards)
653d4d27facSStephan Aßmus // (a is the format you want to feed to something accepting b
654d4d27facSStephan Aßmus
655f6e4cbb9SAxel Dörfler bool string_for_format(const media_format & f, char * buf, size_t size);
65652a38012Sejakowatz
657d4d27facSStephan Aßmus
65852a38012Sejakowatz struct media_seek_tag {
65952a38012Sejakowatz char data[16];
66052a38012Sejakowatz };
66152a38012Sejakowatz
662d4d27facSStephan Aßmus
66352a38012Sejakowatz struct media_header_time_code {
66452a38012Sejakowatz int8 type; // See TimeCode.h; don't use the "DEFAULT" value
66552a38012Sejakowatz int8 _reserved;
66652a38012Sejakowatz int8 hours;
66752a38012Sejakowatz int8 minutes;
66852a38012Sejakowatz int8 seconds;
66952a38012Sejakowatz int8 frames;
670d4d27facSStephan Aßmus int16 subframes; // Set to -1 if not available
67152a38012Sejakowatz };
67252a38012Sejakowatz
673d4d27facSStephan Aßmus
674d4d27facSStephan Aßmus // Broadcast() fills in fields marked with "//+"
675d4d27facSStephan Aßmus struct media_header {
67652a38012Sejakowatz media_type type; // what kind of data (for union)
67752a38012Sejakowatz media_buffer_id buffer; //+ what buffer does this header go with?
67852a38012Sejakowatz int32 destination; //+ what 'socket' is this intended for?
67952a38012Sejakowatz media_node_id time_source; // node that encoded start_time
68052a38012Sejakowatz uint32 _deprecated_; // used to be change_tag
68152a38012Sejakowatz uint32 size_used; // size within buffer that is used
68252a38012Sejakowatz bigtime_t start_time; // performance time
68352a38012Sejakowatz area_id owner; //+ buffer owner info area
68452a38012Sejakowatz enum {
68552a38012Sejakowatz B_SEEK_TAG = 'TRST', // user data type of the codec seek
68652a38012Sejakowatz // protocol. size of seek tag is 16 bytes
68752a38012Sejakowatz B_TIME_CODE = 'TRTC' // user data is media_header_time_code
68852a38012Sejakowatz };
68952a38012Sejakowatz type_code user_data_type;
69052a38012Sejakowatz uchar user_data[64]; // user_data_type indicates what this is
691b289aaf6SAxel Dörfler int32 source;
692b289aaf6SAxel Dörfler port_id source_port;
69352a38012Sejakowatz
69452a38012Sejakowatz off_t file_pos; // where in a file this data came from
69552a38012Sejakowatz size_t orig_size; // and how big it was. if unused, zero out
69652a38012Sejakowatz
69752a38012Sejakowatz uint32 data_offset; // offset within buffer (already reflected in Data())
69852a38012Sejakowatz
69952a38012Sejakowatz union {
70052a38012Sejakowatz media_audio_header raw_audio;
70152a38012Sejakowatz media_video_header raw_video;
70252a38012Sejakowatz media_multistream_header multistream;
70352a38012Sejakowatz media_encoded_audio_header encoded_audio;
70452a38012Sejakowatz media_encoded_video_header encoded_video;
70552a38012Sejakowatz char _reserved_[64]; // pad to 64 bytes
70652a38012Sejakowatz } u;
70752a38012Sejakowatz };
70852a38012Sejakowatz
70952a38012Sejakowatz
71052a38012Sejakowatz struct media_file_format_id {
71152a38012Sejakowatz ino_t node;
71252a38012Sejakowatz dev_t device;
71352a38012Sejakowatz uint32 internal_id;
71452a38012Sejakowatz };
715d4d27facSStephan Aßmus
716d4d27facSStephan Aßmus
717f6e4cbb9SAxel Dörfler bool operator==(const media_file_format_id& a, const media_file_format_id& b);
718f6e4cbb9SAxel Dörfler bool operator<(const media_file_format_id& a, const media_file_format_id& b);
71952a38012Sejakowatz
720d4d27facSStephan Aßmus
72152a38012Sejakowatz typedef enum {
72252a38012Sejakowatz B_ANY_FORMAT_FAMILY = 0,
72352a38012Sejakowatz B_BEOS_FORMAT_FAMILY = 1,
724d4d27facSStephan Aßmus B_QUICKTIME_FORMAT_FAMILY = 2, // QuickTime is a registered
725d4d27facSStephan Aßmus // trademark of Apple Computer.
72652a38012Sejakowatz B_AVI_FORMAT_FAMILY = 3,
72752a38012Sejakowatz B_ASF_FORMAT_FAMILY = 4,
72852a38012Sejakowatz B_MPEG_FORMAT_FAMILY = 5,
72952a38012Sejakowatz B_WAV_FORMAT_FAMILY = 6,
73052a38012Sejakowatz B_AIFF_FORMAT_FAMILY = 7,
73152a38012Sejakowatz B_AVR_FORMAT_FAMILY = 8,
732d4d27facSStephan Aßmus
733da87cefeSbeveloper B_MISC_FORMAT_FAMILY = 99999,
73452a38012Sejakowatz } media_format_family;
73552a38012Sejakowatz
736d4d27facSStephan Aßmus
73752a38012Sejakowatz struct media_file_format {
738d4d27facSStephan Aßmus // Possible flags for capabilities bitmask
739d4d27facSStephan Aßmus enum {
74052a38012Sejakowatz B_READABLE = 0x1,
74152a38012Sejakowatz B_WRITABLE = 0x2,
74252a38012Sejakowatz B_PERFECTLY_SEEKABLE = 0x4,
74352a38012Sejakowatz B_IMPERFECTLY_SEEKABLE = 0x8,
74452a38012Sejakowatz B_KNOWS_RAW_VIDEO = 0x10,
74552a38012Sejakowatz B_KNOWS_RAW_AUDIO = 0x20,
74652a38012Sejakowatz B_KNOWS_MIDI = 0x40,
74752a38012Sejakowatz B_KNOWS_ENCODED_VIDEO = 0x80,
74852a38012Sejakowatz B_KNOWS_ENCODED_AUDIO = 0x100,
749d4d27facSStephan Aßmus B_KNOWS_OTHER = 0x1000000, // For example sub-title streams
75052a38012Sejakowatz B_KNOWS_ANYTHING = 0x2000000
75152a38012Sejakowatz };
752d4d27facSStephan Aßmus uint32 capabilities; // Bitmask, see flags above
753d4d27facSStephan Aßmus media_file_format_id id; // Opaque id used to construct a
754d4d27facSStephan Aßmus // BMediaFile
755d4d27facSStephan Aßmus media_format_family family; // One of the family enums
75652a38012Sejakowatz int32 version; // 100 for 1.0
75752a38012Sejakowatz
75852a38012Sejakowatz uint32 _reserved_[25];
75952a38012Sejakowatz
760d4d27facSStephan Aßmus char mime_type[64];
761d4d27facSStephan Aßmus char pretty_name[64]; // "QuickTime File Format"
762d4d27facSStephan Aßmus char short_name[32]; // "quicktime", "avi", "mpeg"
763d4d27facSStephan Aßmus char file_extension[8]; // "mov", "avi", "mpg"
764d4d27facSStephan Aßmus
76552a38012Sejakowatz char reserved[88];
76652a38012Sejakowatz };
76752a38012Sejakowatz
76852a38012Sejakowatz
769d4d27facSStephan Aßmus // Initialize the cookie to 0 and keep calling this function to iterate
770d4d27facSStephan Aßmus // over all available media file format writers.
77152a38012Sejakowatz status_t get_next_file_format(int32* cookie, media_file_format* mfi);
77252a38012Sejakowatz
77352a38012Sejakowatz
774d4d27facSStephan Aßmus // A buffer of this size is guaranteed to be large enough to hold any
775d4d27facSStephan Aßmus // message, which your service thread can read from read_port() and
776d4d27facSStephan Aßmus // passes on to HandleMessage().
77752a38012Sejakowatz const size_t B_MEDIA_MESSAGE_SIZE = 16384;
77852a38012Sejakowatz
779d4d27facSStephan Aßmus
780f6e4cbb9SAxel Dörfler extern const char* B_MEDIA_SERVER_SIGNATURE;
78152a38012Sejakowatz
782d4d27facSStephan Aßmus class media_node;
78352a38012Sejakowatz struct media_input;
78452a38012Sejakowatz struct media_output;
78552a38012Sejakowatz struct live_node_info;
78652a38012Sejakowatz struct dormant_node_info;
78752a38012Sejakowatz struct buffer_clone_info;
78852a38012Sejakowatz
78952a38012Sejakowatz
790d4d27facSStephan Aßmus // Functions which control the shutdown and launching process of the
791d4d27facSStephan Aßmus // media_server and it's friends. You can provide a call back hook which
792d4d27facSStephan Aßmus // will be called during various steps of the process. This callback should
793d4d27facSStephan Aßmus // currently always return TRUE. A 'stage' value of 100 means the process is
7948acd164fSDario Casalinuovo // completely finished. Differently from BeOS the functions automatically
7958acd164fSDario Casalinuovo // send notifications to the Deskbar if not differently specified.
7968acd164fSDario Casalinuovo // It's also provided a new version of launch_media_server allowing
7978acd164fSDario Casalinuovo // to specify a custom callback for notifications.
7988acd164fSDario Casalinuovo
7998acd164fSDario Casalinuovo status_t launch_media_server(bigtime_t timeout = B_INFINITE_TIMEOUT,
8008acd164fSDario Casalinuovo bool (*progress)(int stage, const char* message, void* cookie) = NULL,
8018acd164fSDario Casalinuovo void* cookie = NULL, uint32 flags = 0);
8028acd164fSDario Casalinuovo
803d4d27facSStephan Aßmus status_t shutdown_media_server(bigtime_t timeout = B_INFINITE_TIMEOUT,
804d4d27facSStephan Aßmus bool (*progress)(int stage, const char* message, void* cookie) = NULL,
805d4d27facSStephan Aßmus void* cookie = NULL);
80652a38012Sejakowatz
807d4d27facSStephan Aßmus
80852a38012Sejakowatz // A teeny bit of legacy preserved for BSoundFile from R3.
80952a38012Sejakowatz // These came from the old MediaDefs.h; don't use them
81052a38012Sejakowatz // unless you get them from BSoundFile.
81152a38012Sejakowatz
81252a38012Sejakowatz
813d4d27facSStephan Aßmus // values for byte_ordering
814d4d27facSStephan Aßmus enum {
815d4d27facSStephan Aßmus B_BIG_ENDIAN,
816d4d27facSStephan Aßmus B_LITTLE_ENDIAN
817d4d27facSStephan Aßmus };
818d4d27facSStephan Aßmus
819d4d27facSStephan Aßmus
820d4d27facSStephan Aßmus // values for sample_format
82152a38012Sejakowatz enum {
82252a38012Sejakowatz B_UNDEFINED_SAMPLES,
82352a38012Sejakowatz B_LINEAR_SAMPLES,
82452a38012Sejakowatz B_FLOAT_SAMPLES,
82552a38012Sejakowatz B_MULAW_SAMPLES
82652a38012Sejakowatz };
82752a38012Sejakowatz
82852a38012Sejakowatz
829d4d27facSStephan Aßmus // #pragma mark - encoders and file writers
830d4d27facSStephan Aßmus
83152a38012Sejakowatz
83252a38012Sejakowatz struct media_encode_info {
833d4d27facSStephan Aßmus uint32 flags; // B_MEDIA_KEY_FRAME, set before every
834d4d27facSStephan Aßmus // use
835d4d27facSStephan Aßmus
836d4d27facSStephan Aßmus int32 used_data_size; // data size used by other tracks
837d4d27facSStephan Aßmus // add output size used by this encoder
838d4d27facSStephan Aßmus
839d4d27facSStephan Aßmus bigtime_t start_time; // us from start of file
840d4d27facSStephan Aßmus bigtime_t time_to_encode; // 0 - hurry up, B_INFINITE_TIMEOUT
841d4d27facSStephan Aßmus // - don't care
84252a38012Sejakowatz int32 _pad[22];
843d4d27facSStephan Aßmus
844d4d27facSStephan Aßmus void* file_format_data; // file format specific info
84552a38012Sejakowatz size_t file_format_data_size;
846d4d27facSStephan Aßmus
847d4d27facSStephan Aßmus void* codec_data; // codec specific info
84852a38012Sejakowatz size_t codec_data_size;
84952a38012Sejakowatz
85052a38012Sejakowatz media_encode_info();
85152a38012Sejakowatz };
85252a38012Sejakowatz
853d4d27facSStephan Aßmus
85452a38012Sejakowatz struct encode_parameters {
85552a38012Sejakowatz float quality; // 0.0-1.0 , 1.0 is high quality
856d4d27facSStephan Aßmus
85752a38012Sejakowatz int32 avg_field_size; // in bytes
85852a38012Sejakowatz int32 max_field_size; // in bytes
859d4d27facSStephan Aßmus
86052a38012Sejakowatz int32 _pad[27];
861d4d27facSStephan Aßmus
86252a38012Sejakowatz void* user_data; // codec specific info
86352a38012Sejakowatz size_t user_data_size;
86452a38012Sejakowatz };
86552a38012Sejakowatz
866d4d27facSStephan Aßmus
86752a38012Sejakowatz struct media_decode_info {
868d4d27facSStephan Aßmus bigtime_t time_to_decode; // 0 - hurry up, B_INFINITE_TIMEOUT
869d4d27facSStephan Aßmus // - don't care
870d4d27facSStephan Aßmus
87152a38012Sejakowatz int32 _pad[26];
872d4d27facSStephan Aßmus
873d4d27facSStephan Aßmus void* file_format_data; // file format specific info
87452a38012Sejakowatz size_t file_format_data_size;
875d4d27facSStephan Aßmus
876d4d27facSStephan Aßmus void* codec_data; // codec specific info
87752a38012Sejakowatz size_t codec_data_size;
87852a38012Sejakowatz
87952a38012Sejakowatz media_decode_info();
88052a38012Sejakowatz };
88152a38012Sejakowatz
88252a38012Sejakowatz
883d4d27facSStephan Aßmus // #pragma mark - inline implementations
884d4d27facSStephan Aßmus
885d4d27facSStephan Aßmus
886d4d27facSStephan Aßmus inline bool
IsVideo()887d4d27facSStephan Aßmus media_format::IsVideo() const
888d4d27facSStephan Aßmus {
889d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO || type == B_MEDIA_RAW_VIDEO;
890d4d27facSStephan Aßmus }
891d4d27facSStephan Aßmus
892d4d27facSStephan Aßmus
893d4d27facSStephan Aßmus inline uint32
Width()894d4d27facSStephan Aßmus media_format::Width() const
895d4d27facSStephan Aßmus {
896d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO
897d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_width
898d4d27facSStephan Aßmus : u.raw_video.display.line_width;
899d4d27facSStephan Aßmus }
900d4d27facSStephan Aßmus
901d4d27facSStephan Aßmus
902d4d27facSStephan Aßmus inline uint32
Height()903d4d27facSStephan Aßmus media_format::Height() const
904d4d27facSStephan Aßmus {
905d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO
906d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_count
907d4d27facSStephan Aßmus : u.raw_video.display.line_count;
908d4d27facSStephan Aßmus }
909d4d27facSStephan Aßmus
910d4d27facSStephan Aßmus
911d4d27facSStephan Aßmus inline color_space
ColorSpace()912d4d27facSStephan Aßmus media_format::ColorSpace() const
913d4d27facSStephan Aßmus {
914d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO
915d4d27facSStephan Aßmus ? u.encoded_video.output.display.format
916d4d27facSStephan Aßmus : u.raw_video.display.format;
917d4d27facSStephan Aßmus }
918d4d27facSStephan Aßmus
919d4d27facSStephan Aßmus
920d4d27facSStephan Aßmus inline uint32&
Width()921d4d27facSStephan Aßmus media_format::Width()
922d4d27facSStephan Aßmus {
923d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO
924d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_width
925d4d27facSStephan Aßmus : u.raw_video.display.line_width;
926d4d27facSStephan Aßmus }
927d4d27facSStephan Aßmus
928d4d27facSStephan Aßmus
929d4d27facSStephan Aßmus inline uint32&
Height()930d4d27facSStephan Aßmus media_format::Height()
931d4d27facSStephan Aßmus {
932d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO
933d4d27facSStephan Aßmus ? u.encoded_video.output.display.line_count
934d4d27facSStephan Aßmus : u.raw_video.display.line_count;
935d4d27facSStephan Aßmus }
936d4d27facSStephan Aßmus
937d4d27facSStephan Aßmus
938d4d27facSStephan Aßmus inline color_space&
ColorSpace()939d4d27facSStephan Aßmus media_format::ColorSpace()
940d4d27facSStephan Aßmus {
941d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO
942d4d27facSStephan Aßmus ? u.encoded_video.output.display.format
943d4d27facSStephan Aßmus : u.raw_video.display.format;
944d4d27facSStephan Aßmus }
945d4d27facSStephan Aßmus
946d4d27facSStephan Aßmus
947d4d27facSStephan Aßmus inline bool
IsAudio()948d4d27facSStephan Aßmus media_format::IsAudio() const
949d4d27facSStephan Aßmus {
950d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO || type == B_MEDIA_RAW_AUDIO;
951d4d27facSStephan Aßmus }
952d4d27facSStephan Aßmus
953d4d27facSStephan Aßmus
954d4d27facSStephan Aßmus inline uint32
AudioFormat()955d4d27facSStephan Aßmus media_format::AudioFormat() const
956d4d27facSStephan Aßmus {
957d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO
958d4d27facSStephan Aßmus ? u.encoded_audio.output.format : u.raw_audio.format;
959d4d27facSStephan Aßmus }
960d4d27facSStephan Aßmus
961d4d27facSStephan Aßmus
962d4d27facSStephan Aßmus inline uint32&
AudioFormat()963d4d27facSStephan Aßmus media_format::AudioFormat()
964d4d27facSStephan Aßmus {
965d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO
966d4d27facSStephan Aßmus ? u.encoded_audio.output.format : u.raw_audio.format;
967d4d27facSStephan Aßmus }
968d4d27facSStephan Aßmus
969d4d27facSStephan Aßmus
970d4d27facSStephan Aßmus inline uint32
AudioFrameSize()971d4d27facSStephan Aßmus media_format::AudioFrameSize() const
972d4d27facSStephan Aßmus {
973d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_AUDIO
974d4d27facSStephan Aßmus ? (u.encoded_audio.output.format
975d4d27facSStephan Aßmus & media_raw_audio_format::B_AUDIO_SIZE_MASK)
976d4d27facSStephan Aßmus * u.encoded_audio.output.channel_count
977d4d27facSStephan Aßmus : (u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK)
978d4d27facSStephan Aßmus * u.raw_audio.channel_count;
979d4d27facSStephan Aßmus }
980d4d27facSStephan Aßmus
981d4d27facSStephan Aßmus
982d4d27facSStephan Aßmus inline uint32
Encoding()983d4d27facSStephan Aßmus media_format::Encoding() const
984d4d27facSStephan Aßmus {
985d4d27facSStephan Aßmus return type == B_MEDIA_ENCODED_VIDEO
986d4d27facSStephan Aßmus ? u.encoded_video.encoding : type == B_MEDIA_ENCODED_AUDIO
987d4d27facSStephan Aßmus ? u.encoded_audio.encoding : type == B_MEDIA_MULTISTREAM
988d4d27facSStephan Aßmus ? u.multistream.format : 0UL;
989d4d27facSStephan Aßmus }
990d4d27facSStephan Aßmus
991d4d27facSStephan Aßmus
992d4d27facSStephan Aßmus #endif /* end of __cplusplus section */
993d4d27facSStephan Aßmus
99452a38012Sejakowatz
99552a38012Sejakowatz #endif /* MEDIA_DEFS_H */
996