summaryrefslogtreecommitdiff
path: root/v4l2_vdin.h (plain)
blob: 5af1a9d12e179bc6240280c49d5c0a4eaa66f3b6
1/*
2 * Copyright (C) 2013 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#include <signal.h>
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
20#include <fcntl.h>
21#include <unistd.h>
22#include <errno.h>
23#include <sys/ioctl.h>
24#include <sys/mman.h>
25#include <sys/select.h>
26#include <linux/videodev.h>
27#include <sys/time.h>
28
29#include <utils/KeyedVector.h>
30#include <cutils/properties.h>
31#include <sys/types.h>
32#include <sys/stat.h>
33
34namespace android {
35
36#define NB_BUFFER 4
37
38struct VideoInfo {
39 struct v4l2_capability cap;
40 struct v4l2_format format;
41 struct v4l2_buffer buf;
42 struct v4l2_requestbuffers rb;
43 void *mem[NB_BUFFER];
44 unsigned canvas[NB_BUFFER];
45 bool isStreaming;
46 int width;
47 int height;
48 int formatIn;
49 int framesizeIn;
50};
51
52class vdin_screen_source {
53 public:
54 vdin_screen_source();
55 ~vdin_screen_source();
56
57 int start();
58 int stop();
59 int get_format();
60 int set_format(int width = 640, int height = 480, int color_format = V4L2_PIX_FMT_NV21);
61 int set_rotation(int degree);
62 int aquire_buffer(unsigned* buff_info);
63 int release_buffer(char* ptr);
64 private:
65 int mCurrentIndex;
66 KeyedVector<int, int> mBufs;
67 int mCameraHandle;
68 struct VideoInfo *mVideoInfo;
69};
70
71}