[ Previous | Next | Contents | Glossary | Home | Search ]
Ultimedia Services Version 2 for AIX: Programmer's Guide and Reference

Using MetaClasses

The use of metaclasses is described using UMSAudioDeviceMClass as an example. This example can be extrapolated and applied to other metaclasses. The UMSAudioDeviceMClass provides the method:

make_by_alias (
   in string alias,
   in string mode,
   in long flags,
   inout ErrorCode error,
   out string error_string,
   out string audio_formats_alias,
   out string audio_inputs_alias,
   out string audio_outputs_alias
   );

You can construct a generic UMSAudioDevice by defining an audio device alias and a mode (play or record) in the UMS_config configuration file. Any of the audio devices contained within the device alias stanza of the configuration file are acceptable to the application. The first available device supporting the mode is returned.

Audio devices differ in the supported formats, inputs, and outputs. Capabilities of specific audio devices are specified in the respective alias stanzas for the device. These aliases are returned by the construction method to permit the application to further query device capability. (All Ultimedia Services audio devices minimally support formats of PCM, A_law and mu_law.) If successful, a device is returned opened for the specified mode and with default input or output connections.

An instance of the UMSAudioDeviceMClass (a class object) is created using the following procedure:

<className>NewClass(MajorVersion,MinorVersion)

Defined in the class header file (in this case, UMSAudioDevice.h). The MajorVersion and MinorVersion parameters specify the minimally acceptable revision level of the object (object revision levels are specified in the className.idl in the include directory for the product and are defined in the className header file).

An example using the metaclass to construct a generic UMSAudioDevice follows.

  1. Include the className header file:
    #include <UMSAudioDevice.h>
  2. Declare the object and parameter variables:
    UMSAudioDeviceMClass audioDeviceClass = NULL ;
    UMSAudioDevice adev = NULL;
UMSAudioDeviceMClass_ErrorCode errorCode:
string device_alias = "Audio"; /* any audio device */ 
string mode = "PLAY"; /* acquire device for PLAY mode */
string errorString ; /* to access returned errorString */
string inputAlias ; /* to access returned inputAlias */
string outputAlias ; /* to access returned outputAlias */
string audioFormatAlias ; /* to access returned outputAlias */
long block = 1;
  1. Construct a metaclass:
    audioDeviceClass = UMSAudioDeviceNewClass
    (UMSAudioDevice_MajorVersion, UMSAudioDevice_MinorVersion);
  2. Construct the generic object:
    adev = UMSAudioDeviceMClass_make_by_alias( audioDeviceClass,
    somGetGlobalEnvironment(), device_alias,mode, block,
    &errorCode, &errorString, &audioFormatAlias,
    &inputAlias, &outputAlias); 

UMSAudioFileMClass and UMSMovieFileReaderMClass construct media file access objects with methods:

make_by_pathname
&
make_by_alias

The make_by_pathname method detects the file type of a given file and constructs the appropriate file access object. If a specific file type object is desired, the make_by_alias method constructs the desired file access object given the file type alias.

The UMSVideoDecoderMClass constructs UMSVideoDecoder objects with the method:

make_by_transformation

This method constructs an appropriate decoder object given the desired input data format and output data format of the decoder.

For introductory information, see Programming with MetaClass Objects.


[ Previous | Next | Contents | Glossary | Home | Search ]