diff --git a/README.md b/README.md index 95f6ca3a..c3cab3ec 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ See below for a [list of what was done](#roadmap) and [licensing info](#contribu - **Metadata** support for pictures and videos - Automatically detected orientation tags - Plug in location tags with `setLocation()` API -- **`CameraUtils`** to help with Bitmaps and orientations +- `CameraUtils` to help with Bitmaps and orientations - **Lightweight**, no dependencies, just support `ExifInterface` - Works down to API level 15 @@ -62,8 +62,8 @@ See below for a [list of what was done](#roadmap) and [licensing info](#contribu - [Other APIs](#other-apis) - [Permissions Behavior](#permissions-behavior) - [Logging](#logging) -- [Roadmap](#roadmap) - [Device-specific issues](#device-specific-issues) +- [Roadmap](#roadmap) ## Usage @@ -444,16 +444,14 @@ We support frame processors that will receive data from the camera preview strea ```java cameraView.addFrameProcessor(new FrameProcessor() { - @Override @WorkerThread public void process(Frame frame) { byte[] data = frame.getData(); int rotation = frame.getRotation(); long time = frame.getTime(); - // Process.. + // Process... } - } ``` @@ -471,7 +469,7 @@ apply new data to it. So: |`frame.getTime()`|`long`|The preview timestamp, in `System.currentTimeMillis()` reference.| |`frame.getRotation()`|`int`|The rotation that should be applied to the byte array in order to see what the user sees.| |`frame.freeze()`|`Frame`|Clones this frame and makes it immutable. Can be expensive because requires copying the byte array.| -|`frame.clear()`|`-`|Disposes the content of this frame. Should be used on frozen frames to release memory.| +|`frame.release()`|`-`|Disposes the content of this frame. Should be used on frozen frames to release memory.| ## Other APIs @@ -497,7 +495,7 @@ Other APIs not mentioned above are provided, and are well documented and comment |`getSnapshotSize()`|Returns `getPreviewSize()`, since a snapshot is a preview frame.| |`getPictureSize()`|Returns the size of the output picture. The aspect ratio is consistent with `getPreviewSize()`.| -Take also a look at public methods in `CameraUtils`, `CameraOptions`, `ExtraProperties`, `CameraLogger`. +Take also a look at public methods in `CameraUtils`, `CameraOptions`, `ExtraProperties`. ## Permissions behavior @@ -559,6 +557,17 @@ CameraLogger.registerLogger(new Logger() { Make sure you enable the logger using `CameraLogger.setLogLevel(@LogLevel int)`. The default will only log error events. +## Device-specific issues + +There are a couple of known issues if you are working with certain devices. The emulator is one of +the most tricky in this sense. + +- Devices, or activities, with hardware acceleration turned off: this can be the case with emulators. + In this case we will use SurfaceView as our surface provider. That is intrinsically flawed and can't + deal with all we want to do here (runtime layout changes, scaling, etc.). So, nothing to do in this case. +- Devices with no support for MediaRecorder: the emulator does not support it, officially. This means + that video/audio recording is flawed. Again, not our fault. + ## Roadmap This is what was done since the library was forked. I have kept the original structure, but practically @@ -602,17 +611,6 @@ These are still things that need to be done, off the top of my head: - [ ] better error handling, maybe with a onError(e) method in the public listener, or have each public method return a boolean - [ ] decent code coverage -## Device-specific issues - -There are a couple of known issues if you are working with certain devices. The emulator is one of -the most tricky in this sense. - -- Devices, or activities, with hardware acceleration turned off: this can be the case with emulators. - In this case we will use SurfaceView as our surface provider. That is intrinsically flawed and can't - deal with all we want to do here (runtime layout changes, scaling, etc.). So, nothing to do in this case. -- Devices with no support for MediaRecorder: the emulator does not support it, officially. This means - that video/audio recording is flawed. Again, not our fault. - # Contributing and licenses The original project which served as a starting point for this library, diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Frame.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Frame.java index af3fb051..930d63f6 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Frame.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Frame.java @@ -26,7 +26,7 @@ public class Frame { /** * Clones the frame, returning a frozen content that will not be overwritten. * This can be kept or safely passed to other threads. - * Using freeze without clearing with {@link #clear()} can result in memory leaks. + * Using freeze without clearing with {@link #release()} can result in memory leaks. * * @return a frozen Frame */ @@ -44,7 +44,7 @@ public class Frame { * Disposes the contents of this frame. Can be useful for frozen frames * that are not useful anymore. */ - public void clear() { + public void release() { mData = null; mRotation = 0; mTime = -1; diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/FrameProcessor.java b/cameraview/src/main/java/com/otaliastudios/cameraview/FrameProcessor.java index c3db1342..1c3245ef 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/FrameProcessor.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/FrameProcessor.java @@ -15,7 +15,7 @@ public interface FrameProcessor { * * To keep working with the Frame in an async manner, please use {@link Frame#freeze()}, * which will return an immutable Frame. In that case you can pass / hold the frame for - * as long as you want, and then release its contents using {@link Frame#clear()}. + * as long as you want, and then release its contents using {@link Frame#release()}. * * @param frame the new frame */ diff --git a/cameraview/src/test/java/com/otaliastudios/cameraview/FrameTest.java b/cameraview/src/test/java/com/otaliastudios/cameraview/FrameTest.java index 83c8a5b5..3d784647 100644 --- a/cameraview/src/test/java/com/otaliastudios/cameraview/FrameTest.java +++ b/cameraview/src/test/java/com/otaliastudios/cameraview/FrameTest.java @@ -33,10 +33,10 @@ public class FrameTest { } @Test - public void testClear() { + public void testRelease() { Frame frame = new Frame(); frame.set(new byte[2], 1000, 90); - frame.clear(); + frame.release(); assertEquals(frame.getTime(), -1); assertEquals(frame.getRotation(), 0);