mmOpenFile

Opens a multimedia file for read or write operations.

Prototype

DWORD mmOpenFile ( char *pFileName, unsigned openMode, unsigned fileType, FILE_FORMAT_DESC *pFileFormatDesc, unsigned verboseLevel, MMFILE *pMMFile)

Argument

Description

pFileName

A pointer to a text string that contains the name of the 3GP file.

openMode

Specifies whether the file will be opened for reading or writing. Valid values are:

  • OPEN_MODE_READ - Opens a file for reading.

  • OPEN_MODE_WRITE - Open a file for writing. If the file exists, its contents are destroyed.

fileType

Determines the type of file; and therefore, the file handler. The only valid value is FILE_TYPE_3GP. (File is a 3GP file.)

pFileFormatDesc

(Write mode only) A pointer to the FILE_FORMAT_DESC data structure that determines the format of the created file. A value of NULL specifies that the file will be created with the default format.

The structure definition is:

typedef struct
{
    char     format [8];
    DWORD    version;
    DWORD    flags;
    DWORD     maxFileSize;
    DWORD    maxFileTime;
    DWORD    interleave;
} FILE_FORMAT_DESC;

For information about the fields in this structure, see FILE_FORMAT_DESC.

verboseLevel

Controls the trace information printed on stdoutput. Valid values are:

  • VERBOSE_NOTRACES_LEVEL - No printouts.

  • VERBOSE_INFO_LEVEL - Full informative printouts.

  • VERBOSE_DEBUG_LEVEL - Debug printouts.

  • VERBOSE_WARNING_LEVEL - Warning printouts.

  • VERBOSE_ERROR_LEVEL - Error-level printouts.

pMMFile

A pointer to the object that controls the multimedia file.

Return values

Return value

Description

SUCCESS

 

MMERR_FILE_ACCESS_DENIED

Access denied in specified open mode.

MMERR_FILE_FORMAT

Error in file format.

MMERR_FILE_OPEN_FAILED

File was not found.

MMERR_INTERNAL_RESOURCE

Error on internal resource.

MMERR_INVALID_FILE_TYPE

Specified file type is not supported.

MMERR_INVALID_FORMAT_DESC

Invalid field in format descriptor.

MMERR_INVALID_OPEN_MODE

Invalid open mode.

MMERR_INVALID_POINTER

pMMFile or pFileName is NULL.

Details

Use mmOpenFile to open a multimedia file in read mode or write mode.

Opening a file in read mode

Opening a file in read mode gives you read access to the existing file. After you open the file, you can invoke mmGetFileInfo to obtain detailed information about the file.

Opening a file in write mode

Opening a file in write mode allows you to create a new file or overlay an existing file. If you open an existing file in write mode, the file contents are automatically destroyed.

To update the opened file, make changes to the returned MMFILE structure by using mmWriteStream. Depending on the format settings you specify when you open the file, the data either gets written to the media stream every time you invoke mmWriteStream, or it gets written later on, when you close the file.

Examples

Opening a 3GP file for read mode

DWORD ret;
insigned verboseLevel = 0;
MMFILE mmFile;
ret = mmOpenFile( “record.3gp”, OPEN_MODE_READ, FILE_TYPE_3GP,
                  NULL, verboseLevel, &mmFile);
If( ret != SUCCESS )
{
    printf ("\nERROR in mmOpenFile (%d)\n", ret);
    return -1;
}

Opening a 3GP file for write mode

DWORD ret;
insigned verboseLevel = 0;
MMFILE mmFile;
FILE_FORMAT_DESC fileFormatDesc;
ret = mmOpenFile( “record.3gp”, OPEN_MODE_READ, FILE_TYPE_3GP,
                  &fileFormatDesc, verboseLevel, &mmFile);
If( ret != SUCCESS )
{
    printf ("\nERROR in mmOpenFile (%d)\n", ret);
    return -1;
}