Camera2: Skeleton for output frame processing, plus face detect

- Plumbing for processing output metadata frames from the HAL
- Support for passing face detection metadata from said frames
  to the application.
- Switch calls on ICameraClient interface to use separate mutex to
  avoid deadlock scenarios with messages being communicated from the
  HAL to the camera user while calls from the user to the service are
  active.

Bug: 6243944

Change-Id: Id4cf821d9c5c3c0069be4c0f669874b6ff0d1ecd
diff --git a/services/camera/libcameraservice/Camera2Device.h b/services/camera/libcameraservice/Camera2Device.h
index 9be370f..790b946 100644
--- a/services/camera/libcameraservice/Camera2Device.h
+++ b/services/camera/libcameraservice/Camera2Device.h
@@ -124,6 +124,27 @@
     status_t setNotifyCallback(NotificationListener *listener);
 
     /**
+     * Abstract class for HAL frame available notifications
+     */
+    class FrameListener {
+      public:
+        virtual void onNewFrameAvailable() = 0;
+      protected:
+        virtual ~FrameListener();
+    };
+
+    /**
+     * Set a frame listener to be notified about new frames.
+     */
+    status_t setFrameListener(FrameListener *listener);
+
+    /**
+     * Get next metadata frame from the frame queue. Returns NULL if the queue
+     * is empty; caller takes ownership of the metadata buffer.
+     */
+    status_t getNextFrame(camera_metadata_t **frame);
+
+    /**
      * Trigger auto-focus. The latest ID used in a trigger autofocus or cancel
      * autofocus call will be returned by the HAL in all subsequent AF
      * notifications.
@@ -180,6 +201,7 @@
         status_t dequeue(camera_metadata_t **buf, bool incrementCount = true);
         int      getBufferCount();
         status_t waitForBuffer(nsecs_t timeout);
+        status_t setListener(FrameListener *listener);
 
         // Set repeating buffer(s); if the queue is empty on a dequeue call, the
         // queue copies the contents of the stream slot into the queue, and then
@@ -208,6 +230,7 @@
         List<camera_metadata_t*> mStreamSlot;
 
         bool mSignalConsumer;
+        FrameListener *mListener;
 
         static MetadataQueue* getInstance(
             const camera2_frame_queue_dst_ops_t *q);