1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
/*
* camerasrc
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Jeongmo Yang <jm80.yang@samsung.com>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __GSTCAMERASRC_H__
#define __GSTCAMERASRC_H__
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gst/interfaces/colorbalance.h>
#include <gst/interfaces/cameracontrol.h>
#include "camerasrc.h"
#ifndef _SPEED_UP_RAW_CAPTURE
/* Disabled now
#define _SPEED_UP_RAW_CAPTURE
*/
#endif /* _SPEED_UP_RAW_CAPTURE */
G_BEGIN_DECLS
#define GST_TYPE_CAMERA_SRC (gst_camerasrc_get_type())
#define GST_CAMERA_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CAMERA_SRC,GstCameraSrc))
#define GST_CAMERA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CAMERA_SRC,GstCameraSrcClass))
#define GST_IS_CAMERA_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMERA_SRC))
#define GST_IS_CAMERA_SRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMERA_SRC))
/**
* Quality.
*/
typedef enum {
GST_CAMERASRC_QUALITY_LOW, /**< Low quality */
GST_CAMERASRC_QUALITY_HIGH, /**< High quality */
} GstCameraSrcQuality;
#define MAX_USR_BUFFER_NUM 12
typedef struct _GstCameraSrc GstCameraSrc;
typedef struct _GstCameraSrcClass GstCameraSrcClass;
typedef struct _GstCameraBuffer GstCameraBuffer;
/* global info */
struct _GstCameraBuffer {
GstBuffer buffer;
int v4l2_buffer_index;
GstCameraSrc *camerasrc;
gboolean is_alloc_data;
};
struct _GstCameraSrc
{
GstPushSrc element;
/*private*/
void *v4l2_handle; /**< video4linux2 handle */
int mode;
int sensor_mode; /**< sensor mode - camera or movie(camcorder) */
gboolean vflip; /**< flip camera input vertically */
gboolean hflip; /**< flip camera input horizontally */
gboolean firsttime;
int main_buf_sz;
int cap_count_current; /**< current capture count */
int cap_count_reverse; /**< current capture count (reverse counting) */
unsigned long cap_next_time; /**< next shot time for capture */
GQueue *command_list; /**< Command list(Start capture, Stop capture) queue */
GCond *cond;
GMutex *mutex;
/*camera property*/
int width; /**< Width */
int height; /**< Height */
int fps; /**< Video source fps */
guint32 fourcc; /**< Four CC */
int pix_format; /**< Image format of video source */
int colorspace; /**< Colorspace of video source */
int high_speed_fps; /**< Video source fps for high speed recording */
gboolean fps_auto; /**< Auto Video source fps */
gboolean req_negotiation; /**< Video source fps for high speed recording */
int camera_id;
int rotate; /**< Video source rotate */
gboolean use_rotate_caps; /**< Use or not rotate value in caps */
int external_videofd; /**< video FD from external module */
GCond *buffer_cond;
GMutex *buffer_lock;
gboolean buffer_running; /* with lock */
gint num_live_buffers; /* with lock */
guint buffer_count;
gboolean bfirst; /* temp */
#ifdef _SPEED_UP_RAW_CAPTURE
gboolean cap_stream_diff; /* whether preview and capture streams are different each other */
#endif
GQueue *pad_alloc_list;
GMutex *pad_alloc_mutex;
gint current_buffer_data_index;
gboolean first_invokation;
GstBuffer *usr_buffer[MAX_USR_BUFFER_NUM];
gboolean use_pad_alloc;
guint num_alloc_buf;
/* Colorbalance , CameraControl interface */
GList *colors;
GList *camera_controls;
/*capture property*/
guint32 cap_fourcc; /**< gstreamer fourcc value(GST_MAKE_FOURCC format) for raw capturing */
GstCameraSrcQuality cap_quality; /**< Capture quality */
int cap_width; /**< Capture width */
int cap_height; /**< Capture height */
int cap_interval; /**< Capture interval */
int cap_count; /**< Capture count */
int cap_jpg_quality; /**< Capture quality for jpg compress ratio */
gboolean cap_provide_exif; /**< Is exif provided? */
/*etc property*/
gboolean signal_still_capture; /**< enable still capture signal */
gboolean hold_af_after_capturing; /**< Whether to hold af after capturing */
gboolean create_jpeg;
GMutex *jpg_mutex;
};
struct _GstCameraSrcClass {
GstPushSrcClass parent_class;
/* signals */
void (*still_capture) (GstElement *element, GstBuffer *main, GstBuffer *sub, GstBuffer *scrnl);
void (*nego_complete) (GstElement *element);
void (*register_trouble) (GstElement *element);
};
typedef enum {
INTERFACE_NONE,
INTERFACE_COLOR_BALANCE,
INTERFACE_CAMERA_CONTROL,
} GstInterfaceType;
void gst_camerasrc_set_capture_command(GstCameraSrc* camerasrc, GstCameraControlCaptureCommand cmd);
GType gst_camerasrc_get_type(void);
G_END_DECLS
#endif /* __GSTCAMERASRC_H__ */
|