Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef HDR_PLUS_CLIENT_LISTENER_H
     18 #define HDR_PLUS_CLIENT_LISTENER_H
     19 
     20 #include "hardware/camera3.h"
     21 #include "HdrPlusTypes.h"
     22 
     23 namespace android {
     24 
     25 
     26 class HdrPlusClient;
     27 
     28 /*
     29  * HdrPlusClientListener defines callbacks that will be invoked by HdrPlusClient for events like
     30  * returning capture results.
     31  */
     32 class HdrPlusClientListener {
     33 public:
     34     virtual ~HdrPlusClientListener() {};
     35 
     36     /*
     37      * Invoked when an HDR+ client is opened successfully via
     38      * EaselManagerClient::openHdrPlusClientAsync.
     39      */
     40     virtual void onOpened(std::unique_ptr<HdrPlusClient> client) = 0;
     41 
     42     /*
     43      * Invoked when opening an HDR+ client failed via EaselManagerClient::openHdrPlusClientAsync.
     44      *
     45      * err is
     46      *  -EEXIST:    if an HDR+ client is already opened.
     47      *  -ENODEV:    if opening an HDR+ failed due to a serious error.
     48      */
     49     virtual void onOpenFailed(status_t err) = 0;
     50 
     51     /*
     52      * Invoked when HDR+ client is in a fatal error state. After receiving this error, calls to HDR+
     53      * client will not succeed and HDR+ client should be closed.
     54      */
     55     virtual void onFatalError() = 0;
     56 
     57     /*
     58      * Invoked when a CaptureResult, containing a subset or all output buffers for a CaptureRequest,
     59      * is received. This may be invoked multiple times for one CaptureRequest but each CaptureResult
     60      * will contain distinct output buffers that have not been received yet.
     61      */
     62     virtual void onCaptureResult(pbcamera::CaptureResult *result,
     63             const camera_metadata_t &resultMetadata) = 0;
     64 
     65     /*
     66      * Invoked when a failed CaptureResult, containing a subset or all output buffers for a
     67      * CaptureRequest, is received. Output buffers in a failed capture result may contain garbage
     68      * data. This may be invoked multiple times for one CaptureRequest but each CaptureResult
     69      * will contain distinct output buffers that have not been received yet.
     70      */
     71     virtual void onFailedCaptureResult(pbcamera::CaptureResult *failedResult) = 0;
     72 
     73     /*
     74      * Invoked when HDR+ processing has started for a request. requestId is the ID of the request.
     75      * apSensorTimestampNs is the AP sensor timestamp of the base frame, in nanoseconds.
     76      */
     77     virtual void onShutter(uint32_t requestId, int64_t apSensorTimestampNs) = 0;
     78 
     79     /*
     80      * Invoked when Easel is ready to take another HDR+ request.
     81      */
     82     virtual void onNextCaptureReady(uint32_t requestId) = 0;
     83 
     84     /*
     85      * Invoked when the postview for a request is ready.
     86      */
     87     virtual void onPostview(uint32_t requestId, std::unique_ptr<std::vector<uint8_t>> postview,
     88             uint32_t width, uint32_t height, uint32_t stride, int32_t format) = 0;
     89 };
     90 
     91 } // namespace android
     92 
     93 #endif // HDR_PLUS_CLIENT_LISTENER_H
     94