Merge "Fix for inputsize calculation" into main
diff --git a/camera/Camera.cpp b/camera/Camera.cpp
index d90f7c9..0bc735f 100644
--- a/camera/Camera.cpp
+++ b/camera/Camera.cpp
@@ -99,23 +99,21 @@
return c->unlock();
}
-// pass the buffered IGraphicBufferProducer to the camera service
-status_t Camera::setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer)
-{
- ALOGV("setPreviewTarget(%p)", bufferProducer.get());
- sp <::android::hardware::ICamera> c = mCamera;
+// pass the Surface to the camera service
+status_t Camera::setPreviewTarget(const sp<SurfaceType>& target) {
+ ALOGV("setPreviewTarget(%p)", target.get());
+ sp<::android::hardware::ICamera> c = mCamera;
if (c == 0) return NO_INIT;
- ALOGD_IF(bufferProducer == 0, "app passed NULL surface");
- return c->setPreviewTarget(bufferProducer);
+ ALOGD_IF(target == 0, "app passed NULL surface");
+ return c->setPreviewTarget(target);
}
-status_t Camera::setVideoTarget(const sp<IGraphicBufferProducer>& bufferProducer)
-{
- ALOGV("setVideoTarget(%p)", bufferProducer.get());
- sp <::android::hardware::ICamera> c = mCamera;
+status_t Camera::setVideoTarget(const sp<SurfaceType>& target) {
+ ALOGV("setVideoTarget(%p)", target.get());
+ sp<::android::hardware::ICamera> c = mCamera;
if (c == 0) return NO_INIT;
- ALOGD_IF(bufferProducer == 0, "app passed NULL video surface");
- return c->setVideoTarget(bufferProducer);
+ ALOGD_IF(target == 0, "app passed NULL video surface");
+ return c->setVideoTarget(target);
}
// start preview mode
@@ -272,12 +270,10 @@
c->setPreviewCallbackFlag(flag);
}
-status_t Camera::setPreviewCallbackTarget(
- const sp<IGraphicBufferProducer>& callbackProducer)
-{
- sp <::android::hardware::ICamera> c = mCamera;
+status_t Camera::setPreviewCallbackTarget(const sp<SurfaceType>& target) {
+ sp<::android::hardware::ICamera> c = mCamera;
if (c == 0) return NO_INIT;
- return c->setPreviewCallbackTarget(callbackProducer);
+ return c->setPreviewCallbackTarget(target);
}
status_t Camera::setAudioRestriction(int32_t mode)
diff --git a/camera/ICamera.cpp b/camera/ICamera.cpp
index b83edf7..0b811d2 100644
--- a/camera/ICamera.cpp
+++ b/camera/ICamera.cpp
@@ -17,16 +17,16 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "ICamera"
-#include <utils/Log.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <binder/Parcel.h>
-#include <camera/CameraUtils.h>
#include <android/hardware/ICamera.h>
#include <android/hardware/ICameraClient.h>
-#include <gui/IGraphicBufferProducer.h>
+#include <binder/Parcel.h>
+#include <camera/CameraUtils.h>
#include <gui/Surface.h>
+#include <gui/view/Surface.h>
#include <media/hardware/HardwareAPI.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <utils/Log.h>
namespace android {
namespace hardware {
@@ -34,8 +34,14 @@
enum {
DISCONNECT = IBinder::FIRST_CALL_TRANSACTION,
SET_PREVIEW_TARGET,
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ SET_PREVIEW_TARGET_SURFACE,
+#endif
SET_PREVIEW_CALLBACK_FLAG,
SET_PREVIEW_CALLBACK_TARGET,
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ SET_PREVIEW_CALLBACK_TARGET_SURFACE,
+#endif
START_PREVIEW,
STOP_PREVIEW,
AUTO_FOCUS,
@@ -54,6 +60,9 @@
RELEASE_RECORDING_FRAME,
SET_VIDEO_BUFFER_MODE,
SET_VIDEO_BUFFER_TARGET,
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ SET_VIDEO_BUFFER_TARGET_SURFACE,
+#endif
RELEASE_RECORDING_FRAME_HANDLE,
RELEASE_RECORDING_FRAME_HANDLE_BATCH,
SET_AUDIO_RESTRICTION,
@@ -79,15 +88,20 @@
return binder::Status::ok();
}
- // pass the buffered IGraphicBufferProducer to the camera service
- status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer)
- {
+ // pass the Surface to the camera service
+ status_t setPreviewTarget(const sp<SurfaceType>& target) {
ALOGV("setPreviewTarget");
Parcel data, reply;
data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
- sp<IBinder> b(IInterface::asBinder(bufferProducer));
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ view::Surface viewSurfaceProducer = view::Surface::fromSurface(target);
+ data.writeParcelable(viewSurfaceProducer);
+ remote()->transact(SET_PREVIEW_TARGET_SURFACE, data, &reply);
+#else
+ sp<IBinder> b(IInterface::asBinder(target));
data.writeStrongBinder(b);
remote()->transact(SET_PREVIEW_TARGET, data, &reply);
+#endif
return reply.readInt32();
}
@@ -102,15 +116,19 @@
remote()->transact(SET_PREVIEW_CALLBACK_FLAG, data, &reply);
}
- status_t setPreviewCallbackTarget(
- const sp<IGraphicBufferProducer>& callbackProducer)
- {
+ status_t setPreviewCallbackTarget(const sp<SurfaceType>& target) {
ALOGV("setPreviewCallbackTarget");
Parcel data, reply;
data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
- sp<IBinder> b(IInterface::asBinder(callbackProducer));
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ view::Surface viewCallbackProducer = view::Surface::fromSurface(target);
+ data.writeParcelable(viewCallbackProducer);
+ remote()->transact(SET_PREVIEW_CALLBACK_TARGET_SURFACE, data, &reply);
+#else
+ sp<IBinder> b(IInterface::asBinder(target));
data.writeStrongBinder(b);
remote()->transact(SET_PREVIEW_CALLBACK_TARGET, data, &reply);
+#endif
return reply.readInt32();
}
@@ -326,14 +344,19 @@
return reply.readInt32();
}
- status_t setVideoTarget(const sp<IGraphicBufferProducer>& bufferProducer)
- {
+ status_t setVideoTarget(const sp<SurfaceType>& target) {
ALOGV("setVideoTarget");
Parcel data, reply;
data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
- sp<IBinder> b(IInterface::asBinder(bufferProducer));
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ view::Surface viewSurfaceProducer = view::Surface::fromSurface(target);
+ data.writeParcelable(viewSurfaceProducer);
+ remote()->transact(SET_VIDEO_BUFFER_TARGET_SURFACE, data, &reply);
+#else
+ sp<IBinder> b(IInterface::asBinder(target));
data.writeStrongBinder(b);
remote()->transact(SET_VIDEO_BUFFER_TARGET, data, &reply);
+#endif
return reply.readInt32();
}
};
@@ -358,9 +381,25 @@
CHECK_INTERFACE(ICamera, data, reply);
sp<IGraphicBufferProducer> st =
interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ sp<Surface> sp = new Surface(st);
+ reply->writeInt32(setPreviewTarget(sp));
+#else
+ reply->writeInt32(setPreviewTarget(st));
+#endif
+ return NO_ERROR;
+ } break;
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ case SET_PREVIEW_TARGET_SURFACE: {
+ ALOGV("SET_PREVIEW_TARGET_SURFACE");
+ CHECK_INTERFACE(ICamera, data, reply);
+ view::Surface viewSurface;
+ data.readParcelable(&viewSurface);
+ sp<Surface> st = viewSurface.toSurface();
reply->writeInt32(setPreviewTarget(st));
return NO_ERROR;
} break;
+#endif
case SET_PREVIEW_CALLBACK_FLAG: {
ALOGV("SET_PREVIEW_CALLBACK_TYPE");
CHECK_INTERFACE(ICamera, data, reply);
@@ -373,9 +412,25 @@
CHECK_INTERFACE(ICamera, data, reply);
sp<IGraphicBufferProducer> cp =
interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ sp<Surface> sp = new Surface(cp);
+ reply->writeInt32(setPreviewCallbackTarget(sp));
+#else
+ reply->writeInt32(setPreviewCallbackTarget(cp));
+#endif
+ return NO_ERROR;
+ }
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ case SET_PREVIEW_CALLBACK_TARGET_SURFACE: {
+ ALOGV("SET_PREVIEW_CALLBACK_TARGET_SURFACE");
+ CHECK_INTERFACE(ICamera, data, reply);
+ view::Surface viewSurface;
+ data.readParcelable(&viewSurface);
+ sp<Surface> cp = viewSurface.toSurface();
reply->writeInt32(setPreviewCallbackTarget(cp));
return NO_ERROR;
}
+#endif
case START_PREVIEW: {
ALOGV("START_PREVIEW");
CHECK_INTERFACE(ICamera, data, reply);
@@ -508,9 +563,25 @@
CHECK_INTERFACE(ICamera, data, reply);
sp<IGraphicBufferProducer> st =
interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ sp<Surface> sp = new Surface(st);
+ reply->writeInt32(setVideoTarget(sp));
+#else
reply->writeInt32(setVideoTarget(st));
+#endif
return NO_ERROR;
} break;
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ case SET_VIDEO_BUFFER_TARGET_SURFACE: {
+ ALOGV("SET_VIDEO_BUFFER_TARGET_SURFACE");
+ CHECK_INTERFACE(ICamera, data, reply);
+ view::Surface viewSurface;
+ data.readParcelable(&viewSurface);
+ sp<Surface> cp = viewSurface.toSurface();
+ reply->writeInt32(setVideoTarget(cp));
+ return NO_ERROR;
+ } break;
+#endif
case SET_AUDIO_RESTRICTION: {
CHECK_INTERFACE(ICamera, data, reply);
int32_t mode = data.readInt32();
diff --git a/camera/include/camera/Camera.h b/camera/include/camera/Camera.h
index 646b139..fa84b4e 100644
--- a/camera/include/camera/Camera.h
+++ b/camera/include/camera/Camera.h
@@ -21,13 +21,18 @@
#include <android/hardware/ICameraService.h>
-#include <gui/IGraphicBufferProducer.h>
-#include <system/camera.h>
+#include <camera/CameraBase.h>
+#include <camera/CameraUtils.h>
#include <camera/ICameraRecordingProxy.h>
#include <camera/android/hardware/ICamera.h>
#include <camera/android/hardware/ICameraClient.h>
-#include <camera/CameraBase.h>
-#include <camera/CameraUtils.h>
+#include <gui/Flags.h>
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+#include <gui/Surface.h>
+#else
+#include <gui/IGraphicBufferProducer.h>
+#endif
+#include <system/camera.h>
namespace android {
@@ -91,8 +96,8 @@
status_t lock();
status_t unlock();
- // pass the buffered IGraphicBufferProducer to the camera service
- status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer);
+ // pass the SurfaceType to the camera service
+ status_t setPreviewTarget(const sp<SurfaceType>& target);
// start preview mode, must call setPreviewTarget first
status_t startPreview();
@@ -148,7 +153,7 @@
// Set the video buffer producer for camera to use in VIDEO_BUFFER_MODE_BUFFER_QUEUE
// mode.
- status_t setVideoTarget(const sp<IGraphicBufferProducer>& bufferProducer);
+ status_t setVideoTarget(const sp<SurfaceType>& target);
void setListener(const sp<CameraListener>& listener);
@@ -158,8 +163,7 @@
// disabled by calling it with CAMERA_FRAME_CALLBACK_FLAG_NOOP, and
// Target by calling it with a NULL interface.
void setPreviewCallbackFlags(int preview_callback_flag);
- status_t setPreviewCallbackTarget(
- const sp<IGraphicBufferProducer>& callbackProducer);
+ status_t setPreviewCallbackTarget(const sp<SurfaceType>& target);
sp<ICameraRecordingProxy> getRecordingProxy();
diff --git a/camera/include/camera/android/hardware/ICamera.h b/camera/include/camera/android/hardware/ICamera.h
index ec19e5d..eb887fb 100644
--- a/camera/include/camera/android/hardware/ICamera.h
+++ b/camera/include/camera/android/hardware/ICamera.h
@@ -22,6 +22,7 @@
#include <binder/Parcel.h>
#include <binder/IMemory.h>
#include <binder/Status.h>
+#include <gui/Flags.h>
#include <utils/String8.h>
namespace android {
@@ -61,9 +62,8 @@
// allow other processes to use this ICamera interface
virtual status_t unlock() = 0;
- // pass the buffered IGraphicBufferProducer to the camera service
- virtual status_t setPreviewTarget(
- const sp<IGraphicBufferProducer>& bufferProducer) = 0;
+ // pass the SurfaceType to the camera service
+ virtual status_t setPreviewTarget(const sp<SurfaceType>& bufferProducer) = 0;
// set the preview callback flag to affect how the received frames from
// preview are handled. Enabling preview callback flags disables any active
@@ -73,8 +73,7 @@
// of preview callback buffers. Passing a valid interface here disables any
// active preview callbacks set by setPreviewCallbackFlag(). Passing NULL
// disables the use of the callback target.
- virtual status_t setPreviewCallbackTarget(
- const sp<IGraphicBufferProducer>& callbackProducer) = 0;
+ virtual status_t setPreviewCallbackTarget(const sp<SurfaceType>& callbackProducer) = 0;
// start preview mode, must call setPreviewTarget first
virtual status_t startPreview() = 0;
@@ -138,8 +137,7 @@
virtual status_t setVideoBufferMode(int32_t videoBufferMode) = 0;
// Set the video buffer producer for camera to use in VIDEO_BUFFER_MODE_BUFFER_QUEUE mode.
- virtual status_t setVideoTarget(
- const sp<IGraphicBufferProducer>& bufferProducer) = 0;
+ virtual status_t setVideoTarget(const sp<SurfaceType>& bufferProducer) = 0;
// Set the audio restriction mode
virtual status_t setAudioRestriction(int32_t mode) = 0;
diff --git a/camera/ndk/include/camera/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h
index 7fb2d05..acc3c7c 100644
--- a/camera/ndk/include/camera/NdkCameraMetadataTags.h
+++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h
@@ -573,7 +573,7 @@
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
* capability or devices where
* <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
- * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a>
+ * lists ACAMERA_SENSOR_PIXEL_MODE,
* ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION /
* ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION must be used as the
* coordinate system for requests where ACAMERA_SENSOR_PIXEL_MODE is set to
@@ -802,7 +802,7 @@
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
* capability or devices where
* <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
- * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a>,
+ * lists ACAMERA_SENSOR_PIXEL_MODE,
* ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION /
* ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION must be used as the
* coordinate system for requests where ACAMERA_SENSOR_PIXEL_MODE is set to
@@ -1008,7 +1008,7 @@
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
* capability or devices where
* <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
- * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a>,
+ * lists ACAMERA_SENSOR_PIXEL_MODE,
* ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION /
* ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION must be used as the
* coordinate system for requests where ACAMERA_SENSOR_PIXEL_MODE is set to
@@ -4052,8 +4052,8 @@
* <p>For camera devices with the
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
* capability or devices where <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
- * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a></p>
- * <p>ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION /
+ * lists ACAMERA_SENSOR_PIXEL_MODE,
+ * ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION /
* ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION must be used as the
* coordinate system for requests where ACAMERA_SENSOR_PIXEL_MODE is set to
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION">CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION</a>.</p>
@@ -5999,7 +5999,7 @@
* This key will only be present for devices which advertise the
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
* capability or devices where <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
- * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a></p>
+ * lists ACAMERA_SENSOR_PIXEL_MODE.</p>
* <p>The data representation is <code>int[4]</code>, which maps to <code>(left, top, width, height)</code>.</p>
*
* @see ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE
@@ -6032,7 +6032,7 @@
* This key will only be present for devices which advertise the
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
* capability or devices where <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
- * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a></p>
+ * lists ACAMERA_SENSOR_PIXEL_MODE.</p>
*
* @see ACAMERA_SENSOR_INFO_PHYSICAL_SIZE
* @see ACAMERA_SENSOR_PIXEL_MODE
@@ -6061,7 +6061,7 @@
* This key will only be present for devices which advertise the
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
* capability or devices where <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
- * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a></p>
+ * lists ACAMERA_SENSOR_PIXEL_MODE.</p>
* <p>The data representation is <code>int[4]</code>, which maps to <code>(left, top, width, height)</code>.</p>
*
* @see ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE
@@ -6100,7 +6100,7 @@
* <ul>
* <li>This key will be present if
* <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
- * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a>, since RAW
+ * lists ACAMERA_SENSOR_PIXEL_MODE, since RAW
* images may not necessarily have a regular bayer pattern when
* <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a> is set to
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION">CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION</a>.</li>
@@ -6470,9 +6470,19 @@
* height dimensions are given in ACAMERA_SENSOR_INFO_PIXEL_ARRAY_SIZE.
* This may include hot pixels that lie outside of the active array
* bounds given by ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE.</p>
+ * <p>For camera devices with the
+ * <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
+ * capability or devices where
+ * <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
+ * lists ACAMERA_SENSOR_PIXEL_MODE,
+ * ACAMERA_SENSOR_INFO_PIXEL_ARRAY_SIZE_MAXIMUM_RESOLUTION will be used as the
+ * pixel array size if the corresponding request sets ACAMERA_SENSOR_PIXEL_MODE to
+ * <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION">CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION</a>.</p>
*
* @see ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE
* @see ACAMERA_SENSOR_INFO_PIXEL_ARRAY_SIZE
+ * @see ACAMERA_SENSOR_INFO_PIXEL_ARRAY_SIZE_MAXIMUM_RESOLUTION
+ * @see ACAMERA_SENSOR_PIXEL_MODE
*/
ACAMERA_STATISTICS_HOT_PIXEL_MAP = // int32[2*n]
ACAMERA_STATISTICS_START + 15,
@@ -7622,8 +7632,8 @@
* <p>For camera devices with the
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR">CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR</a>
* capability or devices where <a href="https://developer.android.com/reference/CameraCharacteristics.html#getAvailableCaptureRequestKeys">CameraCharacteristics#getAvailableCaptureRequestKeys</a>
- * lists <a href="https://developer.android.com/reference/CaptureRequest.html#SENSOR_PIXEL_MODE">ACAMERA_SENSOR_PIXEL_MODE</a>
- * , the current active physical device
+ * lists ACAMERA_SENSOR_PIXEL_MODE,
+ * the current active physical device
* ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION /
* ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION must be used as the
* coordinate system for requests where ACAMERA_SENSOR_PIXEL_MODE is set to
diff --git a/camera/tests/CameraZSLTests.cpp b/camera/tests/CameraZSLTests.cpp
index 2740d09..b06f9b4 100644
--- a/camera/tests/CameraZSLTests.cpp
+++ b/camera/tests/CameraZSLTests.cpp
@@ -20,17 +20,18 @@
#include <gtest/gtest.h>
#include <android/content/AttributionSourceState.h>
+#include <android/hardware/ICameraService.h>
#include <binder/ProcessState.h>
-#include <utils/Errors.h>
-#include <utils/Log.h>
-#include <gui/Surface.h>
-#include <gui/SurfaceComposerClient.h>
-#include <camera/CameraParameters.h>
-#include <camera/CameraMetadata.h>
#include <camera/Camera.h>
+#include <camera/CameraMetadata.h>
+#include <camera/CameraParameters.h>
#include <camera/CameraUtils.h>
#include <camera/StringUtils.h>
-#include <android/hardware/ICameraService.h>
+#include <gui/Flags.h>
+#include <gui/Surface.h>
+#include <gui/SurfaceComposerClient.h>
+#include <utils/Errors.h>
+#include <utils/Log.h>
using namespace android;
using namespace android::hardware;
@@ -276,8 +277,11 @@
previewSurface = surfaceControl->getSurface();
ASSERT_TRUE(previewSurface != NULL);
- ASSERT_EQ(NO_ERROR, cameraDevice->setPreviewTarget(
- previewSurface->getIGraphicBufferProducer()));
+ ASSERT_EQ(NO_ERROR, cameraDevice->setPreviewTarget(previewSurface
+#if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ ->getIGraphicBufferProducer()
+#endif
+ ));
cameraDevice->setPreviewCallbackFlag(
CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER);
diff --git a/camera/tests/fuzzer/camera_fuzzer.cpp b/camera/tests/fuzzer/camera_fuzzer.cpp
index f46d246..f976fe1 100644
--- a/camera/tests/fuzzer/camera_fuzzer.cpp
+++ b/camera/tests/fuzzer/camera_fuzzer.cpp
@@ -20,6 +20,7 @@
#include <android/content/AttributionSourceState.h>
#include <binder/MemoryDealer.h>
#include <fuzzer/FuzzedDataProvider.h>
+#include <gui/Flags.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include "camera2common.h"
@@ -210,7 +211,11 @@
auto callCameraAPIs = mFDP->PickValueInArray<const std::function<void()>>({
[&]() {
if (surfaceControl) {
- mCamera->setPreviewTarget(surface->getIGraphicBufferProducer());
+ mCamera->setPreviewTarget(surface
+#if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ ->getIGraphicBufferProducer()
+#endif
+ );
}
},
[&]() {
@@ -267,7 +272,11 @@
},
[&]() {
if (surfaceControl) {
- mCamera->setVideoTarget(surface->getIGraphicBufferProducer());
+ mCamera->setVideoTarget(surface
+#if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ ->getIGraphicBufferProducer()
+#endif
+ );
}
},
[&]() {
@@ -283,7 +292,11 @@
},
[&]() {
if (surfaceControl) {
- mCamera->setPreviewCallbackTarget(surface->getIGraphicBufferProducer());
+ mCamera->setPreviewCallbackTarget(surface
+#if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ ->getIGraphicBufferProducer()
+#endif
+ );
}
},
[&]() { mCamera->getRecordingProxy(); },
diff --git a/drm/mediadrm/plugins/clearkey/aidl/Android.bp b/drm/mediadrm/plugins/clearkey/aidl/Android.bp
index 079e075..4132ba2 100644
--- a/drm/mediadrm/plugins/clearkey/aidl/Android.bp
+++ b/drm/mediadrm/plugins/clearkey/aidl/Android.bp
@@ -134,6 +134,7 @@
required: [
"com.android.hardware.drm.clearkey",
],
+ vendor: true,
}
cc_defaults {
diff --git a/media/aconfig/codec_fwk.aconfig b/media/aconfig/codec_fwk.aconfig
index ed53fe1..84c0f48 100644
--- a/media/aconfig/codec_fwk.aconfig
+++ b/media/aconfig/codec_fwk.aconfig
@@ -126,6 +126,13 @@
}
flag {
+ name: "rendering_depth_removal"
+ namespace: "codec_fwk"
+ description: "Feature flag for removing rendering depth"
+ bug: "275527219"
+}
+
+flag {
name: "secure_codecs_require_crypto"
namespace: "codec_fwk"
description: "Bugfix flag for requiring setting crypto for secure codecs"
diff --git a/media/audio/aconfig/Android.bp b/media/audio/aconfig/Android.bp
index 47418cf..2da6758 100644
--- a/media/audio/aconfig/Android.bp
+++ b/media/audio/aconfig/Android.bp
@@ -116,7 +116,10 @@
package: "android.media.audio",
container: "system",
srcs: ["audio_framework.aconfig"],
- visibility: ["//frameworks/base/api"],
+ visibility: [
+ "//frameworks/base/api",
+ "//frameworks/base/core/res",
+ ],
}
aconfig_declarations {
diff --git a/media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp b/media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp
index 562dcf5..52920c2 100644
--- a/media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp
+++ b/media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp
@@ -743,6 +743,25 @@
}
status_t C2SoftMpeg2Dec::deleteDecoder() {
+ // API call to IV_CMD_RETRIEVE_MEMREC not only retrieves the memory records
+ // but also joins active threads and destroys conditional thread variables and
+ // mutex locks for each thread.
+ iv_retrieve_mem_rec_ip_t s_retrieve_mem_ip;
+ iv_retrieve_mem_rec_op_t s_retrieve_mem_op;
+
+ s_retrieve_mem_ip.pv_mem_rec_location = (iv_mem_rec_t *)mMemRecords;
+ s_retrieve_mem_ip.e_cmd = IV_CMD_RETRIEVE_MEMREC;
+ s_retrieve_mem_ip.u4_size = sizeof(iv_retrieve_mem_rec_ip_t);
+ s_retrieve_mem_op.u4_size = sizeof(iv_retrieve_mem_rec_op_t);
+
+ IV_API_CALL_STATUS_T status = ivdec_api_function(mDecHandle,
+ &s_retrieve_mem_ip,
+ &s_retrieve_mem_op);
+ if (IV_SUCCESS != status) {
+ ALOGE("error in %s: 0x%x", __func__, s_retrieve_mem_op.u4_error_code);
+ return UNKNOWN_ERROR;
+ }
+
if (mMemRecords) {
iv_mem_rec_t *ps_mem_rec = mMemRecords;
diff --git a/media/codec2/sfplugin/Android.bp b/media/codec2/sfplugin/Android.bp
index 15a7a6a..cc5d10c 100644
--- a/media/codec2/sfplugin/Android.bp
+++ b/media/codec2/sfplugin/Android.bp
@@ -50,6 +50,7 @@
],
static_libs: [
+ "libPlatformProperties",
"libSurfaceFlingerProperties",
"aconfig_mediacodec_flags_c_lib",
"android.media.codec-aconfig-cc",
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index acf1c0b..5c46d99 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -38,6 +38,7 @@
#include <android/hardware/cas/native/1.0/IDescrambler.h>
#include <android/hardware/drm/1.0/types.h>
+#include <android/sysprop/MediaProperties.sysprop.h>
#include <android-base/parseint.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
@@ -207,8 +208,18 @@
Mutexed<BlockPools>::Locked pools(mBlockPools);
pools->outputPoolId = C2BlockPool::BASIC_LINEAR;
}
- std::string value = GetServerConfigurableFlag("media_native", "ccodec_rendering_depth", "3");
- android::base::ParseInt(value, &mRenderingDepth);
+ if (android::media::codec::provider_->rendering_depth_removal()) {
+ constexpr int kAndroidApi202404 = 202404;
+ int vendorVersion = ::android::base::GetIntProperty("ro.vendor.api_level", -1);
+ using ::android::sysprop::MediaProperties::codec2_remove_rendering_depth;
+ if (vendorVersion > kAndroidApi202404 || codec2_remove_rendering_depth().value_or(false)) {
+ mRenderingDepth = 0;
+ }
+ } else {
+ std::string value = GetServerConfigurableFlag(
+ "media_native", "ccodec_rendering_depth", "3");
+ android::base::ParseInt(value, &mRenderingDepth);
+ }
mOutputSurface.lock()->maxDequeueBuffers = kSmoothnessFactor + mRenderingDepth;
}
diff --git a/media/libaudiohal/Android.bp b/media/libaudiohal/Android.bp
index 75e2c11..74a64bf 100644
--- a/media/libaudiohal/Android.bp
+++ b/media/libaudiohal/Android.bp
@@ -23,7 +23,6 @@
],
required: [
- "libaudiohal@5.0",
"libaudiohal@6.0",
"libaudiohal@7.0",
"libaudiohal@7.1",
diff --git a/media/libaudiohal/FactoryHal.cpp b/media/libaudiohal/FactoryHal.cpp
index 15cb297..2c30693 100644
--- a/media/libaudiohal/FactoryHal.cpp
+++ b/media/libaudiohal/FactoryHal.cpp
@@ -50,12 +50,11 @@
* This list need to keep sync with AudioHalVersionInfo.VERSIONS in
* media/java/android/media/AudioHalVersionInfo.java.
*/
-static const std::array<AudioHalVersionInfo, 5> sAudioHALVersions = {
+static const std::array<AudioHalVersionInfo, 4> sAudioHALVersions = {
AudioHalVersionInfo(AudioHalVersionInfo::Type::AIDL, 1, 0),
AudioHalVersionInfo(AudioHalVersionInfo::Type::HIDL, 7, 1),
AudioHalVersionInfo(AudioHalVersionInfo::Type::HIDL, 7, 0),
AudioHalVersionInfo(AudioHalVersionInfo::Type::HIDL, 6, 0),
- AudioHalVersionInfo(AudioHalVersionInfo::Type::HIDL, 5, 0),
};
static const std::map<AudioHalVersionInfo::Type, InterfaceName> sDevicesHALInterfaces = {
diff --git a/media/libaudiohal/impl/Android.bp b/media/libaudiohal/impl/Android.bp
index 1a6b949..f5dec56 100644
--- a/media/libaudiohal/impl/Android.bp
+++ b/media/libaudiohal/impl/Android.bp
@@ -83,32 +83,6 @@
}
cc_library_shared {
- name: "libaudiohal@5.0",
- defaults: [
- "libaudiohal_default",
- "libaudiohal_hidl_default",
- ],
- srcs: [
- ":audio_core_hal_client_sources",
- ":audio_effect_hidl_hal_client_sources",
- "EffectsFactoryHalEntry.cpp",
- ],
- shared_libs: [
- "android.hardware.audio.common@5.0",
- "android.hardware.audio.common@5.0-util",
- "android.hardware.audio.effect@5.0",
- "android.hardware.audio.effect@5.0-util",
- "android.hardware.audio@5.0",
- "android.hardware.audio@5.0-util",
- ],
- cflags: [
- "-DMAJOR_VERSION=5",
- "-DMINOR_VERSION=0",
- "-include common/all-versions/VersionMacro.h",
- ],
-}
-
-cc_library_shared {
name: "libaudiohal@6.0",
defaults: [
"libaudiohal_default",
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index 086baa3..23e7a47 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -59,6 +59,7 @@
#include <media/stagefright/PersistentSurface.h>
#include <media/MediaProfiles.h>
#include <camera/CameraParameters.h>
+#include <gui/Flags.h>
#include <utils/Errors.h>
#include <sys/types.h>
@@ -1932,16 +1933,32 @@
return BAD_VALUE;
}
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ sp<Surface> surface = new Surface(mPreviewSurface);
+ mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera(
+ mCamera, mCameraProxy, mCameraId, clientName, uid, pid,
+ videoSize, mFrameRate, surface,
+ std::llround(1e6 / mCaptureFps));
+#else
mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera(
mCamera, mCameraProxy, mCameraId, clientName, uid, pid,
videoSize, mFrameRate, mPreviewSurface,
std::llround(1e6 / mCaptureFps));
+#endif
*cameraSource = mCameraSourceTimeLapse;
} else {
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ sp<Surface> surface = new Surface(mPreviewSurface);
+ *cameraSource = CameraSource::CreateFromCamera(
+ mCamera, mCameraProxy, mCameraId, clientName, uid, pid,
+ videoSize, mFrameRate,
+ surface);
+#else
*cameraSource = CameraSource::CreateFromCamera(
mCamera, mCameraProxy, mCameraId, clientName, uid, pid,
videoSize, mFrameRate,
mPreviewSurface);
+#endif
}
mCamera.clear();
mCameraProxy.clear();
diff --git a/media/libmediaplayerservice/fuzzer/mediarecorder_fuzzer.cpp b/media/libmediaplayerservice/fuzzer/mediarecorder_fuzzer.cpp
index 2518c21..3339ae8 100644
--- a/media/libmediaplayerservice/fuzzer/mediarecorder_fuzzer.cpp
+++ b/media/libmediaplayerservice/fuzzer/mediarecorder_fuzzer.cpp
@@ -24,6 +24,7 @@
#include <fakeservicemanager/FakeServiceManager.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/Surface.h>
+#include <gui/Flags.h>
#include <gui/SurfaceComposerClient.h>
#include <media/stagefright/PersistentSurface.h>
#include <media/stagefright/foundation/AString.h>
@@ -126,14 +127,9 @@
status_t connect(const sp<ICameraClient> & /*client*/) override { return 0; };
status_t lock() override { return 0; };
status_t unlock() override { return 0; };
- status_t setPreviewTarget(const sp<IGraphicBufferProducer> & /*bufferProducer*/) override {
- return 0;
- };
+ status_t setPreviewTarget(const sp<SurfaceType> & /*target*/) override { return 0; };
+ status_t setPreviewCallbackTarget(const sp<SurfaceType> & /*target*/) override { return 0; };
void setPreviewCallbackFlag(int /*flag*/) override{};
- status_t setPreviewCallbackTarget(
- const sp<IGraphicBufferProducer> & /*callbackProducer*/) override {
- return 0;
- };
status_t startPreview() override { return 0; };
void stopPreview() override{};
bool previewEnabled() override { return true; };
@@ -152,9 +148,7 @@
return 0;
};
status_t setVideoBufferMode(int32_t /*videoBufferMode*/) override { return 0; };
- status_t setVideoTarget(const sp<IGraphicBufferProducer> & /*bufferProducer*/) override {
- return 0;
- };
+ status_t setVideoTarget(const sp<SurfaceType> & /*target*/) override { return 0; };
status_t setAudioRestriction(int32_t /*mode*/) override { return 0; };
int32_t getGlobalAudioRestriction() override { return 0; };
IBinder *onAsBinder() override { return reinterpret_cast<IBinder *>(this); };
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index e26f189..81a5508 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -35,6 +35,7 @@
#include <camera/StringUtils.h>
#include <com_android_graphics_libgui_flags.h>
#include <gui/Surface.h>
+#include <gui/Flags.h>
#include <utils/String8.h>
#include <cutils/properties.h>
@@ -99,7 +100,7 @@
pid_t clientPid,
Size videoSize,
int32_t frameRate,
- const sp<IGraphicBufferProducer>& surface) {
+ const sp<SurfaceType>& surface) {
CameraSource *source = new CameraSource(camera, proxy, cameraId,
clientName, clientUid, clientPid, videoSize, frameRate, surface);
@@ -115,7 +116,7 @@
pid_t clientPid,
Size videoSize,
int32_t frameRate,
- const sp<IGraphicBufferProducer>& surface)
+ const sp<SurfaceType>& surface)
: mCameraFlags(0),
mNumInputBuffers(0),
mVideoFrameRate(-1),
@@ -490,11 +491,23 @@
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)
mVideoBufferConsumer = new BufferItemConsumer(usage, bufferCount);
mVideoBufferConsumer->setName(String8::format("StageFright-CameraSource"));
+
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ mVideoBufferProducer = mVideoBufferConsumer->getSurface();
+#else
mVideoBufferProducer = mVideoBufferConsumer->getSurface()->getIGraphicBufferProducer();
+#endif // WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+
#else
mVideoBufferConsumer = new BufferItemConsumer(consumer, usage, bufferCount);
mVideoBufferConsumer->setName(String8::format("StageFright-CameraSource"));
+
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ mVideoBufferProducer = new Surface(producer);
+#else
mVideoBufferProducer = producer;
+#endif // WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+
#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)
status_t res = mVideoBufferConsumer->setDefaultBufferSize(width, height);
diff --git a/media/libstagefright/CameraSourceTimeLapse.cpp b/media/libstagefright/CameraSourceTimeLapse.cpp
index 50a512f..b1a005b 100644
--- a/media/libstagefright/CameraSourceTimeLapse.cpp
+++ b/media/libstagefright/CameraSourceTimeLapse.cpp
@@ -29,6 +29,7 @@
#include <media/stagefright/MetaData.h>
#include <camera/Camera.h>
#include <camera/CameraParameters.h>
+#include <gui/Flags.h>
#include <utils/String8.h>
#include <utils/Vector.h>
@@ -44,7 +45,11 @@
pid_t clientPid,
Size videoSize,
int32_t videoFrameRate,
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ const sp<Surface>& surface,
+#else
const sp<IGraphicBufferProducer>& surface,
+#endif
int64_t timeBetweenFrameCaptureUs) {
CameraSourceTimeLapse *source = new
@@ -71,7 +76,11 @@
pid_t clientPid,
Size videoSize,
int32_t videoFrameRate,
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ const sp<Surface>& surface,
+#else
const sp<IGraphicBufferProducer>& surface,
+#endif
int64_t timeBetweenFrameCaptureUs)
: CameraSource(camera, proxy, cameraId, clientName, clientUid, clientPid,
videoSize, videoFrameRate, surface),
diff --git a/media/libstagefright/include/media/stagefright/CameraSource.h b/media/libstagefright/include/media/stagefright/CameraSource.h
index f42e315..54e4f18 100644
--- a/media/libstagefright/include/media/stagefright/CameraSource.h
+++ b/media/libstagefright/include/media/stagefright/CameraSource.h
@@ -25,6 +25,8 @@
#include <camera/ICameraRecordingProxy.h>
#include <camera/CameraParameters.h>
#include <gui/BufferItemConsumer.h>
+#include <gui/Surface.h>
+#include <gui/Flags.h>
#include <utils/List.h>
#include <utils/RefBase.h>
#include <utils/String16.h>
@@ -77,7 +79,7 @@
pid_t clientPid,
Size videoSize,
int32_t frameRate,
- const sp<IGraphicBufferProducer>& surface);
+ const sp<SurfaceType>& surface);
virtual ~CameraSource();
@@ -165,7 +167,7 @@
sp<Camera> mCamera;
sp<ICameraRecordingProxy> mCameraRecordingProxy;
sp<DeathNotifier> mDeathNotifier;
- sp<IGraphicBufferProducer> mSurface;
+ sp<SurfaceType> mSurface;
sp<MetaData> mMeta;
int64_t mStartTimeUs;
@@ -180,8 +182,7 @@
CameraSource(const sp<hardware::ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
int32_t cameraId, const String16& clientName, uid_t clientUid, pid_t clientPid,
- Size videoSize, int32_t frameRate,
- const sp<IGraphicBufferProducer>& surface);
+ Size videoSize, int32_t frameRate, const sp<SurfaceType> & surface);
virtual status_t startCameraRecording();
virtual void releaseRecordingFrame(const sp<IMemory>& frame);
@@ -221,7 +222,7 @@
static const nsecs_t kMemoryBaseAvailableTimeoutNs = 200000000; // 200ms
// Consumer and producer of the buffer queue between this class and camera.
sp<BufferItemConsumer> mVideoBufferConsumer;
- sp<IGraphicBufferProducer> mVideoBufferProducer;
+ sp<SurfaceType> mVideoBufferProducer;
// Memory used to send the buffers to encoder, where sp<IMemory> stores VideoNativeMetadata.
sp<IMemoryHeap> mMemoryHeapBase;
List<sp<IMemory>> mMemoryBases;
diff --git a/media/libstagefright/include/media/stagefright/CameraSourceTimeLapse.h b/media/libstagefright/include/media/stagefright/CameraSourceTimeLapse.h
index 3c311cf..a789b12 100644
--- a/media/libstagefright/include/media/stagefright/CameraSourceTimeLapse.h
+++ b/media/libstagefright/include/media/stagefright/CameraSourceTimeLapse.h
@@ -23,6 +23,7 @@
#include <utils/RefBase.h>
#include <utils/threads.h>
#include <utils/String16.h>
+#include <gui/Flags.h>
namespace android {
@@ -44,7 +45,7 @@
pid_t clientPid,
Size videoSize,
int32_t videoFrameRate,
- const sp<IGraphicBufferProducer>& surface,
+ const sp<SurfaceType>& surface,
int64_t timeBetweenTimeLapseFrameCaptureUs);
virtual ~CameraSourceTimeLapse();
@@ -120,7 +121,7 @@
pid_t clientPid,
Size videoSize,
int32_t videoFrameRate,
- const sp<IGraphicBufferProducer>& surface,
+ const sp<SurfaceType>& surface,
int64_t timeBetweenTimeLapseFrameCaptureUs);
// Wrapper over CameraSource::signalBufferReturned() to implement quick stop.
diff --git a/services/audiopolicy/common/managerdefinitions/include/IOProfile.h b/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
index 688772c..c2ee5f6 100644
--- a/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
+++ b/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
@@ -73,7 +73,8 @@
enum CompatibilityScore{
NO_MATCH = 0,
PARTIAL_MATCH = 1,
- EXACT_MATCH = 2
+ PARTIAL_MATCH_WITH_FLAG = 2,
+ EXACT_MATCH = 3
};
/**
@@ -92,7 +93,6 @@
* @param channelMask to be checked for compatibility. Must be specified
* @param updatedChannelMask if non-NULL, it is assigned the actual channel mask
* @param flags to be checked for compatibility
- * @param exactMatchRequiredForInputFlags true if exact match is required on flags
* @return how the IO profile is compatible with the given parameters.
*/
CompatibilityScore getCompatibilityScore(const DeviceVector &devices,
@@ -103,8 +103,7 @@
audio_channel_mask_t channelMask,
audio_channel_mask_t *updatedChannelMask,
// FIXME parameter type
- uint32_t flags,
- bool exactMatchRequiredForInputFlags = false) const;
+ uint32_t flags) const;
/**
* @brief areAllDevicesSupported: Checks if the given devices are supported by the IO profile.
@@ -119,11 +118,9 @@
* specified flags.
*
* @param flags to be checked for compatibility
- * @param exactMatchRequiredForInputFlags true if exact match is required on flags
* @return true if the profile is compatible, false otherwise.
*/
- bool isCompatibleProfileForFlags(uint32_t flags,
- bool exactMatchRequiredForInputFlags = false) const;
+ bool isCompatibleProfileForFlags(uint32_t flags) const;
void dump(String8 *dst, int spaces) const;
void log();
@@ -235,6 +232,7 @@
private:
void refreshMixerBehaviors();
+ CompatibilityScore getFlagsCompatibleScore(uint32_t flags) const;
DeviceVector mSupportedDevices; // supported devices: this input/output can be routed from/to
diff --git a/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp b/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp
index 991b103..bc9eb20 100644
--- a/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp
@@ -42,15 +42,14 @@
audio_channel_mask_t channelMask,
audio_channel_mask_t *updatedChannelMask,
// FIXME type punning here
- uint32_t flags,
- bool exactMatchRequiredForInputFlags) const {
+ uint32_t flags) const {
const bool isPlaybackThread =
getType() == AUDIO_PORT_TYPE_MIX && getRole() == AUDIO_PORT_ROLE_SOURCE;
const bool isRecordThread =
getType() == AUDIO_PORT_TYPE_MIX && getRole() == AUDIO_PORT_ROLE_SINK;
ALOG_ASSERT(isPlaybackThread != isRecordThread);
- if (!areAllDevicesSupported(devices) ||
- !isCompatibleProfileForFlags(flags, exactMatchRequiredForInputFlags)) {
+ const auto flagsCompatibleScore = getFlagsCompatibleScore(flags);
+ if (!areAllDevicesSupported(devices) || flagsCompatibleScore == NO_MATCH) {
return NO_MATCH;
}
@@ -81,7 +80,11 @@
result = EXACT_MATCH;
} else if (checkCompatibleAudioProfile(
myUpdatedSamplingRate, myUpdatedChannelMask, myUpdatedFormat) == NO_ERROR) {
- result = PARTIAL_MATCH;
+ if (flagsCompatibleScore == EXACT_MATCH) {
+ result = PARTIAL_MATCH_WITH_FLAG;
+ } else {
+ result = PARTIAL_MATCH;
+ }
} else {
return result;
}
@@ -118,32 +121,8 @@
return mSupportedDevices.containsAllDevices(devices);
}
-bool IOProfile::isCompatibleProfileForFlags(uint32_t flags,
- bool exactMatchRequiredForInputFlags) const {
- const bool isPlaybackThread =
- getType() == AUDIO_PORT_TYPE_MIX && getRole() == AUDIO_PORT_ROLE_SOURCE;
- const bool isRecordThread =
- getType() == AUDIO_PORT_TYPE_MIX && getRole() == AUDIO_PORT_ROLE_SINK;
- ALOG_ASSERT(isPlaybackThread != isRecordThread);
-
- const uint32_t mustMatchOutputFlags =
- AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_HW_AV_SYNC|AUDIO_OUTPUT_FLAG_MMAP_NOIRQ;
- if (isPlaybackThread &&
- !audio_output_flags_is_subset((audio_output_flags_t)getFlags(),
- (audio_output_flags_t)flags,
- mustMatchOutputFlags)) {
- return false;
- }
- // The only input flag that is allowed to be different is the fast flag.
- // An existing fast stream is compatible with a normal track request.
- // An existing normal stream is compatible with a fast track request,
- // but the fast request will be denied by AudioFlinger and converted to normal track.
- if (isRecordThread && ((getFlags() ^ flags) &
- ~(exactMatchRequiredForInputFlags ? AUDIO_INPUT_FLAG_NONE : AUDIO_INPUT_FLAG_FAST))) {
- return false;
- }
-
- return true;
+bool IOProfile::isCompatibleProfileForFlags(uint32_t flags) const {
+ return getFlagsCompatibleScore(flags) != NO_MATCH;
}
bool IOProfile::containsSingleDeviceSupportingEncodedFormats(
@@ -228,6 +207,39 @@
}
}
+IOProfile::CompatibilityScore IOProfile::getFlagsCompatibleScore(uint32_t flags) const {
+ const bool isPlaybackThread =
+ getType() == AUDIO_PORT_TYPE_MIX && getRole() == AUDIO_PORT_ROLE_SOURCE;
+ const bool isRecordThread =
+ getType() == AUDIO_PORT_TYPE_MIX && getRole() == AUDIO_PORT_ROLE_SINK;
+ ALOG_ASSERT(isPlaybackThread != isRecordThread);
+
+ const uint32_t mustMatchOutputFlags =
+ AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_HW_AV_SYNC|AUDIO_OUTPUT_FLAG_MMAP_NOIRQ;
+ if (isPlaybackThread &&
+ !audio_output_flags_is_subset((audio_output_flags_t)getFlags(),
+ (audio_output_flags_t)flags,
+ mustMatchOutputFlags)) {
+ return NO_MATCH;
+ }
+ // The only input flag that is allowed to be different is the fast flag.
+ // An existing fast stream is compatible with a normal track request.
+ // An existing normal stream is compatible with a fast track request,
+ // but the fast request will be denied by AudioFlinger and converted to normal track.
+ if (isRecordThread) {
+ const auto unmatchedFlag = getFlags() ^ flags;
+ if (unmatchedFlag == AUDIO_INPUT_FLAG_NONE) {
+ return EXACT_MATCH;
+ } else if (unmatchedFlag == AUDIO_INPUT_FLAG_FAST) {
+ return PARTIAL_MATCH;
+ } else {
+ return NO_MATCH;
+ }
+ }
+
+ return EXACT_MATCH;
+}
+
void IOProfile::dump(String8 *dst, int spaces) const
{
String8 extraInfo;
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 62cb6c7..0aa3dfc 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -5025,8 +5025,7 @@
nullptr /*updatedFormat*/,
mixerAttributes->config.channel_mask,
nullptr /*updatedChannelMask*/,
- flags,
- false /*exactMatchRequiredForInputFlags*/)
+ flags)
!= IOProfile::NO_MATCH) {
profile = curProfile;
break;
@@ -8236,7 +8235,7 @@
const underlying_input_flag_t oriFlags = flags;
for (;;) {
- sp<IOProfile> firstInexact = nullptr;
+ sp<IOProfile> inexact = nullptr;
uint32_t inexactSamplingRate = 0;
audio_format_t inexactFormat = AUDIO_FORMAT_INVALID;
audio_channel_mask_t inexactChannelMask = AUDIO_CHANNEL_INVALID;
@@ -8247,7 +8246,7 @@
for (const auto& profile : hwModule->getInputProfiles()) {
// profile->log();
//updatedFormat = format;
- if (profile->getCompatibilityScore(
+ auto compatibleScore = profile->getCompatibilityScore(
DeviceVector(device),
samplingRate,
&updatedSamplingRate,
@@ -8256,27 +8255,16 @@
channelMask,
&updatedChannelMask,
// FIXME ugly cast
- (audio_output_flags_t) flags,
- true /*exactMatchRequiredForInputFlags*/) == IOProfile::EXACT_MATCH) {
+ (audio_output_flags_t) flags);
+ if (compatibleScore == IOProfile::EXACT_MATCH) {
samplingRate = updatedSamplingRate;
format = updatedFormat;
channelMask = updatedChannelMask;
return profile;
- }
- if (firstInexact == nullptr
- && profile->getCompatibilityScore(
- DeviceVector(device),
- samplingRate,
- &updatedSamplingRate,
- format,
- &updatedFormat,
- channelMask,
- &updatedChannelMask,
- // FIXME ugly cast
- (audio_output_flags_t) flags,
- false /*exactMatchRequiredForInputFlags*/)
- != IOProfile::NO_MATCH) {
- firstInexact = profile;
+ } else if ((flags != AUDIO_INPUT_FLAG_NONE
+ && compatibleScore == IOProfile::PARTIAL_MATCH_WITH_FLAG)
+ || (inexact == nullptr && compatibleScore != IOProfile::NO_MATCH)) {
+ inexact = profile;
inexactSamplingRate = updatedSamplingRate;
inexactFormat = updatedFormat;
inexactChannelMask = updatedChannelMask;
@@ -8284,11 +8272,11 @@
}
}
- if (firstInexact != nullptr) {
+ if (inexact != nullptr) {
samplingRate = inexactSamplingRate;
format = inexactFormat;
channelMask = inexactChannelMask;
- return firstInexact;
+ return inexact;
} else if (flags & AUDIO_INPUT_FLAG_RAW) {
flags = (audio_input_flags_t) (flags & ~AUDIO_INPUT_FLAG_RAW); // retry
} else if ((flags & mustMatchFlag) == AUDIO_INPUT_FLAG_NONE &&
@@ -9261,8 +9249,7 @@
: hwModule->getOutputProfiles();
for (const auto& profile : ioProfiles) {
if (!profile->areAllDevicesSupported(devices) ||
- !profile->isCompatibleProfileForFlags(
- flags, false /*exactMatchRequiredForInputFlags*/)) {
+ !profile->isCompatibleProfileForFlags(flags)) {
continue;
}
audioProfiles.addAllValidProfiles(profile->asAudioPort()->getAudioProfiles());
diff --git a/services/audiopolicy/tests/audiopolicymanager_tests.cpp b/services/audiopolicy/tests/audiopolicymanager_tests.cpp
index d83a277..e901cfd 100644
--- a/services/audiopolicy/tests/audiopolicymanager_tests.cpp
+++ b/services/audiopolicy/tests/audiopolicymanager_tests.cpp
@@ -1276,6 +1276,33 @@
EXPECT_EQ(expectedChannelMask, requestedChannelMask);
}
+TEST_F(AudioPolicyManagerTestWithConfigurationFile, MatchesMoreInputFlagsWhenPossible) {
+ const audio_format_t expectedFormat = AUDIO_FORMAT_PCM_16_BIT;
+ const uint32_t expectedSampleRate = 48000;
+ const audio_channel_mask_t expectedChannelMask = AUDIO_CHANNEL_IN_STEREO;
+ const std::string expectedIOProfile = "mixport_fast_input";
+
+ auto devices = mManager->getAvailableInputDevices();
+ sp<DeviceDescriptor> mic = nullptr;
+ for (auto device : devices) {
+ if (device->type() == AUDIO_DEVICE_IN_BUILTIN_MIC) {
+ mic = device;
+ break;
+ }
+ }
+ EXPECT_NE(nullptr, mic);
+
+ audio_format_t requestedFormat = AUDIO_FORMAT_PCM_24_BIT_PACKED;
+ uint32_t requestedSampleRate = 48000;
+ audio_channel_mask_t requestedChannelMask = AUDIO_CHANNEL_IN_STEREO;
+ auto profile = mManager->getInputProfile(
+ mic, requestedSampleRate, requestedFormat, requestedChannelMask, AUDIO_INPUT_FLAG_FAST);
+ EXPECT_EQ(expectedIOProfile, profile->getName());
+ EXPECT_EQ(expectedFormat, requestedFormat);
+ EXPECT_EQ(expectedSampleRate, requestedSampleRate);
+ EXPECT_EQ(expectedChannelMask, requestedChannelMask);
+}
+
class AudioPolicyManagerTestDynamicPolicy : public AudioPolicyManagerTestWithConfigurationFile {
protected:
void TearDown() override;
diff --git a/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml b/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml
index 3c64898..9cb3608 100644
--- a/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml
+++ b/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml
@@ -71,6 +71,11 @@
samplingRates="48000"
channelMasks="AUDIO_CHANNEL_IN_5POINT1"/>
</mixPort>
+ <mixPort name="mixport_fast_input" role="sink" flags="AUDIO_INPUT_FLAG_FAST">
+ <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ samplingRates="48000"
+ channelMasks="AUDIO_CHANNEL_IN_STEREO"/>
+ </mixPort>
</mixPorts>
<devicePorts>
<devicePort tagName="Speaker" type="AUDIO_DEVICE_OUT_SPEAKER" role="sink">
@@ -121,6 +126,8 @@
sources="USB Device In" />
<route type="mix" sink="multiple_channels_input"
sources="Built-In Mic" />
+ <route type="mix" sink="mixport_fast_input"
+ sources="Built-In Mic"/>
</routes>
</module>
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 07c9d00..fd051db 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -24,18 +24,19 @@
#include <android/hardware/camera2/BnCameraInjectionSession.h>
#include <android/hardware/camera2/ICameraInjectionCallback.h>
-#include <cutils/multiuser.h>
-#include <utils/Vector.h>
-#include <utils/KeyedVector.h>
#include <binder/ActivityManager.h>
#include <binder/AppOpsManager.h>
#include <binder/BinderService.h>
-#include <binder/IServiceManager.h>
#include <binder/IActivityManager.h>
#include <binder/IAppOpsCallback.h>
+#include <binder/IServiceManager.h>
#include <binder/IUidObserver.h>
+#include <cutils/multiuser.h>
+#include <gui/Flags.h>
#include <hardware/camera.h>
#include <sensorprivacy/SensorPrivacyManager.h>
+#include <utils/KeyedVector.h>
+#include <utils/Vector.h>
#include <android/hardware/camera/common/1.0/types.h>
@@ -543,10 +544,9 @@
virtual status_t connect(const sp<hardware::ICameraClient>& client) = 0;
virtual status_t lock() = 0;
virtual status_t unlock() = 0;
- virtual status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer)=0;
+ virtual status_t setPreviewTarget(const sp<SurfaceType>& target) = 0;
virtual void setPreviewCallbackFlag(int flag) = 0;
- virtual status_t setPreviewCallbackTarget(
- const sp<IGraphicBufferProducer>& callbackProducer) = 0;
+ virtual status_t setPreviewCallbackTarget(const sp<SurfaceType>& target) = 0;
virtual status_t startPreview() = 0;
virtual void stopPreview() = 0;
virtual bool previewEnabled() = 0;
@@ -561,7 +561,7 @@
virtual status_t setParameters(const String8& params) = 0;
virtual String8 getParameters() const = 0;
virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0;
- virtual status_t setVideoTarget(const sp<IGraphicBufferProducer>& bufferProducer) = 0;
+ virtual status_t setVideoTarget(const sp<SurfaceType>& target) = 0;
// Interface used by CameraService
Client(const sp<CameraService>& cameraService,
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
index 861414f..af422a7 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.cpp
+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
@@ -30,6 +30,7 @@
#include <com_android_internal_camera_flags.h>
#include <cutils/properties.h>
#include <gui/Surface.h>
+#include <gui/view/Surface.h>
#include "api1/Camera2Client.h"
@@ -587,26 +588,56 @@
return EBUSY;
}
-status_t Camera2Client::setPreviewTarget(
- const sp<IGraphicBufferProducer>& bufferProducer) {
+status_t Camera2Client::setPreviewTarget(const sp<SurfaceType>& target) {
ATRACE_CALL();
ALOGV("%s: E", __FUNCTION__);
Mutex::Autolock icl(mBinderSerializationLock);
status_t res;
- if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+ if ((res = checkPid(__FUNCTION__)) != OK) return res;
- sp<IBinder> binder;
- sp<Surface> window;
- if (bufferProducer != 0) {
- binder = IInterface::asBinder(bufferProducer);
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ sp<Surface> surface;
+ view::Surface viewSurface;
+ if (target != nullptr) {
// Using controlledByApp flag to ensure that the buffer queue remains in
// async mode for the old camera API, where many applications depend
// on that behavior.
- window = new Surface(bufferProducer, /*controlledByApp*/ true);
+ surface = new Surface(target->getIGraphicBufferProducer(), true);
+ viewSurface = view::Surface::fromSurface(surface);
+ }
+ return setPreviewWindowL(viewSurface, surface);
+#else
+ sp<IBinder> binder;
+ sp<Surface> window;
+ if (target != 0) {
+ binder = IInterface::asBinder(target);
+ // Using controlledByApp flag to ensure that the buffer queue remains in
+ // async mode for the old camera API, where many applications depend
+ // on that behavior.
+ window = new Surface(target, /*controlledByApp*/ true);
}
return setPreviewWindowL(binder, window);
+#endif
}
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+status_t Camera2Client::setPreviewWindowL(const view::Surface& viewSurface,
+ const sp<Surface>& window) {
+ ATRACE_CALL();
+ status_t res;
+
+ uint64_t viewSurfaceID;
+ res = viewSurface.getUniqueId(&viewSurfaceID);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Could not getUniqueId.", __FUNCTION__, mCameraId);
+ return res;
+ }
+
+ if (viewSurfaceID == mPreviewViewSurfaceID) {
+ ALOGV("%s: Camera %d: New window is same as old window", __FUNCTION__, mCameraId);
+ return NO_ERROR;
+ }
+#else
status_t Camera2Client::setPreviewWindowL(const sp<IBinder>& binder,
const sp<Surface>& window) {
ATRACE_CALL();
@@ -617,6 +648,7 @@
__FUNCTION__, mCameraId);
return NO_ERROR;
}
+#endif
Parameters::State state;
{
@@ -628,9 +660,8 @@
case Parameters::RECORD:
case Parameters::STILL_CAPTURE:
case Parameters::VIDEO_SNAPSHOT:
- ALOGE("%s: Camera %d: Cannot set preview display while in state %s",
- __FUNCTION__, mCameraId,
- Parameters::getStateName(state));
+ ALOGE("%s: Camera %d: Cannot set preview display while in state %s", __FUNCTION__,
+ mCameraId, Parameters::getStateName(state));
return INVALID_OPERATION;
case Parameters::STOPPED:
case Parameters::WAITING_FOR_PREVIEW_WINDOW:
@@ -640,19 +671,23 @@
// Already running preview - need to stop and create a new stream
res = stopStream();
if (res != OK) {
- ALOGE("%s: Unable to stop preview to swap windows: %s (%d)",
- __FUNCTION__, strerror(-res), res);
+ ALOGE("%s: Unable to stop preview to swap windows: %s (%d)", __FUNCTION__,
+ strerror(-res), res);
return res;
}
state = Parameters::WAITING_FOR_PREVIEW_WINDOW;
break;
}
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ mPreviewViewSurfaceID = viewSurfaceID;
+#else
mPreviewSurface = binder;
+#endif
+
res = mStreamingProcessor->setPreviewWindow(window);
if (res != OK) {
- ALOGE("%s: Unable to set new preview window: %s (%d)",
- __FUNCTION__, strerror(-res), res);
+ ALOGE("%s: Unable to set new preview window: %s (%d)", __FUNCTION__, strerror(-res), res);
return res;
}
@@ -725,23 +760,26 @@
}
}
-status_t Camera2Client::setPreviewCallbackTarget(
- const sp<IGraphicBufferProducer>& callbackProducer) {
+status_t Camera2Client::setPreviewCallbackTarget(const sp<SurfaceType>& target) {
ATRACE_CALL();
ALOGV("%s: E", __FUNCTION__);
Mutex::Autolock icl(mBinderSerializationLock);
status_t res;
- if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+ if ((res = checkPid(__FUNCTION__)) != OK) return res;
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ sp<Surface> window = target;
+#else
sp<Surface> window;
- if (callbackProducer != 0) {
- window = new Surface(callbackProducer);
+ if (target != 0) {
+ window = new Surface(target);
}
+#endif
res = mCallbackProcessor->setCallbackWindow(window);
if (res != OK) {
- ALOGE("%s: Camera %d: Unable to set preview callback surface: %s (%d)",
- __FUNCTION__, mCameraId, strerror(-res), res);
+ ALOGE("%s: Camera %d: Unable to set preview callback surface: %s (%d)", __FUNCTION__,
+ mCameraId, strerror(-res), res);
return res;
}
@@ -757,7 +795,7 @@
l.mParameters.previewCallbackSurface = false;
}
- switch(l.mParameters.state) {
+ switch (l.mParameters.state) {
case Parameters::PREVIEW:
res = startPreviewL(l.mParameters, true);
break;
@@ -769,15 +807,13 @@
break;
}
if (res != OK) {
- ALOGE("%s: Camera %d: Unable to refresh request in state %s",
- __FUNCTION__, mCameraId,
- Parameters::getStateName(l.mParameters.state));
+ ALOGE("%s: Camera %d: Unable to refresh request in state %s", __FUNCTION__, mCameraId,
+ Parameters::getStateName(l.mParameters.state));
}
return OK;
}
-
status_t Camera2Client::startPreview() {
ATRACE_CALL();
ALOGV("%s: E", __FUNCTION__);
@@ -2266,29 +2302,47 @@
return res;
}
-status_t Camera2Client::setVideoTarget(const sp<IGraphicBufferProducer>& bufferProducer) {
+status_t Camera2Client::setVideoTarget(const sp<SurfaceType>& target) {
ATRACE_CALL();
ALOGV("%s: E", __FUNCTION__);
Mutex::Autolock icl(mBinderSerializationLock);
status_t res;
if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
- sp<IBinder> binder = IInterface::asBinder(bufferProducer);
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ uint64_t videoSurfaceID;
+ res = target->getUniqueId(&videoSurfaceID);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Could not getUniqueId in setVideoTarget.", __FUNCTION__, mCameraId);
+ return res;
+ }
+ if (videoSurfaceID == mVideoSurfaceID) {
+ ALOGE("%s: Camera %d: New video window is same as old video window", __FUNCTION__,
+ mCameraId);
+ return NO_ERROR;
+ }
+#else
+ sp<IBinder> binder = IInterface::asBinder(target);
if (binder == mVideoSurface) {
ALOGV("%s: Camera %d: New video window is same as old video window",
__FUNCTION__, mCameraId);
return NO_ERROR;
}
+#endif
sp<Surface> window;
int format;
android_dataspace dataSpace;
- if (bufferProducer != nullptr) {
+ if (target != nullptr) {
// Using controlledByApp flag to ensure that the buffer queue remains in
// async mode for the old camera API, where many applications depend
// on that behavior.
- window = new Surface(bufferProducer, /*controlledByApp*/ true);
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ window = new Surface(target->getIGraphicBufferProducer(), /*controlledByApp*/ true);
+#else
+ window = new Surface(target, /*controlledByApp*/ true);
+#endif
ANativeWindow *anw = window.get();
@@ -2327,7 +2381,11 @@
return INVALID_OPERATION;
}
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ mVideoSurfaceID = videoSurfaceID;
+#else
mVideoSurface = binder;
+#endif
res = mStreamingProcessor->setRecordingWindow(window);
if (res != OK) {
ALOGE("%s: Unable to set new recording window: %s (%d)",
diff --git a/services/camera/libcameraservice/api1/Camera2Client.h b/services/camera/libcameraservice/api1/Camera2Client.h
index a0c9f2d..ce668dd 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.h
+++ b/services/camera/libcameraservice/api1/Camera2Client.h
@@ -17,12 +17,14 @@
#ifndef ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H
#define ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H
-#include "CameraService.h"
-#include "common/CameraDeviceBase.h"
-#include "common/Camera2ClientBase.h"
-#include "api1/client2/Parameters.h"
-#include "api1/client2/FrameProcessor.h"
+#include <gui/Flags.h>
+#include <gui/view/Surface.h>
#include <media/RingBuffer.h>
+#include "CameraService.h"
+#include "api1/client2/FrameProcessor.h"
+#include "api1/client2/Parameters.h"
+#include "common/Camera2ClientBase.h"
+#include "common/CameraDeviceBase.h"
namespace android {
@@ -53,11 +55,9 @@
virtual status_t connect(const sp<hardware::ICameraClient>& client);
virtual status_t lock();
virtual status_t unlock();
- virtual status_t setPreviewTarget(
- const sp<IGraphicBufferProducer>& bufferProducer);
+ virtual status_t setPreviewTarget(const sp<SurfaceType>& target);
virtual void setPreviewCallbackFlag(int flag);
- virtual status_t setPreviewCallbackTarget(
- const sp<IGraphicBufferProducer>& callbackProducer);
+ virtual status_t setPreviewCallbackTarget(const sp<SurfaceType>& target);
virtual status_t startPreview();
virtual void stopPreview();
@@ -78,7 +78,7 @@
virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
virtual void notifyError(int32_t errorCode,
const CaptureResultExtras& resultExtras);
- virtual status_t setVideoTarget(const sp<IGraphicBufferProducer>& bufferProducer);
+ virtual status_t setVideoTarget(const sp<SurfaceType>& target);
virtual status_t setAudioRestriction(int mode);
virtual int32_t getGlobalAudioRestriction();
virtual status_t setRotateAndCropOverride(uint8_t rotateAndCrop, bool fromHal = false);
@@ -183,8 +183,12 @@
/** ICamera interface-related private members */
typedef camera2::Parameters Parameters;
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ status_t setPreviewWindowL(const view::Surface& viewSurface, const sp<Surface>& window);
+#else
status_t setPreviewWindowL(const sp<IBinder>& binder,
const sp<Surface>& window);
+#endif
status_t startPreviewL(Parameters ¶ms, bool restart);
void stopPreviewL();
status_t startRecordingL(Parameters ¶ms, bool restart);
@@ -221,8 +225,13 @@
/* Preview/Recording related members */
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ uint64_t mPreviewViewSurfaceID;
+ uint64_t mVideoSurfaceID;
+#else
sp<IBinder> mPreviewSurface;
sp<IBinder> mVideoSurface;
+#endif
sp<camera2::StreamingProcessor> mStreamingProcessor;
/** Preview callback related members */
diff --git a/services/camera/libcameraservice/libcameraservice_fuzzer/camera_service_fuzzer.cpp b/services/camera/libcameraservice/libcameraservice_fuzzer/camera_service_fuzzer.cpp
index 12ac33f..86e2c70 100644
--- a/services/camera/libcameraservice/libcameraservice_fuzzer/camera_service_fuzzer.cpp
+++ b/services/camera/libcameraservice/libcameraservice_fuzzer/camera_service_fuzzer.cpp
@@ -40,6 +40,7 @@
#include <fakeservicemanager/FakeServiceManager.h>
#include <fuzzbinder/random_binder.h>
#include <gui/BufferItemConsumer.h>
+#include <gui/Flags.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
@@ -620,7 +621,11 @@
previewSurface = surfaceControl->getSurface();
if (previewSurface.get()) {
- cameraDevice->setPreviewTarget(previewSurface->getIGraphicBufferProducer());
+ cameraDevice->setPreviewTarget(previewSurface
+#if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ ->getIGraphicBufferProducer()
+#endif
+ );
}
}
cameraDevice->setPreviewCallbackFlag(CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER);
@@ -675,7 +680,11 @@
.apply();
sp<Surface> previewSurfaceVideo = surfaceControlVideo->getSurface();
if (previewSurfaceVideo.get()) {
- cameraDevice->setVideoTarget(previewSurfaceVideo->getIGraphicBufferProducer());
+ cameraDevice->setVideoTarget(previewSurfaceVideo
+#if !WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ ->getIGraphicBufferProducer()
+#endif
+ );
}
}
cameraDevice->stopPreview();