示例#1
0
SIPXTAPI_API SIPX_RESULT sipxAudioGetInputDevice(const SIPX_INST hInst,
                                                 SIPX_AUDIO_DEVICE* deviceInfo)
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioGetInputDevice");
   OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,
      "sipxAudioGetInputDevice hInst=%p", hInst);

   SIPX_RESULT rc = SIPX_RESULT_INVALID_ARGS;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst && deviceInfo)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();

      if (pInterface)
      {
         CpAudioDeviceInfo cpDeviceInfo;
         OsStatus res = pInterface->getCurrentAudioInputDevice(cpDeviceInfo);
         if (res == OS_SUCCESS)
         {
            SAFE_STRNCPY(deviceInfo->deviceName, cpDeviceInfo.m_deviceName, sizeof(deviceInfo->deviceName));
            SAFE_STRNCPY(deviceInfo->driverName, cpDeviceInfo.m_driverName, sizeof(deviceInfo->deviceName));
            deviceInfo->bIsInput = cpDeviceInfo.m_bIsInput;
            deviceInfo->defaultSampleRate = cpDeviceInfo.m_defaultSampleRate;
            deviceInfo->maxChannels = cpDeviceInfo.m_maxChannels;
            rc = SIPX_RESULT_SUCCESS;
         }
      }
   }

   return rc;
}
示例#2
0
SIPXTAPI_API SIPX_RESULT sipxAudioSetOutputDevice(const SIPX_INST hInst,
                                                  const char* szDevice,
                                                  const char* szDriver)
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioSetOutputDevice");
   OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,
      "sipxAudioSetOutputDevice hInst=%p device=%s",
      hInst, szDevice ? szDevice : "null");

   SIPX_RESULT rc = SIPX_RESULT_INVALID_ARGS;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();

      if (pInterface)
      {
         OsStatus res = pInterface->setAudioOutputDevice(szDevice, szDriver);
         if (res == OS_SUCCESS)
         {
            rc = SIPX_RESULT_SUCCESS;
         }
      }
   }

   return rc;
}
示例#3
0
SIPXTAPI_API SIPX_RESULT sipxAudioGetAGCMode(const SIPX_INST hInst,
                                             int* bEnabled) 
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioGetAGCMode");

   OsSysLog::add(FAC_SIPXTAPI, PRI_DEBUG,
      "sipxAudioGetAGCMode hInst=%p",
      hInst);

   SIPX_RESULT sr = SIPX_RESULT_FAILURE;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst && bEnabled)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();

      if (pInterface)
      {
         UtlBoolean bCheck;
         if (pInterface->isAGCEnabled(bCheck) == OS_SUCCESS)
         {
            *bEnabled = bCheck;
            sr = SIPX_RESULT_SUCCESS;
         }
      }      
   }

   return sr;
}
示例#4
0
SIPXTAPI_API SIPX_RESULT sipxAudioGetNoiseReductionMode(const SIPX_INST hInst,
                                                        SIPX_NOISE_REDUCTION_MODE* mode) 
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioGetNoiseReductionMode");

   OsSysLog::add(FAC_SIPXTAPI, PRI_DEBUG,
      "sipxAudioGetNoiseReductionMode hInst=%p",
      hInst);

   SIPX_RESULT sr = SIPX_RESULT_FAILURE;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst && mode)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();

      if (pInterface)
      {
         MEDIA_NOISE_REDUCTION_MODE nrMode;
         if (pInterface->getAudioNoiseReductionMode(nrMode) == OS_SUCCESS)
         {
            *mode = (SIPX_NOISE_REDUCTION_MODE)nrMode;
            sr = SIPX_RESULT_SUCCESS;
         }
      }
   }

   return sr;
}
示例#5
0
SIPXTAPI_API SIPX_RESULT sipxAudioGetOutputVolume(const SIPX_INST hInst,
                                                  int* iLevel)
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioGetOutputVolume");
   OsSysLog::add(FAC_SIPXTAPI, PRI_INFO, "sipxAudioGetOutputVolume hInst=%p", hInst);

   SIPX_RESULT sr = SIPX_RESULT_FAILURE;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst && iLevel)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();

      if (pInterface)
      {
         OsStatus status = pInterface->getAudioPCMOutputVolume(*iLevel);
         if (status == OS_SUCCESS)
         {
            sr = SIPX_RESULT_SUCCESS;
         }
      }
   }

   return sr;
}
示例#6
0
SIPXTAPI_API SIPX_RESULT sipxAudioSetAGCMode(const SIPX_INST hInst,
                                             const int bEnable) 
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioSetAGCMode");

   OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,
      "sipxAudioSetAGCMode hInst=%p enable=%d",
      hInst, bEnable);

   SIPX_RESULT sr = SIPX_RESULT_FAILURE;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();

      if (pInterface)
      {
         if (pInterface->enableAGC(bEnable) == OS_SUCCESS)
         {
            sr = SIPX_RESULT_SUCCESS;
         }
      }
   }

   return sr;
}
示例#7
0
SIPXTAPI_API SIPX_RESULT sipxAudioSetOutputVolume(const SIPX_INST hInst,
                                                  const int iLevel)
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioSetOutputVolume");
   OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,
      "sipxAudioSetOutputVolume hInst=%p iLevel=%d",
      hInst, iLevel);

   SIPX_RESULT sr = SIPX_RESULT_FAILURE;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();

      if (pInterface)
      {
         // Validate Params
         if (iLevel >= OUTPUT_VOLUME_MIN && iLevel <= OUTPUT_VOLUME_MAX)
         {
            // the CpMediaInterfaceFactoryImpl always uses a scale of 0 - 100
            OsStatus status = pInterface->setAudioPCMOutputVolume(iLevel);
            if (status == OS_SUCCESS)
            {
               sr = SIPX_RESULT_SUCCESS;
            }
         }
      }      
   }

   return sr;
}
示例#8
0
SIPXTAPI_API SIPX_RESULT sipxAudioIsOutputMuted(const SIPX_INST hInst,
                                                int* bMuted)
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioIsOutputMuted");
   OsSysLog::add(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioIsOutputMuted hInst=%p", hInst);

   SIPX_RESULT sr = SIPX_RESULT_FAILURE;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst && bMuted)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();
      if (pInterface)
      {
         UtlBoolean bIsMuted;
         OsStatus res = pInterface->isAudioOutputMuted(bIsMuted);
         if (res == OS_SUCCESS)
         {
            *bMuted = bIsMuted;
            sr = SIPX_RESULT_SUCCESS;
         }         
      }
   }

   return sr;
}
示例#9
0
SIPXTAPI_API SIPX_RESULT sipxAudioMuteOutput(const SIPX_INST hInst,
                                             const int bMute)
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioMuteOutput");
   OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,
      "sipxAudioMuteOutput hInst=%p bMute=%d",
      hInst, bMute);

   SIPX_RESULT sr = SIPX_RESULT_FAILURE;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();

      if (pInterface)
      {
         // Mute or unmute speaker
         OsStatus rc = pInterface->muteAudioOutput(bMute);

         if (rc == OS_SUCCESS)
         {
            sr = SIPX_RESULT_SUCCESS;
         }
      }     
   }

   return sr;
}
示例#10
0
SIPXTAPI_API SIPX_RESULT sipxAudioSetInputVolume(const SIPX_INST hInst,
                                                 const int iLevel)
{
   OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxAudioSetInputVolume");
   OsSysLog::add(FAC_SIPXTAPI, PRI_INFO,
      "sipxAudioSetInputVolume hInst=%p iLevel=%d",
      hInst, iLevel);

   SIPX_RESULT sr = SIPX_RESULT_FAILURE;
   SIPX_INSTANCE_DATA* pInst = SAFE_PTR_CAST(SIPX_INSTANCE_DATA, hInst);

   if (pInst)
   {
      CpMediaInterfaceFactory* pInterface = pInst->pCallManager->getMediaInterfaceFactory();

      if (pInterface)
      {
         // Validate gain is within range
         if (iLevel >= INPUT_VOLUME_MIN && iLevel <= INPUT_VOLUME_MAX)
         {
            OsStatus rc = OS_FAILED;
            rc = pInterface->setAudioInputVolume(iLevel);

            if (rc == OS_SUCCESS)
            {
               sr = SIPX_RESULT_SUCCESS;
            }
         }
         else
         {
            sr = SIPX_RESULT_INVALID_ARGS;
         }
      }      
   }

   return sr;
}
示例#11
0
bool SipXMessageObserver::handleIncomingInfoStatus(SipMessage* pSipMessage, int messageType)
{
    OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "SipXMessageObserver::handleIncomingInfoStatus");

    if (NULL == pSipMessage)
    {
        // something went wrong
        return false;
    }
    
    SIPX_INFO hInfo = (SIPX_INFO)pSipMessage->getResponseListenerData();
    if (hInfo)
    {
        SIPX_INFOSTATUS_INFO infoStatus;
        
        memset((void*) &infoStatus, 0, sizeof(SIPX_INFOSTATUS_INFO));
        infoStatus.nSize = sizeof(SIPX_INFOSTATUS_INFO);
        infoStatus.responseCode = pSipMessage->getResponseStatusCode();
        infoStatus.event = INFOSTATUS_RESPONSE;
        
        infoStatus.hInfo = hInfo;
        SIPX_INFO_DATA* pInfoData = sipxInfoLookup(hInfo, SIPX_LOCK_READ, stackLogger);

        if(pInfoData)
        {
            
            int statusCode = pSipMessage->getResponseStatusCode();
            if (statusCode < 400)
            {
                infoStatus.status = SIPX_MESSAGE_OK;
            }
            // May want to add special case for authentication
            //else if(statusCode == HTTP_PROXY_UNAUTHORIZED_CODE || statusCode == HTTP_UNAUTHORIZED_CODE)
            //{
            //    infoStatus.status = 
            //}
            else if (statusCode < 500)
            {
                infoStatus.status = SIPX_MESSAGE_FAILURE;
            }
            else if (statusCode < 600)
            {
                infoStatus.status = SIPX_MESSAGE_SERVER_FAILURE;
            }
            else 
            {
                infoStatus.status = SIPX_MESSAGE_GLOBAL_FAILURE;
            }
            
            UtlString sResponseText;
            pSipMessage->getResponseStatusText(&sResponseText);
            infoStatus.szResponseText = sResponseText.data();
            
            UtlVoidPtr* ptr = NULL;
            OsLock eventLock(*g_pEventListenerLock) ;
            UtlSListIterator eventListenerItor(*g_pEventListeners);
            while ((ptr = (UtlVoidPtr*) eventListenerItor()) != NULL)
            {
                EVENT_LISTENER_DATA *pData = (EVENT_LISTENER_DATA*) ptr->getValue();
                if (pData)
                {
                    if(pInfoData->pInst == pData->pInst)
                    {
                        pData->pCallbackProc(EVENT_CATEGORY_INFO_STATUS, &infoStatus, pData->pUserData);
                    }
                }
                else
                {
                    OsSysLog::add(FAC_SIPXTAPI, PRI_ERR,
                            "SipXMessageObserver::handleIncomingInfoStatus NULL pData  in listener");
                }
            }

            // I think the following is incorrect.  I think this is not added as a global mssage observer, only
            // as an obsever to individual transactions when the INFO is sent.  So this is not needed.
            pInfoData->pInst->pSipUserAgent->removeMessageObserver(*(this->getMessageQueue()), (void*)hInfo);
            
            // release lock
            sipxInfoReleaseLock(pInfoData, SIPX_LOCK_READ, stackLogger);
        }

        // If an INFO was resent with auth credentials, don't remove the INFO object.  Wait
        // for the response to the resend.
        if(messageType != SipMessageEvent::AUTHENTICATION_RETRY)
        {
            // info message has been handled, so go ahead and delete the object    
            sipxInfoObjectFree(hInfo);
        }
     }
     return true;
}