Rename clear() to release()

pull/82/head
Mattia Iavarone 8 years ago
parent 592bd05259
commit c0345f4e62
  1. 34
      README.md
  2. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/Frame.java
  3. 2
      cameraview/src/main/java/com/otaliastudios/cameraview/FrameProcessor.java
  4. 4
      cameraview/src/test/java/com/otaliastudios/cameraview/FrameTest.java

@ -43,7 +43,7 @@ See below for a [list of what was done](#roadmap) and [licensing info](#contribu
- **Metadata** support for pictures and videos - **Metadata** support for pictures and videos
- Automatically detected orientation tags - Automatically detected orientation tags
- Plug in location tags with `setLocation()` API - 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` - **Lightweight**, no dependencies, just support `ExifInterface`
- Works down to API level 15 - 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) - [Other APIs](#other-apis)
- [Permissions Behavior](#permissions-behavior) - [Permissions Behavior](#permissions-behavior)
- [Logging](#logging) - [Logging](#logging)
- [Roadmap](#roadmap)
- [Device-specific issues](#device-specific-issues) - [Device-specific issues](#device-specific-issues)
- [Roadmap](#roadmap)
## Usage ## Usage
@ -444,16 +444,14 @@ We support frame processors that will receive data from the camera preview strea
```java ```java
cameraView.addFrameProcessor(new FrameProcessor() { cameraView.addFrameProcessor(new FrameProcessor() {
@Override @Override
@WorkerThread @WorkerThread
public void process(Frame frame) { public void process(Frame frame) {
byte[] data = frame.getData(); byte[] data = frame.getData();
int rotation = frame.getRotation(); int rotation = frame.getRotation();
long time = frame.getTime(); 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.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.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.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 ## 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.| |`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()`.| |`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 ## 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 Make sure you enable the logger using `CameraLogger.setLogLevel(@LogLevel int)`. The default will only
log error events. 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 ## Roadmap
This is what was done since the library was forked. I have kept the original structure, but practically 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 - [ ] better error handling, maybe with a onError(e) method in the public listener, or have each public method return a boolean
- [ ] decent code coverage - [ ] 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 # Contributing and licenses
The original project which served as a starting point for this library, The original project which served as a starting point for this library,

@ -26,7 +26,7 @@ public class Frame {
/** /**
* Clones the frame, returning a frozen content that will not be overwritten. * Clones the frame, returning a frozen content that will not be overwritten.
* This can be kept or safely passed to other threads. * 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 * @return a frozen Frame
*/ */
@ -44,7 +44,7 @@ public class Frame {
* Disposes the contents of this frame. Can be useful for frozen frames * Disposes the contents of this frame. Can be useful for frozen frames
* that are not useful anymore. * that are not useful anymore.
*/ */
public void clear() { public void release() {
mData = null; mData = null;
mRotation = 0; mRotation = 0;
mTime = -1; mTime = -1;

@ -15,7 +15,7 @@ public interface FrameProcessor {
* *
* To keep working with the Frame in an async manner, please use {@link Frame#freeze()}, * 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 * 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 * @param frame the new frame
*/ */

@ -33,10 +33,10 @@ public class FrameTest {
} }
@Test @Test
public void testClear() { public void testRelease() {
Frame frame = new Frame(); Frame frame = new Frame();
frame.set(new byte[2], 1000, 90); frame.set(new byte[2], 1000, 90);
frame.clear(); frame.release();
assertEquals(frame.getTime(), -1); assertEquals(frame.getTime(), -1);
assertEquals(frame.getRotation(), 0); assertEquals(frame.getRotation(), 0);

Loading…
Cancel
Save