1 /* 2 * smart_buffer_priv.cpp - smart buffer for XCamVideoBuffer 3 * 4 * Copyright (c) 2016-2017 Intel Corporation 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 * Author: Wind Yuan <feng.yuan@intel.com> 19 */ 20 #ifndef _SMART_BUFFER_PRIV_H_ 21 #define _SMART_BUFFER_PRIV_H_ 22 23 #include <xcam_std.h> 24 #include "xcam_buffer.h" 25 #include "video_buffer.h" 26 27 namespace XCam { 28 29 #define SMTBUF_NAME_STR_LEN (32) 30 31 typedef void (*SmartBufferCbNotify_t) 32 ( 33 void* pUserContext, 34 XCamVideoBuffer* pVideoBuffer 35 ); 36 37 class SmartBufferPriv 38 : public XCamVideoBufferRK 39 { 40 public: 41 SmartBufferPriv (const SmartPtr<VideoBuffer> &buf); 42 SmartBufferPriv (uint32_t frameId, const SmartPtr<VideoBuffer> &buf); 43 ~SmartBufferPriv (); 44 is_valid()45 bool is_valid () const { 46 return _buf_ptr.ptr (); 47 } 48 49 int registerNotifyCb(SmartBufferCbNotify_t fpCallback, void *pUserContext); 50 51 static void buf_ref (XCamVideoBuffer *data); 52 static uint32_t buf_unref (XCamVideoBuffer *data); 53 static uint8_t *buf_map (XCamVideoBuffer *data); 54 static void buf_unmap (XCamVideoBuffer *data); 55 static int buf_get_fd (XCamVideoBuffer *data); 56 static void *buf_get_bo (XCamVideoBufferRK *data); 57 get_video_buffer()58 SmartPtr<VideoBuffer> get_video_buffer() { return _buf_ptr; } 59 60 private: 61 XCAM_DEAD_COPY (SmartBufferPriv); 62 mutable RefCount *_ref; 63 SmartPtr<VideoBuffer> _buf_ptr; 64 char nameStr[SMTBUF_NAME_STR_LEN]; 65 }; 66 67 XCamVideoBuffer * 68 convert_to_XCamVideoBuffer (const SmartPtr<VideoBuffer> &buf); 69 70 } 71 #endif 72