modules: camera: Abstract device-specific camera

ExampleCamera represents a specific (e.g. front or back) camera device,
and contains all the device and logic for that device/sensor.

Change-Id: Iecc1a1d905501a66edb6e3994ff93d8761b82f8b
diff --git a/modules/camera/Camera.h b/modules/camera/Camera.h
index be672f9..53672ae 100644
--- a/modules/camera/Camera.h
+++ b/modules/camera/Camera.h
@@ -28,12 +28,14 @@
 // This is constructed when the HAL module is loaded, one per physical camera.
 // It is opened by the framework, and must be closed before it can be opened
 // again.
+// This is an abstract class, containing all logic and data shared between all
+// camera devices (front, back, etc) and common to the ISP.
 class Camera {
     public:
         // id is used to distinguish cameras. 0 <= id < NUM_CAMERAS.
         // module is a handle to the HAL module, used when the device is opened.
         Camera(int id);
-        ~Camera();
+        virtual ~Camera();
 
         // Common Camera Device Operations (see <hardware/camera_common.h>)
         int open(const hw_module_t *module, hw_device_t **device);
@@ -49,12 +51,20 @@
         void getMetadataVendorTagOps(vendor_tag_query_ops_t *ops);
         void dump(int fd);
 
-        // Camera device handle returned to framework for use
-        camera3_device_t mDevice;
+
+    protected:
+        // Initialize static camera characteristics for individual device
+        virtual camera_metadata_t *initStaticInfo() = 0;
+        // Verify settings are valid for a capture
+        virtual bool isValidCaptureSettings(const camera_metadata_t *) = 0;
+        // Separate initialization method for individual devices when opened
+        virtual int initDevice() = 0;
+        // Accessor used by initDevice()
+        void setTemplate(int type, camera_metadata_t *static_info);
 
     private:
-        // Separate initialization method for static metadata
-        camera_metadata_t *initStaticInfo();
+        // Camera device handle returned to framework for use
+        camera3_device_t mDevice;
         // Reuse a stream already created by this device
         Stream *reuseStream(camera3_stream_t *astream);
         // Destroy all streams in a stream array, and the array itself
@@ -65,8 +75,6 @@
         void setupStreams(Stream **array, int count);
         // Copy new settings for re-use and clean up old settings.
         void setSettings(const camera_metadata_t *new_settings);
-        // Verify settings are valid for a capture
-        bool isValidCaptureSettings(const camera_metadata_t *settings);
         // Verify settings are valid for reprocessing an input buffer
         bool isValidReprocessSettings(const camera_metadata_t *settings);
         // Process an output buffer
@@ -74,6 +82,8 @@
                 camera3_stream_buffer_t *out);
         // Send a shutter notify message with start of exposure time
         void notifyShutter(uint32_t frame_number, uint64_t timestamp);
+        // Is type a valid template type (and valid index into mTemplates)
+        bool isValidTemplateType(int type);
 
         // Identifier used by framework to distinguish cameras
         const int mId;
@@ -97,7 +107,7 @@
         // Number of streams in mStreams
         int mNumStreams;
         // Static array of standard camera settings templates
-        Metadata *mTemplates[CAMERA3_TEMPLATE_COUNT];
+        camera_metadata_t *mTemplates[CAMERA3_TEMPLATE_COUNT];
         // Most recent request settings seen, memoized to be reused
         camera_metadata_t *mSettings;
 };