How to record a wave file
Client develoer can make a recording file of PTT.
Record of sending PTT
1. onChannelLocked
- create a wave file
- write an wave header
2. onTrackDataCaptured
- write a frame to the file.
3. onChannelUnlocked
- write a final wave header at position 0.
- close the file.
- add to DB
Record of receiving PTT
1. onChannelLocked
- create a wave file
- write an wave header
2. onTrackDataRendered
- write a frame to the file.
3. onChannelUnlocked
- write a final wave header at position 0.
- close the file.
- add to DB
Android sample
WaveContainer: Muxer for wave. download WaveContainer.java
WaveContainer waveContainer = new WaveContainer(); // Locked int channelCount = 1; int sampleRate = 16000; //In case of onTrackDataRendered, it is 16000. But onTrackDataCaptured, it is depended on lockMediaprofile. (8000/16000) int bitPerSample = 16; int byteRate = bitPerSample / 8 * sampleRate * channelCount; waveContainer.initialize(channelCount,sampleRate,bitPerSample,byteRate); waveContainer.open(Environment.getExternalStorageDirectory()+"/Download/test.wav"); // onTrackDataCaptured or onTrackDataRendered waveContainer.writeFrame(trackDataBuffer,dataLength); // Unlocked waveContainer.close();
iOS sample
int sampleRate = 16000; //Always 16000