示例#1
0
文件: testapp.cpp 项目: kennych/ikran
//Returns true if given capability is available on entry to this function, or became
//available within the specified timeframe
bool awaitCallCapability (CC_CallPtr call, CC_CallCapabilityEnum::CC_CallCapability capToWaitFor, int timeoutMilliSeconds)
{
    int nTimeStart = GetTimeNow();
    int remainingTimeout = timeoutMilliSeconds;

    do
    {
        CC_CallInfoPtr info = call->getCallInfo();

        if (info != NULL)
        {
            if (info->hasCapability(capToWaitFor))
            {
                return true;
            }
        }
        else
        {
        	CSFLogDebugS(logTag, "CC_CallPtr->getCallInfo() failed");
            return false;
        }

        int nTimeElapsed = GetTimeElapsedSince( nTimeStart );
        remainingTimeout -= nTimeElapsed;
    } while (_callCapsMayHaveChanged.TimedWait(base::TimeDelta::FromMilliseconds(remainingTimeout)));

    return false;
}
示例#2
0
文件: testapp.cpp 项目: kennych/ikran
static void handleUnmuteVideoForFirstConnectedCall (CallControlManagerPtr ccmPtr)
{
    //If there is more than 1 call with a mix of audio/video calls
    //the we may need to look at the cc_sdp_direction_t to figure out
    //which CONNECTED call is actually a video call and is sending video
    CC_CallPtr call = getFirstCallInGivenState(ccmPtr, CONNECTED);

    if (call != NULL)
    {
    	CSFLogDebugS(logTag, "Unmuting (video) 1st connected call...");
    	if (!call->unmuteVideo())
    	{
    		CSFLogDebugS(logTag, "Attempt to unmute (video) failed.");
    	}
        CC_CallInfoPtr info = call->getCallInfo();
        if (info->isVideoMuted())
        {
        	CSFLogDebugS(logTag, "UNMUTE FAILED TO BE REFLECTED IN CALL INFO.");
        }
    }
    else
    {
    	CSFLogDebugS(logTag, "No calls exist that can be unmuted (video).");
    }
}
示例#3
0
文件: testapp.cpp 项目: kennych/ikran
void MyPhoneListener::onCallEvent   ( ccapi_call_event_e callEvent, CC_CallPtr call, CC_CallInfoPtr info )
{
	CSFLogDebugS(logTag, "MyPhoneListener::onCallEvent");

	_callCapsMayHaveChanged.Signal();

    if (callEvent == CCAPI_CALL_EV_STATE)
    {
        if (info->getCallState() == RINGIN)
        {
            addUserOperationAndSignal(UserOperationRequestDataPtr(new UserOperationRequestData(eIncomingCallReceived, NULL)));
        }
        else if (info->getCallState() == ONHOOK)
        {
        	CSFLogDebugS(logTag, "MyPhoneListener::onCallEvent -- ONHOOK");
        }
    }

	else if(callEvent == CCAPI_CALL_EV_VIDEO_AVAIL)
	{
        addUserOperationAndSignal(UserOperationRequestDataPtr(new UserOperationRequestData(eVideoAvailableChange, NULL)));
	}
	else if(callEvent == CCAPI_CALL_EV_VIDEO_OFFERED)
	{
        addUserOperationAndSignal(UserOperationRequestDataPtr(new UserOperationRequestData(eVideoOffered, NULL)));
	}
}
示例#4
0
void printCallSummary(CC_DevicePtr devicePtr)
{
    if (devicePtr == NULL)
    {
        return;
    }

    CC_DeviceInfoPtr deviceInfoPtr = devicePtr->getDeviceInfo();

    if (deviceInfoPtr == NULL)
    {
        return;
    }

    vector<CC_CallPtr> calls = deviceInfoPtr->getCalls();

    CSFLogDebugS(logTag, " List of all calls ");
    for (vector<CC_CallPtr>::iterator it = calls.begin(); it != calls.end(); it++)
    {
        CC_CallPtr call = *it;

        if (call==NULL)
        {
            continue;
        }

        CC_CallInfoPtr callInfoPtr = call->getCallInfo();

        if (callInfoPtr==NULL)
        {
            continue;
		}
        bool audioMute = callInfoPtr->isAudioMuted();
        bool videoMute = callInfoPtr->isVideoMuted();
        
        PRINT_OFFSET_1;
        PRINT_EVENT_INFO_NICELY_USING_GETNAME("CallState", callInfoPtr, getCallState, call_state_getname);
        PRINT_OFFSET_1;
        PRINT_EVENT_INFO_NICELY_USING_GETNAME("CallType", callInfoPtr, getCallType, call_type_getname);
        PRINT_OFFSET_1;
        PRINT_EVENT_INFO_NICELY_USING_GETNAME("VideoDirection", callInfoPtr, getVideoDirection, sdp_direction_getname);
        PRINT_OFFSET_1;
        CSFLogDebugS(logTag, "(AudioMute ");
        CSFLogDebugS(logTag, "----------");
        CSFLogDebug(logTag, " %s )", (audioMute) ? "true" : "false");
        PRINT_OFFSET_1;
        CSFLogDebugS(logTag, "(VideoMute ");
        CSFLogDebugS(logTag, "----------");
        CSFLogDebug(logTag, " %s )", (videoMute) ? "true" : "false");
        PRINT_OFFSET_1;
        printCallPartiesInfo(callInfoPtr);
        PRINT_OFFSET_1;
        CSFLogDebugS(logTag, "(CallCaps ");
        CSFLogDebugS(logTag, "----------");
        printCallCapabilities(callInfoPtr, WRAPPED_LINE_ALIGNMENT_OFFSET_2);

    }//end for (calls)
    CSFLogDebugS(logTag, "End of List");
}
示例#5
0
文件: testapp.cpp 项目: kennych/ikran
/**
  This function gets a snapshot of all calls and examines each one in turn. If it find a call whose
  state is one of the specified states then it returns that call.

  @param [in] ccmPtr -

  @param [in] callStates - A vector of the call states being checked for. All existing calls are examined and the
                          first (in no particular order) call that is in one of those states is returned,
                          if there is one.

  @return Returns a NULL_PTR if there are no calls in the given states. If a call is found in the given states
          then that CC_CallPtr is returned.
*/
static CC_CallPtr getFirstCallInGivenStates (CallControlManagerPtr ccmPtr, const vector<cc_call_state_t>& callStates)
{
	CSFLogDebugS(logTag, "getFirstCallInGivenStates()");

	if (ccmPtr == NULL)
    {
        return NULL_PTR(CC_Call);
    }

    CC_DevicePtr devicePtr = ccmPtr->getActiveDevice();

    if (devicePtr == NULL)
    {
    	CSFLogDebugS(logTag, "devicePtr was NULL, returning");
        return NULL_PTR(CC_Call);
    }

    CC_DeviceInfoPtr deviceInfoPtr = devicePtr->getDeviceInfo();

    if (deviceInfoPtr == NULL)
    {
    	CSFLogDebugS(logTag, "deviceInfoPtr was NULL, returning");
        return NULL_PTR(CC_Call);
    }

    vector<CC_CallPtr> calls = deviceInfoPtr->getCalls();

    for (vector<CC_CallPtr>::iterator it = calls.begin(); it != calls.end(); it++)
    {
        CC_CallPtr call = *it;

        if (call == NULL)
        {
            continue;
        }

        CC_CallInfoPtr callInfoPtr = call->getCallInfo();

        if (callInfoPtr == NULL)
        {
            continue;
        }

        CSFLogDebugS(logTag, "about to check call for states");

        for (vector<cc_call_state_t>::const_iterator it = callStates.begin(); it != callStates.end(); it++)
        {
          	cc_call_state_t callState = *it;
            if (callInfoPtr->getCallState() == callState)
            {
                return call;
            }
        }
    }//end for (calls)

    return NULL_PTR(CC_Call);
}
示例#6
0
static void printCallPartiesInfo(const CC_CallInfoPtr & info)
{
    bool isConference = info->getIsConference();;

    if (isConference)
    {
        CSFLogDebugS(logTag, "(IsConference ");
        CSFLogDebugS(logTag, "----------");
        CSFLogDebug(logTag, " %s )", (isConference) ? "true" : "false");
    }
    else
    {
        PRINT_EVENT_INFO_NICELY_USING_GETNAME("CallType", info, getCallType, call_type_getname);
        PRINT_OFFSET_1;
        PRINT_EVENT_INFO_NICELY_FOR_STRING   ("CalledPartyName", info, getCalledPartyName);
        PRINT_OFFSET_1;
        PRINT_EVENT_INFO_NICELY_FOR_STRING   ("CalledPartyNumber", info, getCalledPartyNumber);
        PRINT_OFFSET_1;
        PRINT_EVENT_INFO_NICELY_FOR_STRING   ("CallingPartyName", info, getCallingPartyName);
        PRINT_OFFSET_1;
        PRINT_EVENT_INFO_NICELY_FOR_STRING   ("CallingPartyNumber", info, getCallingPartyNumber);
        PRINT_OFFSET_1;
        PRINT_EVENT_INFO_NICELY_FOR_STRING   ("AlternateNumber", info, getAlternateNumber);
    }
}
示例#7
0
文件: testapp.cpp 项目: kennych/ikran
/**
  This function gets a snapshot of all calls and examines each one in turn. If it find a call that is in
  the specified state then it returns this call.

  @param [in] ccmPtr - 

  @param [in] callState - This is the call state being checked for. All existing calls are examined and the
                          first (in no particular order) call that is in this state is returned, if there is one.
                    
  @return Returns a NULL_PTR if there are no calls in the given state. If a call is found in the given state
          then that CC_CallPtr is returned.
*/
static CC_CallPtr getFirstCallInGivenState (CallControlManagerPtr ccmPtr, cc_call_state_t callState)
{
    if (ccmPtr == NULL)
    {
        return NULL_PTR(CC_Call);
    }

    CC_DevicePtr devicePtr = ccmPtr->getActiveDevice();

    if (devicePtr == NULL)
    {
        return NULL_PTR(CC_Call);
    }

    CC_DeviceInfoPtr deviceInfoPtr = devicePtr->getDeviceInfo();

    if (deviceInfoPtr == NULL)
    {
        return NULL_PTR(CC_Call);
    }

    vector<CC_CallPtr> calls = deviceInfoPtr->getCalls();

    for (vector<CC_CallPtr>::iterator it = calls.begin(); it != calls.end(); it++)
    {
        CC_CallPtr call = *it;

        if (call == NULL)
        {
            continue;
        }

        CC_CallInfoPtr callInfoPtr = call->getCallInfo();

        if (callInfoPtr == NULL)
        {
            continue;
        }

        if (callInfoPtr->getCallState() == callState)
        {
            return call;
        }
    }//end for (calls)

    return NULL_PTR(CC_Call);
}
示例#8
0
文件: testapp.cpp 项目: kennych/ikran
/**
  This function gets a snapshot of all calls and examines each one in turn. If it find a call that has the
  specified capability then it returns this call.

  @param [in] ccmPtr - 

  @param [in] cap - This is the capability being examined. All existing calls are examined and the first (in
                    no particular order) call that has this capability is returned, if there is one.
                    
  @return Returns a NULL_PTR if there are no calls with the given capability. If a call is found with the given
          capability then that CC_CallPtr is returned.
*/
static CC_CallPtr getFirstCallWithCapability (CallControlManagerPtr ccmPtr, CC_CallCapabilityEnum::CC_CallCapability cap)
{
    if (ccmPtr == NULL)
    {
        return NULL_PTR(CC_Call);
    }

    CC_DevicePtr devicePtr = ccmPtr->getActiveDevice();

    if (devicePtr == NULL)
    {
        return NULL_PTR(CC_Call);
    }

    CC_DeviceInfoPtr deviceInfoPtr = devicePtr->getDeviceInfo();

    if (deviceInfoPtr == NULL)
    {
        return NULL_PTR(CC_Call);
    }

    vector<CC_CallPtr> calls = deviceInfoPtr->getCalls();

    for (vector<CC_CallPtr>::iterator it = calls.begin(); it != calls.end(); it++)
    {
        CC_CallPtr call = *it;

        if (call == NULL)
        {
            continue;
        }

        CC_CallInfoPtr callInfoPtr = call->getCallInfo();

        if (callInfoPtr == NULL)
        {
            continue;
        }

        if (callInfoPtr->hasCapability(cap))
        {
            return call;
        }
    }//end for (calls)

    return NULL_PTR(CC_Call);
}
示例#9
0
文件: testapp.cpp 项目: kennych/ikran
static void handleUnmuteAudioForFirstConnectedCall (CallControlManagerPtr ccmPtr)
{
    CC_CallPtr call = getFirstCallInGivenState(ccmPtr, CONNECTED);

    if (call != NULL)
    {
    	CSFLogDebugS(logTag, "Unmuting (audio) 1st connected call...");
    	if (!call->unmuteAudio())
    	{
    		CSFLogDebugS(logTag, "Attempt to unmute (audio) failed.");
    	}
        CC_CallInfoPtr info = call->getCallInfo();
        if (info->isAudioMuted())
        {
            // note that when CTI adds mute it might fail here, because the setAudioMute will not be a synchronous call
            // So we might change this check for CTI when that time comes.
        	CSFLogDebugS(logTag, "MUTE FAILED TO BE REFLECTED IN CALL INFO");
        }
    }
    else
    {
    	CSFLogDebugS(logTag, "No calls exist that can be unmuted (audio).");
    }
}
示例#10
0
void CC_CapsPrinter::onCallEvent (ccapi_call_event_e callEvent, CC_CallPtr call, CC_CallInfoPtr info, char* sdp )
{
	base::AutoLock lock(eventPrinterMutex);
    printHeaderBlockIfNotAlreadyPrinted();

    CSFLogDebugS(logTag, "C:");
    printCurrentThreadID();

    std::string eventNameStr = truncateLeft(call_event_getname(callEvent), EVENT_NAME_FIELD_WIDTH);

    CSFLogDebug(logTag, "%*s %s ", EVENT_NAME_FIELD_WIDTH, eventNameStr.c_str(), call->toString().c_str());

    switch (callEvent)
    {
    case CCAPI_CALL_EV_CALLINFO:
        printCallPartiesInfo(info);
        break;
    case CCAPI_CALL_EV_STATE:
        /*
         Whenever we get a CCAPI_CALL_EV_STATE the expectation is that we call getCapabilitySet() to
         get the current list of caps, or we call hasCapability(ccapi_call_capability_e) to determine
         if a given capability is available or not.
         */
        PRINT_EVENT_INFO_NICELY_USING_GETNAME("CallState", info, getCallState, call_state_getname);
        PRINT_OFFSET_1;
        if (info->getCallState() == RINGIN)
        {
            printCallPartiesInfo(info);
        }
        PRINT_OFFSET_1;
        PRINT_EVENT_INFO_NICELY_USING_GETNAME("CallType", info, getCallType, call_type_getname);
        PRINT_OFFSET_1;
		PRINT_EVENT_INFO_NICELY_USING_GETNAME("VideoDirection", info, getVideoDirection, sdp_direction_getname);
	    PRINT_OFFSET_1;
        CSFLogDebugS(logTag, "(CallCaps ");
        CSFLogDebugS(logTag, "----------");

        printCallCapabilities(info, WRAPPED_LINE_ALIGNMENT_OFFSET_2);
        break;
    case CCAPI_CALL_EV_STATUS:
        PRINT_EVENT_INFO_NICELY_FOR_STRING   ("CallStatus", info, getStatus);
        break;
    case CCAPI_CALL_EV_ATTR:
        PRINT_EVENT_INFO_NICELY_USING_GETNAME("CallAttr", info, getCallAttr, call_attr_getname);
        break;
    case CCAPI_CALL_EV_SECURITY:
        PRINT_EVENT_INFO_NICELY_USING_GETNAME("CallSecurity", info, getSecurity, call_security_getname);
        break;
    case CCAPI_CALL_EV_CAPABILITY:
        //
        printCallCapabilities(info, WRAPPED_LINE_ALIGNMENT_OFFSET_1);
        break;
    case CCAPI_CALL_EV_VIDEO_AVAIL:
		PRINT_EVENT_INFO_NICELY_USING_GETNAME("VideoDirection", info, getVideoDirection, sdp_direction_getname);
	    PRINT_OFFSET_1;
	    break;
    case CCAPI_CALL_EV_VIDEO_OFFERED:
		PRINT_EVENT_INFO_NICELY_USING_GETNAME("VideoDirection", info, getVideoDirection, sdp_direction_getname);
	    PRINT_OFFSET_1;
	    break;
    default:
    	break;
    }//end switch
}
示例#11
0
static void printCallCapabilities (const CC_CallInfoPtr& info, int wrapOffsetValue)
{
	printCallCaps(info->getCapabilitySet(), wrapOffsetValue);
}
示例#12
0
文件: testapp.cpp 项目: kennych/ikran
// Volume change: If a RINGIN call exists, adjust ringer volume.
//                If CONNECTED exists, adjust current call volume.
//                Otherwise, adjust default call volume.
static void handleAdjustVolume (CallControlManagerPtr ccmPtr, int adjust)
{
    CC_CallPtr call = getFirstCallInGivenState(ccmPtr, RINGIN);
    if (call != NULL)
    {
    	CSFLogDebug(logTag, "Changing ringer volume %d...", adjust);
        int currentVolume = ccmPtr->getAudioControl()->getRingerVolume();
    	if (currentVolume == -1)
    	{
    		CSFLogDebugS(logTag, "Attempt to determine ringer volume failed.");
    	}
    	else
    	{
    		int newVolume = currentVolume + adjust;
    		newVolume = newVolume > 100 ? 100 : newVolume < 0 ? 0 : newVolume;
    		if(!ccmPtr->getAudioControl()->setRingerVolume(newVolume))
    		{
    			CSFLogDebugS(logTag, "Attempt to adjust ringer volume failed.");
    		}
    	}
    	return;
    }

    call = getFirstCallInGivenState(ccmPtr, CONNECTED);
    if (call != NULL)
    {
    	CSFLogDebug(logTag, "Changing call volume %d...", adjust);
        CC_CallInfoPtr info = call->getCallInfo();
        int currentVolume = info->getVolume();
    	if (currentVolume == -1)
    	{
    		CSFLogDebugS(logTag, "Attempt to determine call volume failed.");
    	}
    	else
    	{
    		int newVolume = currentVolume + adjust;
    		newVolume = newVolume > 100 ? 100 : newVolume < 0 ? 0 : newVolume;
    		if(!call->setVolume(newVolume))
    		{
    			CSFLogDebugS(logTag, "Attempt to adjust call volume failed.");
    		}
    	}
    	return;
    }

    CSFLogDebug(logTag, "Changing default call volume %d...", adjust);
	int currentVolume = ccmPtr->getAudioControl()->getDefaultVolume();
	if (currentVolume == -1)
	{
		CSFLogDebugS(logTag, "Attempt to determine default call volume failed.");
	}
	else
	{
		int newVolume = currentVolume + adjust;
		newVolume = newVolume > 100 ? 100 : newVolume < 0 ? 0 : newVolume;
		if(!ccmPtr->getAudioControl()->setDefaultVolume(newVolume))
		{
			CSFLogDebugS(logTag, "Attempt to adjust default call volume failed.");
		}
	}
}