OsStatus ConferenceEngineMediaInterface::deleteConnection(int connectionId)
{
    mLock.acquire();
    OsStatus rc = OS_NOT_FOUND ;

    ConferenceEngineMediaConnection* pMediaConnection = getMediaConnection(connectionId) ;
    if (pMediaConnection)
    {
        stopRtpSend(connectionId) ;
        stopRtpReceive(connectionId) ;

        OsProtectEventMgr* eventMgr = OsProtectEventMgr::getEventMgr();
        OsProtectedEvent* rtpSockeRemoveEvent = eventMgr->alloc();
        OsProtectedEvent* rtcpSockeRemoveEvent = eventMgr->alloc();
        OsTime maxEventTime(20, 0);

        ConferenceEngineNetTask* pNetTask = NULL;

        pNetTask = ConferenceEngineNetTask::getConferenceEngineNetTask();

        if (pNetTask)
        {
            pNetTask->removeInputSource(pMediaConnection->mpRtpSocket, rtpSockeRemoveEvent) ;
            pNetTask->removeInputSource(pMediaConnection->mpRtcpSocket, rtcpSockeRemoveEvent) ;
            // Wait until the call sets the number of connections
            rtpSockeRemoveEvent->wait(0, maxEventTime);
            rtcpSockeRemoveEvent->wait(0, maxEventTime);
        }

        mpFactoryImpl->releaseRtpPort(pMediaConnection->mRtcpReceivePort) ;

        UtlInt container(connectionId);
        mMediaConnections.destroy(&container);

        int iRC = mpConferenceEngine->GIPSConf_DeleteChannel(connectionId) ;
        assert(iRC == 0);

        eventMgr->release(rtpSockeRemoveEvent);
        eventMgr->release(rtcpSockeRemoveEvent);
        delete pMediaConnection;

        rc = OS_SUCCESS;
    }

    mLock.release();
    return rc ;
}
Beispiel #2
0
PtStatus PtPhoneLamp::setMode(int mode)
{
        if (mpAssociatedButton &&
                (mode == MODE_OFF || mode == MODE_STEADY || mode == MODE_FLASH ||
                mode ==  MODE_FLUTTER || mode == MODE_BROKENFLUTTER || mode == MODE_WINK))
        {
                char buf[DEF_TAO_MAX_BUFFER_SIZE];

                if (mpClient && PT_SUCCESS == mpAssociatedButton->getInfo(buf, (DEF_TAO_MAX_BUFFER_SIZE - 1)))
                {
                        UtlString arg;
                        arg.append(buf);

                        sprintf(buf, "%d", mode);
                        arg += TAOMESSAGE_DELIMITER + buf;

                        OsProtectedEvent *pe = mpEventMgr->alloc();
                        TaoMessage      msg(TaoMessage::REQUEST_PHONECOMPONENT,
                                                                                        TaoMessage::LAMP_SET_MODE,
                                                                                        0,
                                                                                        (TaoObjHandle)0,
                                                                                        (TaoObjHandle)pe,
                                                                                        2,
                                                                                        arg);
                        mpClient->sendRequest(msg);

                        intptr_t rc;
                        if (OS_SUCCESS != pe->wait(msg.getCmd(), mTimeOut))
                        {
                                mpClient->resetConnectionSocket(msg.getMsgID());
                // If the event has already been signalled, clean up
                if(OS_ALREADY_SIGNALED == pe->signal(0))
                {
                    mpEventMgr->release(pe);
                }
                                return PT_BUSY;
                        }

                        pe->getEventData(rc);
#ifdef PTAPI_TEST
        intptr_t cmd;
        pe->getIntData2(cmd);
        assert(cmd == TaoMessage::LAMP_SET_MODE);
#endif
                        mpEventMgr->release(pe);

                        mMode = mode;
                        return PT_SUCCESS;
                }
                else
                        return PT_RESOURCE_UNAVAILABLE;
        }
        else
                return PT_INVALID_ARGUMENT;
}
Beispiel #3
0
PtStatus PtPhoneSpeaker::setVolume(int volume)
{
        if (volume < 0)
                volume = 0;

        if (volume > 10)
                volume = 10;

        char buf[MAXIMUM_INTEGER_STRING_LENGTH];
        sprintf(buf, "%d", volume);

        UtlString arg;
        arg.append(buf);

        sprintf(buf, "%d", mGroupType);
        arg += TAOMESSAGE_DELIMITER + buf;

        OsProtectedEvent *pe = mpEventMgr->alloc();
        TaoMessage      msg(TaoMessage::REQUEST_PHONECOMPONENT,
                                                                        TaoMessage::SPEAKER_SET_VOLUME,
                                                                        0,
                                                                        (TaoObjHandle)0,
                                                                        (TaoObjHandle)pe,
                                                                        2,
                                                                        arg);
        mpClient->sendRequest(msg);

        intptr_t rc;
        if (OS_SUCCESS != pe->wait(msg.getCmd(), mTimeOut))
        {
                mpClient->resetConnectionSocket(msg.getMsgID());
        // If the event has already been signalled, clean up
        if(OS_ALREADY_SIGNALED == pe->signal(0))
        {
            mpEventMgr->release(pe);
        }
                return PT_BUSY;
        }

        pe->getEventData(rc);
#ifdef PTAPI_TEST
        intptr_t cmd;
        pe->getIntData2(cmd);
        assert(cmd == TaoMessage::SPEAKER_SET_VOLUME);
#endif
        mpEventMgr->release(pe);

        return PT_SUCCESS;
}
PtStatus PtPhoneMicrophone::setGain(int gain)
{
        if (gain < 0)
                gain = 0;

        if (gain > 10)
                gain = 10;

        char buf[MAXIMUM_INTEGER_STRING_LENGTH];
        sprintf(buf, "%d", mGroupType);

        UtlString arg(buf);

        sprintf(buf, "%d", gain);
        arg += TAOMESSAGE_DELIMITER + buf;

        OsProtectedEvent *pe = mpEventMgr->alloc();
        TaoMessage      msg(TaoMessage::REQUEST_PHONECOMPONENT,
                                                                        TaoMessage::MIC_SET_GAIN,
                                                                        0,
                                                                        (TaoObjHandle)0,
                                                                        (TaoObjHandle)pe,
                                                                        2,
                                                                        arg);
        mpClient->sendRequest(msg);

        int rc;
        if (OS_SUCCESS != pe->wait(msg.getCmd(), mTimeOut))
        {
                mpClient->resetConnectionSocket(msg.getMsgID());
        // If the event has already been signalled, clean up
        if(OS_ALREADY_SIGNALED == pe->signal(0))
        {
            mpEventMgr->release(pe);
        }
                return PT_BUSY;
        }

        pe->getEventData((int &)rc);
#ifdef PTAPI_TEST
        int cmd;
        pe->getIntData2(cmd);
        assert(cmd == TaoMessage::MIC_SET_GAIN);
#endif
        mpEventMgr->release(pe);

        return PT_SUCCESS;
}
Beispiel #5
0
PtStatus PtPhoneSpeaker::getNominalVolume(int& rVolume)
{
        char buf[MAXIMUM_INTEGER_STRING_LENGTH];
        sprintf(buf, "%d", mGroupType);

        OsProtectedEvent *pe = mpEventMgr->alloc();
        TaoMessage      msg(TaoMessage::REQUEST_PHONECOMPONENT,
                                                                        TaoMessage::SPEAKER_GET_NOMINAL_VOLUME,
                                                                        0,
                                                                        (TaoObjHandle)0,
                                                                        (TaoObjHandle)pe,
                                                                        1,
                                                                        buf);
        mpClient->sendRequest(msg);

        intptr_t rc;
        UtlString arg;

        if (OS_SUCCESS != pe->wait(msg.getCmd(), mTimeOut))
        {
                mpClient->resetConnectionSocket(msg.getMsgID());
        // If the event has already been signalled, clean up
        if(OS_ALREADY_SIGNALED == pe->signal(0))
        {
            mpEventMgr->release(pe);
        }
                return PT_BUSY;
        }

        pe->getEventData(rc);
        pe->getStringData((UtlString &)arg);
#ifdef PTAPI_TEST
        intptr_t cmd;
        pe->getIntData2(cmd);
        assert(cmd == TaoMessage::SPEAKER_GET_NOMINAL_VOLUME);
#endif
        mpEventMgr->release(pe);

        rVolume = atoi(arg);

        return PT_SUCCESS;
}
PtStatus PtPhoneMicrophone::getGain(int& rGain)
{
        char buf[16];
        memset(buf, 0, 16);

        sprintf(buf, "%d", mGroupType);

        OsProtectedEvent *pe = mpEventMgr->alloc();
        TaoMessage      msg(TaoMessage::REQUEST_PHONECOMPONENT,
                                                                        TaoMessage::MIC_GET_GAIN,
                                                                        0,
                                                                        (TaoObjHandle)0,
                                                                        (TaoObjHandle)pe,
                                                                        1,
                                                                        buf);
        mpClient->sendRequest(msg);

        UtlString arg;
        if (OS_SUCCESS != pe->wait(msg.getCmd(), mTimeOut))
        {
                mpClient->resetConnectionSocket(msg.getMsgID());
        // If the event has already been signalled, clean up
        if(OS_ALREADY_SIGNALED == pe->signal(0))
        {
            mpEventMgr->release(pe);
        }
                return PT_BUSY;
        }

        pe->getStringData((UtlString &)arg);
#ifdef PTAPI_TEST
        int cmd;
        pe->getIntData2(cmd);
        assert(cmd == TaoMessage::MIC_GET_GAIN);
#endif
        mpEventMgr->release(pe);

        TaoString value(arg, TAOMESSAGE_DELIMITER);
        rGain = atoi(value[1]);

        return PT_SUCCESS;
}
Beispiel #7
0
PtStatus PtPhoneButton::buttonPress(void)
{
        if (mpInfo[0])
        {
                UtlString arg(mpInfo);

                OsProtectedEvent *pe = mpEventMgr->alloc();
                TaoMessage      msg(TaoMessage::REQUEST_PHONECOMPONENT,
                                                                                TaoMessage::BUTTON_PRESS,
                                                                                0,
                                                                                (TaoObjHandle)0,
                                                                                (TaoObjHandle)pe,
                                                                                1,
                                                                                arg);
                mpClient->sendRequest(msg);

                int rc;
                if (OS_SUCCESS != pe->wait(msg.getCmd(), mTimeOut))
                {
                        mpClient->resetConnectionSocket(msg.getMsgID());
            // If the event has already been signalled, clean up
            if(OS_ALREADY_SIGNALED == pe->signal(0))
            {
                mpEventMgr->release(pe);
            }
                        return PT_BUSY;
                }

                pe->getEventData((int &)rc);
#ifdef PTAPI_TEST
        int cmd;
        pe->getIntData2(cmd);
        assert(cmd == TaoMessage::BUTTON_PRESS);
#endif
                mpEventMgr->release(pe);
                return PT_SUCCESS;
        }
        return PT_RESOURCE_UNAVAILABLE;
}