blob: 9e94390081bdba2f5ac685bda7725ad75e255618 [file] [log] [blame]
Chih-Wei Huang0d92eda2012-02-07 16:55:49 +08001/*
2 libcamera: An implementation of the library required by Android OS 3.2 so
3 it can access V4L2 devices as cameras.
4
5 (C) 2011 Eduardo José Tagle <ejtagle@tutopia.com>
6
7 Based on several packages:
8 - luvcview: Sdl video Usb Video Class grabber
9 (C) 2005,2006,2007 Laurent Pinchart && Michel Xhaard
10
11 - spcaview
12 (C) 2003,2004,2005,2006 Michel Xhaard
13
14 - JPEG decoder from http://www.bootsplash.org/
15 (C) August 2001 by Michael Schroeder, <mls@suse.de>
16
17 - libcamera V4L for Android 2.2
18 (C) 2009 0xlab.org - http://0xlab.org/
19 (C) 2010 SpectraCore Technologies
20 Author: Venkat Raju <codredruids@spectracoretech.com>
21 Based on a code from http://code.google.com/p/android-m912/downloads/detail?name=v4l2_camera_v2.patch
22
23 - guvcview: http://guvcview.berlios.de
24 Paulo Assis <pj.assis@gmail.com>
25 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
26
27 This program is free software: you can redistribute it and/or modify
28 it under the terms of the GNU General Public License as published by
29 the Free Software Foundation, either version 3 of the License, or
30 (at your option) any later version.
31
32 This program is distributed in the hope that it will be useful,
33 but WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 GNU General Public License for more details.
36
37 You should have received a copy of the GNU General Public License
38 along with this program. If not, see <http://www.gnu.org/licenses/>.
39
40 */
41
42
43#ifndef __SURFACEDESC_H
44#define __SURFACEDESC_H
45
46#include "SurfaceSize.h"
47
48namespace android {
49
50// Video Mode information
51class SurfaceDesc {
52protected:
53
54 SurfaceSize sz;
55 int fps;
56
57public:
58 // Constructors
59 SurfaceDesc() : fps(0) {}
60 SurfaceDesc(const SurfaceDesc& v) : sz(v.sz), fps(v.fps) {}
61 SurfaceDesc(int pwidth,int pheight, int pfps) :
62 sz(pwidth,pheight), fps(pfps) {}
63
64 // Assignment operators
65 const SurfaceDesc& operator=(const SurfaceDesc& v) {
66 sz = v.sz; fps = v.fps;
67 return *this;
68 }
69
70 // Accessors
71 inline int getWidth() const { return sz.getWidth(); }
72 inline int getHeight() const { return sz.getHeight(); }
73 inline const SurfaceSize& getSize() const { return sz; }
74 inline void setSize( const SurfaceSize& psz) { sz = psz; }
75 inline void setSize( int pw, int ph) { sz.set(pw,ph); }
76 inline int getArea() const { return sz.getArea(); }
77 inline int getFps() const { return fps; }
78 inline void setFps( int pfps ) { fps = pfps; }
79
80 // Comparison operators
81 int compare(const SurfaceDesc& other) const;
82
83 inline bool operator<(const SurfaceDesc& other) const;
84 inline bool operator<=(const SurfaceDesc& other) const;
85 inline bool operator==(const SurfaceDesc& other) const;
86 inline bool operator!=(const SurfaceDesc& other) const;
87 inline bool operator>=(const SurfaceDesc& other) const;
88 inline bool operator>(const SurfaceDesc& other) const;
89
90};
91
92inline int compare_type(const SurfaceDesc& lhs, const SurfaceDesc& rhs)
93{
94 return lhs.compare(rhs);
95}
96
97inline int strictly_order_type(const SurfaceDesc& lhs, const SurfaceDesc& rhs)
98{
99 return compare_type(lhs, rhs) < 0;
100}
101
102inline bool SurfaceDesc::operator<(const SurfaceDesc& other) const
103{
104 return compare(other) < 0;
105}
106
107inline bool SurfaceDesc::operator<=(const SurfaceDesc& other) const
108{
109 return compare(other) <= 0;
110}
111
112inline bool SurfaceDesc::operator==(const SurfaceDesc& other) const
113{
114 return compare(other) == 0;
115}
116
117inline bool SurfaceDesc::operator!=(const SurfaceDesc& other) const
118{
119 return compare(other) != 0;
120}
121
122inline bool SurfaceDesc::operator>=(const SurfaceDesc& other) const
123{
124 return compare(other) >= 0;
125}
126
127inline bool SurfaceDesc::operator>(const SurfaceDesc& other) const
128{
129 return compare(other) > 0;
130}
131
132};
133
134#endif