#ifndef __IP_CAMERA_H
#define __IP_CAMERA_H

#include <string.h>
#include <syslog.h>
#include "dy_utils/dy_mqtt.h"
#include "dy_utils/dy_list.h"
#include "dy_utils/dy_common.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/newstrong_ship_cfg.json"

#define IP_CAMERA_SCRIPT "script_newstrong_ship"
#define IP_CAMERA_FUN	"protocol_encode"

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 ws_url[256];
	char ws_host[64];
	char ws_username[64];
	char ws_password[64];
	char *rtsp_url;
	char *rtsp_url_local;
	char *server_url;
	char *init_info;
} camera_config_t;

typedef struct _newstrong_ship_config_s 
{
	struct list_head list;
	camera_config_t camera_cfg;
	int push_video_flag;
	char video_file[128];
	int online;
	time_t last_push;
} newstrong_ship_config_t;

typedef struct _dev_info_config_s 
{
	struct list_head list;
	char gw_sn[64];
	char dev_sn[64];
	char server_set[128];
} dev_info_config_t;

typedef struct _newstrong_ship_data_s 
{
	struct list_head list;
	int len;
	char *data;
} newstrong_ship_data_t;

typedef struct _newstrong_ship_var_s
{
	mqtt_session_t* session_ext;//外部broker的MQTT client，用于从外部订阅数据
    mqtt_session_t* session; //内部broker的MQTT session，用于进程间通信
    struct list_head connect_list;
	struct list_head config_list;
	struct list_head data_list;
    nodes_cfg_table_t *nodes_cfg_table; //节点信息
    template_table_t *template_table; //模板信息
    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;
} newstrong_ship_var_t;

#endif
