#include <Winsock2.h>
#include <windows.h>
#include "demo.h"
#include "ctrl.h"
#include "refrash.h"
#include "h264.h"
#define RUSULT_ERROR 0
#define RUSULT_WRITE 1
#define PROG_NAME "sipreg"
#define PROG_VER "1.0"
#define UA_STRING "DatangAgent"
#define SYSLOG_FACILITY LOG_DAEMON
using namespace std;
FILE* logfile;
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/用来分辨不同的会话:视音频文件下载
// 常量
char eXosip_server_id[30] = "35020000002000000001";
char eXosip_server_ip[20] = "192.168.12.54";
char eXosip_server_port[10] = "15060";
char eXosip_ipc_id[30] = "35020000001320000005";
char eXosip_ipc_pwd[20] = "12345678";
char eXosip_ipc_ip[20] = "192.168.12.42";
char eXosip_ipc_media_port[10] = "20000";
char eXosip_ipc_sess_port[10] = "5060";
char eXosip_alarm_id[30] = "35020000001340000005";
char eXosip_media_ip[30] = "192.168.12.54";
char eXosip_media_port[10] = "10000";
char eXosip_device_name[30] = "zwj-ceshi";
char eXosip_device_manufacturer[30] = "datang";
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] = "2014-01-17T16:30:20";
int dt_initDeviceParm(void);
int dt_eXosip_init(eXosip_t *context);// 初始化eXosip
int dt_eXosip_register(eXosip_t *context, const int expires = 3600);// 注册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 dump_request(eXosip_event_t *evtp);
void dump_reponse(eXosip_event_t *evtp);
void dump_req_resp(osip_message_t *msg, char** msgStr);
string get_sip_message_body(osip_message_t* msg);
vector<string> split(const string& s, const char *delim);
string parserSdp(const string& sdp, char field);
// SetTimer定时器回调函数
void CALLBACK TimeProc(
HWND hwnd,
UINT uMsg,
UINT_PTR idEvent,
DWORD dwTime);
// 线程函数
DWORD CALLBACK threadFunc(PVOID pvoid)
{
MSG msg;
PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
UINT timerid = SetTimer(NULL, 111, 60000, 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[])
{
// 指向应用程序定义的要添加或删除的 HandlerRoutine 函数的指针
if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)ctrlHandler, true) == FALSE)
{
dbg("SetConsoleCtrlHandler failed\n");
return 0;
}
// open log file.
logfile = fopen("./output.log", "w+");
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");
return -1;
}
// 初始化eXosip
while (dt_eXosip_init(eXosipContext) == -1)
{
static int cnt = 0;
cnt++;
if (cnt > 10)
{
system("pause");
cnt = 0;
return -1;
}
}
// 注册到SIP服务器
if(dt_eXosip_register(eXosipContext, 600) == 0)
{
dbg("use timer in workthread of console application\n");
CreateThread(NULL, 0, threadFunc, NULL, 0, NULL);
dt_eXosip_processEvent(eXosipContext);
}
return 0;
}
int dt_initDeviceParm(void)
{
// device_info.server_id = "13101811171909469000";
// device_info.server_ip = "192.168.26.121";
// device_info.server_port = "5060";
//
// device_info.device_name = "IPC";
// device_info.device_manufacturer = "datang";
// device_info.device_model = "GB28181";
// device_info.device_firmware = "V1.0";
// device_info.device_encode = "ON";
// device_info.device_record = "OFF";
//
// device_info.ipc_id = "14011702045241050300";
// device_info.ipc_pwd =
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于osip2和eXosip2实现的GB28181测试客户端(模拟IPC功能) (153个子文件)
test.264 660KB
Makefile.am 849B
Makefile.am 291B
Makefile.am 200B
Makefile.am 189B
demo.cpp 53KB
PS_Packet_Packaging.cpp 11KB
ctrl.cpp 7KB
h264.cpp 5KB
config.cpp 3KB
refrash.cpp 457B
osip2.dll 1.48MB
osipparser2.dll 1.46MB
gb28181_client.vcxproj.filters 2KB
osip.h 45KB
osip_parser.h 35KB
rtpsession.h 26KB
sdp_message.h 22KB
rtpsourcedata.h 20KB
rtpsources.h 18KB
osip_message.h 16KB
eXosip.h 15KB
osip_uri.h 14KB
rtcpcompoundpacketbuilder.h 12KB
eX_setup.h 12KB
rtcppacketbuilder.h 12KB
rtpudpv6transmitter.h 12KB
rtptransmitter.h 12KB
rtpudpv4transmitter.h 11KB
rtcpsdespacket.h 11KB
rtperrors.h 11KB
rtpsessionparams.h 11KB
osip_port.h 11KB
rtppacketbuilder.h 10KB
rtpexternaltransmitter.h 9KB
rtpkeyhashtable.h 9KB
rtptimeutilities.h 9KB
rtphashtable.h 9KB
osip_proxy_authorization.h 8KB
rtcpsdesinfo.h 8KB
osip_authorization.h 8KB
eX_call.h 8KB
rtcpsrpacket.h 8KB
rtpmemorymanager.h 8KB
osip_dialog.h 8KB
rtppacket.h 8KB
internal.h 7KB
rtcpscheduler.h 7KB
osip_www_authenticate.h 7KB
eX_subscribe.h 7KB
osip_proxy_authenticate.h 7KB
osip_via.h 7KB
rtcprrpacket.h 7KB
osip_const.h 6KB
demo.h 6KB
config.h 5KB
h264.h 5KB
osip_authentication_info.h 5KB
osip_proxy_authentication_info.h 5KB
osip_list.h 5KB
osip_to.h 5KB
osip_from.h 5KB
rtpinternalsourcedata.h 5KB
rtprawpacket.h 4KB
rtpipv6address.h 4KB
rtcpcompoundpacket.h 4KB
osip_contact.h 4KB
rtcpbyepacket.h 4KB
rtpipv4address.h 4KB
osip_mt.h 4KB
osip_record_route.h 4KB
osip_accept_encoding.h 4KB
rtpbyteaddress.h 4KB
rtcpapppacket.h 4KB
osip_route.h 4KB
eX_register.h 4KB
rtpipv4destination.h 4KB
rtpipv6destination.h 4KB
osip_body.h 4KB
rtpaddress.h 4KB
osip_accept_language.h 4KB
osip_header.h 3KB
osip_fifo.h 3KB
osip_call_id.h 3KB
rtpsessionsources.h 3KB
osip_content_type.h 3KB
rtpcollisionlist.h 3KB
osip_cseq.h 3KB
rtpdefines.h 3KB
eX_message.h 3KB
rtcppacket.h 3KB
osip_content_disposition.h 3KB
eX_options.h 3KB
rtpstructs.h 3KB
osip_call_info.h 3KB
osip_accept.h 3KB
rtcpunknownpacket.h 3KB
PS_Packet_Packaging.h 3KB
osip_error_info.h 3KB
osip_alert_info.h 3KB
共 153 条
- 1
- 2
资源评论
orgotF
- 粉丝: 33
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功