parent
							
								
									0494477c3b
								
							
						
					
					
						commit
						e9cba8c6ec
					
				| @ -0,0 +1,36 @@ | ||||
| package com.otaliastudios.cameraview; | ||||
| 
 | ||||
| 
 | ||||
| import android.hardware.Camera; | ||||
| import android.media.MediaRecorder; | ||||
| import android.support.test.filters.SmallTest; | ||||
| import android.support.test.runner.AndroidJUnit4; | ||||
| 
 | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| 
 | ||||
| 
 | ||||
| @RunWith(AndroidJUnit4.class) | ||||
| @SmallTest | ||||
| public class MapperTest extends BaseTest { | ||||
| 
 | ||||
|     private Mapper mapper = new Mapper() { | ||||
|         <T> T map(Flash flash) { return null; } | ||||
|         <T> T map(Facing facing) { return null; } | ||||
|         <T> T map(WhiteBalance whiteBalance) { return null; } | ||||
|         <T> T map(Hdr hdr) { return null; } | ||||
|         <T> Flash unmapFlash(T cameraConstant) { return null; } | ||||
|         <T> Facing unmapFacing(T cameraConstant) { return null; } | ||||
|         <T> WhiteBalance unmapWhiteBalance(T cameraConstant) { return null; } | ||||
|         <T> Hdr unmapHdr(T cameraConstant) { return null; } | ||||
|     }; | ||||
| 
 | ||||
|     @Test | ||||
|     public void testMap() { | ||||
|         assertEquals(mapper.map(VideoCodec.DEVICE_DEFAULT), MediaRecorder.VideoEncoder.DEFAULT); | ||||
|         assertEquals(mapper.map(VideoCodec.H_263), MediaRecorder.VideoEncoder.H263); | ||||
|         assertEquals(mapper.map(VideoCodec.H_264), MediaRecorder.VideoEncoder.H264); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,49 @@ | ||||
| package com.otaliastudios.cameraview; | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * Constants for selecting the encoder of video recordings. | ||||
|  * https://developer.android.com/guide/topics/media/media-formats.html#video-formats
 | ||||
|  * | ||||
|  * @see CameraView#setVideoCodec(VideoCodec) | ||||
|  */ | ||||
| public enum VideoCodec implements Control { | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Let the device choose its codec. | ||||
|      */ | ||||
|     DEVICE_DEFAULT(0), | ||||
| 
 | ||||
|     /** | ||||
|      * The H.263 codec. | ||||
|      */ | ||||
|     H_263(1), | ||||
| 
 | ||||
|     /** | ||||
|      * The H.264 codec. | ||||
|      */ | ||||
|     H_264(2); | ||||
| 
 | ||||
|     static final VideoCodec DEFAULT = DEVICE_DEFAULT; | ||||
| 
 | ||||
|     private int value; | ||||
| 
 | ||||
|     VideoCodec(int value) { | ||||
|         this.value = value; | ||||
|     } | ||||
| 
 | ||||
|     int value() { | ||||
|         return value; | ||||
|     } | ||||
| 
 | ||||
|     static VideoCodec fromValue(int value) { | ||||
|         VideoCodec[] list = VideoCodec.values(); | ||||
|         for (VideoCodec action : list) { | ||||
|             if (action.value() == value) { | ||||
|                 return action; | ||||
|             } | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue