コード例 #1
0
ファイル: ooCalls.c プロジェクト: OPSF/uClinux
int ooAddMediaInfo(OOH323CallData *call, OOMediaInfo mediaInfo)
{
   OOMediaInfo *newMediaInfo=NULL;

   if(!call)
   {
      OOTRACEERR3("Error:Invalid 'call' param for ooAddMediaInfo.(%s, %s)\n",
                   call->callType, call->callToken);
      return OO_FAILED;
   }
   newMediaInfo = (OOMediaInfo*) memAlloc(call->pctxt, sizeof(OOMediaInfo));
   if(!newMediaInfo)
   {
      OOTRACEERR3("Error:Memory - ooAddMediaInfo - newMediaInfo. "
                  "(%s, %s)\n", call->callType, call->callToken);
      return OO_FAILED;
   }

   memcpy (newMediaInfo, &mediaInfo, sizeof(OOMediaInfo));

   OOTRACEDBGC4("Configured mediainfo for cap %s (%s, %s)\n", 
                ooGetCapTypeText(mediaInfo.cap),
                call->callType, call->callToken);
   if(!call->mediaInfo) {
      newMediaInfo->next = NULL;
      call->mediaInfo = newMediaInfo;
   }
   else {
      newMediaInfo->next = call->mediaInfo;
      call->mediaInfo = newMediaInfo;
   }
   return OO_OK;
}
コード例 #2
0
ファイル: ooCalls.c プロジェクト: OPSF/uClinux
int ooCallAddAlias
   (OOH323CallData *call, int aliasType, const char *value, OOBOOL local)
{
   ooAliases * psNewAlias=NULL;
   psNewAlias = (ooAliases*)memAlloc(call->pctxt, sizeof(ooAliases));
   if(!psNewAlias)
   {
      OOTRACEERR3("Error:Memory - ooCallAddAlias - psNewAlias"
                  "(%s, %s)\n", call->callType, call->callToken);
      return OO_FAILED;
   }
   psNewAlias->type = aliasType;
   psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(value)+1);
   if(!psNewAlias->value)
   {
      OOTRACEERR3("Error:Memory - ooCallAddAlias - psNewAlias->value"
                  " (%s, %s)\n", call->callType, call->callToken);
      memFreePtr(call->pctxt, psNewAlias);
      return OO_FAILED;
   }
   strcpy(psNewAlias->value, value);

   if(local)
   {
      psNewAlias->next = call->ourAliases;
      call->ourAliases = psNewAlias;
   }
   else {
     psNewAlias->next = call->remoteAliases;
     call->remoteAliases = psNewAlias;
   }

   OOTRACEDBGC5("Added %s alias %s to call. (%s, %s)\n", 
              local?"local":"remote", value, call->callType, call->callToken);
   return OO_OK;
}
コード例 #3
0
ファイル: ooCalls.c プロジェクト: OPSF/uClinux
int ooCallSetCalledPartyNumber(OOH323CallData *call, const char *number)
{
   if(call->calledPartyNumber) 
      memFreePtr(call->pctxt, call->calledPartyNumber);

   call->calledPartyNumber = (char*) memAlloc(call->pctxt, strlen(number)+1);
   if(call->calledPartyNumber)
   {
     strcpy(call->calledPartyNumber, number);
   }
   else{
      OOTRACEERR3("Error:Memory - ooCallSetCalledPartyNumber - "
                  "calledPartyNumber.(%s, %s)\n", call->callType, 
                  call->callToken);
      return OO_FAILED;
   }
   return OO_OK;
}
コード例 #4
0
ファイル: ooLogChan.c プロジェクト: Evangileon/asterisk
OOLogicalChannel* ooFindLogicalChannelByLogicalChannelNo(OOH323CallData *call,
                                                         int ChannelNo)
{
   OOLogicalChannel *pLogicalChannel=NULL;
   if(!call->logicalChans)
   {
      OOTRACEERR3("ERROR: No Open LogicalChannels - Failed "
                  "FindLogicalChannelByChannelNo (%s, %s\n", call->callType,
                   call->callToken);
      return NULL;
   }
   pLogicalChannel = call->logicalChans;
   while(pLogicalChannel)
   {
      if(pLogicalChannel->channelNo == ChannelNo)
         break;
      else
         pLogicalChannel = pLogicalChannel->next;
   }

   return pLogicalChannel;
}
コード例 #5
0
ファイル: ooCalls.c プロジェクト: OPSF/uClinux
int ooCallSetCallingPartyNumber(OOH323CallData *call, const char *number)
{
   if(call->callingPartyNumber) 
      memFreePtr(call->pctxt, call->callingPartyNumber);

   call->callingPartyNumber = (char*) memAlloc(call->pctxt, strlen(number)+1);
   if(call->callingPartyNumber)
   {
     strcpy(call->callingPartyNumber, number);
   }
   else{
      OOTRACEERR3("Error:Memory - ooCallSetCallingPartyNumber - "
                  "callingPartyNumber.(%s, %s)\n", call->callType, 
                  call->callToken);
      return OO_FAILED;
   }
   /* Set dialed digits alias */
   /*   if(!strcmp(call->callType, "outgoing"))
   {
      ooCallAddAliasDialedDigits(call, number);
   }*/
   return OO_OK;
}
コード例 #6
0
ファイル: ooLogChan.c プロジェクト: Evangileon/asterisk
OOLogicalChannel* ooAddNewLogicalChannel(OOH323CallData *call, int channelNo, 
                                         int sessionID, char *dir, 
                                         ooH323EpCapability *epCap)
{
   OOLogicalChannel *pNewChannel=NULL, *pChannel=NULL;
   OOMediaInfo *pMediaInfo = NULL;
   OOTRACEDBGC5("Adding new media channel for cap %d dir %s (%s, %s)\n",
               epCap->cap, dir, call->callType, call->callToken);
   /* Create a new logical channel entry */
   pNewChannel = (OOLogicalChannel*)memAlloc(call->pctxt, 
                                                     sizeof(OOLogicalChannel));
   if(!pNewChannel)
   {
      OOTRACEERR3("ERROR:Memory - ooAddNewLogicalChannel - pNewChannel "
                  "(%s, %s)\n", call->callType, call->callToken);
      return NULL;
   }
   
   memset(pNewChannel, 0, sizeof(OOLogicalChannel));
   pNewChannel->channelNo = channelNo;
   pNewChannel->sessionID = sessionID;
   pNewChannel->state = OO_LOGICALCHAN_IDLE;
   pNewChannel->type = epCap->capType;
   /*   strcpy(pNewChannel->type, type);*/
   strcpy(pNewChannel->dir, dir);

   pNewChannel->chanCap = epCap;
   OOTRACEDBGC4("Adding new channel with cap %d (%s, %s)\n", epCap->cap,
                call->callType, call->callToken); 
   /* As per standards, media control port should be same for all 
      proposed channels with same session ID. However, most applications
      use same media port for transmit and receive of audio streams. Infact,
      testing of OpenH323 based asterisk assumed that same ports are used. 
      Hence we first search for existing media ports for same session and use 
      them. This should take care of all cases.
   */
   if(call->mediaInfo)
   {
      pMediaInfo = call->mediaInfo;
      while(pMediaInfo)
      {
         if(!strcmp(pMediaInfo->dir, dir) &&
            (pMediaInfo->cap == epCap->cap))
         {
            break;
         }
         pMediaInfo = pMediaInfo->next;
      }
   }
    
   if(pMediaInfo)
   {
      OOTRACEDBGC3("Using configured media info (%s, %s)\n", call->callType,
                   call->callToken);
      pNewChannel->localRtpPort = pMediaInfo->lMediaPort;
      pNewChannel->localRtcpPort = pMediaInfo->lMediaCntrlPort;
      /* If user application has not specified a specific ip and is using 
         multihomed mode, substitute appropriate ip.
      */
      if(!strcmp(pMediaInfo->lMediaIP, "0.0.0.0"))
         strcpy(pNewChannel->localIP, call->localIP);
      else
         strcpy(pNewChannel->localIP, pMediaInfo->lMediaIP);
   }
   else{
      OOTRACEDBGC3("Using default media info (%s, %s)\n", call->callType,
                   call->callToken);
      pNewChannel->localRtpPort = ooGetNextPort (OORTP);

      /* Ensures that RTP port is an even one */
      if((pNewChannel->localRtpPort & 1) == 1)
        pNewChannel->localRtpPort = ooGetNextPort (OORTP);

      pNewChannel->localRtcpPort = ooGetNextPort (OORTP);
      strcpy(pNewChannel->localIP, call->localIP);
   }
   
   /* Add new channel to the list */
   pNewChannel->next = NULL;
   if(!call->logicalChans) {
      call->logicalChans = pNewChannel;
   }
   else{
      pChannel = call->logicalChans;
      while(pChannel->next)  pChannel = pChannel->next;
      pChannel->next = pNewChannel;
   }
   
   /* increment logical channels */
   call->noOfLogicalChannels++;
   OOTRACEINFO3("Created new logical channel entry (%s, %s)\n", call->callType,
                call->callToken);
   return pNewChannel;
}
コード例 #7
0
ファイル: oosndrtp.c プロジェクト: tempbottle/TestSet
int ooLoadSndRTPPlugin(struct ooAppContext* context, char * name)
{
   media = 0;
   /* Load the plugin library */
#ifdef _WIN32
   media = LoadLibrary(name);
#else
   media = dlopen(name, RTLD_NOW|RTLD_GLOBAL);
#endif
   if(media == 0)
   {
      OOTRACEERR3(context, "ERROR:Failed to load plug-in library %s", name);
      return OO_FAILED;
   }
   
   /* Retrieve addreses of the plugin interface functions */
#ifdef _WIN32
   FuncPtr_InitializePlugin = (MediaAPI_InitializePlugin) GetProcAddress(media,
                                                         "ooInitializePlugin");
#else
   FuncPtr_InitializePlugin = (MediaAPI_InitializePlugin) dlsym(media, 
                                                         "ooInitializePlugin");
#endif
   if(FuncPtr_InitializePlugin == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooInitializePlugin");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_CreateTxRTPChan = (MediaAPI_CreateTxRTPChan) GetProcAddress(media, 
                                                 "ooCreateTransmitRTPChannel");
#else
   FuncPtr_CreateTxRTPChan = (MediaAPI_CreateTxRTPChan) dlsym(media, 
                                                 "ooCreateTransmitRTPChannel");
#endif
   if(FuncPtr_CreateTxRTPChan == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooCreateTransmitRTPChannel");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_CloseTxRTPChan = (MediaAPI_CloseTxRTPChan) GetProcAddress(media, 
                                                 "ooCloseTransmitRTPChannel");
#else
   FuncPtr_CloseTxRTPChan = (MediaAPI_CloseTxRTPChan) dlsym(media, 
                                                 "ooCloseTransmitRTPChannel");
#endif
   if(FuncPtr_CloseTxRTPChan == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooCloseTransmitRTPChannel");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_CreateRecvRTPChan = (MediaAPI_CreateRecvRTPChan) GetProcAddress
                                          (media, "ooCreateReceiveRTPChannel");
#else
   FuncPtr_CreateRecvRTPChan = (MediaAPI_CreateRecvRTPChan) dlsym(media, 
                                                 "ooCreateReceiveRTPChannel");
#endif
   if(FuncPtr_CreateRecvRTPChan == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooCreateReceiveRTPChannel");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_CloseRecvRTPChan = (MediaAPI_CloseRecvRTPChan)GetProcAddress(media, 
                                                 "ooCloseReceiveRTPChannel");
#else
   FuncPtr_CloseRecvRTPChan = (MediaAPI_CloseRecvRTPChan) dlsym(media, 
                                                 "ooCloseReceiveRTPChannel");
#endif
   if(FuncPtr_CloseRecvRTPChan == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooCloseReceiveRTPChannel");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_StartTxWaveFile = (MediaAPI_StartTxWaveFile) GetProcAddress(media, 
                                                  "ooStartTransmitWaveFile");
#else
   FuncPtr_StartTxWaveFile = (MediaAPI_StartTxWaveFile) dlsym(media, 
                                                 "ooStartTransmitWaveFile");
#endif
   if(FuncPtr_StartTxWaveFile == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStartTransmitWaveFile");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_StopTxWaveFile = (MediaAPI_StopTxWaveFile) GetProcAddress(media, 
                                                  "ooStopTransmitWaveFile");
#else
   FuncPtr_StopTxWaveFile = (MediaAPI_StopTxWaveFile) dlsym(media, 
                                                 "ooStopTransmitWaveFile");
#endif

   if(FuncPtr_StopTxWaveFile == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStopTransmitWaveFile");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_StartTxMic = (MediaAPI_StartTxMic) GetProcAddress(media, 
                                                  "ooStartTransmitMic");
#else
   FuncPtr_StartTxMic = (MediaAPI_StartTxMic) dlsym(media, 
                                                 "ooStartTransmitMic");
#endif
   if(FuncPtr_StartTxMic == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStartTransmitMic");
      return OO_FAILED;
   }
   
#ifdef _WIN32
   FuncPtr_StopTxMic = (MediaAPI_StopTxMic) GetProcAddress(media, 
                                                  "ooStopTransmitMic");
#else
   FuncPtr_StopTxMic = (MediaAPI_StopTxMic) dlsym(media, 
                                                 "ooStopTransmitMic");
#endif
   if(FuncPtr_StopTxMic == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStopTransmitMic");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_StartRecvAndPlayback =(MediaAPI_StartRecvAndPlayback)GetProcAddress
                                     (media, "ooStartReceiveAudioAndPlayback");
#else
   FuncPtr_StartRecvAndPlayback = (MediaAPI_StartRecvAndPlayback) dlsym(media, 
                                             "ooStartReceiveAudioAndPlayback");
#endif
   if(FuncPtr_StartRecvAndPlayback == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStartReceiveAudioAndPlayback");
      return OO_FAILED;
   }

#ifdef _WIN32
   FuncPtr_StopRecvAndPlayback = (MediaAPI_StopRecvAndPlayback) GetProcAddress
                                      (media, "ooStopReceiveAudioAndPlayback");
#else
   FuncPtr_StopRecvAndPlayback = (MediaAPI_StopRecvAndPlayback) dlsym(media, 
                                              "ooStopReceiveAudioAndPlayback");
#endif

   if(FuncPtr_StopRecvAndPlayback == 0)
   {
      OOTRACEERR2(context, "ERROR: Failed to retrieve the address of "
                           "ooStopRecvAndPlayback");
      return OO_FAILED;
   }
   
   /* Initialize the plugin */
   FuncPtr_InitializePlugin();

   return OO_OK;
}
コード例 #8
0
ファイル: ooCalls.c プロジェクト: OPSF/uClinux
OOH323CallData* ooCreateCall(char* type, char*callToken)
{
   OOH323CallData *call=NULL;
   OOCTXT *pctxt=NULL;

   pctxt = newContext();
   if(!pctxt)
   {
      OOTRACEERR1("ERROR:Failed to create OOCTXT for new call\n");
      return NULL;
   }
   call = (OOH323CallData*)memAlloc(pctxt, sizeof(OOH323CallData));
   if(!call)
   {
      OOTRACEERR1("ERROR:Memory - ooCreateCall - call\n");
      return NULL;
   } 
   /*   memset(call, 0, sizeof(OOH323CallData));*/
   call->pctxt = pctxt;
   call->callMode = gH323ep.callMode;
   sprintf(call->callToken, "%s", callToken);
   sprintf(call->callType, "%s", type);
   call->callReference = 0;
   if(gH323ep.callerid) {
     strncpy(call->ourCallerId, gH323ep.callerid, sizeof(call->ourCallerId)-1);
     call->ourCallerId[sizeof(call->ourCallerId)-1] = '\0';
   }
   else {
      call->ourCallerId[0] = '\0';
   }
   
   memset(&call->callIdentifier, 0, sizeof(H225CallIdentifier));
   memset(&call->confIdentifier, 0, sizeof(H225ConferenceIdentifier));

   call->flags = 0;
   if (OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING))
      OO_SETFLAG (call->flags, OO_M_TUNNELING);

   if(gH323ep.gkClient)
   {
      if(OO_TESTFLAG(gH323ep.flags, OO_M_GKROUTED))
      {
         OO_SETFLAG(call->flags, OO_M_GKROUTED);
      }
   }

   if (OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART))
      OO_SETFLAG (call->flags, OO_M_FASTSTART);

   if (OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN))
      OO_SETFLAG (call->flags, OO_M_MEDIAWAITFORCONN);
   
   call->callState = OO_CALL_CREATED;
   call->callEndReason = OO_REASON_UNKNOWN;
   call->pCallFwdData = NULL;

   if(!strcmp(call->callType, "incoming"))
   {
      call->callingPartyNumber = NULL;
   }
   else{      
      if(ooUtilsIsStrEmpty(gH323ep.callingPartyNumber))
      {
         call->callingPartyNumber = NULL;
      }
      else{
         call->callingPartyNumber = (char*) memAlloc(call->pctxt, 
                                         strlen(gH323ep.callingPartyNumber)+1);
         if(call->callingPartyNumber)
         {
            strcpy(call->callingPartyNumber, gH323ep.callingPartyNumber);
         }
         else{
            OOTRACEERR3("Error:Memory - ooCreateCall - callingPartyNumber"
                        ".(%s, %s)\n", call->callType, call->callToken);
            freeContext(pctxt);
            return NULL;
         }
      }
   }

   call->calledPartyNumber = NULL;
   call->h245ConnectionAttempts = 0;
   call->h245SessionState = OO_H245SESSION_IDLE;
   call->dtmfmode = gH323ep.dtmfmode;
   call->mediaInfo = NULL;
   strcpy(call->localIP, gH323ep.signallingIP);
   call->pH225Channel = NULL;
   call->pH245Channel = NULL;
   call->h245listener = NULL;
   call->h245listenport = NULL;
   call->remoteIP[0] = '\0';
   call->remotePort = 0;
   call->remoteH245Port = 0;
   call->remoteDisplayName = NULL;
   call->remoteAliases = NULL;
   call->ourAliases = NULL;
   call->masterSlaveState = OO_MasterSlave_Idle;
   call->statusDeterminationNumber = 0;
   call->localTermCapState = OO_LocalTermCapExchange_Idle;
   call->remoteTermCapState = OO_RemoteTermCapExchange_Idle; 
   call->ourCaps = NULL;
   call->remoteCaps = NULL;
   call->jointCaps = NULL;
   dListInit(&call->remoteFastStartOLCs);
   call->remoteTermCapSeqNo =0;
   call->localTermCapSeqNo = 0;
   memcpy(&call->capPrefs, &gH323ep.capPrefs, sizeof(OOCapPrefs));    
   call->logicalChans = NULL;
   call->noOfLogicalChannels = 0;
   call->logicalChanNoBase = 1001;
   call->logicalChanNoMax = 1100;
   call->logicalChanNoCur = 1001;
   call->nextSessionID = 4; /* 1,2,3 are reserved for audio, video and data */
   dListInit(&call->timerList);
   call->msdRetries = 0;
   call->pFastStartRes = NULL;
   call->usrData = NULL;
   OOTRACEINFO3("Created a new call (%s, %s)\n", call->callType, 
                 call->callToken);
   /* Add new call to calllist */
   ooAddCallToList (call);
   if(gH323ep.h323Callbacks.onNewCallCreated)
     gH323ep.h323Callbacks.onNewCallCreated(call);
   return call;
}
コード例 #9
0
ファイル: ooCalls.c プロジェクト: OPSF/uClinux
int ooCleanCall(OOH323CallData *call)
{
   OOCTXT *pctxt;

   OOTRACEWARN4 ("Cleaning Call (%s, %s)- reason:%s\n", 
                 call->callType, call->callToken, 
                 ooGetReasonCodeText (call->callEndReason));

   /* First clean all the logical channels, if not already cleaned. */
   if(call->logicalChans)
      ooClearAllLogicalChannels(call);
   
   /* Close H.245 connection, if not already closed */
   if(call->h245SessionState != OO_H245SESSION_CLOSED)
      ooCloseH245Connection(call);
   else{
      if(call->pH245Channel && call->pH245Channel->outQueue.count > 0)
      {
         dListFreeAll(call->pctxt, &(call->pH245Channel->outQueue));
         memFreePtr(call->pctxt, call->pH245Channel);
      }
   }

   /* Close H.245 listener, if not already closed */
   if(call->h245listener)
   {
      ooCloseH245Listener(call);
   }
   
   /* Close H225 connection, if not already closed. */
   if (0 != call->pH225Channel && 0 != call->pH225Channel->sock)
   {
      ooCloseH225Connection(call);
   }

   /* Clean timers */
   if(call->timerList.count > 0)
   {
      dListFreeAll(call->pctxt, &(call->timerList));
   }

   if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK))
   {
      ooGkClientCleanCall(gH323ep.gkClient, call);
   }

   ooRemoveCallFromList (call);
   OOTRACEINFO3("Removed call (%s, %s) from list\n", call->callType, 
                 call->callToken);

   if(call->pCallFwdData && call->pCallFwdData->fwdedByRemote)
   {

      if(gH323ep.h323Callbacks.onCallForwarded)
         gH323ep.h323Callbacks.onCallForwarded(call);

      if(ooH323HandleCallFwdRequest(call)!= OO_OK)
      {
         OOTRACEERR3("Error:Failed to forward call (%s, %s)\n", call->callType,
                     call->callToken);
      }
   }
   else {
      if(gH323ep.h323Callbacks.onCallCleared)
         gH323ep.h323Callbacks.onCallCleared(call);
   }

   pctxt = call->pctxt;
   freeContext(pctxt);
   ASN1CRTFREE0(pctxt);
   return OO_OK;
}