parent
03f8358d67
commit
8ed10fea06
@ -0,0 +1,47 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import android.hardware.Camera; |
||||
import android.location.Location; |
||||
import android.support.test.filters.SmallTest; |
||||
import android.support.test.runner.AndroidJUnit4; |
||||
|
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.mockito.Mockito; |
||||
|
||||
import java.io.File; |
||||
|
||||
import static org.junit.Assert.assertEquals; |
||||
|
||||
|
||||
@RunWith(AndroidJUnit4.class) |
||||
@SmallTest |
||||
public class VideoResultTest extends BaseTest { |
||||
|
||||
private VideoResult result = new VideoResult(); |
||||
|
||||
@Test |
||||
public void testResult() { |
||||
File file = Mockito.mock(File.class); |
||||
int rotation = 90; |
||||
Size size = new Size(20, 120); |
||||
VideoCodec codec = VideoCodec.H_263; |
||||
Location location = Mockito.mock(Location.class); |
||||
boolean isSnapshot = true; |
||||
|
||||
result.file = file; |
||||
result.rotation = rotation; |
||||
result.size = size; |
||||
result.codec = codec; |
||||
result.location = location; |
||||
result.isSnapshot = isSnapshot; |
||||
|
||||
assertEquals(result.getFile(), file); |
||||
assertEquals(result.getRotation(), rotation); |
||||
assertEquals(result.getSize(), size); |
||||
assertEquals(result.getCodec(), codec); |
||||
assertEquals(result.getLocation(), location); |
||||
assertEquals(result.isSnapshot(), isSnapshot); |
||||
} |
||||
} |
@ -0,0 +1,83 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
import android.location.Location; |
||||
import android.support.annotation.NonNull; |
||||
import android.support.annotation.Nullable; |
||||
|
||||
import java.io.File; |
||||
|
||||
/** |
||||
* Wraps the result of a video recording started by {@link CameraView#takeVideo(File)}. |
||||
*/ |
||||
public class VideoResult { |
||||
|
||||
boolean isSnapshot; |
||||
Location location; |
||||
int rotation; |
||||
Size size; |
||||
File file; |
||||
VideoCodec codec; |
||||
|
||||
VideoResult() {} |
||||
|
||||
/** |
||||
* Returns whether this result comes from a snapshot. |
||||
* |
||||
* @return whether this is a snapshot |
||||
*/ |
||||
public boolean isSnapshot() { |
||||
return isSnapshot; |
||||
} |
||||
|
||||
/** |
||||
* Returns geographic information for this video, if any. |
||||
* If it was set, it is also present in the file metadata. |
||||
* |
||||
* @return a nullable Location |
||||
*/ |
||||
@Nullable |
||||
public Location getLocation() { |
||||
return location; |
||||
} |
||||
|
||||
/** |
||||
* Returns the clock-wise rotation that should be applied to the |
||||
* video frames before displaying. If it is non-zero, it is also present |
||||
* in the video metadata, so most reader will take care of it. |
||||
* |
||||
* @return the clock-wise rotation |
||||
*/ |
||||
public int getRotation() { |
||||
return rotation; |
||||
} |
||||
|
||||
/** |
||||
* Returns the size of the frames after the rotation is applied. |
||||
* |
||||
* @return the Size of this video |
||||
*/ |
||||
@NonNull |
||||
public Size getSize() { |
||||
return size; |
||||
} |
||||
|
||||
/** |
||||
* Returns the file where the video was saved. |
||||
* |
||||
* @return the File of this video |
||||
*/ |
||||
@NonNull |
||||
public File getFile() { |
||||
return file; |
||||
} |
||||
|
||||
/** |
||||
* Returns the codec that was used to encode the video frames. |
||||
* |
||||
* @return the video codec |
||||
*/ |
||||
@NonNull |
||||
public VideoCodec getCodec() { |
||||
return codec; |
||||
} |
||||
} |
Loading…
Reference in new issue