The Media Kit Table of Contents The Media Kit Index

Constants and Defined Types

This section describes the constants and defined types that make the Media Kit tick.


Constants


Codec Type Info

Declared in: be/media/MediaDefs.h

Constant Description
B_CODEC_TYPE_INFO Data is in codec type info format.

The B_CODEC_TYPE_INFO constant is used to indicate that data is a codec info structure; it's used in the user_data_type field in the media_format structure, for example.


Data Endianness

Declared in: be/media/MediaDefs.h

Constant Description
B_MEDIA_BIG_ENDIAN The media data is big-endian
B_MEDIA_LITTLE_ENDIAN The media data is little-endian.

These values indicate whether media data is little-endian or big-endian.


Media Message Size

Declared in: <be/media/MediaDefs.h>

   const size_t B_MEDIA_MESSAGE_SIZE = 16384;

The B_MEDIA_MESSAGE_SIZE constant specifies the maximum possible size a message a node's service thread can receive. 16k is an upper limit and won't be exceeded. Your thread can simply create a buffer this large, read_port() into it, and call HandleMessage() to process it.


media_flags

Declared in: be/media/MediaDefs.h

Constant Description
B_MEDIA_FLAGS_VERSION Returns the Media Kit version as an int32 value.

The media_flags indicate values you can pass to BMediaRoster::MediaFlags() to get information about the version of the Media Kit that your application is running under.


media_format_family

Declared in: be/media/MediaDefs.h

Constant Meaning
B_ANY_FORMAT_FAMILY Any family.
B_BEOS_FORMAT_FAMILY BeOS format.
B_QUICKTIME_FORMAT_FAMILY QuickTime format.
B_AVI_FORMAT_FAMILY AVI format.
B_ASF_FORMAT_FAMILY ASF format.
B_MPEG_FORMAT_FAMILY MPEG format.
B_WAV_FORMAT_FAMILY WAVE format audio.
B_AIFF_FORMAT_FAMILY AIFF format audio.
B_MISC_FORMAT_FAMILY Miscellaneous.

These constants indicate the media format families the BMediaFormats class can map among.


media_producer_status

Declared in: <be/media/MediaDefs.h>

Constant Description
B_DATA_NOT_AVAILABLE There aren't any buffers ready for the destination.
B_DATA_AVAILABLE There are buffers ready for the destination.
B_PRODUCER_STOPPED The producer isn't running.

These values can be specified when your producer node calls BBufferProducer::SendDataStatus() to tell the consumers it's feeding whether or not data is available for it to process. The B_PRODUCER_STOPPED code is sent to indicate to downstream consumers that it's no longer running.

Consumers receive these values in the BBufferConsumer::ProducerDataStatus() hook function.


media_realtime_flags

Declared in: be/media/MediaDefs.h

Constant Description
B_MEDIA_REALTIME_ALLOCATOR When set, rtm_alloc() will return locked memory.
B_MEDIA_REALTIME_AUDIO Audio add-ons in the Media Server are locked in memory, and should lock their thread stacks using media_init_realtime_thread().
B_MEDIA_REALTIME_VIDEO Video add-ons are locked in memory, and should lock their thread stacks using media_init_realtime_thread().
B_MEDIA_REALTIME_ANYKIND All Media add-ons are locked in memory, and should lock their thread stacks using media_init_realtime_thread().

These values are passed to realtime allocator functions to indicate what types of nodes should use locked memory.


media_type

Declared in: be/media/MediaNode.h

Constant Description
B_MEDIA_NO_TYPE Typeless media data.
B_MEDIA_UNKNOWN_TYPE Unknown media type.
B_MEDIA_RAW_AUDIO Uncompressed, linear audio.
B_MEDIA_RAW_VIDEO Uncompressed, linear video.
B_MEDIA_VBL Raw data from VBL area.
B_MEDIA_TIMECODE Timecode data. Undetermined format.
B_MEDIA_MIDI MIDI.
B_MEDIA_TEXT Text data; typically closed-captioning information.
B_MEDIA_HTML HTML data.
B_MEDIA_MULTISTREAM Multi-stream media data, such as AVI or QuickTime.
B_MEDIA_PARAMETERS BControllable change data.
B_MEDIA_ENCODED_AUDIO Encoded audio (such as AC3 or DTS).
B_MEDIA_ENCODED_VIDEO Encoded video (such as Indeo or MPEG).
B_MEDIA_PRIVATE Base value for private Be media types.
B_MEDIA_FIRST_USER_TYPE Base value for user-defined media types.

Types of media data.


node_kind

Declared in: be/media/MediaNode.h

Constant Description
B_BUFFER_PRODUCER The flavor implements BBufferProducer.
B_BUFFER_CONSUMER The flavor implements BBufferConsumer.
B_TIME_SOURCE The flavor implements BTimeSource.
B_CONTROLLABLE The flavor implements BControllable.
B_FILE_INTERFACE The flavor implements BFileInterface.
B_ENTITY_INTERFACE The flavor implements BEntityInterface (not available for R4).
B_PHYSICAL_INPUT The flavor represents a physical input point (such as an input jack).
B_PHYSICAL_OUTPUT The flavor represents a physical output point (such as line output).
B_SYSTEM_MIXER The flavor represents the system mixer.

Defines the type or types of node that a particular flavor supports. Note that a flavor can implement more than one type of node, so you can combine these values using a bitwise or.


video_orientation

Declared in: be/media/MediaNode.h

Constant Description
B_VIDEO_TOP_LEFT_RIGHT Typical progressive scan: top to bottom, left to right.
B_VIDEO_BOTTOM_LEFT_RIGHT Bottom to top, left to right (BMP and TGA graphics are oriented this way).

Indicates the orientation of video data (whether the data is oriented top to bottom or bottom to top).


Defined Types


live_node_info

Declared in: be/media/MediaDefs.h
                                                         
  

struct live_node_info {
      live_node_info();
      ~live_node_info();
      media_node node;
      BPoint hint_point;
      char name[B_MEDIA_NAME_LENGTH];
      private:
      reserved[160];
      };

The live_node_info structure describes an active node, and is returned by BMediaRoster::GetLiveNodes().


media_addon_id

Declared in: be/media/MediaDefs.h
                                                         
  

typdef int32 media_addon_id;

A media add-on ID number.


media_audio_header

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_audio_header {
         int32 _reserved_[16];
      };

Defines the header of an audio buffer. There are no Be-defined fields in this structure as of the release of BeOS R4; however, you may append fields to the end of this structure if you wish.


media_buffer_id

Declared in: be/media/MediaDefs.h
                                                         
  

typdef int32 media_buffer_id;

A media buffer ID number.


media_destination

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_destination {
      media_destination(port_id, int32);
      media_destination(const media_destination &clone);
      media_destination & operator= (const media_destination &clone);
      media_destination();
      ~media_destination();
      port_id port;
      int32 id;
      static media_destination null;
      private:
         uint32 _reserved_media_destination_[2];
      };

Describes the destination end of a media connection between two nodes. The port indicates the port ID on which the destination communicates. This can be different from the media_node.port value.


media_encoded_audio_format

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_encoded_audio_format {
      enum audio_encoding {   
         B_ANY,
      };
      media_raw_audio_format output;
      audio_encoding encoding;
      float bit_rate;
      size_t frame_size;
      static media_encoded_audio_format wildcard;
      };

Describes the format of encoded audio data.


media_encoded_audio_header

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_encoded_audio_header {
      int32 _reserved_0[14];
      uint32 buffer_flags;
      uchar unused_mask;
      uchar _reserved_2[3];
      };

Defines the header of a an encoded audio buffer.

If you wish, you can add more fields to the end of the header.


media_encoded_video_format

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_encoded_video_format {
      enum video_encoding {   
         B_ANY
      };
      media_raw_video_format output;
      float avg_bit_rate;
      float max_bit_rate;
      video_encoding encoding;
      size_t frame_size;
      int16 forward_history;
      int16 backward_history;
      static media_encoded_video_format wildcard;
      };

Describes the format of encoded video data.


media_encoded_video_header

Declared in: be/media/MediaDefs.h
                                                         
  

struct first_active_line {
      uint32 first_active_line[9];
      uint32 first_active_line;
      int16 first_active_line;
      int16 first_active_line;
      uchar first_active_line;
      uchar first_active_line[3];
      float first_active_line;
      uint32 first_active_line;
      uint16 first_active_line;
      uint16 first_active_line;
      uint16 first_active_line;
      uint32 first_active_line;
      uint32 line_count;
      };

Defines the header of a video buffer. The fields in this buffer are the same as those in the media_video_header structure, except for the reserved fields, the forward_history and backward_history fields, the unused_mask, which indicates which bits are unused in the last byte of the video buffer, and field_flags, which can be either 0 or B_MEDIA_KEY_FRAME (which indicates that the field is a key frame).

The forward_history field indicates how many buffers ahead of the current one are required in order to decode the current buffer. The backward_history field indicates the number of previous buffers are required to decode the current buffer.

You may add fields to the end of this buffer if your video format requires them.


media_file_format

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_file_format {
      enum {   
         B_READABLE = 0x1,
         B_WRITABLE = 0x2,
         B_PERFECTLY_SEEKABLE = 0x4,
         B_IMPERFECTLY_SEEKABLE = 0x8,
         B_KNOWS_RAW_VIDEO = 0x10,
         B_KNOWS_RAW_AUDIO = 0x20,
         B_KNOWS_MIDI = 0x40,
         B_KNOWS_ENCODED_VIDEO = 0x80,
         B_KNOWS_ENCODED_AUDIO = 0x100,
         B_KNOWS_OTHER = 0x1000000,
         B_KNOWS_ANYTHING = 0x2000000
      };
      uint32 capabilities;
      media_file_format_id id;
      media_format_family family;
      int32 version;
      
      uint32 _reserved_[25];
      char mime_type[64];
      char pretty_name[64];
      char short_name[32];
      char file_extension[8];
      char reserved[88];
      };

Describes a media file format.


media_file_format_id

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_file_format_id {
      ino_t node;
      dev_t device;
      uint32 internal_id;
      };

A simple means for identifying file formats; used by the media_file_format structure.


media_format

Declared in: be/media/MediaDefs.h

   struct media_format {
      media_type type;
      type_code user_data_type;
      uchar user_data[64];
   
      private:
   
      void *meta_data;
      int32 meta_data_size;
      area_id meta_data_area;
      area_id use_area;
      team_id team;
      void *thisPtr;
   
      public:
   
      union {
         media_raw_audio_format raw_audio;
         media_raw_video_format raw_video;
         media_multistream_format multistream;
         media_encoded_audio_format encoded_audio;
         media_encoded_video_format encoded_video;
         char _reserved_[96];
      } u;
   
      bool IsVideo();
      uint32 &Width();
      uint32 &Height();
      color_space &ColorSpace();
   
      bool IsAudio();
      uint32 &AudioFormat();
   
      bool Matches(media_format *otherFormat);
      void SpecializeTo(media_format *otherFormat);
   
      void SetMetaData(void *data, int32 size);
      void *MetaData() const;
      int32 MetaDataSize() const;
   
      media_format();
      media_format(const media_format &other);
      ~media_format();
      media_format & operator=(const media_format &clone);
   };


The media_format structure can describe any media data format the BeOS can support.

If any field is 0, it's treated as a wildcard.

There are several convenience functions for fetching information from the format that take care of dealing with different types automatically:


media_header

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_header {
      media_type type;
      media_buffer_id buffer;
      int32 destination;
      media_node_id time_source;
      uint32 _depreciated_
      
uint32 size_used;
      bigtime_t start_time;
      area_id owner;
      enum {
         B_SEEK_TAG = 'TRST'
      };
      type_code user_data_type;
      uchar user_data[64];
      uint32 _reserved_[2];
      off_t file_pos;
      size_t orig_size;
      uint32 data_offset;
      union {
         media_audio_header raw_audio;
         media_video_header raw_video;
         media_multistream_header multistream;
         media_encoded_audio_header encoded_audio;
         media_encoded_video_header encoded_video;
         char _reserved_[64];
      } u;
      };

Defines the header of a media data buffer.


media_input

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_input {
      media_input();
      ~media_input();
      media_node node;
      media_source source;
      media_destination destination;
      media_format format;
      char name[B_MEDIA_NAME_LENGTH];
      private:
      _reserved_media_input_[4];
      };

The media_input structure describes a complete connection between a media_source and media_destination, from the point-of-view of the consumer (the destination).


media_multistream_format

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_multistream_format {
      enum {         B_ANY = 0,
         B_VID = 1,   
         B_AVI,
         B_MPEG1,
         B_MPEG2,
         B_QUICKTIME,
         B_PRIVATE = 90000,
         B_FIRST_USER_TYPE = 100000
      };
      float avg_bit_rate;
      float max_bit_rate;
      uint32 avg_chunk_size;
      uint32 max_chunk_size;
      enum {
         B_HEADER_HAS_FLAGS = 0x1,
         B_CLEAN_BUFFERS = 0x2,
         B_HOMOGENOUS_BUFFERS = 0x4
      };
      uint32 flags;
      int32 format;
      uint32 _reserved_[2];
      struct vid_info {
         float frame_rate;
         uint16 width;
         uint16 height;
         color_space space;
         float sampling_rate;
         uint32 sample_format;
         uint16 byte_order;
         uint16 channel_count;
      };
      struct avi_info {
         uint32 us_per_frame;
         uint16 width;
         uint16 height;
         uint16 _reserved_;
         uint16 type_count;
         media_type types[5];
      };
      union {
         vid_info vid;
         avi_info avi;
      } u;
      static media_multistream_format wildcard;
      };

Describes the format of multistream media data, such as a QuickTime, AVI, or MPEG movie.

vid_info

avi_info


media_multistream_header

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_multistream_header {
      uint32 _reserved_[14];
      uchar unused_mask;
      uchar _reserved_2[3];
      enum {
         B_MASTER_HEADER = 0x1,
         B_SUBSTREAM_HEADER = 0x2,
         B_COMPLETE_BUFFER = 0x4
      };
      uint32 flags;
      };

Defines the header of a multistream media buffer.

You may add fields to the end of this structure if your multistream media format requires them.


media_node

Declared in: <be/media/MediaDefs.h>
                                                         
  

class media_node {
      public:
      media_node();
      ~media_node();
      media_node_id node;
      port_id port;
      uint32 kind;
      static media_node null;
      private:
      uint32 _reserved_[3];
      };

The media_node structure is the class that defines a node to client applications; interactions with the BMediaRoster regarding nodes is done using media_node objects.

Applications will usually treat this as a black box.


media_node_attribute

Declared in: be/media/MediaNode.h
                                                         
  

struct media_node_attribute {
         enum {
            B_R40_COMPILED = 1,
            B_USER_ATTRIBUTE_NAME = 0x1000000,
            B_FIRST_USER_ATTRIBUTE
      
   };
         uint32 what;
         uint32 flags;
         uint64 data;
      };

The media_node_attribute structure provides additional information about nodes. Nodes can have as many of these as they want, and will return them from their BMediaNode::GetNodeAttributes() function. Applications query the node using the BMediaRoster::GetNodeAttributesFor() function.

The what field indicates the attribute type. B_R40_COMPILED indicates that the node was compiled using BeOS Release 4.0; BMediaNode returns this attribute automatically for nodes that were compiled using the Release 4.0 headers. Nodes may create their own attribute types, beginning at B_FIRST_USER_ATTRIBUTE.

The B_USER_ATTRIBUTE_NAME attribute specifies the name of a protocol for the user attributes implemented by the node. For example, if you devise a third-party standard for attribute values whose attribute IDs are greater than B_FIRST_USER_ATTRIBUTE, the value of B_USER_ATTRIBUTE_NAME would be the name of the standard.

The flags and data fields are used for different things depending on the what value; the B_R40_COMPILED attribute doesn't use them.


media_node_id

Declared in: be/media/MediaDefs.h
                                                         
  

typdef int32 media_node_id;

A node ID number.


media_output

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_output {
      media_output();
      ~media_output();
      media_node node;
      media_source source;
      media_destination destination;
      media_format format;
      char name[B_MEDIA_NAME_LENGTH];
      
      private:
      _reserved_media_output_[4];
      };

The media_output structure describes a complete connection between a media_source and media_destination, from the point-of-view of the consumer (the destination).


media_raw_audio_format

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_raw_audio_format {
      enum {   
         B_AUDIO_UCHAR = 0x11,
         B_AUDIO_SHORT = 0x2,
         B_AUDIO_FLOAT = 0x24,
         B_AUDIO_INT = 0x4
      }
      float frame_rate;
      uint32 channel_count;
      uint32 format;
      uint32 byte_order;
      size_t buffer_size;
      
      static media_raw_audio_format wildcard;
      };

Describes the format of raw audio data.

The frame_rate indicates the frame rate, in Hertz. One frame is one sample per channel (stereo buffers contain two samples per channel). For audio, each buffer contains multiple audio samples, whereas video contains one frame, or one field (half-frame) per buffer.

The channel_count indicates the number of channels of audio (typically this is either 1 for mono or 2 for stereo).

The format specifies the sample format (for compressed formats, see media_encoded_audio_format):

The byte_order indicates the endianness of the data (either B_MEDIA_BIG_ENDIAN or B_MEDIA_LITTLE_ENDIAN).

buffer_size indicates the size of each buffer.


media_raw_video_format

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_raw_video_format {
      float field_rate;
      uint32 interlace;
      uint32 first_active;
      uint32 last_active;
      uint32 orientation;
      uint16 pixel_width_aspect;
      uint16 pixel_height_aspect;
      media_video_display_info display
      

      static media_raw_video_format wildcard;
      };

Describes the format of raw video data.


media_request_info

Declared in: be/media/MediaNode.h
                                                         
  

struct media_request_info {
      enum what_code {
         B_SET_VIDEO_CLIPPING_FOR = 1,
         B_REQUEST_FORMAT_CHANGE,
         B_SET_OUTPUT_ENABLED,
         B_SET_OUTPUT_BUFFERS_FOR,
         B_FORMAT_CHANGED = 4097
      };
      what_code what;
      int32 change_tag;
      status_t status;
      int32 cookie;
      void * user_data;
      media_source source;
      media_destination destination;
      media_format format;
      uint32 _reserved_[32];
      };

This structure contains information that describes a request that has been completed (or has failed). It gets passed into the BMediaNode::RequestCompleted() function.

The what field describes what type of request has been completed:

The user_data field contains the userData pointer passed to the function that initiated the request; this can be anything the node making the request wants.

status indicates the status of the function called, and is B_OK if no error occurred.


media_seek_tag

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_seek_tag {
      char data[16];
      };

The media_seek_tag type is used to contain the seek tag data placed in buffer headers by producers. This can contain whatever information the producer deems necessary.


media_source

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_source {
      media_source(port_id, int32);
      media_source(const media_source &clone);
      media_source & operator= (const media_source &clone);
      media_source();
      ~media_source();
      port_id port;
      int32 id;
      static media_source null;
      private:
      uint32 _reserved_media_source_[2];
      };

Describes the source end of a media connection between two nodes. The port field indicates the port ID on which the source communicates. This must be the same as the media_node.port value.


media_video_display_info

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_video_display_info {
      color_space format;
      uint32 line_width;
      uint32 line_count;
      uint32 bytes_per_row;
      uint32 pixel_offset;
      uint32 line_offset;
      uint32 _reserved_[4];
      static media_video_display_info wildcard;
      };

Describes a video buffer in terms of how its contents should be interpreted in order to display it on the screen.


media_video_header

Declared in: be/media/MediaDefs.h
                                                         
  

struct media_video_header {
      uint32 _reserved_[11];
      float field_gamma;
      uint32 field_sequence;
      uint16 field_number;
      uint16 pulldown_number;
      uint32 first_active_line;
      uint32 line_count;
      };

Defines the header of a video buffer.

You may add fields to the end of this buffer if your video format requires them.


The Media Kit Table of Contents The Media Kit Index


The Be Book,
...in lovely HTML...
for BeOS Release 4.5.

Copyright © 1999 Be, Inc. All rights reserved.

Text last modified June 4, 1999.