PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFBMediaUtil
Wrapper Class for the IMediaUtil interface.
#include <SFBMediaUtil.h.hpp>
class SFBMediaUtil : public SFBQuery;
SFMTYPEDEFWRAPPER(SFBMediaUtil)

Inheritance diagram

 Inheritance diagram of SFBMediaUtilClass

Version

BREW 2.0 BREW 2.1 BREW 3.1 BREW 4.0
X O O O

Reference

BREW API IMediaUtil

Member

Public Functions
SFCError CreateMedia( AEEMediaData* data , SFBMediaSmpPtr media )
Given media data, this function analyzes media data and creates a SFBMedia-based object (SFBMedia Interface object).
SFCError CreateMediaEx( AEEMediaCreateInfo* info , SFBMediaSmpPtr media )
Provide more flexibility than SFBMediaUtil::CreateMedia to specify information required to create SFBMedia based object.
SFCError EncodeJPEG( AEEMediaEncodeResult* result , AEEMediaEncodeInfo* spec , SFXCallbackPtr callback )
Encode a media of JPEG format based on encode specifications and one or more input media.
SFCError EncodeMedia( AEEMediaEncodeResult* result , AEECLSID clsidDest , AEEMediaEncodeInfo* spec , SFXCallbackPtr callback )
Encode a new media of specified format based on encode specifications and one or more input media.
SFCError EncodePMD( AEEMediaEncodeResult* result , AEEMediaEncodeInfo* spec , SFXCallbackPtr callback )
Encode a media of the PMD format based on encode specifications and one or more input media (typically JPEG and QCP).
static
SFBMediaUtilSmp
NewInstance( SFCErrorPtr exception = null )
SCreate a new SFBMediaUtil instance.
static
SFBMediaUtilSmp
NewInstance( AEECLSID id , SFCErrorPtr exception = null )
SCreate a new SFBMediaUtil instance.
SFCError QueryInterface( AEECLSID clsid , VoidHandle handle ) (inherits from SFBQuery)
Ask an object for another API contract from the object in question.
SFCError QueryInterface( AEECLSID clsid , SFBBaseSmpPtr handle ) (inherits from SFBQuery)
Ask an object for another API contract from the object in question.
SFBBaseSmp QueryInterface( AEECLSID clsid ) (inherits from SFBQuery)
Ask an object for another API contract from the object in question.
Void Self( AEECLSID clsidReq , SFBQuerySmpPtr clone , AEECLSID clsidImp ) (inherits from SFBQuery)
Helper macro for those implementing an object with a single interface.
SFBQuerySmp Self( AEECLSID clsidReq , AEECLSID clsidImp ) (inherits from SFBQuery)
Helper macro for those implementing an object with a single interface.
Protected Functions
static
SFBBaseSmp
FactoryByCreate( AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface.
static
SFBBaseSmp
FactoryByQuery( SFBQuerySmpConstRef query , AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface using the SFBQuery instance.

SFBMediaUtil::CreateMedia
Given media data, this function analyzes media data and creates a SFBMedia-based object (SFBMedia Interface object).
[ public ]
SFCError CreateMedia(
    AEEMediaData* data     // media data info 
    SFBMediaSmpPtr media   // SFBMedia object pointer returned to caller 
);

Example

Create a instance of SFBMedia derived dlass with SFBMediaUtil::CreateMedia(), play back sound.

#include <SophiaFramework.hpp>
#include "MediaSample.bid"

//
// mediaSample application class
// SFMTYPEDEFCLASS(MediaSample)
class MediaSample : public SFRApplication
{
private:
    SFBMediaSmp             _media;
    AEEMediaData            _mdata;

public:
    static SFCInvokerPtr ructorConst() { return new MediaSample; }

private:
    MediaSample(Void);

    // hide to prevent copy.
    MediaSample(MediaSampleConstRef);
    MediaSampleConstRef operator = (ConstMediaSampleRef);

    // handler for application start.
    Void OnAppStart(Void);
    static Bool OnAppStartEntry(SFXEventConstRef event, VoidPtr data)
    { MediaSamplePtr(data)->OnAppStart(); return true; }

    // handler for application end.
    Void OnAppStop(Void);
    static Bool OnAppStopEntry(SFXEventConstRef event, VoidPtr data)
    { MediaSamplePtr(data)->OnAppStop(); return true; }

};

// boot code of BREW Application.
SFCInvokerSPP SFCApplet::Boot(AEECLSID id)
{
    if (id == AEECLSID_MEDIASAMPLE)
    {
        return MediaSample::ructorConst;
    }
    else
    {
        return null;
    }
}

// constructor
MediaSample::MediaSample(Void)
{
    // register event handler 
    RegisterHandler(SFEVT_APP_START, HANDLER_BEFORE, OnAppStartEntry, this);
    RegisterHandler(SFEVT_APP_STOP, HANDLER_BEFORE, OnAppStopEntry, this);

    // initialize the media data
    _mdata.pData = null;
}

// handler for application start.
Void MediaSample::OnAppStart(Void)
{
    // play back sound with SFBMediaUtil object
    SFBShellSmp         shell    = SFBShell::GetInstance();
    SFBMediaUtilSmp     mutil    = SFBMediaUtil::NewInstance();
    const char*         filename = "sample.mid";

    if (mutil != null) {
        // set media data
        _mdata.clsData  = MMD_FILE_NAME;
        _mdata.pData    = STRDUP(filename);
        _mdata.dwSize   = 0;

        // create a instance of SFBMedia derived dlass
        mutil->CreateMedia(&_mdata, &_media);
    }

    if (_media != null) {
        // play back media
        _media->Play();
    }

}

// handler for application end.
Void MediaSample::OnAppStop(Void)
{
    // abandon the media data
    if (_mdata.pData != null) {
        FREE(_mdata.pData);
    }
}

Reference

BREW API IMEDIAUTIL_CreateMedia


SFBMediaUtil::CreateMediaEx
Provide more flexibility than SFBMediaUtil::CreateMedia to specify information required to create SFBMedia based object.
[ public ]
SFCError CreateMediaEx(
    AEEMediaCreateInfo* info   // pointer to structure containing creating information
    SFBMediaSmpPtr media       // pointer that receives instance of SFBMedia derived class
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If invalid argument: SFERR_INVALID_PARAM
  • Class not found: SFERR_UNSUPPORTED
  • If failed: SFERR_FAILED
  • Media data is not correct : MM_EBADMEDIADATA
  • If insufficient memory : MM_ENOMEDIAMEMORY
  • Need more data to create SFBMedia object : ENEEDMORE
  • Error while peeking for the data : MM_EPEEK
  • Aborted due to insufficient data : MM_ENOTENOUGHDATA

Reference

BREW API IMEDIAUTIL_CreateMediaEx


SFBMediaUtil::EncodeJPEG
Encode a media of JPEG format based on encode specifications and one or more input media.
[ public ]
SFCError EncodeJPEG(
    AEEMediaEncodeResult* result   // pointer to resulting encoding info 
    AEEMediaEncodeInfo* spec       // input encode specifications 
    SFXCallbackPtr callback        // callback for asynchronous notifications 
);

Reference

BREW API IMEDIAUTIL_EncodeJPEG


SFBMediaUtil::EncodeMedia
Encode a new media of specified format based on encode specifications and one or more input media.
[ public ]
SFCError EncodeMedia(
    AEEMediaEncodeResult* result   // pointer to resulting encoding info 
    AEECLSID clsidDest             // destination encode ClassID
    AEEMediaEncodeInfo* spec       // input encode specifications 
    SFXCallbackPtr callback        // callback for asynchronous notifications 
);

Reference

BREW API IMEDIAUTIL_EncodeMedia


SFBMediaUtil::EncodePMD
Encode a media of the PMD format based on encode specifications and one or more input media (typically JPEG and QCP).
[ public ]
SFCError EncodePMD(
    AEEMediaEncodeResult* result   // pointer to resulting encoding info 
    AEEMediaEncodeInfo* spec       // input encode specifications 
    SFXCallbackPtr callback        // callback for asynchronous notifications 
);

Reference

BREW API IMEDIAUTIL_EncodePMD


SFBMediaUtil::NewInstance
SCreate a new SFBMediaUtil instance.
[ public, static ]
SFBMediaUtilSmp NewInstance(
    SFCErrorPtr exception = null   // Error
);
[ public, static ]
SFBMediaUtilSmp NewInstance(
    AEECLSID id                    // Class ID
    SFCErrorPtr exception = null   // Error
);