IRIX 5.3 » Books » Developer »
IRIS Digital Media Programming Guide
(document number: 007-1799-040 / published: 1994-11-14)
table of contents | additional info | download find in page
Chapter 2. Programming with the Digital Media Library
The Digital Media (DM) Library, libdmedia.so, is a library that provides type definitions for digital media and currently supports parameter setting and ring buffering for applications that use the IRIS digital media libraries.
This chapter contains basic concepts for working with the Digital Media Library. It describes the digital media data types and explains how to use the digital media parameters.
Digital Media Library Basics
It is not likely that you'll use the DM Library by itself. Typically, you call DM Library routines from an application that is written using one or more of the IRIS digital media libraries. Currently, you can use the DM routines with the Movie Library and the Video Library.
The DM Library features:
type definitions for digital media
routines for creating and configuring digital media parameters
routines for creating and configuring digital media ring buffers
a debugging version of the library that lets you check for proper usage
Digital Media Type Definitions
The DM Library provides type definitions for digital media. Data types and constant names have an uppercase DM prefix; routines have a lowercase dm prefix.
The dmedia/dmedia.h header file provides these type definitions:
| DMboolean | | integer for conditionals; DM_FALSE is 0 and DM_TRUE is 1
| | DMfraction | | integer numerator divided by integer denominator
| | DMstatus | | enumerated type consisting of DM_SUCCESS and DM_FAILURE
|
Table 2-1 lists the digital media parameter type definitions that are defined in dmedia/dm_params.h.
Table 2-1. Digital Media Parameter Types
Parameter Type
| Meaning
|
|---|
DM_TYPE_ENUM
| Enumerated type
| DM_TYPE_ENUM_ARRAY
| Array of enumerated types
| DM_TYPE_INT
| Integer value
| DM_TYPE_INT_ARRAY
| Array of integers
| DM_TYPE_INT_RANGE
| Range of integers
| DM_TYPE_STRING
| String
| DM_TYPE_STRING_ARRAY
| Array of strings
| DM_TYPE_FLOAT
| Floating point value
| DM_TYPE_FLOAT_ARRAY
| Array of floats
| DM_TYPE_FLOAT_RANGE
| Range of floats
| DM_TYPE_FRACTION
| Ratio
| DM_TYPE_FRACTION_ARRAY
| Array of fractions
| DM_TYPE_FRACTION_RANGE
| Range of fractions
| DM_TYPE_PARAMS
| Parameter-value list
| DM_TYPE_TOC_ENTRY
| Table-of-contents entry for ring buffers
|
Parameter-value lists are used to store configuration information for movies, movie tracks, ring buffers, and video paths. A parameter-value list is a list of pairs, where each pair contains the name of a parameter and the corresponding value for that parameter.
Typical ways in which you might use a parameter-value list include:
passing a parameter-value list to a routine that configures a structure
passing a parameter-value list that contains new parameter settings to a routine that changes the settings
using convenience routines provided by one of the IRIS digital media libraries to set and get parameter values that apply to that library
Every parameter-value list that describes a format includes the parameter DM_MEDIUM to indicate what kind of data it describes. DM_MEDIUM is an enumerated type consisting of DM_IMAGE and DM_AUDIO.
The routines described in this chapter follow the general rule that ownership of data is not passed during procedure calls, except in the routines that create and destroy parameter-value lists. Functions that take strings copy the strings if they want to keep them. Functions that return strings or other structures retain ownership and the caller must not free them.
Compiling and Linking a Digital Media Library Application
Applications that call DM Library routines must include the libdmedia header files to obtain definitions for the library; however, these files are usually included in the header file of the library you are using.
This code fragment includes all the libdmedia header files:
#include <dmedia/dmedia.h>
#include <dmedia/dm_audio.h>
#include <dmedia/dm_image.h>
#include <dmedia/dm_params.h>
|
Link with the DM Library when compiling an application that makes DM Library calls by including -ldmedia on the link line. It's likely that you'll be linking with other libraries as well, and because the linking order is usually specific, follow the linking instructions for the library you are using.
Debugging a Digital Media Library Application
The debugging version of the DM Library checks for library usage violations by setting assertions that state the requirements for a parameter or value.
To debug your DM application, link with the debugging version of the DM Library, libdmedia_d.so, by using -ldmedia_d instead of -ldmedia, and then run your program. Your application will abort with an error message if it fails an assertion. The message explains the situation that caused the error and, by implication or by explicit description, suggests a corrective action.
When you have finished debugging your application, you should relink with the nondebugging library, libdmedia.a, because the runtime checks imposed by the debugging library cause an undesirable size and performance overhead for a packaged application.
Initializing a Digital Media Application
This section explains how to use the DM Library routines for:
creating and destroying parameter-value lists
creating default audio and image configurations
setting and getting values in parameter-value lists
manipulating parameter-value lists
In the initialization section of your application, you create and use parameter-value lists to configure data structures for your application as described in the following steps:
Create an empty parameter-value list by calling dmParamsCreate().
Set the parameter values by one of the methods listed below:
Free the parameter-value list and its contents by calling dmParamsDestroy().
These steps are described in detail in the sections that follow.
Creating and Destroying Parameter-value Lists
Some libraries require you to allocate memory for parameter-value lists, but with the DM library, you need not allocate memory for parameter-value lists, because memory management is provided for you by the dmParamsCreate() and dmParamsDestroy() routines. These routines work together as a self-contained block within which you create the parameter-value list, set the parameter value(s) and use them, and then destroy the structure, freeing its associated memory.
dmParamsCreate() is the only function that can create a parameter-value list, and dmParamsDestroy() is the only function that can free one. This means that parameter-value lists are managed correctly when every call to create one is balanced by a call to destroy one.
The creation function can fail because of lack of memory, so it returns an error code. The destructor can never fail.
To create an empty parameter-value list, call dmParamsCreate(). Its function prototype is:
DMstatus dmParamsCreate ( DMparams** returnNewList )
|
where:
| returnNewList | | is a pointer to a handle that is returned by the DM Library
|
If there is sufficient memory to allocate the structure, a pointer to the newly created structure is put into *returnNewList and DM_SUCCESS is returned; otherwise, DM_FAILURE is returned.
When you have finished using the parameter-value list, you must destroy it to free the associated memory. To free both the parameter-value list structure and its contents, call dmParamsDestroy(). Its function prototype is:
void dmParamsDestroy ( DMparams* params )
|
where:
| params | | is a pointer to the parameter-value list you want to destroy
|
Example 2-1 is a code fragment that creates a parameter-value list called params, then calls a Movie Library routine, mvSetDefaults(), to initialize the default movie parameters, and then destroys the list, freeing both the structure and its contents.
Example 2-1. Creating and Destroying a Parameter-value List
DMparams* params;
if ( dmParamsCreate( ¶ms ) != DM_SUCCESS ) {
printf( "Out of memory.\n" );
exit( 1 );
}
if ( mvSetMovieDefaults(params, MV_FORMAT_SGI_3) != DM_SUCCESS ) {
printf( "Out of memory.\n" );
exit( 1 );
}
dmParamsDestroy ( params );
|
Creating Default Audio and Image Configurations
There are standard parameters that apply to images (for video and movies) and standard parameters that apply to audio (for movies). This section explains how to use the DM Library convenience routines that initialize parameter-value lists for standard audio and image configurations.
Audio uses these parameters:
audio channels
audio compression scheme
audio sample format (e.g., twos-complement binary, floating point)
audio sample rate
audio sample width (number of bits per sample)
Table 2-2 lists the audio parameters and the valid values for each (not all values are supported by all libraries).
Table 2-2. Audio Parameters
Parameter
| Type
| Values
|
|---|
DM_AUDIO_CHANNELS
| Integer
| 1, 2, or 4
| DM_AUDIO_COMPRESSIO
N
| String
| DM_AUDIO_UNCOMPRESSED (default)
DM_AUDIO_G711_U_LAW
DM_AUDIO_G711_A_LAW
DM_AUDIO_MPEG
DM_AUDIO_MPEG1
DM_AUDIO_MULTIRATE
DM_AUDIO_G722
| DM_AUDIO_FORMAT
| DMaudioforma
t
| DM_AUDIO_TWOS_COMPLEMENT
(default)
DM_AUDIO_UNSIGNED
DM_AUDIO_FLOAT
DM_AUDIO_DOUBLE
| DM_AUDIO_RATE
| Double
| Native rates are 8000, 11025, 16000, 22050, 32000,
44100, and 48000 Hz
| DM_AUDIO_WIDTH
| Integer
| 8, 16, or 24
|
See Part II, “Digital Audio and MIDI Programming,” for complete definitions of the audio parameters.
See “Setting and Getting Audio Track Properties” in Chapter 28 for a description of audio parameters that apply to Movie Library programs.
To initialize a parameter-value list with the default audio configuration, call dmSetAudioDefaults(), passing in the desired sample width, sample rate, and number of channels. Its function prototype is:
DMstatus dmSetAudioDefaults ( DMparams* params, int width,
double rate, int channels )
|
where:
| params | | is a pointer to a parameter-value list that was returned from dmParamsCreate()
| | width | | is the number of bits per audio sample: 8, 16, or 24
| | rate | | is the audio sample rate; the native audio sample rates are 8000, 11025, 16000, 22050, 32000, 44100, and 48000 Hz
| | channels | | is the number of audio channels: 1, 2, or 4
|
dmSetAudioDefaults() returns DM_SUCCESS if there was enough memory available to set up the parameters; otherwise, it returns DM_FAILURE.
Table 2-3 lists the parameters and values set by dmSetAudioDefaults().
Table 2-3. Audio Defaults
Parameter
| Default
|
|---|
DM_MEDIUM
| DM_AUDIO
| DM_AUDIO_WIDTH
| width
| DM_AUDIO_FORMAT
| DM_AUDIO_TWOS_COMPLEMENT
| DM_AUDIO_RATE
| rate
| DM_AUDIO_CHANNELS
| channels
| DM_AUDIO_COMPRESSION
| DM_AUDIO_UNCOMPRESSED
|
Determining the Buffer Size Needed to Store an Audio Frame
To determine the audio frame size for a given parameter-value list, call dmAudioFrameSize(). dmAudioFrameSize() returns the number of bytes needed to store one audio frame (one sample from each channel). Its function prototype is:
size_t dmAudioFrameSize ( DMparams* params )
|
Example 2-2 is a code fragment that creates a parameter-value list, fills in the audio defaults, and then frees the structure and its contents.
Example 2-2. Setting Audio Defaults
DMparams* audioParams;
if ( dmParamsCreate( &audioParams ) != DM_SUCCESS ) {
printf( "Out of memory.\n" );
exit( 1 );
}
if ( dmSetAudioDefaults ( audioParams,
16, /* width (in bits/sample) */
22050, /* sampling rate */
2 /* # channels (stereo) */
) != DM_SUCCESS ) {
printf( "Out of memory.\n" );
exit( 1 );
}
printf( "%d bytes per audio frame.\n",
dmAudioFrameSize( audioParams ) );
dmParamsDestroy( audioParams );
|
Images use these parameters:
image compression scheme
image dimensions (width and height)
image interlacing
image orientation (top-to-bottom vs. bottom-to-top)
image packing format
image rate (number of frames per second)
Table 2-4 lists the image parameters and the valid values for each (not all values are supported by all libraries).
Table 2-4. Image Parameters
Parameter
| Values
|
|---|
DM_IMAGE_HEIGHT
| Integer value
| DM_IMAGE_WIDTH
| Integer value
| DM_IMAGE_RATE
| Floating point value
| DM_IMAGE_COMPRESSION
| DM_IMAGE_UNCOMPRESSED
DM_IMAGE_RLE
DM_IMAGE_RLE24
DM_IMAGE_JPEG
DM_IMAGE_MPEG1
DM_IMAGE_MVC1
DM_IMAGE_MVC2
DM_IMAGE_RTR
DM_IMAGE_HDCC
DM_IMAGE_QT_VIDEO
DM_IMAGE_QT_ANIM
| DM_IMAGE_INTERLACING
| DM_IMAGE_NONINTERLACED (full frame)
DM_IMAGE_INTERLACED_EVEN (two fields,
even field first)
DM_IMAGE_INTERLACED_ODD (two fields,
odd field first)
DM_IMAGE_NONINTERLEAVED (obsolete,
use DM_IMAGE_NONINTERLACED instead)
DM_IMAGE_INTERLEAVED(obsolete, use
DM_IMAGE_INTERLACED_ODD instead)
| DM_IMAGE_ORIENTATION
| DM_TOP_TO_BOTTOM
DM_BOTTOM_TO_TOP
| DM_IMAGE_PACKING
| DM_PACKING_RGB
DM_PACKING_RGBX
DM_PACKING_RGBA
DM_PACKING_RGB332 (Indigo Entry graphics)
DM_PACKING_RGB8
DM_PACKING_GRAYSCALE
DM_PACKING_YUV
DM_PACKING_YUV411
DM_PACKING_YUV422
DM_PACKING_YUV422HC
DM_PACKING_APPLE_32
DM_PACKING_APPLE_16
DM_PACKING_Y (equivalent to
DM_PACKING_GRAYSCALE)
DM_PACKING_YCbCr (equivalent to
DM_PACKING_YUV)
DM_PACKING_YCbCr422 (equivalent to
DM_PACKING_YUV422)
DM_PACKING_YCbCr422HC (equivalent to
DM_PACKING_YUV422HC)
DM_PACKING_YUV422DC (equivalent to
DM_PACKING_YUV422HC)
DM_PACKING_YCbCr422DC (equivalent to
DM_PACKING_YUV422HC)
|
See “Setting and Getting Image Track Properties” in Chapter 28 for a description of image parameters that apply to Movie Library programs. See Table 12-10 in Chapter 12, “Getting Started with the Video Library,” for a description of image parameters that apply to Video Library programs.
To initialize a parameter-value list with the default image configuration, call dmSetImageDefaults(), passing in the width and height of the image frame, and the image packing format. Its function prototype is:
DMstatus dmSetImageDefaults ( DMparams* params, int width,
int height, DMpacking packing )
|
where:
| params | | is a pointer to a parameter-value list that was returned from dmParamsCreate()
| | width | | is the width of the image
| | height | | is the height of the image
| | packing | | is the image packing format
|
Table 2-5 lists the parameters and values set by dmSetImageDefaults().
Table 2-5. Image Defaults
Parameter
| Default
|
|---|
DM_MEDIUM
| DM_IMAGE
| DM_IMAGE_WIDTH
| width
| DM_IMAGE_HEIGHT
| height
| DM_IMAGE_RATE
| 15.0
| DM_IMAGE_INTERLACING
| DM_IMAGE_NONINTERLACED
| DM_IMAGE_PACKING
| packing
| DM_IMAGE_ORIENTATION
| DM_BOTTOM_TO_TOP
| DM_IMAGE_COMPRESSION
| DM_IMAGE_UNCOMPRESSED
|
Determining the Buffer Size Needed to Store an Image Frame
To determine the image frame size for a given parameter-value list, call dmImageFrameSize(). dmImageFrameSize() returns the number of bytes needed to store one uncompressed image frame in the given format. Its function prototype is:
size_t dmImageFrameSize ( DMparams* params )
|
Example 2-3 is a code fragment that creates a parameter-value list, fills in the image defaults, and then frees the structure and its contents.
Example 2-3. Setting Image Defaults
DMparams* imageParams;
if ( dmParamsCreate( &imageParams ) != DM_SUCCESS ) {
printf( "Out of memory.\n" );
exit( 1 );
}
if ( dmSetImageDefaults( imageParams,
320, /* width */
240, /* height */
DM_PACKING_RGBX ) != DM_SUCCESS ) {
printf( "Out of memory.\n" );
exit( 1 );
}
printf( "%d bytes per image frame.\n",
dmImageFrameSize( imageParams ) );
dmParamsDestroy( imageParams );
|
Setting and Getting Individual Parameter Values
After creating an empty parameter-value list or a default audio or image configuration, you can use the routines described in this section to set and get values for individual elements of a parameter-value list.
There is a routine for setting and getting the parameter values for each parameter data type defined in the DM Library, as listed in Table 2-1.
All of these functions store and retrieve entries in parameter-value lists. They assume that the named parameter is present and is of the specified type; the debugging version of the library asserts that this is the case. All functions that can possibly fail return an error code indicating success or failure. Insufficient memory is the only reason these routines can fail.
Table 2-6 lists the DM Library routines for setting parameter values. These routines require three arguments:
| params | | a pointer to a parameter-value list
| | paramName | | the name of the parameter whose value you want to set
| | value | | a value of the appropriate type for the given parameter
Table 2-6. DM Library Routines for Setting Parameter Values
Routine
| Purpose
|
|---|
dmParamsSetInt()
| Sets the value of a parameter whose type is DMint
| dmParamsSetIntArray()
| Sets the value of a parameter whose type is
DMintarray
| dmParamsSetIntRange()
| Sets the value of a parameter whose type is
DMintrange
| dmParamsSetEnum()
| Sets the value of a parameter whose type is DMenum
| dmParamsSetEnumArray(
)
| Sets the value of a parameter whose type is
DMenumarray
| dmParamsSetFloat()
| Sets the value of a parameter whose type is DMfloat
| dmParamsSetFloatArray()
| Sets the value of a parameter whose type is
DMfloatarray
| dmParamsSetFloatRange()
| Sets the value of a parameter whose type is
DMfloatrange
| dmParamsSetFract()
| Sets the value of a parameter whose type is DMfract
| dmParamsSetFractArray()
| Sets the value of a parameter whose type is
DMfractionarray
| dmParamsSetFractRange()
| Sets the value of a parameter whose type is
DMfractionrange
| dmParamsSetParams()
| Sets the value of a parameter whose type is DMparam
| dmParamsSetString()
| Sets the value of a parameter whose type is DMstring
| dmParamsSetStringArray(
)
| Sets the value of a parameter whose type is
DMstringarray
| dmParamsSetTocEntry()
| Sets the value of a parameter whose type is
DMTocEntry
|
|
These routines return either DM_SUCCESS or DM_FAILURE.
Table 2-7 lists the DM Library routines for setting parameter values. These routines require two arguments:
| params | | a pointer to a parameter-value list
| | paramName | | the name of the parameter whose value you want to get
|
Routines that get values return either a pointer to a value or the value itself. For strings, parameter-value lists, and table-of-contents entries, the pointer that is returned points into the internal data structure of the parameter-value list. This pointer should never be freed and is only guaranteed to remain valid until the next time the list is changed. In general, if you need to keep a string value around after getting it from a parameter-value list, it should be copied.
Table 2-7. DM Library Routines for Getting Parameter Values
Routine
| Purpose
|
|---|
dmParamsGetInt()
| Returns an integer value for the given parameter
| dmParamsGetIntArray()
| Returns a pointer to a value of type DMintarray for
the given parameter
| dmParamsGetIntRange()
| Returns a pointer to a value of type DMintrange for
the given parameter
| dmParamsGetEnum()
| Returns an integer value for the given parameter
| dmParamsGetEnumArray(
)
| Returns a pointer to a value of type DMenumarray
for the given parameter
| dmParamsGetString()
| Returns a pointer to a value of type const char for the
given parameter
| dmParamsGetStringArray(
)
| Returns a pointer to a value of type DMstringarray
for the given parameter
| dmParamsGetFloat()
| Returns a value of type double for the given
parameter
| dmParamsGetFloatArray()
| Returns a pointer to a value of type DMfloatarray for
the given parameter
| dmParamsGetFloatRange()
| Returns a pointer to a value of type DMfloatrange for
the given parameter
| dmParamsGetFract()
| Returns a value of type DMfraction for the given
parameter
| dmParamsGetFractArray()
| Returns a pointer to a value of type DMfractionarray
for the given parameter
| dmParamsGetFractRange()
| Returns apointer to a value of type DMfractionrange
for the given parameter
| dmParamsGetParams()
| Returns a pointer to a value of type DMparams for
the given parameter
| dmParamsGetTocEntry()
| Returns a value of type DMTocEntry for the given
parameter
|
Example 2-4 shows two equivalent ways of setting up a complete image format description; the first sets the parameter values individually, the second creates a default image configuration with the appropriate values.
Example 2-4. Setting Individual Parameter Values
DMparams* format;
dmParamsCreate( &format );
dmParamsSetInt ( format, DM_IMAGE_WIDTH, 320 );
dmParamsSetInt ( format, DM_IMAGE_HEIGHT, 240 );
dmParamsSetFloat ( format, DM_IMAGE_RATE, 15.0 );
dmParamsSetString( format, DM_IMAGE_COMPRESSION, DM_IMAGE_UNCOMPRESSED );
dmParamsSetEnum( format, DM_IMAGE_INTERLACING, DM_IMAGE_NONINTERLEAVED );
dmParamsSetEnum ( format, DM_IMAGE_PACKING, DM_PACKING_RGBX );
dmParamsSetEnum ( format, DM_IMAGE_ORIENTATION, DM_BOTTOM_TO_TOP );
dmParamsDestroy ( format );
|
The following is equivalent:
DMparams* format;
dmParamsCreate ( &format );
dmSetImageDefaults ( format, 320, 240, DM_PACKING_RGBX );
dmParamsDestroy ( format );
|
Manipulating Parameter-value Lists
This section explains how to manipulate parameter-value lists.
Table 2-8 lists the routines that perform operations on parameter-value lists and the entries within them.
Table 2-8. Routines for Manipulating Parameter-value Lists and Entries
Routine
| Purpose
|
|---|
dmParamsCopyAllElems()
| Copy the entire contents of one list to another
| dmParamsCopyElem()
| Copy one parameter-value pair from one list to
another
| dmParamsGetElem()
| Get the name of a given parameter
| dmParamsGetElemType()
| Get the data type of a given parameter
| dmParamsGetNumElems(
)
| Get the number of parameters in a list
| dmParamsIsPresent()
| Determine if a given parameter is in the list
| dmParamsRemoveElem()
| Remove a given parameter from the list
|
The sections that follow explain how to use each routine.
Determining the Number of Elements in a Parameter-value List
To perform any task that requires your application to loop through the contents of a parameter-value list—for example, to print out a list of parameters and their values—you need to know how many parameters are in the list in order to set up a loop to step through the entries one-by-one.
To get the total number of elements present in a parameter-value list, call dmParamsGetNumElems(). Its function prototype is:
int dmParamsGetNumElems ( DMparams* params )
|
The number of elements and their position in a list is guaranteed to remain stable unless the list is changed by using one of the “set” functions, by copying an element into it, or by removing an element from it.
Copying the Contents of One Parameter-value List into Another
To copy the entire contents of the fromParams list into the toParams list, call dmParamsCopyAllElems(). Its function prototype is:
DMstatus dmParamsCopyAllElems ( DMparams* fromParams,
DMparams* toParams )
|
If there are any parameters of the same name in both lists, the corresponding value(s) in the destination list are overwritten. DM_SUCCESS is returned if there is enough memory to hold the copied data; otherwise, DM_FAILURE is returned.
Copying an Individual Parameter Value from One List into Another
If a parameter appears in more than one parameter-value list, it is sometimes more convenient to copy the individual parameter or group of parameters from one list to another, rather than individually setting the parameter value(s) for each list.
To copy the parameter-value pair for the parameter named paramName from the fromParams list into the toParams list, call dmParamsCopyElem(). Its function prototype is:
DMstatus dmParamsCopyElem ( DMparamsfromParams,
const char* paramName,
DMparams* toParams )
|
If there is a preexisting parameter with the same name in the destination list, that value is overwritten. DM_SUCCESS is returned if there is enough memory to hold the copied element; otherwise, DM_FAILURE is returned.
Determining the Name of a Given Parameter
To get the name of the entry occupying the position given by index in the params list, call dmParamsGetElem(). Its function prototype is:
const char* dmParamsGetElem ( DMparams* params, int index )
|
The index must be from 0 to one less than the number of elements in the list.
Determining the Data Type of a Given Parameter
To get the data type of the value occupying the position given by index in the params list, call dmParamsGetElemType(). Its function prototype is:
DMparamtype dmParamsGetElemType ( DMparams* params, int index )
|
See Table 2-1 for a list of valid return values.
Determining if a Given Parameter Exists
To determine whether the element named paramName exists in the params list, call dmParamsIsPresent(). Its function prototype is:
DMboolean dmParamsIsPresent ( DMparams* params, const char* paramName )
|
DM_TRUE is returned if paramName is in params; otherwise, DM_FALSE is returned.
Removing an Element from a Parameter-value List
To remove the paramName entry from the params list, call dmParamsRemoveElem(). Its function prototype is:
const char* dmParamsRemoveElem( DMparams* params, const char* paramName )
|
The element named paramName must be present.
Example 2-5 prints the contents of a parameter-value list.
Example 2-5. Printing the Contents of a Digital Media Parameter-value List
void PrintParams( DMparams* params )
{
int i;
int numElems = dmParamsGetNumElems( params );
for ( i = 0; i < numElems; i++ ) {
const char* name = dmParamsGetElem( params, i );
DMparamtype type = dmParamsGetElemType( params, i );
printf( " %20s: ", name );
switch( type )
{
case DM_TYPE_ENUM:
printf( "%d", dmParamsGetEnum( params, name ) );
break;
case DM_TYPE_INT:
printf( "%d", dmParamsGetInt( params, name ) );
break;
case DM_TYPE_STRING:
printf( "%s", dmParamsGetString( params, name ) );
break;
case DM_TYPE_FLOAT:
printf( "%f", dmParamsGetFloat( params, name ) );
break;
case DM_TYPE_FRACTION:
{
DMfraction f = dmParamsGetFract( params, name );
printf( "%d/%d", f.numerator, f.denominator );
}
break;
case DM_TYPE_PARAMS:
printf( "... param list ... " );
break;
case DM_TYPE_TOC_ENTRY:
printf( "... toc entry ..." );
break;
default:
assert( DM_FALSE );
}
printf( "\n" );
}
}
|
Synchronizing Digital Media
Most digital media applications use more than one medium in conjunction, for example, audio and video. Handling concurrent media streams requires the ability to process coincident data. This section explains how the data can be related to each other for the various IRIS digital media functions that perform capture and presentation of data.
The Digital digital media libraries provide their own temporal reference, called unadjusted system time (UST). The UST is an unsigned 64-bit number that measures the number of nanoseconds since the system was booted. UST values are guaranteed to be monotonically increasing and are readily available for all the IRIS digital media libraries.
Typically, the UST is used as a timestamp, that is, it is paired with a specific item or location in a digital media stream. Because each type of media, and similarly each of the libraries, possess unique attributes, the UST information is presented in a different manner in each library. Table 2-9 describes how UST information is provided by each of the libraries.
Table 2-9. Methods for Obtaining Unadjusted System Time
Library
| UST Method
|
|---|
Digital Media Library
| dmGetUST()
| Audio Library
| ALgetframenumber() and ALgetframetime()
| MIDI Library
| mdTell() and mdSetTimestampMode()
| Video Library
| ustime field in the DMediaInfo structure
| Compression Library
| ustime field in the CLimageInfo structure
|
The DM Library routine, dmGetUST(), returns a high-resolution, unsigned 64-bit number to processes using the digital media subsystem. Typically, you use the appropriate routine for the library that handles the type of media being processed, as listed in Table 2-9, rather than dmGetUST(). However, dmGetUST() is useful for correlating UST to system time for events that are not related to a media stream, such as pushing a button or making a network connection.
IRIS Digital Media Programming Guide
(document number: 007-1799-040 / published: 1994-11-14)
table of contents | additional info | download
Front Matter
About This Guide
Part I. Digital Media Programming
Part II. Digital Audio and MIDI Programming
Part III. Video Programming
Part IV. IndigoVideo Programming
Part V. Compression Programming
Part VI. Movie Programming
Appendix A. Audio Specifications
Appendix B. Aware Scalable Audio Compression Software
Glossary
Chapter 33.
Glossary
Chapter 34.
Glossary
Index
home/search |
what's new |
help
|