#include <eXosip2/eXosip.h>
#include <stdio.h>
#include <stdlib.h>
#include <Winsock2.h>
#include <windows.h>
#include "demo.h"
#include "ctrl.h"
#include "refrash.h"
#include "h264.h"
#include <sys/types.h>
#include <string>
#include <vector>
FILE* logfile;
#define RUSULT_ERROR 0
#define RUSULT_WRITE 1
#define PROG_NAME "sipreg"
#define PROG_VER "1.0"
#define UA_STRING "dtagent"
#define SYSLOG_FACILITY LOG_DAEMON
// sip服务器
char eXosip_server_id[30] = "34020000002000000001";
char eXosip_server_ip[20] = "192.168.1.19";
char eXosip_server_port[10] = "15060";
/// local ipc:
char eXosip_ipc_id[30] = "34020000001380000001";
char eXosip_ipc_pwd[20] = "12345678";
char eXosip_ipc_ip[20] = "192.168.1.105";
char eXosip_ipc_media_port[10] = "20000";
char eXosip_ipc_sess_port[10] = "5080";
//char eXosip_alarm_id[30]
char eXosip_alarm_id[30] = "34020000001340000010";
/// rtp: av: localip:
char eXosip_media_ip[30] = "192.168.1.105";
char eXosip_media_port[10] = "15070";
char eXosip_device_name[30] = "zhangsanceshi";
char eXosip_device_manufacturer[30] = "charles";
char eXosip_device_model[30] = "ABC_model2";
char eXosip_device_firmware[30] = "V1.0";
char eXosip_device_encode[10] = "ON";
char eXosip_device_record[10] = "OFF";
char eXosip_status_on[10] = "ON";
char eXosip_status_ok[10] = "OK";
char eXosip_status_online[10] = "ONLINE";
char eXosip_status_guard[10] = "OFFDUTY";
char eXosip_status_time[30] = "2023-05-04T22:31:22";
char aFileNameTime[16] = { 0 };//以时间格式命名的文件名如201805181536(2018/5/15 15:36)
char aFileName[200] = { 0 };//以时间格式命名的带后缀的文件名如201805181536.txt(2018/5/15 15:36)
// 为了适配wvp-GB28181-pro
char eXosip_media_ssrc[10] = "200005269";
void gettime(char* buf)
{
char szContentBuf[200] = "";
time_t timep;
struct tm *p;
#if 0
time(&timep);
p = gmtime(&timep);//格林时间
#else
time(&timep);
p = localtime(&timep);//当地时间
#endif
sprintf(szContentBuf, "%04d%02d%02d%02d%02d%02d", (1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
strcpy(buf, szContentBuf);
}
DEVICE_INFO device_info;
DEVICE_STATUS device_status;
DEVICE_CONTROL device_control;
DT_EXOSIP_CALLBACK dt_eXosip_callback;
BOOL SenAliveFlag = FALSE;
int g_register_id = 0;/*注册ID/用来更新注册或取消注册*/
int g_call_id = 0;/*INVITE连接ID/用来分辨不同的INVITE连接,每个时刻只允许有一个INVITE连接*/
int g_did_realPlay = 0;/*会话ID/用来分辨不同的会话:实时视音频点播*/
int g_did_backPlay = 0;/*会话ID/用来分辨不同的会话:历史视音频回放*/
int g_did_fileDown = 0;/*会话ID/用来分辨不同的会话:视音频文件下载*/
int dt_initDeviceParm(void);
int dt_eXosip_init(eXosip_t *context);/*初始化eXosip*/
int dt_eXosip_register(eXosip_t *context,int expires);/*注册eXosip,手动处理服务器返回的401状态*/
int dt_eXosip_unregister(eXosip_t *context);/*注销eXosip*/
void dt_eXosip_sendEventAlarm(eXosip_t *context,char *alarm_time);/*报警事件通知和分发:发送报警通知*/
void dt_eXosip_sendFileEnd(eXosip_t *context);/*历史视音频回放:发送文件结束*/
void dt_eXosip_paraseMsgBody(eXosip_t *context,eXosip_event_t *p_event);/*解析MESSAGE的XML消息体*/
void dt_eXosip_paraseInviteBody(eXosip_t *context,eXosip_event_t *p_event);/*解析INVITE的SDP消息体,同时保存全局INVITE连接ID和全局会话ID*/
void dt_eXosip_paraseInfoBody(eXosip_t *context,eXosip_event_t *p_event);/*解析INFO的RTSP消息体*/
void dt_eXosip_printEvent(eXosip_t *context,eXosip_event_t *p_event);/*检测并打印事件*/
void dt_eXosip_processEvent(eXosip_t *context);/*消息循环处理*/
void dt_eXosip_launch(eXosip_t *context);/*启动并注册eXosip*/
void CALLBACK TimeProc(
HWND hwnd,
UINT uMsg,
UINT_PTR idEvent,
DWORD dwTime);
DWORD CALLBACK Thread(PVOID pvoid)
{
MSG msg;
PeekMessage(&msg,NULL,WM_USER,WM_USER,PM_NOREMOVE);
UINT timerid = SetTimer(NULL,111,20000,TimeProc);
BOOL bRet;
while ((bRet = GetMessage(&msg,NULL,0,0))!=0)
{
if (bRet == -1)
{
dbg("Error:the thread will quit,error id is %d\n",GetLastError());
break;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
KillTimer(NULL,timerid);
dbg("thread end here/n");
return 0;
}
bool ctrlhandler(DWORD fdwctrltype)
{
switch (fdwctrltype)
{
// handle the ctrl-c signal.
case CTRL_C_EVENT:
dbg("ctrl-c event\n\n");
return(true);
// ctrl-close: confirm that the user wants to exit.
case CTRL_CLOSE_EVENT://右上角关闭事件
dbg("ctrl-close event\n\n");
fflush(logfile);
fclose(logfile);
//system("pause");
return(true);
// pass other signals to the next handler.
case CTRL_BREAK_EVENT:
dbg("ctrl-break event\n\n");
return false;
case CTRL_LOGOFF_EVENT:
dbg("ctrl-logoff event\n\n");
return false;
case CTRL_SHUTDOWN_EVENT:
dbg("ctrl-shutdown event\n\n");
return false;
default:
return false;
}
}
//主函数
int main (int argc, char *argv[])
{
if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)ctrlhandler, true) == FALSE)
{
dbg("SetConsoleCtrlHandler failed\r\n");
return 0;
}
gettime(aFileNameTime);//C语言字符串是用字符数组表示的
sprintf(aFileName, "%s%s", aFileNameTime, ".txt");//格式化写到字符串aFileName
logfile = fopen(aFileName, "wt");
device_info.server_id = eXosip_server_id;
device_info.server_ip = eXosip_server_ip;
device_info.server_port = eXosip_server_port;
device_info.ipc_id = eXosip_ipc_id;
device_info.ipc_pwd = eXosip_ipc_pwd;
device_info.ipc_ip = eXosip_ipc_ip;
device_info.ipc_media_port = eXosip_ipc_media_port;
device_info.ipc_sess_port = eXosip_ipc_sess_port;
device_info.alarm_id = eXosip_alarm_id;
device_info.media_ip = eXosip_media_ip;
device_info.media_port = eXosip_media_port;
device_info.device_name = eXosip_device_name;
device_info.device_manufacturer = eXosip_device_manufacturer;
device_info.device_model = eXosip_device_model;
device_info.device_firmware = eXosip_device_firmware;
device_info.device_encode = eXosip_device_encode;
device_info.device_record = eXosip_device_record;
device_status.status_on = eXosip_status_on;
device_status.status_ok = eXosip_status_ok;
device_status.status_online = eXosip_status_online;
device_status.status_guard = eXosip_status_guard;
device_status.status_time = eXosip_status_time;
dt_eXosip_callback.dt_eXosip_deviceControl = dt_eXosip_deviceControl;
dt_eXosip_callback.dt_eXosip_getDeviceInfo = dt_eXosip_getDeviceInfo;
dt_eXosip_callback.dt_eXosip_getDeviceStatus = dt_eXosip_getDeviceStatus;
dt_eXosip_callback.dt_eXosip_getRecordTime = dt_eXosip_getRecordTime;
dt_eXosip_callback.dt_eXosip_mediaControl = dt_eXosip_mediaControl;
dt_eXosip_callback.dt_eXosip_playControl = dt_eXosip_playControl;
//分配一个eXosip_t结构体
eXosip_t *eXosipContext = eXosip_malloc();
if (eXosipContext == NULL)
dbg("mallco failed\n");
int cnt = 0;
while (dt_eXosip_init(eXosipContext) == -1)
{
cnt++;
if (cnt > 10)
{
system("pause");
cnt = 0;
return -1;
}
}
if(dt_eXosip_register(eXosipContext,3600) == 0)
{
dbg("use timer in workthread of console application\n");
CreateThread(NULL,0,Thread,NULL,0,NULL); //MessageLoop, 防止直接退出
dt_eXosip_processEvent(eXosipContext);
}
return 0;
}
int dt_initDeviceParm(void)
{
return 0;
}
/*初始化eXosip*/
int dt_eXosip_init(eXosip_t *context)
{
int ret = 0;
InitiateWinsock();
ret = eXosip_init(context); /*初始化osip和eXosip协议�
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
GB28181网络摄像机模拟器,支持注册保活,推送ps流到gb28181平台,和接收sip指令 (150个子文件)
Makefile.am 834B
Makefile.am 280B
Makefile.am 170B
demo.cpp 50KB
PS_Packet_Packaging.cpp 11KB
ctrl.cpp 8KB
h264.cpp 5KB
refrash.cpp 950B
eXosip.dll 1.23MB
eXosip.dll 1.23MB
libeay32.dll 1.2MB
libeay32.dll 1.2MB
ssleay32.dll 289KB
ssleay32.dll 289KB
osipparser2.dll 207KB
osipparser2.dll 207KB
osip2.dll 112KB
osip2.dll 112KB
osip.h 41KB
osip_parser.h 34KB
rtpsession.h 26KB
rtpsourcedata.h 20KB
sdp_message.h 20KB
eX_setup.h 19KB
rtpsources.h 18KB
osip_message.h 15KB
eXosip.h 15KB
osip_uri.h 14KB
rtcpcompoundpacketbuilder.h 12KB
rtcppacketbuilder.h 12KB
rtpudpv6transmitter.h 12KB
rtptransmitter.h 12KB
rtpudpv4transmitter.h 11KB
rtcpsdespacket.h 11KB
rtperrors.h 11KB
rtpsessionparams.h 11KB
rtppacketbuilder.h 10KB
osip_port.h 10KB
osip_authorization.h 10KB
osip_proxy_authorization.h 10KB
eX_call.h 9KB
rtpexternaltransmitter.h 9KB
rtpkeyhashtable.h 9KB
rtptimeutilities.h 9KB
rtphashtable.h 9KB
osip_www_authenticate.h 9KB
osip_proxy_authenticate.h 8KB
rtcpsdesinfo.h 8KB
rtcpsrpacket.h 8KB
osip_authentication_info.h 8KB
eX_subscribe.h 8KB
rtpmemorymanager.h 8KB
rtppacket.h 8KB
internal.h 8KB
osip_proxy_authentication_info.h 7KB
rtcpscheduler.h 7KB
osip_dialog.h 7KB
rtcprrpacket.h 7KB
osip_via.h 6KB
h264.h 6KB
osip_const.h 5KB
osip_list.h 5KB
osip_to.h 5KB
osip_from.h 5KB
rtpinternalsourcedata.h 5KB
demo.h 5KB
rtprawpacket.h 4KB
rtpipv6address.h 4KB
rtcpcompoundpacket.h 4KB
eX_register.h 4KB
rtcpbyepacket.h 4KB
rtpipv4address.h 4KB
osip_contact.h 4KB
osip_mt.h 4KB
osip_record_route.h 4KB
rtpbyteaddress.h 4KB
rtcpapppacket.h 4KB
eX_message.h 4KB
osip_accept_encoding.h 4KB
rtpipv4destination.h 4KB
rtpipv6destination.h 4KB
rtpaddress.h 4KB
eX_options.h 4KB
osip_route.h 4KB
osip_accept_language.h 3KB
rtpsessionsources.h 3KB
osip_header.h 3KB
osip_body.h 3KB
rtpcollisionlist.h 3KB
osip_call_id.h 3KB
osip_fifo.h 3KB
osip_content_type.h 3KB
rtpdefines.h 3KB
osip_cseq.h 3KB
internal.h 3KB
eX_publish.h 3KB
rtcppacket.h 3KB
PS_Packet_Packaging.h 3KB
rtpstructs.h 3KB
osip_content_disposition.h 3KB
共 150 条
- 1
- 2
资源评论
Charles技术成长之路
- 粉丝: 35
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功