QCameraChannel.h revision 6f83d735d8e3b918da42e6b559fcd0efb78133e5
1/* Copyright (c) 2012-2013, The Linux Foundataion. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30#ifndef __QCAMERA_CHANNEL_H__ 31#define __QCAMERA_CHANNEL_H__ 32 33#include <hardware/camera.h> 34#include "QCameraStream.h" 35 36extern "C" { 37#include <mm_camera_interface.h> 38} 39 40namespace qcamera { 41 42class QCameraChannel 43{ 44public: 45 QCameraChannel(uint32_t cam_handle, 46 mm_camera_ops_t *cam_ops); 47 QCameraChannel(); 48 virtual ~QCameraChannel(); 49 virtual int32_t init(mm_camera_channel_attr_t *attr, 50 mm_camera_buf_notify_t dataCB, // data CB for channel data 51 void *userData); 52 // Owner of memory is transferred from the caller to the caller with this call. 53 virtual int32_t addStream(QCameraAllocator& allocator, 54 QCameraHeapMemory *streamInfoBuf, 55 uint8_t minStreamBufnum, 56 cam_padding_info_t *paddingInfo, 57 stream_cb_routine stream_cb, 58 void *userdata); 59 virtual int32_t start(QCameraParameters ¶m); 60 virtual int32_t stop(); 61 virtual int32_t bufDone(mm_camera_super_buf_t *recvd_frame); 62 virtual int32_t processZoomDone(preview_stream_ops_t *previewWindow, 63 cam_crop_data_t &crop_info); 64 QCameraStream *getStreamByHandle(uint32_t streamHandle); 65 uint32_t getMyHandle() const {return m_handle;}; 66 uint8_t getNumOfStreams() const {return m_numStreams;}; 67 QCameraStream *getStreamByIndex(uint8_t index); 68 69protected: 70 uint32_t m_camHandle; 71 mm_camera_ops_t *m_camOps; 72 bool m_bIsActive; 73 74 uint32_t m_handle; 75 uint8_t m_numStreams; 76 QCameraStream *mStreams[MAX_STREAM_NUM_IN_BUNDLE]; 77 mm_camera_buf_notify_t mDataCB; 78 void *mUserData; 79}; 80 81// burst pic channel: i.e. zsl burst mode 82class QCameraPicChannel : public QCameraChannel 83{ 84public: 85 QCameraPicChannel(uint32_t cam_handle, 86 mm_camera_ops_t *cam_ops); 87 QCameraPicChannel(); 88 virtual ~QCameraPicChannel(); 89 int32_t takePicture(uint8_t num_of_snapshot); 90 int32_t cancelPicture(); 91}; 92 93// video channel class 94class QCameraVideoChannel : public QCameraChannel 95{ 96public: 97 QCameraVideoChannel(uint32_t cam_handle, 98 mm_camera_ops_t *cam_ops); 99 QCameraVideoChannel(); 100 virtual ~QCameraVideoChannel(); 101 int32_t releaseFrame(const void *opaque, bool isMetaData); 102}; 103 104// reprocess channel class 105class QCameraReprocessChannel : public QCameraChannel 106{ 107public: 108 QCameraReprocessChannel(uint32_t cam_handle, 109 mm_camera_ops_t *cam_ops); 110 QCameraReprocessChannel(); 111 virtual ~QCameraReprocessChannel(); 112 int32_t addReprocStreamsFromSource(QCameraAllocator& allocator, 113 cam_pp_feature_config_t &config, 114 QCameraChannel *pSrcChannel, 115 uint8_t minStreamBufNum, 116 cam_padding_info_t *paddingInfo); 117 // online reprocess 118 int32_t doReprocess(mm_camera_super_buf_t *frame); 119 // offline reprocess 120 int32_t doReprocess(int buf_fd, uint32_t buf_length, int32_t &ret_val); 121 122private: 123 QCameraStream *getStreamBySrouceHandle(uint32_t srcHandle); 124 125 uint32_t mSrcStreamHandles[MAX_STREAM_NUM_IN_BUNDLE]; 126 QCameraChannel *m_pSrcChannel; // ptr to source channel for reprocess 127}; 128 129}; // namespace qcamera 130 131#endif /* __QCAMERA_CHANNEL_H__ */ 132