BMediaFormats

Derived from: none

Declared in: be/media/MediaFormats.h

Library: libmedia.so

Allocation: Constructor only

[method summary]

The BMediaFormat class provides a means for translating between BeOS media format identifiers and those used by the codecs themselves. This is primarily useful if you're writing a codec add-on or a file format parser.


Supported Codecs

The BMediaFormats class currently knows how to translate among the following formats' codec identification methods:

  • BeOS
    BeOS uses a constant within the media_format structure to indicate the kind of media being handled.

  • QuickTime
    QuickTime uses a two-word vendor/codec pair to indicate the type of media.

  • AVI
    The media format is indicated by a one-word constant.

  • ASF
    The media format is indicated by a 128-bit UUID value.


    Member Function Summary

    Function Description
    virtual GetNextRef() Returns the next entry_ref for a given media type.
    virtual GetNextType() Returns the next media type that's in the registry.
    virtual GetRefFor() Returns the entry_ref for a specific type and item name.
    virtual RemoveRefFor() Removes the entry_ref for a specific type and item name.
    virtual SetRefFor() Sets the entry_ref for a specific type and item name.
    virtual RewindRefs() Rewinds to the beginning of the entry_refs list for a given type.
    virtual RewindTypes() Rewinds the the beginning of the media type list.


    Constructor and Destructor


    BMediaFormats()

          BMediaFormats(void) 

    Constructor. Call InitCheck() to ensure that the object was initialized properly after you instantiate it.


    ~BMediaFormats()

          virtual ~BMediaFormats(void) 

    Destructor.


    Member Functions


    GetCodeFor()

          status_t GetCodeFor(const media_format &format,
             media_format_family family,
             media_format_description *outDescription)

    Given the specified media format, returns in outDescription the media format description for the specified format family.

    RETURN CODES

    B_OK. No error.

    B_MEDIA_BAD_FORMAT. The specified format isn't recognized.

    Other errors. The code couldn't be determined.


    GetFormatFor()

          status_t GetFormatFor(const media_format_description &description
             media_format *outFormat)

    Returns in outFormat a media_format structure that describes the media format specified by description. This lets you easily obtain a media_format structure from file-native description information.

    RETURN CODES

    B_OK. No error.

    B_MEDIA_BAD_FORMAT. The specified description isn't recognized.

    Other errors. The format couldn't be determined.


    GetNextFormat()

          status_t GetNextFormat(media_format *outFormat,
             media_format_description *outDescription)

    Fills outFormat and outDescription with the media_format and media_format_description of the next supported media format.

    RETURN CODES

    B_OK. No error.

    B_BAD_INDEX. No more formats to return.

    Other errors. The format couldn't be determined.


    InitCheck()

          status_t InitCheck(void)

    Returns the status code from the constructor; you should call this to be sure the object was properly initialized before issuing any other calls.

    RETURN CODES

    B_OK. The object is ready to use.

    B_BAD_HANDLER. The object isn't ready.

    Other errors. The Media Server couldn't be contacted.


    Lock(), Unlock()

          bool Lock(void)
          void Unlock(void)

    Lock() locks the BMediaFormats object so you can use it with the assurance that it won't change while you're working. You should call this before using any of the other BMediaFormats functions. Returns true if it's safe to use the BMediaFormats object; otherwise returns false.

    Unlock() releases the BMediaFormats object when you're done with it; be sure to call it when you've finished your work.


    MakeFormatFor()

          status_t MakeFormatFor(const media_format_description &description
             media_format &inFormat,
             media_format *outFormat)

    Given the media format description description and the media_format inFormat, registers your format description and supported media_format with the Media Kit, and returns a media_format you can use from then on.

    This function is called to let the Media Server assign you an encoding value for your media_format_description. If you're implementing a codec add-on or a file parser, you should call this function to let the Media Kit know what you handle.

    RETURN CODES

    B_OK. No error.

    Other errors. The format couldn't be registered.


    RewindFormats()

          status_t RewindFormats(void)

    Resets format scanning to the first supported format; this causes GetNextFormat() to start at the beginning of the list.

    RETURN CODES

    B_OK. The object is ready to use.

    Other errors. Unable to communicate with the Media Server.


    Unlock() see Lock()


    Constants


    Media Format Families

    Declared in: <be/media/MediaFormats.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.

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

    ASF isn't currently supported.


    Defined Types


    media_beos_description

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

       
       typedef struct {
          int32 format;
       } media_beos_description;

    Describes the format of media data in a way the BeOS Media Kit understands and appreciates. The format field has no predetermined meaning; it's a magic number that only the Media Kit understands.


    media_quicktime_description

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

       
       typedef struct {
          uint32 codec;
          uint32 vendor;
       } media_quicktime_description;

    Describes the format of media data as a QuickTime codec/vendor pair.


    media_avi_description

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

       
       typedef struct {
          uint32 codec;
       } media_avi_description;

    Describes the format of media data as an AVI codec ID.


    media_format_description

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

       
       typedef struct _media_format_description {
       #if defined(__cplusplus)
          _media_format_description();
          ~_media_format_description();
          _media_format_description(const _media_format_description &other);
          _media_format_description & operator=(const _media_format_description
                &other);
       #endif
          media_format_family family;
          uint32 _reserved_[3];
          union {
             media_beos_description beos;
             media_quicktime_description quicktime;
             media_avi_description avi;
       #if GUID_SUPPORT
             media_asf_description asf;
       #endif
             uint32 _reserved_[12];
          } u;
       } media_format_description;

    Describes a media format. The family indicates which media family in the union the description uses to identify the format.

    ASF format isn't currently supported.





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

    Copyright © 1998 Be, Inc. All rights reserved.

    Last modified November 3, 1998.