Source:
public void init() throws IOException { HandlerThread handlerThread = new HandlerThread(TAG); handlerThread.start(); mIoHandler = new Handler(handlerThread.getLooper(), this); if (mBufferReason == RecordingSampleBuffer.BUFFER_REASON_RECORDED_PLAYBACK) { for (int i = 0; i < mTrackCount; ++i) { mBufferManager.loadTrackFromStorage(mIds.get(i), mSamplePool); } mWriteEnded = true; } else { for (int i = 0; i < mTrackCount; ++i) { mIoHandler.sendMessage(mIoHandler.obtainMessage(MSG_OPEN_WRITE, i)); } } try { if (mBufferReason == RecordingSampleBuffer.BUFFER_REASON_RECORDING && mTrackCount > 0) { List<BufferManager.TrackFormat> audios = new ArrayList<>(mTrackCount); List<BufferManager.TrackFormat> videos = new ArrayList<>(mTrackCount); for (int i = 0; i < mTrackCount; ++i) { if (MimeTypes.isAudio(mMediaFormats.get(i).sampleMimeType)) { MediaFormat format = getAudioMediaFormat(mMediaFormats.get(i)); format.setLong(MediaFormat.KEY_DURATION, mBufferDurationUs); audios.add(new BufferManager.TrackFormat(mIds.get(i), format)); } else if (MimeTypes.isVideo(mMediaFormats.get(i).sampleMimeType)) { MediaFormat format = getVideoMediaFormat(mMediaFormats.get(i)); format.setLong(MediaFormat.KEY_DURATION, mBufferDurationUs); if (mMediaFormats.get(i).pixelWidthHeightRatio > 0) { format.setInteger( android.media.MediaFormat.KEY_WIDTH, (int) (mMediaFormats.get(i).width * mMediaFormats.get(i).pixelWidthHeightRatio)); } videos.add(new BufferManager.TrackFormat(mIds.get(i), format)); } } mBufferManager.writeMetaFilesOnly(audios, videos); } } catch (Exception e) { Log.e(TAG, "Unable to write Meta files for DVR recording.", e); } }

Target:
public void init() throws IOException { HandlerThread handlerThread = new HandlerThread(TAG); handlerThread.start(); mIoHandler = new Handler(handlerThread.getLooper(), this); if (mBufferReason == RecordingSampleBuffer.BUFFER_REASON_RECORDED_PLAYBACK) { for (int i = 0; i < mTrackCount; ++i) { mBufferManager.loadTrackFromStorage(mIds.get(i), mSamplePool); } mWriteEnded = true; } else { for (int i = 0; i < mTrackCount; ++i) { mIoHandler.sendMessage(mIoHandler.obtainMessage(MSG_OPEN_WRITE, i)); } } try { if (mBufferReason == RecordingSampleBuffer.BUFFER_REASON_RECORDING && mTrackCount > 0) { List<BufferManager.TrackFormat> audios = new ArrayList<>(mTrackCount); List<BufferManager.TrackFormat> videos = new ArrayList<>(mTrackCount); for (int i = 0; i < mTrackCount; ++i) { if (MimeTypes.isAudio(mMediaFormats.get(i).sampleMimeType)) { MediaFormat format = getAudioMediaFormat(mMediaFormats.get(i)); format.setLong(MediaFormat.KEY_DURATION, mBufferDurationUs); audios.add(new BufferManager.TrackFormat(mIds.get(i), format)); } else if (MimeTypes.isVideo(mMediaFormats.get(i).sampleMimeType)) { MediaFormat format = getVideoMediaFormat(mMediaFormats.get(i)); format.setLong(MediaFormat.KEY_DURATION, mBufferDurationUs); if (mMediaFormats.get(i).pixelWidthHeightRatio != Format.NO_VALUE) { format.setInteger( MediaFormat.KEY_WIDTH, (int) (mMediaFormats.get(i).width * mMediaFormats.get(i).pixelWidthHeightRatio)); } videos.add(new BufferManager.TrackFormat(mIds.get(i), format)); } } mBufferManager.writeMetaFilesOnly(audios, videos); } } catch (Exception e) { Log.e(TAG, "Unable to write Meta files for DVR recording.", e); } }