OsStatus ConferenceEngineMediaInterface::getPrimaryCodec(int connectionId,
                                                         UtlString& codec,
                                                         UtlString& videoCodec,
                                                         int* payloadType,
                                                         int* videoPayloadType)
{
    mLock.acquire();
    OsStatus rc = OS_FAILED;

    ConferenceEngineMediaConnection* pMediaConnection = getMediaConnection(connectionId);
    if (pMediaConnection && pMediaConnection->mpPrimaryCodec)
    {
        if (getCodecNameByType(pMediaConnection->mpPrimaryCodec->getCodecType(), codec))
        {
            if (NULL != payloadType)
            {
                *payloadType = pMediaConnection->mRtpPayloadType;
            }
            rc = OS_SUCCESS;
        }
    }

    mLock.release();
    return rc;
}
UtlBoolean ConferenceEngineMediaInterface::getConferenceEngineCodec(const SdpCodec& pCodec, GIPS_CodecInst& codecInfo)
{
    mLock.acquire();
    UtlString codecName;
    UtlBoolean matchFound = FALSE;
    int iCodecs;

    if (getCodecNameByType(pCodec.getCodecType(), codecName))
    {
        if ((iCodecs=mpConferenceEngine->GIPSConf_GetNofCodecs()) != -1)
        {
            for (int i=0; i<iCodecs; ++i)
            {
                if (mpConferenceEngine->GIPSConf_GetCodec(i, &codecInfo) == 0)
                {
                    if (strcmp(codecName.data(), codecInfo.plname) == 0)
                    {
                        matchFound = TRUE;
                        break;
                    }
                }
            }
        }
    }

    mLock.release();
    return matchFound;
}
Пример #3
0
OsStatus sipXmediaFactoryImpl::buildCodecFactory(SdpCodecFactory *pFactory, 
                                                 const UtlString& sPreferences,
                                                 const UtlString& sVideoPreferences,
                                                 int* iRejected)
{
    OsStatus rc = OS_FAILED;

    int numCodecs = 0;
    UtlString codecName;
    UtlString codecList;

    *iRejected = 0;

#ifdef HAVE_GIPS /* [ */
    numCodecs = 6;
    SdpCodec::SdpCodecTypes codecs[6];
            
    codecs[0] = SdpCodec::SDP_CODEC_GIPS_PCMU;
    codecs[1] = SdpCodec::SDP_CODEC_GIPS_PCMA;
    codecs[2] = SdpCodec::SDP_CODEC_GIPS_IPCMU;
    codecs[3] = SdpCodec::SDP_CODEC_GIPS_IPCMA;
    codecs[4] = SdpCodec::SDP_CODEC_GIPS_IPCMWB;
    codecs[5] = SdpCodec::SDP_CODEC_TONES;
            
#else /* HAVE_GIPS ] [ */
    numCodecs = 3;
    SdpCodec::SdpCodecTypes codecs[3];
            
    codecs[0] = SdpCodec::SDP_CODEC_GIPS_PCMU;
    codecs[1] = SdpCodec::SDP_CODEC_GIPS_PCMA;
    codecs[2] = SdpCodec::SDP_CODEC_TONES;
#endif /* HAVE_GIPS ] */

    if (pFactory)
    {
        pFactory->clearCodecs();

        // add preferred codecs first
        if (sPreferences.length() > 0)
        {
            UtlString references = sPreferences;
            *iRejected = pFactory->buildSdpCodecFactory(references);
            OsSysLog::add(FAC_MP, PRI_DEBUG, 
                          "sipXmediaFactoryImpl::buildCodecFactory: sReferences = %s with NumReject %d",
                           references.data(), *iRejected);
                           
            // Now pick preferences out of all available codecs
            SdpCodec** codecsArray = NULL;
            pFactory->getCodecs(numCodecs, codecsArray);
            
            UtlString preferences;
            for (int i = 0; i < numCodecs; i++)
            {
                if (getCodecNameByType(codecsArray[i]->getCodecType(), codecName) == OS_SUCCESS)
                {
                    preferences = preferences + " " + codecName;
                }
            }
            
            pFactory->clearCodecs();
            *iRejected = pFactory->buildSdpCodecFactory(preferences);
            OsSysLog::add(FAC_MP, PRI_DEBUG, 
                          "sipXmediaFactoryImpl::buildCodecFactory: supported codecs = %s with NumReject %d",
                          preferences.data(), *iRejected);
                          
            // Free up the codecs and the array
            for (int i = 0; i < numCodecs; i++)
            {
                delete codecsArray[i];
                codecsArray[i] = NULL;
            }
            delete[] codecsArray;
            codecsArray = NULL;
                          
            rc = OS_SUCCESS;
        }
        else
        {
            // Build up the supported codecs
            *iRejected = pFactory->buildSdpCodecFactory(numCodecs, codecs);
            rc = OS_SUCCESS;
        }
    }            

    return rc;
}