|
SASC-NG
DVBSoftCAM
|
00001 #ifndef _PROCESS_REQ_H_ 00002 #define _PROCESS_REQ_H_ 00003 #include <getopt.h> 00004 #include "list.h" 00005 #include "msg_passing.h" 00006 #include "dvbloopback.h" 00007 #include "debug.h" 00008 00009 struct poll_ll { 00010 struct list_head list; //this must remain first!!! 00011 void * kernfd; 00012 struct pollfd *pfd; 00013 int fd; 00014 unsigned int flags; 00015 int poll; 00016 }; 00017 00018 struct common_data { 00019 int virt_adapt; 00020 int real_adapt; 00021 unsigned long buffersize; 00022 void * private_data; 00023 pthread_mutex_t cond_lock; 00024 pthread_cond_t cond; 00025 int cond_count; 00026 00027 }; 00028 00029 00030 struct parser_cmds { 00031 int type; 00032 pthread_t thread; 00033 pthread_t pollthread; 00034 struct common_data *common; 00035 struct list_head pre_open; 00036 struct list_head post_open; 00037 struct list_head pre_close; 00038 struct list_head post_close; 00039 struct list_head pre_read; 00040 struct list_head post_read; 00041 struct list_head pre_poll; 00042 struct list_head post_poll; 00043 struct list_head pre_ioctl; 00044 struct list_head post_ioctl; 00045 unsigned char *mmap; 00046 void * private_data; 00047 00048 /* everything from here down is private to the processor */ 00049 struct poll_ll realfd_ll[DVBLB_MAXFD]; 00050 struct list_head used_list; 00051 int virtfd; 00052 pthread_mutex_t poll_mutex; 00053 pthread_cond_t poll_cond; 00054 }; 00055 00056 struct parser_adpt { 00057 /* NOTE keep these in the same order as dnames! */ 00058 struct parser_cmds *frontend; 00059 struct parser_cmds *demux; 00060 struct parser_cmds *dvr; 00061 struct parser_cmds *ca; 00062 }; 00063 00064 typedef enum { 00065 CMD_NOCHANGE = 0x00, //Default state 00066 CMD_STOP = 0x01, //Don't do any further processing in the current loop 00067 CMD_SKIPCALL = 0x02, //Don't execute the requested command 00068 CMD_SKIPPOST = 0x04, //Don't execute the post-call loop 00069 CMD_STOPALL = 0x07, 00070 } cmdret_t; 00071 00072 struct cmd_list { 00073 struct list_head list; 00074 void (*cmd) (struct parser_cmds *, struct poll_ll *, cmdret_t *, int *, 00075 unsigned long int, unsigned char *); 00076 unsigned int id; 00077 }; 00078 /* 00079 inline static struct cmd_list *register_cmd(void (*cmd) (struct parser_cmds *, struct poll_ll *, cmdret_t *, int *, unsigned long int, unsigned char *)) { 00080 struct cmd_list *reg = (struct cmd_list *)malloc(sizeof(struct cmd_list)); 00081 reg->cmd = cmd; 00082 return reg; 00083 } 00084 */ 00085 static inline void _attach_callback(struct list_head *cb, 00086 void (*cmd) (struct parser_cmds *, struct poll_ll *, cmdret_t *, int *, unsigned long int, unsigned char *), 00087 int priority, int _id) { 00088 struct cmd_list *reg = (struct cmd_list *)malloc(sizeof(struct cmd_list)); 00089 reg->cmd = cmd; 00090 reg->id = _id; 00091 list_add_priority(®->list, cb, priority); 00092 } 00093 #define ATTACH_CALLBACK(_cb, _cmd, _pri) _attach_callback(_cb, _cmd, _pri, PLUGIN_ID) 00094 00095 //#define REGISTER_CMD(var, c) static struct cmd_list var = { {NULL, NULL}, c} 00096 00097 typedef enum { 00098 ARG_INIT, 00099 ARG_HELP, 00100 ARG_PARSE, 00101 } arg_enum_t; 00102 00103 struct plugin_cmd { 00104 struct list_head list; 00105 int plugin; 00106 const char *name; 00107 struct option * (*parse_args)(arg_enum_t); 00108 void (*connect)(struct parser_adpt *); 00109 void (*launch)(); 00110 void (*message)(struct msg *, unsigned int priority); 00111 void (*send_msg)(struct parser_cmds *pc, int msg); 00112 void (*shutdown)(); 00113 void (*user_msg)(char *msg); 00114 }; 00115 00116 extern void launch_processors(struct parser_adpt *pc_all); 00117 extern void shutdown_parser(struct parser_adpt *pc_all); 00118 extern void init_parser(struct parser_adpt *pc_all, struct common_data *common); 00119 00120 extern struct list_head plugin_cmdlist; 00121 extern pthread_attr_t default_attr; 00122 #endif 00123