1/*
2 * Copyright (C) 2012 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_BURST_CAPTURE_H
18#define ANDROID_SERVERS_CAMERA_BURST_CAPTURE_H
19
20#include "camera/CameraMetadata.h"
21#include <binder/MemoryBase.h>
22#include <binder/MemoryHeapBase.h>
23#include <gui/CpuConsumer.h>
24#include "Camera2Device.h"
25
26namespace android {
27
28class Camera2Client;
29
30namespace camera2 {
31
32class CaptureSequencer;
33
34class BurstCapture : public virtual Thread,
35                     public virtual CpuConsumer::FrameAvailableListener
36{
37public:
38    BurstCapture(wp<Camera2Client> client, wp<CaptureSequencer> sequencer);
39    virtual ~BurstCapture();
40
41    virtual void onFrameAvailable();
42    virtual status_t start(Vector<CameraMetadata> &metadatas, int32_t firstCaptureId);
43
44protected:
45    Mutex mInputMutex;
46    bool mInputChanged;
47    Condition mInputSignal;
48    int mCaptureStreamId;
49    wp<Camera2Client> mClient;
50    wp<CaptureSequencer> mSequencer;
51
52    // Should only be accessed by processing thread
53    enum {
54        NO_STREAM = -1
55    };
56
57    CpuConsumer::LockedBuffer* jpegEncode(
58        CpuConsumer::LockedBuffer *imgBuffer,
59        int quality);
60
61    virtual status_t processFrameAvailable(sp<Camera2Client> &client);
62
63private:
64    virtual bool threadLoop();
65    static const nsecs_t kWaitDuration = 10000000; // 10 ms
66};
67
68} // namespace camera2
69} // namespace android
70
71#endif
72