Update MediaClient

This commit is contained in:
2026-03-28 11:39:04 +11:00
parent 24dc6c7cd0
commit f3266566eb
1284 changed files with 462406 additions and 0 deletions

37
ONVIF/include/bm/base64.h Normal file
View File

@@ -0,0 +1,37 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef BASE64_H
#define BASE64_H
#ifdef __cplusplus
extern "C" {
#endif
HT_API int base64_encode(uint8 *source, uint32 sourcelen, char *target, uint32 targetlen);
HT_API int base64_decode(const char *source, uint32 sourcelen, uint8 *target, uint32 targetlen);
#ifdef __cplusplus
}
#endif
#endif /* BASE64_H */

74
ONVIF/include/bm/hqueue.h Normal file
View File

@@ -0,0 +1,74 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef HQUEUE_H
#define HQUEUE_H
/***********************************************************/
#define HQ_PUT_WAIT 0x00000001
#define HQ_GET_WAIT 0x00000002
#define HQ_NO_EVENT 0x00000004
/***********************************************************/
typedef struct h_queue
{
uint32 queue_mode;
uint32 unit_num;
uint32 unit_size;
uint32 front;
uint32 rear;
uint32 queue_buffer;
uint32 count_put_full;
void * queue_putMutex;
void * queue_nnulEvent;
void * queue_nfulEvent;
} HQUEUE;
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************/
HT_API HQUEUE * hqCreate(uint32 unit_num, uint32 unit_size, uint32 queue_mode);
HT_API void hqDelete(HQUEUE * phq);
HT_API BOOL hqBufPut(HQUEUE * phq,char * buf);
HT_API BOOL hqBufGet(HQUEUE * phq,char * buf);
HT_API BOOL hqBufIsEmpty(HQUEUE * phq);
HT_API BOOL hqBufIsFull(HQUEUE * phq);
HT_API char * hqBufGetWait(HQUEUE * phq);
HT_API void hqBufGetWaitPost(HQUEUE * phq);
HT_API char * hqBufPutPtrWait(HQUEUE * phq);
HT_API void hqBufPutPtrWaitPost(HQUEUE * phq, BOOL bPutFinish);
HT_API BOOL hqBufPeek(HQUEUE * phq,char * buf);
#ifdef __cplusplus
}
#endif
#endif // HQUEUE_H

60
ONVIF/include/bm/hxml.h Normal file
View File

@@ -0,0 +1,60 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef H_XML_H
#define H_XML_H
#define XML_MAX_STACK_DEPTH 1024
#define XML_MAX_ATTR_NUM 200
typedef struct xmlparser
{
char * xmlstart;
char * xmlend;
char * ptr; // pointer to current character
int xmlsize;
char * e_stack[XML_MAX_STACK_DEPTH];
int e_stack_index;
char * attr[XML_MAX_ATTR_NUM];
void * userdata;
void (*startElement)(void * userdata, const char * name, const char ** attr);
void (*endElement)(void * userdata, const char * name);
void (*charData)(void * userdata, const char * str, int len);
} XMLPRS;
#ifdef __cplusplus
extern "C" {
#endif
HT_API int hxml_parse_header(XMLPRS * parse);
HT_API int hxml_parse_attr(XMLPRS * parse);
HT_API int hxml_parse_element_end(XMLPRS * parse);
HT_API int hxml_parse_element_start(XMLPRS * parse);
HT_API int hxml_parse_element(XMLPRS * parse);
HT_API int hxml_parse(XMLPRS * parse);
#ifdef __cplusplus
}
#endif
#endif // H_XML_H

View File

@@ -0,0 +1,83 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
/************************************************************************************/
typedef struct LINKED_NODE
{
struct LINKED_NODE * p_next;
struct LINKED_NODE * p_previous;
void * p_data;
} LINKED_NODE;
/************************************************************************************/
typedef struct LINKED_LIST
{
LINKED_NODE * p_first_node;
LINKED_NODE * p_last_node;
void * list_semMutex;
} LINKED_LIST;
#ifdef __cplusplus
extern "C" {
#endif
HT_API LINKED_LIST* h_list_create(BOOL bNeedMutex);
HT_API void h_list_free_container(LINKED_LIST * p_linked_list);
HT_API void h_list_free_all_node(LINKED_LIST * p_linked_list);
HT_API void h_list_get_ownership(LINKED_LIST * p_linked_list);
HT_API void h_list_giveup_ownership(LINKED_LIST * p_linked_list);
HT_API BOOL h_list_remove(LINKED_LIST * p_linked_list, LINKED_NODE * p_node);
HT_API BOOL h_list_remove_data(LINKED_LIST * p_linked_list, void * p_data);
HT_API void h_list_remove_from_front(LINKED_LIST * p_linked_list);
HT_API void h_list_remove_from_front_no_lock(LINKED_LIST * p_linked_list);
HT_API void h_list_remove_from_back(LINKED_LIST * p_linked_list);
HT_API BOOL h_list_add_at_front(LINKED_LIST * p_linked_list, void * p_item);
HT_API BOOL h_list_add_at_back(LINKED_LIST * p_linked_list, void * p_item);
HT_API uint32 h_list_get_number_of_nodes(LINKED_LIST * p_linked_list);
HT_API BOOL h_list_insert(LINKED_LIST * p_linked_list, LINKED_NODE * p_pre_node, void * p_item);
HT_API LINKED_NODE* h_list_lookup_start(LINKED_LIST * p_linked_list);
HT_API LINKED_NODE* h_list_lookup_next(LINKED_LIST * p_linked_list, LINKED_NODE * p_node);
HT_API void h_list_lookup_end(LINKED_LIST * p_linked_list);
HT_API LINKED_NODE* h_list_lookback_start(LINKED_LIST * p_linked_list);
HT_API LINKED_NODE* h_list_lookback_next(LINKED_LIST * p_linked_list, LINKED_NODE * p_node);
HT_API void h_list_lookback_end(LINKED_LIST * p_linked_list);
HT_API BOOL h_list_is_empty(LINKED_LIST * p_list);
HT_API LINKED_NODE* h_list_get_from_front(LINKED_LIST * p_list);
HT_API LINKED_NODE* h_list_get_from_back(LINKED_LIST * p_list);
#ifdef __cplusplus
}
#endif
#endif // LINKED_LIST_H

110
ONVIF/include/bm/ppstack.h Normal file
View File

@@ -0,0 +1,110 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef PPSTACK_H
#define PPSTACK_H
/***************************************************************************************/
typedef struct PPSN // ppstack_node
{
unsigned long prev_node;
unsigned long next_node;
unsigned long node_flag; // 0:idle 1:in FreeList 2:in UsedList
} PPSN;
typedef struct PPSN_CTX
{
char * fl_base;
uint32 head_node;
uint32 tail_node;
uint32 node_num;
uint32 low_offset;
uint32 high_offset;
uint32 unit_size;
void * ctx_mutex;
uint32 pop_cnt;
uint32 push_cnt;
} PPSN_CTX;
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************************/
HT_API PPSN_CTX * pps_ctx_fl_init(unsigned long node_num, unsigned long content_size, BOOL bNeedMutex);
HT_API PPSN_CTX * pps_ctx_fl_init_assign(char * mem_addr, unsigned long mem_len, unsigned long node_num, unsigned long content_size, BOOL bNeedMutex);
HT_API void pps_fl_free(PPSN_CTX * fl_ctx);
HT_API void pps_fl_reinit(PPSN_CTX * fl_ctx);
HT_API BOOL pps_fl_push(PPSN_CTX * pps_ctx, void * content_ptr);
HT_API BOOL pps_fl_push_tail(PPSN_CTX * pps_ctx, void * content_ptr);
HT_API void * pps_fl_pop(PPSN_CTX * pps_ctx);
HT_API PPSN_CTX * pps_ctx_ul_init(PPSN_CTX * fl_ctx, BOOL bNeedMutex);
HT_API BOOL pps_ctx_ul_init_assign(PPSN_CTX * ul_ctx, PPSN_CTX * fl_ctx, BOOL bNeedMutex);
HT_API BOOL pps_ctx_ul_init_nm(PPSN_CTX * fl_ctx, PPSN_CTX * ul_ctx);
HT_API void pps_ul_reinit(PPSN_CTX * ul_ctx);
HT_API void pps_ul_free(PPSN_CTX * ul_ctx);
HT_API BOOL pps_ctx_ul_del(PPSN_CTX * ul_ctx, void * content_ptr);
HT_API PPSN * pps_ctx_ul_del_node_unlock(PPSN_CTX * ul_ctx, PPSN * p_node);
HT_API void * pps_ctx_ul_del_unlock(PPSN_CTX * ul_ctx, void * content_ptr);
HT_API BOOL pps_ctx_ul_add(PPSN_CTX * ul_ctx, void * content_ptr);
HT_API BOOL pps_ctx_ul_add_head(PPSN_CTX * ul_ctx, void * content_ptr);
HT_API uint32 pps_get_index(PPSN_CTX * pps_ctx, void * content_ptr);
HT_API void * pps_get_node_by_index(PPSN_CTX * pps_ctx, unsigned long index);
/***************************************************************************************/
HT_API void * pps_lookup_start(PPSN_CTX * pps_ctx);
HT_API void * pps_lookup_next(PPSN_CTX * pps_ctx, void * ct_ptr);
HT_API void pps_lookup_end(PPSN_CTX * pps_ctx);
HT_API void * pps_lookback_start(PPSN_CTX * pps_ctx);
HT_API void * pps_lookback_next(PPSN_CTX * pps_ctx, void * ct_ptr);
HT_API void pps_lookback_end(PPSN_CTX * pps_ctx);
HT_API void pps_wait_mutex(PPSN_CTX * pps_ctx);
HT_API void pps_post_mutex(PPSN_CTX * pps_ctx);
HT_API BOOL pps_safe_node(PPSN_CTX * pps_ctx, void * content_ptr);
HT_API BOOL pps_idle_node(PPSN_CTX * pps_ctx, void * content_ptr);
HT_API BOOL pps_exist_node(PPSN_CTX * pps_ctx, void * content_ptr);
HT_API BOOL pps_used_node(PPSN_CTX * pps_ctx, void * content_ptr);
/***************************************************************************************/
HT_API int pps_node_count(PPSN_CTX * pps_ctx);
HT_API void * pps_get_head_node(PPSN_CTX * pps_ctx);
HT_API void * pps_get_tail_node(PPSN_CTX * pps_ctx);
HT_API void * pps_get_next_node(PPSN_CTX * pps_ctx, void * content_ptr);
HT_API void * pps_get_prev_node(PPSN_CTX * pps_ctx, void * content_ptr);
#ifdef __cplusplus
}
#endif
#endif // PPSTACK_H

View File

@@ -0,0 +1,46 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef RFC_MD5_H
#define RFC_MD5_H
typedef struct
{
uint32 total[2];
uint32 state[4];
uint8 buffer[64];
} md5_context;
#ifdef __cplusplus
extern "C"{
#endif
HT_API void md5_starts(md5_context *ctx);
HT_API void md5_update(md5_context *ctx, uint8 *input, uint32 length);
HT_API void md5_finish(md5_context *ctx, uint8 digest[16]);
#ifdef __cplusplus
}
#endif
#endif

44
ONVIF/include/bm/sha1.h Normal file
View File

@@ -0,0 +1,44 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef _SHA1_H_
#define _SHA1_H_
typedef struct
{
uint32 total[2];
uint32 state[5];
uint8 buffer[64];
} sha1_context;
#ifdef __cplusplus
extern "C" {
#endif
HT_API void sha1_starts(sha1_context * ctx);
HT_API void sha1_update(sha1_context * ctx, uint8 * input, uint32 length);
HT_API void sha1_finish(sha1_context * ctx, uint8 digest[20]);
#ifdef __cplusplus
}
#endif
#endif // _SHA1_H_

View File

@@ -0,0 +1,6 @@
#include "stdafx.h"

15
ONVIF/include/bm/stdafx.h Normal file
View File

@@ -0,0 +1,15 @@
#pragma once
#include <ws2tcpip.h>
#include <ws2ipdef.h>
#include <winsock2.h>
#include <mmsystem.h>
#include <io.h>
#include <iphlpapi.h>
#include <vfw.h>
#include <tchar.h>

116
ONVIF/include/bm/sys_buf.h Normal file
View File

@@ -0,0 +1,116 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef SYS_BUF_H
#define SYS_BUF_H
/***************************************************************************************/
#define MAX_AVN 8
#define MAX_AVDESCLEN 500
#define MAX_USRL 64
#define MAX_PWDL 32
#define MAX_NUML 64
#define MAX_UA_ALT_NUM 8
/***************************************************************************************/
typedef struct header_value
{
char header[32];
char * value_string;
} HDRV;
typedef struct ua_rtp_info
{
int rtp_cnt;
uint32 rtp_ssrc;
uint32 rtp_ts;
uint8 rtp_pt;
} UA_RTP_INFO;
typedef struct
{
/* rtcp sender statistics */
int64 last_rtcp_ntp_time;
int64 first_rtcp_ntp_time;
uint32 packet_count;
uint32 octet_count;
uint32 last_octet_count;
int first_packet;
char cname[64];
} UA_RTCP_INFO;
typedef struct http_digest_auth_info
{
char auth_name[MAX_USRL];
char auth_pwd[64];
char auth_uri[256];
char auth_qop[32];
char auth_nonce[128];
char auth_cnonce[128];
char auth_realm[128];
char auth_algorithm[32];
int auth_opaque_flag;
char auth_opaque[128];
int auth_nc;
char auth_ncstr[12];
char auth_response[100];
} HD_AUTH_INFO;
#ifdef __cplusplus
extern "C" {
#endif
extern HT_API PPSN_CTX * hdrv_buf_fl;
/***********************************************************************/
HT_API BOOL net_buf_init(int num, int size);
HT_API void net_buf_deinit();
HT_API char * net_buf_get_idle();
HT_API void net_buf_free(char * rbuf);
HT_API uint32 net_buf_get_size();
HT_API uint32 net_buf_idle_num();
/***********************************************************************/
HT_API BOOL hdrv_buf_init(int num);
HT_API void hdrv_buf_deinit();
HT_API HDRV * hdrv_buf_get_idle();
HT_API void hdrv_buf_free(HDRV * pHdrv);
HT_API uint32 hdrv_buf_idle_num();
HT_API void hdrv_ctx_ul_init(PPSN_CTX * ul_ctx);
HT_API void hdrv_ctx_free(PPSN_CTX * p_ctx);
/***********************************************************************/
HT_API BOOL sys_buf_init(int nums);
HT_API void sys_buf_deinit();
/***********************************************************************/
#ifdef __cplusplus
}
#endif
#endif // SYS_BUF_H

186
ONVIF/include/bm/sys_inc.h Normal file
View File

@@ -0,0 +1,186 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef __SYS_INC_H__
#define __SYS_INC_H__
#if defined(_WIN32) || defined(_WIN64)
#define __WINDOWS_OS__ 1
#define __LINUX_OS__ 0
#else
#define __WINDOWS_OS__ 0
#define __LINUX_OS__ 1
#endif
#if __WINDOWS_OS__
#ifdef HT_EXPORTS
#define HT_API __declspec(dllexport)
#else
#define HT_API __declspec(dllimport)
#endif
#ifdef HT_STATIC
#undef HT_API
#define HT_API
#endif
#else
#define HT_API
#endif
/***************************************************************************************/
//typedef int int32;
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
/***************************************************************************************/
#if __WINDOWS_OS__
#include "stdafx.h"
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <time.h>
#include <process.h> /* _beginthread, _endthread */
#include <iphlpapi.h>
#include <assert.h>
#define sleep(x) Sleep((x) * 1000)
#define usleep(x) Sleep((x) / 1000)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define snprintf _snprintf
#define pthread_t DWORD
typedef __int64 int64;
typedef unsigned __int64 uint64;
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "ws2_32.lib")
#elif __LINUX_OS__
#include <sys/types.h>
#include <sys/ipc.h>
#ifndef ANDROID
#include <sys/sem.h>
#endif
#include <semaphore.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#ifndef IOS
#include <linux/netlink.h>
#include <netinet/udp.h>
#include <sys/prctl.h>
#include <sys/epoll.h>
#endif
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <net/if.h>
#include <sys/resource.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <ctype.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include <pthread.h>
#include <dlfcn.h>
#include <dirent.h>
#ifdef IOS
#include <ifaddrs.h>
#endif
typedef signed char BOOL;
typedef int SOCKET;
typedef int64_t int64;
typedef uint64_t uint64;
#define TRUE 1
#define FALSE 0
#define closesocket close
#endif
/*************************************************************************/
#include "sys_log.h"
#include "ppstack.h"
#include "word_analyse.h"
#include "sys_buf.h"
#include "util.h"
#ifdef __cplusplus
extern "C" {
#endif
HT_API void * sys_os_create_mutex();
HT_API void * sys_os_create_sig();
HT_API void sys_os_destroy_sig_mutex(void * ptr);
HT_API int sys_os_mutex_enter(void * p_sem);
HT_API void sys_os_mutex_leave(void * p_sem);
HT_API int sys_os_sig_wait(void * p_sig);
HT_API int sys_os_sig_wait_timeout(void * p_sig, uint32 ms);
HT_API void sys_os_sig_sign(void * p_sig);
HT_API pthread_t sys_os_create_thread(void * thread_func, void * argv);
HT_API uint32 sys_os_get_ms();
HT_API uint32 sys_os_get_uptime();
HT_API char * sys_os_get_socket_error();
HT_API int sys_os_get_socket_error_num();
#ifdef __cplusplus
}
#endif
#endif // __SYS_INC_H__

View File

@@ -0,0 +1,81 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef __H_SYS_LOG_H__
#define __H_SYS_LOG_H__
// log level
#define HT_LOG_TRC 0
#define HT_LOG_DBG 1
#define HT_LOG_INFO 2
#define HT_LOG_WARN 3
#define HT_LOG_ERR 4
#define HT_LOG_FATAL 5
typedef struct
{
FILE * fp; // Log file pointer
void * mutex; // read-write lock
int level; // Log level
uint32 cur_size; // The current write length of the log
uint32 max_size; // Maximum file size in KB
int cur_idx; // Current log file index
int max_idx; // Maximum file indexes
int rewind; // Loop write log flag
int time_init; // Initialize log file names using system time
char name[256]; // Log file name
} HT_LOG_CTX;
#ifdef __cplusplus
extern "C" {
#endif
HT_API int log_init(const char * log_fname);
HT_API int log_time_init(const char * fname_prev);
HT_API int log_reinit(const char * log_fname);
HT_API int log_time_reinit(const char * fname_prev);
HT_API void log_close();
HT_API void log_set_level(int level);
HT_API int log_get_level();
HT_API void log_set_rewind(int rewind);
HT_API int log_get_rewind();
HT_API void log_set_max_size(int max_size);
HT_API int log_get_max_size();
HT_API void log_set_max_idx(int max_idx);
HT_API int log_get_max_idx();
HT_API int log_lock_start(const char * fmt,...);
HT_API int log_lock_print(const char * fmt,...);
HT_API int log_lock_end(const char * fmt,...);
#ifdef IOS
HT_API int log_ios_print(int level, const char * fmt,...);
#define log_print log_ios_print
#else
HT_API int log_print(int level, const char * fmt,...);
#endif
#ifdef __cplusplus
}
#endif
#endif

94
ONVIF/include/bm/util.h Normal file
View File

@@ -0,0 +1,94 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef __H_UTIL_H__
#define __H_UTIL_H__
/*************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************/
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ARRAY_SIZE(ary) (sizeof(ary) / sizeof(ary[0]))
/*************************************************************************/
HT_API int get_if_nums();
HT_API uint32 get_if_ip(int index);
HT_API uint32 get_route_if_ip(uint32 dst_ip);
HT_API uint32 get_default_if_ip();
HT_API const char * get_local_ip();
HT_API uint32 get_if_mask(int index);
HT_API uint32 get_route_if_mask(uint32 dst_ip);
HT_API uint32 get_default_if_mask();
HT_API int is_local_if_net(uint32 destip);
HT_API int get_default_if_mac(uint8 * mac);
HT_API uint32 get_address_by_name(const char * host_name);
HT_API const char * get_default_gateway();
HT_API const char * get_dns_server();
HT_API const char * get_mask_by_prefix_len(int len);
HT_API int get_prefix_len_by_mask(const char * mask);
HT_API const char * get_ip_str(uint32 ipaddr /* network byte order */);
/*************************************************************************/
HT_API char * lowercase(char * str);
HT_API char * uppercase(char * str);
HT_API int unicode(char ** dst, char * src);
HT_API BOOL bin_to_hex_str(uint8 * bin, int binlen, char * hex, int hexlen);
HT_API int hex_str_to_bin(char * hex, int hexlen, uint8 * bin, int binlen);
HT_API int url_encode(const char * src, const int srcsize, char * dst, const int dstsize);
HT_API int url_decode(char * dst, char const * src, uint32 len);
HT_API void url_split(char const* url, char *proto, int proto_size, char *user, int user_size, char *pass, int pass_size, char *host, int host_size, int *port, char *path, int path_size);
/*************************************************************************/
HT_API time_t get_time_by_string(char * p_time_str);
HT_API void get_time_str(char * buff, int len);
HT_API void get_time_str_day_off(time_t nt, char * buff, int len, int dayoff);
HT_API void get_time_str_mon_off(time_t nt, char * buff, int len, int moffset);
HT_API time_t get_time_by_tstring(const char * p_time_str);
HT_API void get_tstring_by_time(time_t t, char * buff, int len);
HT_API SOCKET tcp_connect_timeout(uint32 rip, int port, int timeout);
/*************************************************************************/
HT_API void network_init();
HT_API void network_deinit();
HT_API int daemon_init();
#if __WINDOWS_OS__
HT_API int gettimeofday(struct timeval* tp, int* tz);
#endif
#ifdef __cplusplus
}
#endif
#endif // __H_UTIL_H__

View File

@@ -0,0 +1,55 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef __H_WORD_ANALYSE_H__
#define __H_WORD_ANALYSE_H__
/***************************************************************************************/
typedef enum word_type
{
WORD_TYPE_NULL = 0,
WORD_TYPE_STRING,
WORD_TYPE_NUM,
WORD_TYPE_SEPARATOR
} WORD_TYPE;
#ifdef __cplusplus
extern "C" {
#endif
HT_API BOOL is_char(char ch);
HT_API BOOL is_num(char ch);
HT_API BOOL is_separator(char ch);
HT_API BOOL is_ip_address(const char * address);
HT_API BOOL is_integer(char * p_str);
HT_API BOOL GetLineText(char * buf, int cur_line_offset, int max_len, int * len, int * next_line_offset);
HT_API BOOL GetSipLine(char * p_buf, int max_len, int * len, BOOL * bHaveNextLine);
HT_API BOOL GetLineWord(char * line, int cur_word_offset, int line_max_len, char * word_buf, int buf_len, int * next_word_offset, WORD_TYPE w_t);
HT_API BOOL GetNameValuePair(char * text_buf, int text_len, const char * name, char * value, int value_len);
#ifdef __cplusplus
}
#endif
#endif // __H_WORD_ANALYSE_H__

View File

@@ -0,0 +1,89 @@
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef XML_NODE_H
#define XML_NODE_H
/***************************************************************************************
*
* XML node define
*
***************************************************************************************/
#define NTYPE_TAG 0
#define NTYPE_ATTRIB 1
#define NTYPE_CDATA 2
#define NTYPE_LAST 2
#define NTYPE_UNDEF -1
typedef struct XMLN
{
int flag; // Is the buffer pointed to by data dynamically allocated memory? If so, it needs to be free
const char * name;
uint32 type;
const char * data;
int dlen;
int finish;
struct XMLN * parent;
struct XMLN * f_child;
struct XMLN * l_child;
struct XMLN * prev;
struct XMLN * next;
struct XMLN * f_attrib;
struct XMLN * l_attrib;
} XMLN;
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************************/
HT_API XMLN * xml_node_add(XMLN * parent, const char * name);
HT_API void xml_node_del(XMLN * p_node);
HT_API XMLN * xml_node_get(XMLN * parent, const char * name);
HT_API int soap_strcmp(const char * str1, const char * str2);
HT_API void soap_strncpy(char * dest, const char * src, int size);
HT_API XMLN * xml_node_soap_get(XMLN * parent, const char * name);
/***************************************************************************************/
HT_API XMLN * xml_attr_add(XMLN * p_node, const char * name, const char * value);
HT_API void xml_attr_del(XMLN * p_node, const char * name);
HT_API const char * xml_attr_get(XMLN * p_node, const char * name);
HT_API XMLN * xml_attr_node_get(XMLN * p_node, const char * name);
/***************************************************************************************/
HT_API void xml_cdata_set(XMLN * p_node, const char * value, int len);
/***************************************************************************************/
HT_API int xml_calc_buf_len(XMLN * p_node);
HT_API int xml_write_buf(XMLN * p_node, char * xml_buf, int buf_len);
/***************************************************************************************/
HT_API XMLN * xxx_hxml_parse(char * p_xml, int len);
#ifdef __cplusplus
}
#endif
#endif // XML_NODE_H