• 大小: 1.5M
    文件类型: .bz2
    金币: 1
    下载: 0 次
    发布日期: 2023-09-30
  • 语言: 其他
  • 标签: 其他  

资源简介

GBT28181_Register.tar.bz2

资源截图

代码片段和文件信息

#include 
#include 
#include 
#include 
#include     //INADDR_ANY

#include 


char *pcServerID = “34010000002000000001“;
char *pcServerIP = “192.168.120.107“;
int iServerPort = 5060;
char *pcClientID = “34010000001310000001“;
int iClientPort = 5062;
char *pcPassword = “12345“;


int g_Rid = 0;

/**
 * @brief 注册 向上级服务器注册
 * @param pSClientGB
 * @return
 */
#define GBT28181_REGISTER_SUCCESS 0
#define GBT28181_REGISTER_FAILURE -1
#define GBT28181_REGISTER_TIMEOUT -2
int GBT28181_Register(struct eXosip_t * peCtx)
{
    int i = 0;

    int iRid = 0;

    osip_message_t * reg = NULL;

    char acClientURI[128];
    char acServerURI[128];

    char acDeiveID10Bit[11];
    memset(acDeiveID10Bit011);
    strncpy(acDeiveID10BitpcClientID10);

    sprintf(acClientURI“sip:%s@%s:%d“pcClientIDacDeiveID10BitiClientPort);
    sprintf(acServerURI“sip:%s@%s:%d“pcServerIDpcServerIPiServerPort);

    iRid = eXosip_register_build_initial_register(peCtxacClientURIacServerURINULL3600®);
    if (iRid < 0)
    {
        return -1;
    }

    g_Rid = iRid;

    i = eXosip_register_send_register (peCtxiRidreg);
    if ( i !=  OSIP_SUCCESS )
    {
        return GBT28181_REGISTER_TIMEOUT;
    }
    else
    {

    }

    return GBT28181_REGISTER_SUCCESS;
}



static void *MainProcess(void * pvSClientGB)
{
    struct eXosip_t * peCtx = (struct eXosip_t *)pvSClientGB;

    int iHasStartFlag = 0;
    for(;;)
    {
        eXosip_event_t *je = NULL;

        je = eXosip_event_wait (peCtx04);

        if ( iHasStartFlag == 0 )
        {
            iHasStartFlag = 1;
        }
        if ( iHasStartFlag == 1 )
        {
            //Send Register to Server
            GBT28181_Register(peCtx);
            iHasStartFlag = 2;
        }

        if (je == NULL)
        {
            osip_usleep(10000);
            continue;
        }


        switch (je->type)
        {
         case EXOSIP_REGISTRATION_SUCCESS:
            {
                if ( je->response != NULL )
                {
                    osip_header_t *Date = NULL;
                    osip_message_header_get_byname (je->response“Date“0&Date);
                    if ( (Date != NULL) && (Date->hvalue != NULL) )
                    {
                        char *pcDate = Date->hvalue;
                        //HandleTiming(pSClientGBpcDate);  //处理校时指令

                        fprintf(stderr“Register Success!!\n“);
                    }

                }
            }
            break;
         case EXOSIP_REGISTRATION_FAILURE:
            {
                //发送带用户名密码的注册消息
                if ( je->response != NULL )
                {
                    if(je->response->status_code == 401 || je->response->status_code == 407)
                    {
                        eXosip_lock(peCtx);
                        eXosip_add_authentication_info (peCtxpcClientIDpcClientIDpcPassword“MD5“NULL);//向eXosip提

评论

共有 条评论