Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented being able to toggle audio recording #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

buildscript {
repositories {
google()
jcenter()
}
dependencies {
Expand All @@ -14,6 +15,7 @@ buildscript {

allprojects {
repositories {
google()
jcenter()
}
}
Expand Down
16 changes: 13 additions & 3 deletions mobile/src/main/java/com/opendashcam/BackgroundVideoRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,19 @@ private void initMediaRecorder(final SurfaceHolder surfaceHolder) {

mediaRecorder = new MediaRecorder();
mediaRecorder.setCamera(camera); // TODO See if we can remove this line. We can't, because media recorder should know what camera object will be used
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);

mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(camcorderProfile);

if (settings.getBoolean("record_audio", true)) {
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setProfile(camcorderProfile);
} else {
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the else predicate here, does it mean that the video parameters will be set only when record_audio is false?
Don't we need them for both with and without audio? Need to check this.

mediaRecorder.setVideoFrameRate(camcorderProfile.videoFrameRate);
mediaRecorder.setVideoSize(camcorderProfile.videoFrameWidth, camcorderProfile.videoFrameHeight);
mediaRecorder.setVideoEncoder(camcorderProfile.videoCodec);
}

mediaRecorder.setVideoEncodingBitRate(3000000);
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
// Store previous and current recording filenames, so that they may be retrieved by the
Expand Down Expand Up @@ -356,4 +366,4 @@ public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
public IBinder onBind(Intent intent) {
return null;
}
}
}
3 changes: 3 additions & 0 deletions mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Starred recordings will not be deleted.</string>
you start the app
</string>

<string name="pref_title_record_audio">Record audio</string>
<string name="pref_description_record_audio">Includes audio in the video recordings</string>

<string name="pref_delete_recordings">Delete all recordings</string>
<string name="pref_description_delete_recordings">Delete all recordings created by Open Dash
Cam
Expand Down
6 changes: 6 additions & 0 deletions mobile/src/main/res/xml/pref_general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
android:key="start_maps_in_background"
android:summary="@string/pref_description_start_maps_in_background"
android:title="@string/pref_title_start_maps_in_background" />

<SwitchPreference
android:defaultValue="true"
android:key="record_audio"
android:summary="@string/pref_description_record_audio"
android:title="@string/pref_title_record_audio" />

<Preference
android:key="delete_recordings"
Expand Down