1 /*
2  * Copyright (C) 2020 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 ANDROID_SERVERS_CAMERA_FRAMEPRODUCER_H
18 #define ANDROID_SERVERS_CAMERA_FRAMEPRODUCER_H
19 
20 #include <utils/RefBase.h>
21 #include <utils/String8.h>
22 #include <utils/Timers.h>
23 
24 #include "camera/CameraMetadata.h"
25 #include "camera/CaptureResult.h"
26 
27 namespace android {
28 
29 /**
30  * Abstract class for HAL frame producers
31  */
32 class FrameProducer : public virtual RefBase {
33   public:
34     /**
35      * Retrieve the static characteristics metadata buffer
36      */
37     virtual const CameraMetadata& info() const = 0;
38 
39     /**
40      * Retrieve the device camera ID
41      */
42     virtual const String8& getId() const = 0;
43 
44     /**
45      * Wait for a new frame to be produced, with timeout in nanoseconds.
46      * Returns TIMED_OUT when no frame produced within the specified duration
47      * May be called concurrently to most methods, except for getNextFrame
48      */
49     virtual status_t waitForNextFrame(nsecs_t timeout) = 0;
50 
51     /**
52      * Get next capture result frame from the result queue. Returns NOT_ENOUGH_DATA
53      * if the queue is empty; caller takes ownership of the metadata buffer inside
54      * the capture result object's metadata field.
55      * May be called concurrently to most methods, except for waitForNextFrame.
56      */
57     virtual status_t getNextResult(CaptureResult *frame) = 0;
58 
59 }; // class FrameProducer
60 
61 } // namespace android
62 
63 #endif
64