OSCL_EXPORT_REF PVMFStatus PvmfPortBaseImpl::PeerDisconnect()
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "0x%x PvmfPortBaseImpl::PeerDisconnect", this));

    if (!iConnectedPort)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "0x%x PvmfPortBaseImpl::PeerDisconnect: Error - Port not connected", this));
        return PVMFFailure;
    }

    //reset busy flags - this would prevent any queue / port ready
    //events from being generated as we clear the message queues
    iIncomingQueue.iBusy = false;
    iOutgoingQueue.iBusy = false;

    ClearMsgQueues();

    iConnectedPort = NULL;

#if PVMF_PORT_BASE_IMPL_STATS
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                    (0, "0x%x PvmfPortBaseImpl::PeerDisconnect: Stats: OutMsgQd=%d, OutMsgSent=%d, OutBusy=%d, ConnectedPortBusy=%d",
                     this, iStats.iOutgoingMsgQueued, iStats.iOutgoingMsgSent, iStats.iOutgoingQueueBusy,
                     iStats.iConnectedPortBusy));
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                    (0, "0x%x PvmfPortBaseImpl::PeerDisconnect: Stats: InMsgRecv=%d, InMsgConsumed=%d, InBusy=%d",
                     this, iStats.iIncomingMsgRecv, iStats.iIncomingMsgConsumed, iStats.iIncomingQueueBusy));
#endif

    PortActivity(PVMF_PORT_ACTIVITY_DISCONNECT);
    return PVMFSuccess;
}
OMX_BOOL OmxDecTestBase::VerifyAllBuffersReturned()
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestBase::VerifyAllBuffersReturned() - IN"));

    OMX_U32 ii;
    OMX_BOOL AllBuffersReturned = OMX_TRUE;
    //check here to verify whether all the ip/op buffers are returned back by the component or not

    for (ii = 0; ii < iInBufferCount; ii++)
    {
        if (OMX_FALSE == ipInputAvail[ii])
        {
            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG,
                            (0, "OmxDecTestBase::VerifyAllBuffersReturned() - Not all the input buffers returned by component yet, rescheduling"));
            AllBuffersReturned = OMX_FALSE;
            break;
        }
    }


    for (ii = 0; ii < iOutBufferCount; ii++)
    {
        if (OMX_FALSE == ipOutReleased[ii])
        {
            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG,
                            (0, "OmxDecTestBase::VerifyAllBuffersReturned() - Not all the input buffers returned by component yet, rescheduling"));
            AllBuffersReturned = OMX_FALSE;
            break;
        }
    }

    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestBase::VerifyAllBuffersReturned() - OUT"));

    return AllBuffersReturned;
}
uint32 TSC_324m::MiscIndicationRecv(PS_ControlMsgHeader  pReceiveInf)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "TSC_324m::MiscIndicationRecv"));
    PS_MiscellaneousIndication indication = (PS_MiscellaneousIndication)pReceiveInf->pParameter;
    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "TSC_324m::MiscIndicationRecv lcn(%d),index(%d)",
                     indication->logicalChannelNumber, indication->miType.index));
    switch (indication->miType.index)
    {
        case 9:
            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                            (0, "TSC_324m::MiscIndicationRecv videoSpatialTemporalTradeoff(%d)",
                             indication->miType.videoTemporalSpatialTradeOff));
            if (iTSC_324mObserver)
            {
                iTSC_324mObserver->VideoSpatialTemporalTradeoffIndicationReceived(indication->logicalChannelNumber,
                        indication->miType.videoTemporalSpatialTradeOff);
            }
            break;
        default:
            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                            (0, "TSC_324m::MiscIndicationRecv Indication not handled"));
            break;
    }
    return iTerminalStatus;
}
OSCL_EXPORT_REF PVMFStatus PvmfPortBaseImpl::PeerConnect(PVMFPortInterface* aPort)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "0x%x PvmfPortBaseImpl::PeerConnect: aPort=0x%x", this, aPort));

    if (!aPort)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "0x%x PvmfPortBaseImpl::PeerConnect: Error - Connecting to invalid port", this));
        return PVMFErrArgument;
    }

    if (iConnectedPort)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "0x%x PvmfPortBaseImpl::PeerConnect: Error - Already connected", this));
        return PVMFFailure;
    }

    iConnectedPort = aPort;

#if PVMF_PORT_BASE_IMPL_STATS
    // Reset statistics
    oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
#endif

    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
    return PVMFSuccess;
}
OSCL_EXPORT_REF PVMFStatus PvmfPortBaseImpl::DequeueIncomingMsg(PVMFSharedMediaMsgPtr& aMsg)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "0x%x PvmfPortBaseImpl::DequeueIncomingMsg", this));

    if (iIncomingQueue.iQ.empty())
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "0x%x PvmfPortBaseImpl::DequeueIncomingMsg: Error - Incoming queue is empty", this));
        return PVMFFailure;
    }

    // Save message to output parameter and remove it from queue
    aMsg = iIncomingQueue.iQ.front();
    iIncomingQueue.iQ.pop();

#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
    if (iDatapathLogger)
        LogMediaMsgInfo(aMsg, "In Msg De-Q'd", iIncomingQueue);
#endif

#if PVMF_PORT_BASE_IMPL_STATS
    ++iStats.iIncomingMsgConsumed;
#endif

    // Notify the sender port if the queue was busy and the queue size has just dropped
    // below the threshold. Sender port can resume calling Receive.
    if (iIncomingQueue.iBusy)
        EvaluateIncomingBusy();

    return PVMFSuccess;
}
PVMFStatus PVMFSocketPort::getParametersSync(PvmiMIOSession aSession,
        PvmiKeyType aIdentifier,
        PvmiKvp*& aParameters,
        int& num_parameter_elements,
        PvmiCapabilityContext aContext)
{
    OSCL_UNUSED_ARG(aSession);
    OSCL_UNUSED_ARG(aContext);
    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFSocketPort::getParametersSync: aSession=0x%x, aIdentifier=%s, aParameters=0x%x, num_parameters_elements=%d, aContext=0x%x",
                    aSession, aIdentifier, aParameters, num_parameter_elements, aContext));

    if (pv_mime_strcmp(aIdentifier, PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_KEY) != 0)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSocketPort::getParametersSync: Error - Unsupported PvmiKeyType"));
        return PVMFErrNotSupported;
    }

    num_parameter_elements = 0;
    if (!pvmiGetPortInPlaceDataProcessingInfoSync(PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_VALUE, aParameters))
    {
        return PVMFFailure;
    }
    num_parameter_elements = 1;
    return PVMFSuccess;
}
void CPV2WayRecDatapath::CheckPause()
{
    uint32 i;
    int32 error;

    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause state %d\n", iState));

    for (i = 0; i < iNodeList.size(); i++)
    {
        if (!iNodeList[i].iCanNodePause) continue;

        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause node %d state %d\n", i, iNodeList[i].iNode.node->GetState()));
        switch (iNodeList[i].iNode.node->GetState())
        {
            case EPVMFNodeStarted:
                OSCL_TRY(error, i2Way->SendNodeCmdL(PV2WAY_NODE_CMD_PAUSE, iNodeList[i].iNode.node, iNodeList[i].iNode.session, this));
                OSCL_FIRST_CATCH_ANY(error,
                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckPause unable to pause node\n"));
                                     DatapathError();
                                     return;);
                break;

            default:
                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause transitional node state!\n"));
                break;
        }
    }
OsclReturnCode OmxDecTestBase::ProcessCallbackEventHandler(OsclAny* P)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "OmxDecTestBase::ProcessCallbackEventHandler() - Processing the EventHandler Callback IN"));

    // re-cast the pointer
    EventHandlerSpecificData* ED = (EventHandlerSpecificData*) P;

    OMX_HANDLETYPE aComponent = ED->hComponent;
    OMX_PTR aAppData = ED->pAppData;
    OMX_EVENTTYPE aEvent = ED->eEvent;
    OMX_U32 aData1 = ED->nData1;
    OMX_U32 aData2 = ED->nData2;
    OMX_PTR aEventData = ED->pEventData;

    EventHandler(aComponent, aAppData, aEvent, aData1, aData2, aEventData);

    // release the allocated memory when no longer needed
    ED->hComponent = NULL;
    ED->nData1 = 0;
    ED->nData2 = 0;
    ED->pAppData = NULL;
    ED->pEventData = NULL;

    ipThreadSafeHandlerEventHandler->iMemoryPool->deallocate(ED);

    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "OmxDecTestBase::ProcessCallbackEventHandler() - OUT"));

    return OsclSuccess;
}
OsclReturnCode OmxDecTestBase::ProcessCallbackFillBufferDone(OsclAny* P)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "OmxDecTestBase::ProcessCallbackFillBufferDone() - Processing the FillBufferDone Callback IN"));

    // re-cast the pointer
    FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) P;

    OMX_HANDLETYPE aComponent = ED->hComponent;
    OMX_PTR aAppData = ED->pAppData;
    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;

    FillBufferDone(aComponent, aAppData, aBuffer);

    ED->hComponent = NULL;
    ED->pAppData = NULL;
    ED->pBuffer = NULL;

    ipThreadSafeHandlerFillBufferDone->iMemoryPool->deallocate(ED);

    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "OmxDecTestBase::ProcessCallbackFillBufferDone() - OUT"));

    return OsclSuccess;
}
Beispiel #10
0
/**
 * SetCachePosition
 *
 * Flush any updated data in current cache and reset
 * the cache location and current virtual position to the
 * input file position.
 *
 * On return, cache is empty.
 *
 * @param [in] aNewPos: file position.
 *
 * return 0 on success.
 *
*/
int32 OsclFileCache::SetCachePosition(TOsclFileOffset aNewPos)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                    (0, "OsclFileCache(0x%x)::SetCachePosition curpos %d newpos %d", this, _cacheFilePosition, aNewPos));

    //flush any updated data currently in cache.
    if (_cacheUpdateEnd > _cacheUpdateStart)
    {
        int32 result = WriteCacheToFile();
        if (result != 0)
        {
            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                            (0, "OsclFileCache(0x%x)::SetCachePosition ERROR WriteCacheToFile failed", this));
            return result;//error!
        }
    }

    //reset the virtual position and the cache location.
    _cacheFilePosition = aNewPos;
    _currentCachePos = 0;

    //cache is empty
    _endCachePos = 0;
    _cacheUpdateStart = _cacheUpdateEnd = 0;

    return 0;//success
}
        static void ShowSummaryStats(PVServiStats* aArray)
        {
            //lump this logging with Oscl scheduler perf logging.
            uint32 index = 0;
            PVLogger* logger = PVLogger::GetLoggerObject("OsclSchedulerPerfStats");

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "Session Breakdown:"));
            while (index < EServiSession_Last)
            {
                aArray[index].ShowStats(logger, index, aArray[EServiSession_All]);
                index++;
            }

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "Run Breakdown:"));
            while (index < EServiRun_Last)
            {
                aArray[index].ShowStats(logger, index, aArray[EServiSession_All]);
                index++;
            }

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "ProcessRequests Breakdown:"));
            while (index < EServiProc_Last)
            {
                aArray[index].ShowStats(logger, index, aArray[EServiSession_All]);
                index++;
            }

            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "ProcessRequests Loop Breakdown:"));
            while (index < EServiProcLoop_Last)
            {
                aArray[index].ShowStats(logger, index, aArray[EServiSession_All]);
                index++;
            }
        }
OSCL_EXPORT_REF PVMFStatus PvmfPortBaseImpl::Receive(PVMFSharedMediaMsgPtr aMsg)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "0x%x PvmfPortBaseImpl::Receive", this));

    // Incoming queue is in flush state. Do not receive more messages.
    if (iInputSuspended)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "0x%x PvmfPortBaseImpl::Receive: Incoming queue is flushing", this));
        return PVMFErrInvalidState;
    }

    // Incoming queue is in busy state. Do not receive more messages until the queue
    // is not busy, i.e. queue size drops below specified threshold.
    if (iIncomingQueue.iBusy)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                        (0, "0x%x PvmfPortBaseImpl::Receive: Incoming queue is busy", this));
        return PVMFErrBusy;
    }

    // Add message to queue and notify the node of the activity
    // There is no need to trap the push_back, since it cannot leave in this usage
    // Reason being that we do a reserve in the constructor and we do not let the
    // port queues grow indefinitely (we either a connected port busy or outgoing Q busy
    // before we reach the reserved limit
    iIncomingQueue.iQ.push(aMsg);

    PortActivity(PVMF_PORT_ACTIVITY_INCOMING_MSG);
#if PVMF_PORT_BASE_IMPL_STATS
    ++iStats.iIncomingMsgRecv;
#endif

    // Incoming queue size is at capacity and goes into busy state.
    if (iIncomingQueue.iThreshold != 0 &&
            iIncomingQueue.iQ.size() >= iIncomingQueue.iCapacity)
    {
        iIncomingQueue.iBusy = true;
#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
        //log transitions to Full state
        if (iDatapathLogger)
        {
            LOGDATAPATH(
                (0, "PORT %s Incoming Q Busy, Q-depth %d/%d", iPortName.get_cstr()
                 , iIncomingQueue.iQ.size()
                 , iIncomingQueue.iCapacity));
        }
#endif

#if PVMF_PORT_BASE_IMPL_STATS
        ++iStats.iIncomingQueueBusy;
#endif
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                        (0, "0x%x PvmfPortBaseImpl::Receive: Incoming queue is full. Goes into busy state.", this));
    }

    return PVMFSuccess;
}
int32 OsclFileCache::Open(uint32 mode, uint32 size)
//Called to open the cache for a newly opened file.
//The NativeOpen was just called prior to this and was successful.
{
    //should not be called with zero-size cache.
    OSCL_ASSERT(size > 0);

    //Save the mode
    _mode = mode;

    //open logger object only if logging is enabled on this
    //file
    if (iContainer.iLogger)
        iLogger = PVLogger::GetLoggerObject("OsclFileCache");
    else
        iLogger = NULL;

    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                    (0, "OsclFileCache(0x%x)::Open mode %d size %d", this, mode, size));

    // Create the movable cache.
    // Re-allocate it if the size has changed.
    if (_movableCache.pBuffer
            && size != _movableCache.capacity)
    {
        OSCL_FREE(_movableCache.pBuffer);
        _movableCache.pBuffer = NULL;
    }
    if (!_movableCache.pBuffer
            && size > 0)
    {
        _movableCache.pBuffer = (uint8*)OSCL_MALLOC(size);
    }
    if (!_movableCache.pBuffer)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                        (0, "OsclFileCache(0x%x)::Open ERROR no memory %d", this));
        return (-1);//error
    }
    _movableCache.capacity = _movableCache.usableSize = size;
    _movableCache.filePosition = 0;
    _movableCache.updateStart = _movableCache.updateEnd = 0;
    _movableCache.currentPos = _movableCache.endPos = 0;

    //Position the cache at zero.
    SetCachePosition(0);

    //get initial file size & native position
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                    (0, "OsclFileCache(0x%x)::Open CallingNativeSize", this));
    _fileSize = iContainer.CallNativeSize();
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                    (0, "OsclFileCache(0x%x)::Open CallingNativeTell", this));
    _nativePosition = iContainer.CallNativeTell();

    return 0;
}
int32 OsclFileCache::UpdateFixedCaches()
//Process any queued requests to remove or add fixed caches.
{
    int32 error = 0;
    if (iContainer.iRemoveFixedCache.size())
    {
        for (uint32 i = 0; i < iContainer.iRemoveFixedCache.size(); i++)
        {
            for (uint32 j = 0; j < _fixedCaches.size(); j++)
            {
                if (_fixedCaches[j].filePosition < iContainer.iRemoveFixedCache[i])
                {
                    //fixed cache list is sorted, so we can end search now.
                    break;
                }
                else if (_fixedCaches[j].filePosition == iContainer.iRemoveFixedCache[i])
                {
                    //found it
                    if (_fixedCaches[j].IsUpdated())
                    {
                        int32 result = _fixedCaches[j].WriteUpdatesToFile();
                        if (result != 0)
                        {
                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                                            (0, "OsclFileCache(0x%x)::UpdateFixedCaches ERROR in WriteUpdatesToFile", this));
                            error = result;
                        }
                    }
                    if (_fixedCaches[j].pBuffer)
                    {
                        OSCL_FREE(_fixedCaches[j].pBuffer);
                        _fixedCaches[j].pBuffer = NULL;
                    }
                    _fixedCaches.erase(&_fixedCaches[j]);
                    break;
                }
            }
        }
        iContainer.iRemoveFixedCache.clear();
    }

    if (iContainer.iAddFixedCache.size())
    {
        for (uint32 i = 0; i < iContainer.iAddFixedCache.size(); i++)
        {
            if (!AddFixedCache(iContainer.iAddFixedCache[i]))
            {
                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                                (0, "OsclFileCache(0x%x)::UpdateFixedCaches ERROR in AddFixedCache", this));
                error = (-1);
            }
        }
        iContainer.iAddFixedCache.clear();
    }
    return error;
}
// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
// (i.e. PendForExec control is done in the loop in Run)
OsclAny* OmxEventHandlerThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
{
    OsclAny *pData;
    OsclProcStatus::eOsclProcError sema_status;

    stat = OsclSuccess;

    // Protect the queue while accessing it:
    Mutex.Lock();

    if (Q->NumElem == 0)
    {
        // nothing to de-queue
        stat = OsclFailure;
        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxEventHandlerThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
        Mutex.Unlock();

        return NULL;
    }

    pData = (Q->pFirst[Q->index_out]).pData;

    Q->index_out++;
    // roll-over the index
    if (Q->index_out == Q->MaxNumElements)
        Q->index_out = 0;

    Q->NumElem--;

    // check if there is need to call waitforevent
    if ((Q->NumElem) == 0)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxEventHandlerThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
        PendForExec();
        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
        // so that it can get out of the loop
    }


    //release queue access
    Mutex.Unlock();

    // Signal the semaphore that controls the remote thread.
    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
    sema_status = RemoteThreadCtrlSema.Signal();
    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
    {
        stat = OsclFailure;
        return NULL;
    }

    return pData;
}
unsigned H223LowerLayer::SetPduSize(unsigned pdu_size)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "SetPduSize - current(%d), new(%d)!\n", iPduSize, pdu_size));
    if (pdu_size < iPduSize)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "SetPduSize - setting pdu size to (%d)", pdu_size));
        iPduSize = pdu_size;
    }
    else
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "SetPduSize - not setting pdu size "));
    }
    return iPduSize;
}
OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerPort::PeerConnect(PVMFPortInterface* aPort)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "0x%x PVMp4FFComposerPort::PeerConnect: aPort=0x%x", this, aPort));

    if (!aPort)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "0x%x PVMp4FFComposerPort::PeerConnect: Error - Connecting to invalid port", this));
        return PVMFErrArgument;
    }

    if (iConnectedPort)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "0x%x PVMp4FFComposerPort::PeerConnect: Error - Already connected", this));
        return PVMFFailure;
    }

    // When connection is initiated by peer, this port still needs to query the peer
    // for input format configuration data
    OsclAny* temp = NULL;
    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);

    if (!config)
    {
        LOG_ERR((0, "PVMp4FFComposerPort::PeerConnect: Error - Peer port does not support capability interface"));
        return PVMFFailure;
    }

    PVMFStatus status = GetInputParametersFromPeer(config);
    if (status != PVMFSuccess)
    {
        LOG_ERR((0, "PVMp4FFComposerPort::PeerConnect: Error - GetVideoInputParametersFromPeer failed. status=%d",
                 status));
        return status;
    }

    iConnectedPort = aPort;

#if PVMF_PORT_BASE_IMPL_STATS
    // Reset statistics
    oscl_memset((OsclAny*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
#endif

    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
    return PVMFSuccess;
}
PVMFStatus PVMFSocketPort::QueueOutgoingMsg(PVMFSharedMediaMsgPtr aMsg)
//In this node, we skip the outgoing queue and go directly to the connected port's
//incoming queue.
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFSocketPort::QueueOutgoingMsg"));

    //If port is not connected, don't accept data on the
    //outgoing queue.
    if (!iConnectedPort)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFSocketPort::QueueOutgoingMsg: Error - Port not connected"));
        return PVMFFailure;
    }

    PvmfPortBaseImpl* cpPort = OSCL_STATIC_CAST(PvmfPortBaseImpl*, iConnectedPort);

    // Connected Port incoming Queue is in busy / flushing state.  Do not accept more outgoing messages
    // until the queue is not busy, i.e. queue size drops below specified threshold or FlushComplete
    // is called.
    if (cpPort->iIncomingQueue.iBusy)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFSocketPort::QueueOutgoingMsg: Connected Port Incoming queue in busy / flushing state - Attempting to Q in output port's outgoing msg q"));
        return (PvmfPortBaseImpl::QueueOutgoingMsg(aMsg));
    }

    // Add message to outgoing queue and notify the node of the activity
    // There is no need to trap the push_back, since it cannot leave in this usage
    // Reason being that we do a reserve in the constructor and we do not let the
    // port queues grow indefinitely (we either a connected port busy or outgoing Q busy
    // before we reach the reserved limit
    PVMFStatus status = cpPort->Receive(aMsg);

    if (status != PVMFSuccess)
    {
        return PVMFFailure;
    }

    // Outgoing queue size is at capacity and goes into busy state. The owner node is
    // notified of this transition into busy state.
    if (cpPort->isIncomingFull())
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFSocketPort::QueueOutgoingMsg: Connected Port incoming queue is full. Goes into busy state"));
        cpPort->iIncomingQueue.iBusy = true;
        PvmfPortBaseImpl::PortActivity(PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY);
    }

    return PVMFSuccess;
}
bool
PVMFSocketPort::pvmiGetPortInPlaceDataProcessingInfoSync(const char* aFormatValType,
        PvmiKvp*& aKvp)
{
    /*
     * Create PvmiKvp for capability settings
     */
    aKvp = NULL;
    OsclMemAllocator alloc;
    uint32 strLen = oscl_strlen(aFormatValType) + 1;
    uint8* ptr = (uint8*)alloc.allocate(sizeof(PvmiKvp) + strLen);
    if (!ptr)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSocketPort::pvmiGetPortInPlaceDataProcessingInfoSync: Error - No memory. Cannot allocate PvmiKvp"));
        return false;
    }
    aKvp = new(ptr) PvmiKvp;
    ptr += sizeof(PvmiKvp);
    aKvp->key = (PvmiKeyType)ptr;
    oscl_strncpy(aKvp->key, aFormatValType, strLen);
    aKvp->length = aKvp->capacity = strLen;

#if SNODE_ENABLE_UDP_MULTI_PACKET
    if (iTag == PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
        aKvp->value.bool_value = false;//for the multiple UDP recv feature
    else
#endif
        aKvp->value.bool_value = true;

    return true;
}
void TSC_blc::BlcEtbRps(TPVChannelId incoming_lcn, TPVChannelId outgoing_lcn)
{
    S_ControlMsgHeader  infHeader;
    S_ReverseData       parameter;
    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0,
                     "TSC_blc::BlcEtbRps incoming(%d), outgoing(%d)\n", incoming_lcn, outgoing_lcn));

    // Buffer Allocate
    oscl_memset(&parameter, 0, sizeof(S_ReverseData));

    // ESTABLISH.response primitive - Parameter(REVERSE_DATA)
    parameter.option_of_reverseLogicalChannelParameters = true;
    parameter.reverseLogicalChannelParameters.reverseLogicalChannelNumber =
        (uint16)incoming_lcn; // WWU_BLC: change 0->3
    parameter.reverseLogicalChannelParameters.option_of_portNumber = false;
    parameter.reverseLogicalChannelParameters.option_of_ackMultiplexParameters = false;
    parameter.reverseLogicalChannelParameters.option_of_replacementFor = false;

    Tsc_SendDataSet(&infHeader,
                    H245_PRIMITIVE,
                    E_PtvId_Blc_Etb_Rps,
                    incoming_lcn,
                    outgoing_lcn,
                    (uint8*)&parameter,
                    sizeof(S_ReverseData));

    // Primitive Send
    iH245->DispatchControlMessage(&infHeader);
}
void pv_mediainput_async_test_delete::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
{
    OSCL_UNUSED_ARG(aEvent);
    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "pv_mediainput_async_test_delete::HandleErrorEvent"));
    iState = PVAE_CMD_RESET;
    RunIfNotReady();
}
uint32 TSC_324m::FlowControlIndicationReceived(PS_ControlMsgHeader  pReceiveInf)
{
    OSCL_UNUSED_ARG(pReceiveInf);
    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "TSC_324m::FlowControlIndicationReceived"));
    return iTerminalStatus;
}
void TSC_324m::IndicationMisc(TIndicationMisc type,
                              TPVChannelId channelId,
                              uint32 param,
                              OsclAny* param1)
{
    OSCL_UNUSED_ARG(param1);
    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "TSC_324m::IndicationMisc type(%d), channelId(%d), param(%d), param1(%x)",
                     type, channelId, param, param1));

    S_ControlMsgHeader infHeader;
    S_MiscellaneousIndication miscellaneousIndication;
    oscl_memset(&miscellaneousIndication, 0, sizeof(S_MiscellaneousIndication));

    switch (type)
    {
        case EVideoTemporalSpatialTradeOffIdc:
            miscellaneousIndication.logicalChannelNumber = (uint16)channelId;
            miscellaneousIndication.miType.index = 9;
            miscellaneousIndication.miType.videoTemporalSpatialTradeOff = (uint8)param;
            break;
        default:
            return;
    }

    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Idc_Mscl, 0, 0,
                    (uint8*)&miscellaneousIndication, sizeof(S_MiscellaneousIndication));
    iH245->DispatchControlMessage(&infHeader);
}
void OsclFileStats::LogAll(PVLogger* aLogger, uint32 aLogLevel)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, aLogLevel
                    , (0, "OsclFileStats(0x%x): +++++++++++++++++++++ Begin", iContainer));
    for (uint32 op = 0;op < EOsclFileOp_Last;op++)
    {
        if (iStats[op].iOpCount > 0)
        {
            Log((TOsclFileOp)op, aLogger, aLogLevel);
        }
    }
    //clear all stats once they've been dumped.
    oscl_memset(iStats, 0, sizeof(iStats));
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, aLogLevel
                    , (0, "OsclFileStats(0x%x): +++++++++++++++++++++ End", iContainer));
}
void pv_mediainput_async_test_errorhandling::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
{
    OSCL_UNUSED_ARG(aEvent);
    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "pv_mediainput_async_test_errorhandling::HandleInformationalEvent"));

}
TPVStatusCode H223LowerLayer::SetBitrate(uint32 bitRate)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux[LL]: SetBitrate Request(%d)\n", bitRate));
    iBitrate = bitRate;
    UpdatePduSize();
    return EPVT_Success;
}
OSCL_EXPORT_REF PVMFStatus PvmfPortBaseImpl::ClearMsgQueues()
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "0x%x PvmfPortBaseImpl::ClearMsgQueues", this));

    while (!iIncomingQueue.iQ.empty())
    {
        PVMFSharedMediaMsgPtr msg = iIncomingQueue.iQ.front();
        iIncomingQueue.iQ.pop();
#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
        if (iDatapathLogger)
            LogMediaMsgInfo(msg, "In Msg Cleared", iIncomingQueue);
#endif
    }
    if (iIncomingQueue.iBusy)
        EvaluateIncomingBusy();

    while (!iOutgoingQueue.iQ.empty())
    {
        PVMFSharedMediaMsgPtr msg = iOutgoingQueue.iQ.front();
        iOutgoingQueue.iQ.pop();
#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
        if (iDatapathLogger)
            LogMediaMsgInfo(msg, "Out Msg Cleared", iOutgoingQueue);
#endif
    }
    if (iOutgoingQueue.iBusy)
        EvaluateOutgoingBusy();
    return PVMFSuccess;
}
OSCL_EXPORT_REF bool PvmfPortBaseImpl::isIncomingFull()
//derived class can override this to redefine "queue full" condition.
{
    if (iIncomingQueue.iThreshold == 0)
    {
        //should never happen
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "0x%x PvmfPortBaseImpl::isIncomingFull: Zero Threshold", this));
        OSCL_ASSERT(false);
        return true;
    }
    if (iIncomingQueue.iQ.size() == iIncomingQueue.iCapacity)
    {
        return true;
    }
    if (iIncomingQueue.iBusy == true)
    {
        //this implies that we were at capacity previously
        //wait for occupancy to fall below threshold before
        //treating the queue as "not-full"
        if (iIncomingQueue.iQ.size() >= iIncomingQueue.iThreshold)
        {
            return true;
        }
    }
    //this means that we are below capacity and are approaching
    //capacity, or that we have fallen below threshold. in either
    //case treat queue as "not-full"
    return false;
}
void TSC_324m::Tsc_UII_Alphanumeric(const uint8* str, uint16 str_len)
{
    S_ControlMsgHeader           infHeader;
    PS_UserInputIndication       pUserInputIndication;
    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "TSC_324m:Tsc_UII_Alphanumeric - len(%d)", str_len));

    // Allocate the UII structure
    pUserInputIndication = (PS_UserInputIndication)OSCL_DEFAULT_MALLOC(sizeof(S_UserInputIndication));

    // Fill in the 'signal'
    pUserInputIndication->index = 1;  /* alphanumeric */
    pUserInputIndication->alphanumeric = (PS_int8STRING) OSCL_DEFAULT_MALLOC(sizeof(S_int8STRING));
    pUserInputIndication->alphanumeric->size = str_len;
    pUserInputIndication->alphanumeric->data = (uint8*) OSCL_DEFAULT_MALLOC(str_len * sizeof(uint8));
    oscl_memcpy(pUserInputIndication->alphanumeric->data, str, str_len);

    // Send the message
    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Idc_Ui, 0, 0, (uint8*)pUserInputIndication,
                    sizeof(S_UserInputIndication));
    iH245->DispatchControlMessage(&infHeader);
    Delete_UserInputIndication(pUserInputIndication);
    OSCL_DEFAULT_FREE(pUserInputIndication);
    return;
}
/**
 * Seek
 *
 * @param [in] offset from origin
 * @param [in] origin: either SEEKSET, SEEKCUR, or SEEKEND
 *
 * @return 0 for success.
 */
int32 OsclFileCache::Seek(TOsclFileOffset offset, Oscl_File::seek_type origin)
{
    //figure out the file position we're trying to seek to
    TOsclFileOffset pos;
    switch (origin)
    {
        case Oscl_File::SEEKCUR:
            pos = Tell() + offset;
            break;
        case Oscl_File::SEEKSET:
            pos = 0 + offset;
            break;
        case Oscl_File::SEEKEND:
            pos = FileSize() + offset;
            break;
        default:
            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                            (0, "OsclFileCache(0x%x)::Seek ERROR invalid origin %d", this, origin));
            return (-1);//error-- invalid origin!
    }

    //don't allow seeking outside valid file size
    if (pos < 0 || pos > FileSize())
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                        (0, "OsclFileCache(0x%x)::Seek ERROR invalid seek position %d", this, pos));
        return -1;//error
    }

    if (_curCache->Contains(pos))
    {
        //Seek in cur cache
        _curCache->currentPos = (uint32)(pos - _curCache->filePosition);
    }
    else
    {
        //Seek outside cache
        int32 retval = SetCachePosition(pos);
        if (retval != 0)
        {
            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                            (0, "OsclFileCache(0x%x)::Seek ERROR SetPosition error %d", this, retval));
            return retval;//error
        }
    }
    return 0;
}