1 /*******************************************************************************
2 #                                                                              #
3 #      MJPG-streamer allows to stream JPG frames from an input-plugin          #
4 #      to several output plugins                                               #
5 #                                                                              #
6 #      Copyright (C) 2007 Tom Stöveken                                         #
7 #                                                                              #
8 # This program is free software; you can redistribute it and/or modify         #
9 # it under the terms of the GNU General Public License as published by         #
10 # the Free Software Foundation; version 2 of the License.                      #
11 #                                                                              #
12 # This program is distributed in the hope that it will be useful,              #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of               #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
15 # GNU General Public License for more details.                                 #
16 #                                                                              #
17 # You should have received a copy of the GNU General Public License            #
18 # along with this program; if not, write to the Free Software                  #
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    #
20 #                                                                              #
21 *******************************************************************************/
22 
23 #ifndef MJPG_STREAMER_H
24 #define MJPG_STREAMER_H
25 #define SOURCE_VERSION "2.0"
26 
27 /* FIXME take a look to the output_http clients thread marked with fixme if you want to set more then 10 plugins */
28 #define MAX_INPUT_PLUGINS 10
29 #define MAX_OUTPUT_PLUGINS 10
30 #define MAX_PLUGIN_ARGUMENTS 32
31 
32 #include <netinet/in.h>
33 #include <linux/types.h>          /* for videodev2.h */
34 #include <linux/videodev2.h>
35 #include <pthread.h>
36 
37 #ifdef DEBUG
38 #define DBG(...) fprintf(stderr, " DBG(%s, %s(), %d): ", __FILE__, __FUNCTION__, __LINE__); fprintf(stderr, __VA_ARGS__)
39 #else
40 #define DBG(...)
41 #endif
42 
43 #define LOG(...) { char _bf[1024] = {0}; snprintf(_bf, sizeof(_bf)-1, __VA_ARGS__); fprintf(stderr, "%s", _bf); syslog(LOG_INFO, "%s", _bf); }
44 
45 #include "plugins/input.h"
46 #include "plugins/output.h"
47 
48 /* global variables that are accessed by all plugins */
49 typedef struct _globals globals;
50 
51 /* an enum to identify the commands destination*/
52 typedef enum {
53     Dest_Input = 0,
54     Dest_Output = 1,
55     Dest_Program = 2,
56 } command_dest;
57 
58 /* commands which can be send to the input plugin */
59 //typedef enum _cmd_group cmd_group;
60 enum _cmd_group {
61     IN_CMD_GENERIC =        0, // if you use non V4L2 input plugin you not need to deal the groups.
62     IN_CMD_V4L2 =           1,
63     IN_CMD_RESOLUTION =     2,
64     IN_CMD_JPEG_QUALITY =   3,
65     IN_CMD_PWC =            4,
66 };
67 
68 typedef struct _control control;
69 struct _control {
70     struct v4l2_queryctrl ctrl;
71     int value;
72     struct v4l2_querymenu *menuitems;
73     /*  In the case the control a V4L2 ctrl this variable will specify
74         that the control is a V4L2_CTRL_CLASS_USER control or not.
75         For non V4L2 control it is not acceptable, leave it 0.
76     */
77     int class_id;
78     int group;
79 };
80 
81 struct _globals {
82     int stop;
83 
84     /* input plugin */
85     input in[MAX_INPUT_PLUGINS];
86     int incnt;
87 
88     /* output plugin */
89     output out[MAX_OUTPUT_PLUGINS];
90     int outcnt;
91 
92     /* pointer to control functions */
93     //int (*control)(int command, char *details);
94 };
95 
96 #endif
97