diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java index 538703ac..4ee81244 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java @@ -19,6 +19,7 @@ import android.view.View; import android.view.ViewGroup; import com.otaliastudios.cameraview.controls.Audio; +import com.otaliastudios.cameraview.controls.AudioCodec; import com.otaliastudios.cameraview.controls.ControlParser; import com.otaliastudios.cameraview.controls.Engine; import com.otaliastudios.cameraview.controls.Facing; @@ -165,6 +166,7 @@ public class CameraViewTest extends BaseTest { assertEquals(cameraView.getHdr(), controls.getHdr()); assertEquals(cameraView.getAudio(), controls.getAudio()); assertEquals(cameraView.getVideoCodec(), controls.getVideoCodec()); + assertEquals(cameraView.getAudioCodec(), controls.getAudioCodec()); assertEquals(cameraView.getPictureFormat(), controls.getPictureFormat()); //noinspection SimplifiableJUnitAssertion assertEquals(cameraView.getLocation(), null); @@ -773,6 +775,19 @@ public class CameraViewTest extends BaseTest { assertEquals(cameraView.get(Audio.class), Audio.STEREO); } + @Test + public void testAudioCodec() { + cameraView.set(AudioCodec.DEVICE_DEFAULT); + assertEquals(cameraView.get(AudioCodec.class), AudioCodec.DEVICE_DEFAULT); + cameraView.set(AudioCodec.AAC); + assertEquals(cameraView.get(AudioCodec.class), AudioCodec.AAC); + cameraView.set(AudioCodec.HE_AAC); + assertEquals(cameraView.get(AudioCodec.class), AudioCodec.HE_AAC); + cameraView.set(AudioCodec.AAC_ELD); + assertEquals(cameraView.get(AudioCodec.class), AudioCodec.AAC_ELD); + } + + @Test public void testVideoCodec() { cameraView.set(VideoCodec.H_263); diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/VideoResultTest.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/VideoResultTest.java index b4d9b6fd..e4ed22a4 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/VideoResultTest.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/VideoResultTest.java @@ -4,6 +4,7 @@ package com.otaliastudios.cameraview; import android.location.Location; import com.otaliastudios.cameraview.controls.Audio; +import com.otaliastudios.cameraview.controls.AudioCodec; import com.otaliastudios.cameraview.controls.Facing; import com.otaliastudios.cameraview.controls.VideoCodec; import com.otaliastudios.cameraview.size.Size; @@ -32,7 +33,8 @@ public class VideoResultTest extends BaseTest { File file = Mockito.mock(File.class); int rotation = 90; Size size = new Size(20, 120); - VideoCodec codec = VideoCodec.H_263; + VideoCodec videoCodec = VideoCodec.H_263; + AudioCodec audioCodec = AudioCodec.DEVICE_DEFAULT; Location location = Mockito.mock(Location.class); boolean isSnapshot = true; int maxDuration = 1234; @@ -47,7 +49,8 @@ public class VideoResultTest extends BaseTest { stub.file = file; stub.rotation = rotation; stub.size = size; - stub.videoCodec = codec; + stub.videoCodec = videoCodec; + stub.audioCodec = audioCodec; stub.location = location; stub.isSnapshot = isSnapshot; stub.maxDuration = maxDuration; @@ -63,7 +66,8 @@ public class VideoResultTest extends BaseTest { assertEquals(result.getFile(), file); assertEquals(result.getRotation(), rotation); assertEquals(result.getSize(), size); - assertEquals(result.getVideoCodec(), codec); + assertEquals(result.getVideoCodec(), videoCodec); + assertEquals(result.getAudioCodec(), audioCodec); assertEquals(result.getLocation(), location); assertEquals(result.isSnapshot(), isSnapshot); assertEquals(result.getMaxSize(), maxFileSize); @@ -81,7 +85,8 @@ public class VideoResultTest extends BaseTest { FileDescriptor fileDescriptor = FileDescriptor.in; int rotation = 90; Size size = new Size(20, 120); - VideoCodec codec = VideoCodec.H_263; + VideoCodec videoCodec = VideoCodec.H_263; + AudioCodec audioCodec = AudioCodec.DEVICE_DEFAULT; Location location = Mockito.mock(Location.class); boolean isSnapshot = true; int maxDuration = 1234; @@ -96,7 +101,8 @@ public class VideoResultTest extends BaseTest { stub.fileDescriptor = fileDescriptor; stub.rotation = rotation; stub.size = size; - stub.videoCodec = codec; + stub.videoCodec = videoCodec; + stub.audioCodec = audioCodec; stub.location = location; stub.isSnapshot = isSnapshot; stub.maxDuration = maxDuration; @@ -112,7 +118,8 @@ public class VideoResultTest extends BaseTest { assertEquals(result.getFileDescriptor(), fileDescriptor); assertEquals(result.getRotation(), rotation); assertEquals(result.getSize(), size); - assertEquals(result.getVideoCodec(), codec); + assertEquals(result.getVideoCodec(), videoCodec); + assertEquals(result.getAudioCodec(), audioCodec); assertEquals(result.getLocation(), location); assertEquals(result.isSnapshot(), isSnapshot); assertEquals(result.getMaxSize(), maxFileSize); diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/options/Camera1OptionsTest.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/options/Camera1OptionsTest.java index 4dbbe0b4..8574c9ef 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/options/Camera1OptionsTest.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/options/Camera1OptionsTest.java @@ -7,6 +7,7 @@ import android.hardware.Camera; import com.otaliastudios.cameraview.BaseTest; import com.otaliastudios.cameraview.CameraOptions; import com.otaliastudios.cameraview.controls.Audio; +import com.otaliastudios.cameraview.controls.AudioCodec; import com.otaliastudios.cameraview.controls.Facing; import com.otaliastudios.cameraview.controls.Flash; import com.otaliastudios.cameraview.controls.PictureFormat; @@ -244,10 +245,12 @@ public class Camera1OptionsTest extends BaseTest { Collection grids = o.getSupportedControls(Grid.class); Collection video = o.getSupportedControls(VideoCodec.class); + Collection audioCodecs = o.getSupportedControls(AudioCodec.class); Collection sessions = o.getSupportedControls(Mode.class); Collection