diff options
-rw-r--r-- | api/current.txt | 30 | ||||
-rw-r--r-- | core/java/android/hardware/Camera.java | 53 | ||||
-rw-r--r-- | core/java/android/hardware/camera2/package.html | 12 | ||||
-rw-r--r-- | docs/html/guide/topics/media/camera.jd | 13 | ||||
-rw-r--r-- | graphics/java/android/graphics/ImageFormat.java | 59 | ||||
-rw-r--r-- | graphics/java/android/graphics/SurfaceTexture.java | 20 | ||||
-rw-r--r-- | media/java/android/media/MediaActionSound.java | 26 | ||||
-rw-r--r-- | media/java/android/media/MediaRecorder.java | 27 |
8 files changed, 159 insertions, 81 deletions
diff --git a/api/current.txt b/api/current.txt index 8868c85..d283360 100644 --- a/api/current.txt +++ b/api/current.txt @@ -11857,7 +11857,7 @@ package android.graphics.pdf { package android.hardware { - public class Camera { + public deprecated class Camera { method public final void addCallbackBuffer(byte[]); method public final void autoFocus(android.hardware.Camera.AutoFocusCallback); method public final void cancelAutoFocus(); @@ -11896,21 +11896,21 @@ package android.hardware { field public static final int CAMERA_ERROR_UNKNOWN = 1; // 0x1 } - public static class Camera.Area { + public static deprecated class Camera.Area { ctor public Camera.Area(android.graphics.Rect, int); field public android.graphics.Rect rect; field public int weight; } - public static abstract interface Camera.AutoFocusCallback { + public static abstract deprecated interface Camera.AutoFocusCallback { method public abstract void onAutoFocus(boolean, android.hardware.Camera); } - public static abstract interface Camera.AutoFocusMoveCallback { + public static abstract deprecated interface Camera.AutoFocusMoveCallback { method public abstract void onAutoFocusMoving(boolean, android.hardware.Camera); } - public static class Camera.CameraInfo { + public static deprecated class Camera.CameraInfo { ctor public Camera.CameraInfo(); field public static final int CAMERA_FACING_BACK = 0; // 0x0 field public static final int CAMERA_FACING_FRONT = 1; // 0x1 @@ -11919,11 +11919,11 @@ package android.hardware { field public int orientation; } - public static abstract interface Camera.ErrorCallback { + public static abstract deprecated interface Camera.ErrorCallback { method public abstract void onError(int, android.hardware.Camera); } - public static class Camera.Face { + public static deprecated class Camera.Face { ctor public Camera.Face(); field public int id; field public android.graphics.Point leftEye; @@ -11933,15 +11933,15 @@ package android.hardware { field public int score; } - public static abstract interface Camera.FaceDetectionListener { + public static abstract deprecated interface Camera.FaceDetectionListener { method public abstract void onFaceDetection(android.hardware.Camera.Face[], android.hardware.Camera); } - public static abstract interface Camera.OnZoomChangeListener { + public static abstract deprecated interface Camera.OnZoomChangeListener { method public abstract void onZoomChange(int, boolean, android.hardware.Camera); } - public class Camera.Parameters { + public deprecated class Camera.Parameters { method public java.lang.String flatten(); method public java.lang.String get(java.lang.String); method public java.lang.String getAntibanding(); @@ -12091,19 +12091,19 @@ package android.hardware { field public static final java.lang.String WHITE_BALANCE_WARM_FLUORESCENT = "warm-fluorescent"; } - public static abstract interface Camera.PictureCallback { + public static abstract deprecated interface Camera.PictureCallback { method public abstract void onPictureTaken(byte[], android.hardware.Camera); } - public static abstract interface Camera.PreviewCallback { + public static abstract deprecated interface Camera.PreviewCallback { method public abstract void onPreviewFrame(byte[], android.hardware.Camera); } - public static abstract interface Camera.ShutterCallback { + public static abstract deprecated interface Camera.ShutterCallback { method public abstract void onShutter(); } - public class Camera.Size { + public deprecated class Camera.Size { ctor public Camera.Size(int, int); field public int height; field public int width; @@ -14970,7 +14970,7 @@ package android.media { method public void setAudioEncodingBitRate(int); method public void setAudioSamplingRate(int); method public void setAudioSource(int) throws java.lang.IllegalStateException; - method public void setCamera(android.hardware.Camera); + method public deprecated void setCamera(android.hardware.Camera); method public void setCaptureRate(double); method public void setLocation(float, float); method public void setMaxDuration(int) throws java.lang.IllegalArgumentException; diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index cf462cd..4c73e6a 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -133,7 +133,11 @@ import java.util.List; * <p>For more information about using cameras, read the * <a href="{@docRoot}guide/topics/media/camera.html">Camera</a> developer guide.</p> * </div> + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ +@Deprecated public class Camera { private static final String TAG = "Camera"; @@ -247,7 +251,11 @@ public class Camera { /** * Information about a camera + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public static class CameraInfo { /** * The facing of the camera is opposite to that of the screen. @@ -675,7 +683,11 @@ public class Camera { * @see #setOneShotPreviewCallback(Camera.PreviewCallback) * @see #setPreviewCallbackWithBuffer(Camera.PreviewCallback) * @see #startPreview() + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public interface PreviewCallback { /** @@ -1175,7 +1187,10 @@ public class Camera { * manifest element.</p> * * @see #autoFocus(AutoFocusCallback) + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public interface AutoFocusCallback { /** @@ -1286,7 +1301,11 @@ public class Camera { * Parameters#FOCUS_MODE_CONTINUOUS_VIDEO} and {@link * Parameters#FOCUS_MODE_CONTINUOUS_PICTURE}. Applications can show * autofocus animation based on this.</p> + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public interface AutoFocusMoveCallback { /** @@ -1314,7 +1333,11 @@ public class Camera { * Callback interface used to signal the moment of actual image capture. * * @see #takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback) + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public interface ShutterCallback { /** @@ -1331,7 +1354,11 @@ public class Camera { * Callback interface used to supply image data from a photo capture. * * @see #takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback) + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public interface PictureCallback { /** * Called when image data is available after a picture is taken. @@ -1538,7 +1565,11 @@ public class Camera { * * @see #setZoomChangeListener(OnZoomChangeListener) * @see #startSmoothZoom(int) + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public interface OnZoomChangeListener { /** @@ -1568,7 +1599,10 @@ public class Camera { /** * Callback interface for face detected in the preview frame. * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public interface FaceDetectionListener { /** @@ -1652,7 +1686,10 @@ public class Camera { * list of face objects for use in focusing and metering.</p> * * @see FaceDetectionListener + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public static class Face { /** * Create an empty face. @@ -1766,7 +1803,11 @@ public class Camera { * Callback interface for camera error notification. * * @see #setErrorCallback(ErrorCallback) + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public interface ErrorCallback { /** @@ -1864,7 +1905,10 @@ public class Camera { /** * Image size (width and height dimensions). + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public class Size { /** * Sets the dimensions for pictures. @@ -1931,7 +1975,11 @@ public class Camera { * @see Parameters#setMeteringAreas(List) * @see Parameters#getMeteringAreas() * @see Parameters#getMaxNumMeteringAreas() + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public static class Area { /** * Create an area with specified rectangle and weight. @@ -2005,7 +2053,11 @@ public class Camera { * calling {@link Camera.Parameters#setColorEffect(String)}. If the * camera does not support color effects, * {@link Camera.Parameters#getSupportedColorEffects()} will return null. + * + * @deprecated We recommend using the new {@link android.hardware.camera2} API for new + * applications. */ + @Deprecated public class Parameters { // Parameter keys to communicate with the camera driver. private static final String KEY_PREVIEW_SIZE = "preview-size"; @@ -2960,7 +3012,6 @@ public class Camera { case ImageFormat.YV12: return PIXEL_FORMAT_YUV420P; case ImageFormat.RGB_565: return PIXEL_FORMAT_RGB565; case ImageFormat.JPEG: return PIXEL_FORMAT_JPEG; - case ImageFormat.BAYER_RGGB: return PIXEL_FORMAT_BAYER_RGGB; default: return null; } } diff --git a/core/java/android/hardware/camera2/package.html b/core/java/android/hardware/camera2/package.html index ef0d7bd..719c2f6 100644 --- a/core/java/android/hardware/camera2/package.html +++ b/core/java/android/hardware/camera2/package.html @@ -58,16 +58,16 @@ from a variety of classes, including {@link android.view.SurfaceView}, <p>Generally, camera preview images are sent to {@link android.view.SurfaceView} or {@link android.view.TextureView} (via its {@link android.graphics.SurfaceTexture}). Capture of JPEG images or -RAW buffers for {@link android.hardware.camera2.DngCreator} can be done -with {@link android.media.ImageReader} with the -{android.graphics.ImageFormat#JPEG} and -{android.graphics.ImageFormat#RAW_SENSOR} formats. Application-driven +RAW buffers for {@link android.hardware.camera2.DngCreator} can be +done with {@link android.media.ImageReader} with the {@link +android.graphics.ImageFormat#JPEG} and {@link +android.graphics.ImageFormat#RAW_SENSOR} formats. Application-driven processing of camera data in RenderScript, OpenGL ES, or directly in managed or native code is best done through {@link android.renderscript.Allocation} with a YUV {@link android.renderscript.Type}, {@link android.graphics.SurfaceTexture}, -and {@link android.media.ImageReader} with a -{android.graphics.ImageFormat#YUV_420_888} format, respectively.</p> +and {@link android.media.ImageReader} with a {@link +android.graphics.ImageFormat#YUV_420_888} format, respectively.</p> <p>The application then needs to construct a {@link android.hardware.camera2.CaptureRequest}, which defines all the diff --git a/docs/html/guide/topics/media/camera.jd b/docs/html/guide/topics/media/camera.jd index 56ef624..8b79b23 100644 --- a/docs/html/guide/topics/media/camera.jd +++ b/docs/html/guide/topics/media/camera.jd @@ -86,14 +86,17 @@ see how to implement these options.</li> <h2 id="basics">The Basics</h2> <p>The Android framework supports capturing images and video through the -{@link android.hardware.Camera} API or camera {@link android.content.Intent}. Here are the relevant +{@link android.hardware.camera2} API or camera {@link android.content.Intent}. Here are the relevant classes:</p> <dl> - <dt>{@link android.hardware.Camera}</dt> - <dd>This class is the primary API for controlling device cameras. This class is used to take + <dt>{@link android.hardware.camera2}</dt> + <dd>This package is the primary API for controlling device cameras. It can be used to take pictures or videos when you are building a camera application.</dd> + <dt>{@link android.hardware.Camera}</dt> + <dd>This class is the older deprecated API for controlling device cameras.</dd> + <dt>{@link android.view.SurfaceView}</dt> <dd>This class is used to present a live camera preview to the user.</dd> @@ -354,6 +357,10 @@ application or provides special features. Creating a customized camera activity code than <a href="#intents">using an intent</a>, but it can provide a more compelling experience for your users.</p> +<p><strong> Note: The following guide is for the older, deprecated {@link android.hardware.Camera} +API. For new or advanced camera applications, the newer {@link android.hardware.camera2} API is +recommended.</strong></p> + <p>The general steps for creating a custom camera interface for your application are as follows:</p> <ul> diff --git a/graphics/java/android/graphics/ImageFormat.java b/graphics/java/android/graphics/ImageFormat.java index 28fd7ba..ab4258d 100644 --- a/graphics/java/android/graphics/ImageFormat.java +++ b/graphics/java/android/graphics/ImageFormat.java @@ -54,9 +54,12 @@ public class ImageFormat { * cr_offset = y_size * cb_offset = y_size + c_size</pre> * - * <p>This format is guaranteed to be supported for camera preview images since - * API level 12; for earlier API versions, check - * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}. + * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is + * recommended for YUV output instead.</p> + * + * <p>For the older camera API, this format is guaranteed to be supported for + * {@link android.hardware.Camera} preview images since API level 12; for earlier API versions, + * check {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}. * * <p>Note that for camera preview callback use (see * {@link android.hardware.Camera#setPreviewCallback}), the @@ -133,29 +136,47 @@ public class ImageFormat { public static final int Y16 = 0x20363159; /** - * YCbCr format, used for video. Whether this format is supported by the - * camera hardware can be determined by - * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}. + * YCbCr format, used for video. + * + * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is + * recommended for YUV output instead.</p> + * + * <p>Whether this format is supported by the old camera API can be determined by + * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.</p> + * */ public static final int NV16 = 0x10; /** - * YCrCb format used for images, which uses the NV21 encoding format. This - * is the default format for camera preview images, when not otherwise set - * with {@link android.hardware.Camera.Parameters#setPreviewFormat(int)}. + * YCrCb format used for images, which uses the NV21 encoding format. + * + * <p>This is the default format + * for {@link android.hardware.Camera} preview images, when not otherwise set with + * {@link android.hardware.Camera.Parameters#setPreviewFormat(int)}.</p> + * + * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is + * recommended for YUV output instead.</p> */ public static final int NV21 = 0x11; /** * YCbCr format used for images, which uses YUYV (YUY2) encoding format. - * This is an alternative format for camera preview images. Whether this - * format is supported by the camera hardware can be determined by - * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}. + * + * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is + * recommended for YUV output instead.</p> + * + * <p>This is an alternative format for {@link android.hardware.Camera} preview images. Whether + * this format is supported by the camera hardware can be determined by + * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.</p> */ public static final int YUY2 = 0x14; /** - * Encoded formats. These are not necessarily supported by the hardware. + * Compressed JPEG format. + * + * <p>This format is always supported as an output format for the + * {@link android.hardware.camera2} API, and as a picture format for the older + * {@link android.hardware.Camera} API</p> */ public static final int JPEG = 0x100; @@ -332,16 +353,6 @@ public class ImageFormat { public static final int RAW10 = 0x25; /** - * Raw bayer format used for images, which is 10 bit precision samples - * stored in 16 bit words. The filter pattern is RGGB. Whether this format - * is supported by the camera hardware can be determined by - * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}. - * - * @hide - */ - public static final int BAYER_RGGB = 0x200; - - /** * Use this function to retrieve the number of bits per pixel of an * ImageFormat. * @@ -369,8 +380,6 @@ public class ImageFormat { return 12; case RAW_SENSOR: return 16; - case BAYER_RGGB: - return 16; case RAW10: return 10; } diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java index 17795f3..f52c661 100644 --- a/graphics/java/android/graphics/SurfaceTexture.java +++ b/graphics/java/android/graphics/SurfaceTexture.java @@ -27,14 +27,18 @@ import android.view.Surface; /** * Captures frames from an image stream as an OpenGL ES texture. * - * <p>The image stream may come from either camera preview or video decode. A SurfaceTexture - * may be used in place of a SurfaceHolder when specifying the output destination of a - * {@link android.hardware.Camera} or {@link android.media.MediaPlayer} - * object. Doing so will cause all the frames from the image stream to be sent to the - * SurfaceTexture object rather than to the device's display. When {@link #updateTexImage} is - * called, the contents of the texture object specified when the SurfaceTexture was created are - * updated to contain the most recent image from the image stream. This may cause some frames of - * the stream to be skipped. + * <p>The image stream may come from either camera preview or video decode. A + * {@link android.view.Surface} created from a SurfaceTexture can be used as an output + * destination for the {@link android.hardware.camera2}, {@link android.media.MediaCodec}, + * {@link android.media.MediaPlayer}, and {@link android.renderscript.Allocation} APIs. + * When {@link #updateTexImage} is called, the contents of the texture object specified + * when the SurfaceTexture was created are updated to contain the most recent image from the image + * stream. This may cause some frames of the stream to be skipped. + * + * <p>A SurfaceTexture may also be used in place of a SurfaceHolder when specifying the output + * destination of the older {@link android.hardware.Camera} API. Doing so will cause all the + * frames from the image stream to be sent to the SurfaceTexture object rather than to the device's + * display. * * <p>When sampling from the texture one should first transform the texture coordinates using the * matrix queried via {@link #getTransformMatrix(float[])}. The transform matrix may change each diff --git a/media/java/android/media/MediaActionSound.java b/media/java/android/media/MediaActionSound.java index 7a520fe..2f4d136 100644 --- a/media/java/android/media/MediaActionSound.java +++ b/media/java/android/media/MediaActionSound.java @@ -24,13 +24,15 @@ import android.util.Log; * <p>A class for producing sounds that match those produced by various actions * taken by the media and camera APIs. </p> * - * <p>Use this class to play an appropriate camera operation sound when - * implementing a custom still or video recording mechanism (through the Camera - * preview callbacks with {@link android.hardware.Camera#setPreviewCallback - * Camera.setPreviewCallback}, or through GPU processing with {@link - * android.hardware.Camera#setPreviewTexture Camera.setPreviewTexture}, for - * example), or when implementing some other camera-like function in your - * application.</p> + * <p>This class is recommended for use with the {@link android.hardware.camera2} API, since the + * camera2 API does not play any sounds on its own for any capture or video recording actions.</p> + * + * <p>With the older {@link android.hardware.Camera} API, use this class to play an appropriate + * camera operation sound when implementing a custom still or video recording mechanism (through the + * Camera preview callbacks with + * {@link android.hardware.Camera#setPreviewCallback Camera.setPreviewCallback}, or through GPU + * processing with {@link android.hardware.Camera#setPreviewTexture Camera.setPreviewTexture}, for + * example), or when implementing some other camera-like function in your application.</p> * * <p>There is no need to play sounds when using * {@link android.hardware.Camera#takePicture Camera.takePicture} or @@ -136,10 +138,12 @@ public class MediaActionSound { * {@link android.media.MediaRecorder#start MediaRecorder.start}, and * {@link android.media.MediaRecorder#stop MediaRecorder.stop}.</p> * - * <p>Using this method makes it easy to match the default device sounds - * when recording or capturing data through the preview callbacks, or when - * implementing custom camera-like features in your - * application.</p> + * <p>With the {@link android.hardware.camera2 camera2} API, this method can be used to play + * standard camera operation sounds with the appropriate system behavior for such sounds.</p> + + * <p>With the older {@link android.hardware.Camera} API, using this method makes it easy to + * match the default device sounds when recording or capturing data through the preview + * callbacks, or when implementing custom camera-like features in your application.</p> * * <p>If the sound has not been loaded by {@link #load} before calling play, * play will load the sound at the cost of some additional latency before diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index f8c0494..3917bf1 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -114,23 +114,26 @@ public class MediaRecorder } /** - * Sets a Camera to use for recording. Use this function to switch - * quickly between preview and capture mode without a teardown of - * the camera object. {@link android.hardware.Camera#unlock()} should be - * called before this. Must call before prepare(). + * Sets a {@link android.hardware.Camera} to use for recording. + * + * <p>Use this function to switch quickly between preview and capture mode without a teardown of + * the camera object. {@link android.hardware.Camera#unlock()} should be called before + * this. Must call before {@link #prepare}.</p> * * @param c the Camera to use for recording + * @deprecated Use {@link #getSurface} and the {@link android.hardware.camera2} API instead. */ + @Deprecated public native void setCamera(Camera c); /** * Gets the surface to record from when using SURFACE video source. - * <p> - * Should only be called after prepare(). Frames rendered before start() - * will be discarded. - * </p> - * @throws IllegalStateException if it is called before prepare(), after - * stop() or is called when VideoSource is not set to SURFACE. + * + * <p> May only be called after {@link #prepare}. Frames rendered to the Surface before + * {@link #start} will be discarded.</p> + * + * @throws IllegalStateException if it is called before {@link #prepare}, after + * {@link #stop}, or is called when VideoSource is not set to SURFACE. * @see android.media.MediaRecorder.VideoSource */ public native Surface getSurface(); @@ -239,7 +242,7 @@ public class MediaRecorder public static final int DEFAULT = 0; /** Camera video source * <p> - * Using android.hardware.Camera as video source. + * Using the {@link android.hardware.Camera} API as video source. * </p> */ public static final int CAMERA = 1; @@ -248,7 +251,7 @@ public class MediaRecorder * Using a Surface as video source. * </p><p> * This flag must be used when recording from an - * android.hardware.camera2.CameraDevice source. + * {@link android.hardware.camera2} API source. * </p><p> * When using this video source type, use {@link MediaRecorder#getSurface()} * to retrieve the surface created by MediaRecorder. |