# Recording to a 3GP file

To record to a 3GP file, use the Natural Access ADI service in combination with MMFI functions. Complete the following steps to record to a 3GP file:

Step | Action | Use
1 | Check the library version to ensure that it supports the 3GP format. | mmGetVersion
2 | Create the 3GP file. When you create this file, specify the format descriptor, file information, maximum file size, maximum duration, and interleaving depth. | mmOpenFile in write mode
3 | For each type of media stream, create the media stream structure, and specify the following information: A format of NMS packetized AMR settings Whether NMS native headers should be checked Codec level Whether a hint track should be created MPEG4 or H.264 DCI (optional) Whether a sync point table should be created during record | mmOpenStream
4 | Record the NMS packetized or raw audio data into memory-resident buffers. You can record multiple streams at the same time. | adiRecordMMToMemory adiRecordMMAsync
5 | Set the skew correction time if necessary. The skew correction time is handled automatically by the MMFI during the subsequent mmWriteStream operations. | mmSetSkewCorrection
6 | Store the buffers as the application receives them in ADIEVN_RECORDING_DONE events. If the application is using partial buffer mode (adiRecordMMAsync), repeat the mmWriteStream call for each received event. | mmWriteStream
7 | Close the 3GP file. | mmCloseFile

## Single buffer record call flow

The call flow for a single buffer record is shown below:

MMFI Lib | App | ADI service
mmGetVersion |
mmOpenFile (write) |
mmOpenStream (audio) |
mmOpenStream (video) |
| adiRecordMMToMemory (audio)
| adiRecordMMToMemory (video)
| ADIEVN_RECORD_DONE (audio)
mmSetSkewCorrection(file) |
mmWriteStream (audio) |
| ADIEVN_RECORD_DONE (video)
mmWriteStream (video) |
mmCloseFile (write) |

## Partial buffer record call flow

The call flow for a partial buffer record is shown below:

MMFI Lib | App | ADI service
mmGetVersion |
mmOpenFile (write) |
mmOpenStream (audio) |
mmOpenStream (video) |
| adiRecordMMAsync
| ADIEVN_RECORD_STARTED
| adiSubmitRecordBuffer
| ADIEVN_RECORD_BUFFER_FULL
mmSetSkewCorrection(file) |
mmWriteStream |
| ADIEVN_RECORD_BUFFER_FULL
mmWriteStream |
| ADIEVN_RECORD_DONE
mmCloseFile (write) |