#ifndef __IP_CAMERA_H
#define __IP_CAMERA_H

#include <string.h>
#include <syslog.h>
#include "ipc_session.h"
#include "lnxall_list.h"
#include "dy_utils/dy_common.h"
#include "python2.7/Python.h"
#include "dy_utils/dy_pp.h"
#include "dy_utils/dy_ipc.h"
#include "dy_utils/dy_pp.h"


#define IP_CAMERA_CFG "/app/config/ip_camera_cfg.json"

#define IP_CAMERA_SCRIPT "script_ip_camera"
#define IP_CAMERA_FUN	"protocol_encode"


typedef struct
{
	PyObject *pName;
    PyObject *pModule;
    PyObject *pDict;
	PyObject *pFunc;
	int inited;
}camera_handle_t;

typedef struct _common_config_s 
{
	char sn[SN_MAX_LEN];
	char ip_addr[SN_MAX_LEN];
	int port;
	char user[SN_MAX_LEN];
	char password[SN_MAX_LEN];
	char *rtsp_url;
	char *rtsp_url_local;
	char *server_url;
	char *init_info;
} camera_config_t;

typedef struct _ip_camera_config_s 
{
	struct list_head list;
	camera_config_t camera_cfg;
    camera_handle_t *python;
	int push_video_flag;
	time_t last_push;
} ip_camera_config_t;

typedef struct _ip_camera_var_s
{
    ipc_session_t* session; //内部broker的MQTT session，用于进程间通信
    struct list_head connect_list;
	struct list_head config_list;
    nodes_cfg_table_t *nodes_cfg_table; //节点信息
    template_table_t *template_table; //模板信息
    int python;
    char sn_str[SN_MAX_LEN];
    char proc_name[PROGRAM_NAME_LEN];
    char gprs_no[16];
    int heartbeat_timer;
	int push_video_timer;
	int node_cnt;
	int init;
	int send_package_cnt;
} ip_camera_var_t;

#endif
