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;
}
PVMp4FFComposerPort::~PVMp4FFComposerPort()
{
    if (memfrag_sps)
    {
        for (uint32 i = 0; i < iNode->memvector_sps.size(); i++)
        {
            OSCL_FREE(iNode->memvector_sps[i]->ptr);
        }

        while (!iNode->memvector_sps.empty())
        {
            if (iNode->memvector_sps.front())
            {
                OSCL_FREE(iNode->memvector_sps.front());
            }
            iNode->memvector_sps.erase(&iNode->memvector_sps.front());
        }
    }

    if (memfrag_pps)
    {
        for (uint32 i = 0; i < iNode->memvector_pps.size(); i++)
        {
            OSCL_FREE(iNode->memvector_pps[i]->ptr);
        }

        while (!iNode->memvector_pps.empty())
        {
            if (iNode->memvector_pps.front())
            {
                OSCL_FREE(iNode->memvector_pps.front());
            }
            iNode->memvector_pps.erase(&iNode->memvector_pps.front());
        }
    }

    if (iNode->textdecodervector.size() > 0)
    {

        while (!iNode->textdecodervector.empty())
        {
            if (iNode->textdecodervector.front())
            {
                OSCL_DELETE(iNode->textdecodervector.front());
            }

            iNode->textdecodervector.erase(&iNode->textdecodervector.front());
        }
    }
    Disconnect();
    ClearMsgQueues();

    // we need to clear the activity handler, since otherwise the PvmfPortBaseImpl destructor
    // ends up calling back onto our HandlePortActivity method, which no longer exists because
    // this objects's destructor has already been called.
    SetActivityHandler(NULL);
}
OSCL_EXPORT_REF PVMFOMXDecPort::~PVMFOMXDecPort()
{
    if (iTrackConfig != NULL)
    {
        OSCL_FREE(iTrackConfig);
        iTrackConfigSize = 0;
    }

    Disconnect();
    ClearMsgQueues();
}
PVMFAvcEncPort::~PVMFAvcEncPort()
{
    Disconnect();
    ClearMsgQueues();
}
void PVMFLoopbackIOPort::Reset()
{
    Cancel();
    ClearMsgQueues();
    iWaiting = false;
}
PVMFVideoEncPort::~PVMFVideoEncPort()
{
	Disconnect();
	ClearMsgQueues();
}
PVMFWAVFFParserOutPort::~PVMFWAVFFParserOutPort()
{
    Disconnect();
    ClearMsgQueues();
}
PVMFFileOutputInPort::~PVMFFileOutputInPort()
{
    Disconnect();
    ClearMsgQueues();
    iDataQueue.Clear();
}