xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/xcore/video_buffer.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * video_buffer.h - video buffer base
3  *
4  *  Copyright (c) 2014-2015 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 
21 #ifndef XCAM_VIDEO_BUFFER_H
22 #define XCAM_VIDEO_BUFFER_H
23 
24 #include <xcam_std.h>
25 #include <meta_data.h>
26 #include <base/xcam_buffer.h>
27 #include <list>
28 
29 namespace XCam {
30 
31 class VideoBuffer;
32 typedef std::list<SmartPtr<VideoBuffer>>  VideoBufferList;
33 
34 struct VideoBufferPlanarInfo
35     : XCamVideoBufferPlanarInfo
36 {
37     VideoBufferPlanarInfo ();
38 };
39 
40 struct VideoBufferInfo
41     : XCamVideoBufferInfo
42 {
43     VideoBufferInfo ();
44     bool init (
45         uint32_t format,
46         uint32_t width, uint32_t height,
47         uint32_t aligned_width = 0, uint32_t aligned_height = 0, uint32_t size = 0, bool compacted = false);
48 
49     bool fill (const XCamVideoBufferInfo &info);
50 
51     bool get_planar_info (
52         VideoBufferPlanarInfo &planar, const uint32_t index = 0) const;
53 
54     bool is_valid () const;
55 };
56 
57 class VideoBuffer {
58 public:
59     explicit VideoBuffer (int64_t timestamp = InvalidTimestamp)
60         : _buf_type(0), _timestamp(timestamp)
61     {}
62     explicit VideoBuffer (const VideoBufferInfo &info, int64_t timestamp = InvalidTimestamp)
_videoinfo(info)63         : _videoinfo (info)
64         , _timestamp (timestamp)
65     {}
66     virtual ~VideoBuffer ();
67 
68     virtual uint8_t *map () = 0;
69     virtual bool unmap () = 0;
70     virtual int get_fd () = 0;
71 
get_video_info()72     const VideoBufferInfo & get_video_info () const {
73         return _videoinfo;
74     }
get_timestamp()75     int64_t get_timestamp () const {
76         return _timestamp;
77     }
78 
set_video_info(const VideoBufferInfo & info)79     void set_video_info (const VideoBufferInfo &info) {
80         _videoinfo = info;
81     }
82 
set_timestamp(int64_t timestamp)83     void set_timestamp (int64_t timestamp) {
84         _timestamp = timestamp;
85     }
86 
get_size()87     uint32_t get_size () const {
88         return _videoinfo.size;
89     }
90 
set_sequence(uint32_t sequence)91     void set_sequence (uint32_t sequence) {
92         _sequence = sequence;
93     }
94 
get_sequence()95     uint32_t get_sequence () const {
96         return _sequence;
97     }
98 
99     int _buf_type;
100 private:
101     XCAM_DEAD_COPY (VideoBuffer);
102 
103 private:
104     VideoBufferInfo           _videoinfo;
105     int64_t                   _timestamp; // in microseconds
106     uint32_t                  _sequence;
107 };
108 
109 XCamVideoBuffer *convert_to_external_buffer (const SmartPtr<VideoBuffer> &buf);
110 
111 }
112 
113 #endif //XCAM_VIDEO_BUFFER_H
114