use of android.media.MediaRecorder in project storymaker by StoryMaker.
the class ExtAudioRecorder method reset.
/**
*
*
* Resets the recorder to the INITIALIZING state, as if it was just created.
* In case the class was in RECORDING state, the recording is stopped.
* In case of exceptions the class is set to the ERROR state.
*
*/
public void reset() {
try {
if (state != State.ERROR) {
release();
// Reset file path
filePath = null;
// Reset amplitude
cAmplitude = 0;
if (rUncompressed) {
audioRecorder = new AudioRecord(aSource, sRate, nChannels + 1, aFormat, bufferSize);
} else {
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
}
state = State.INITIALIZING;
}
} catch (Exception e) {
Timber.e(e.getMessage());
state = State.ERROR;
}
}
use of android.media.MediaRecorder in project android_frameworks_base by DirtyUnicorns.
the class CodecTest method mediaRecorderRecord.
public static boolean mediaRecorderRecord(String filePath) {
Log.v(TAG, "SoundRecording - " + filePath);
//This test is only for the short media file
int duration = 0;
try {
MediaRecorder mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile(filePath);
mRecorder.prepare();
mRecorder.start();
Thread.sleep(500);
mRecorder.stop();
Log.v(TAG, "sound recorded");
mRecorder.release();
} catch (Exception e) {
Log.v(TAG, e.toString());
}
//Verify the recorded file
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(filePath);
mp.prepare();
duration = mp.getDuration();
Log.v(TAG, "Duration " + duration);
mp.release();
} catch (Exception e) {
}
//Check the record media file length is greate than zero
if (duration > 0)
return true;
else
return false;
}
use of android.media.MediaRecorder in project android_frameworks_base by DirtyUnicorns.
the class MediaPlayerPerformance method stressAudioRecord.
public void stressAudioRecord(String filePath) {
// This test is only for the short media file
for (int i = 0; i < NUM_PLAYBACk_IN_EACH_LOOP; i++) {
MediaRecorder mRecorder = new MediaRecorder();
try {
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile(filePath);
mRecorder.prepare();
mRecorder.start();
Thread.sleep(MEDIA_STRESS_WAIT_TIME);
mRecorder.stop();
mRecorder.release();
} catch (Exception e) {
Log.v(TAG, e.toString());
mRecorder.release();
}
}
}
use of android.media.MediaRecorder in project android_frameworks_base by DirtyUnicorns.
the class Camera2RecordingTest method doBasicRecording.
private void doBasicRecording(boolean useVideoStab) throws Exception {
for (int i = 0; i < mCameraIds.length; i++) {
try {
Log.i(TAG, "Testing basic recording for camera " + mCameraIds[i]);
// Re-use the MediaRecorder object for the same camera device.
mMediaRecorder = new MediaRecorder();
openDevice(mCameraIds[i]);
if (!mStaticInfo.isColorOutputSupported()) {
Log.i(TAG, "Camera " + mCameraIds[i] + " does not support color outputs, skipping");
continue;
}
if (!mStaticInfo.isVideoStabilizationSupported() && useVideoStab) {
Log.i(TAG, "Camera " + mCameraIds[i] + " does not support video stabilization, skipping the stabilization" + " test");
continue;
}
initSupportedVideoSize(mCameraIds[i]);
// Test iteration starts...
for (int iteration = 0; iteration < getIterationCount(); ++iteration) {
Log.v(TAG, String.format("Recording video: %d/%d", iteration + 1, getIterationCount()));
basicRecordingTestByCamera(mCamcorderProfileList, useVideoStab);
getResultPrinter().printStatus(getIterationCount(), iteration + 1, mCameraIds[i]);
Thread.sleep(getTestWaitIntervalMs());
}
} finally {
closeDevice();
releaseRecorder();
}
}
}
use of android.media.MediaRecorder in project android_frameworks_base by DirtyUnicorns.
the class Camera2RecordingTest method videoSnapshotHelper.
/**
* Simple wrapper to wrap normal/burst video snapshot tests
*/
private void videoSnapshotHelper(boolean burstTest) throws Exception {
for (String id : mCameraIds) {
try {
Log.i(TAG, "Testing video snapshot for camera " + id);
// Re-use the MediaRecorder object for the same camera device.
mMediaRecorder = new MediaRecorder();
openDevice(id);
if (!mStaticInfo.isColorOutputSupported()) {
Log.i(TAG, "Camera " + id + " does not support color outputs, skipping");
continue;
}
initSupportedVideoSize(id);
// Test iteration starts...
for (int iteration = 0; iteration < getIterationCount(); ++iteration) {
Log.v(TAG, String.format("Video snapshot: %d/%d", iteration + 1, getIterationCount()));
videoSnapshotTestByCamera(burstTest);
getResultPrinter().printStatus(getIterationCount(), iteration + 1, id);
Thread.sleep(getTestWaitIntervalMs());
}
} finally {
closeDevice();
releaseRecorder();
}
}
}
Aggregations