void OsclSocketServI::StopServImp()
{
#if(PV_SOCKET_SERVER_IS_THREAD)
    //stop the thread.
    iClose = true;
    iSockServRequestList.Wakeup();//wake up the thread if needed.
    WakeupBlockingSelect();
    //wait til thread exits
    iExit.Wait();

#else//PV_SOCKET_SERVER_IS_THREAD

    //Socket server AO cleanup.
    if (iServState != OsclSocketServI::ESocketServ_Connected)
    {
        return;
    }

    //cancel any active request.
    if (IsAdded())
    {
        Cancel();
    }

    ServerExit();

    //remove AO from scheduler.
    if (IsAdded())
    {
        RemoveFromScheduler();
    }
#endif//PV_SOCKET_SERVER_IS_THREAD
}
// Destructor
CompositionOffsetAtom::~CompositionOffsetAtom()
{
    if (_psampleCountVec != NULL)
        PV_MP4_ARRAY_DELETE(NULL, _psampleCountVec);

    if (_psampleOffsetVec != NULL)
        PV_MP4_ARRAY_DELETE(NULL, _psampleOffsetVec);

    if (_stbl_fptr_vec != NULL)
        PV_MP4_ARRAY_DELETE(NULL, _stbl_fptr_vec);

    DeleteMarkerTable();

    if (_fileptr != NULL)
    {
        if (_fileptr->IsOpen())
        {
            AtomUtils::CloseMP4File(_fileptr);
        }
        oscl_free(_fileptr);
    }

    if (IsAdded())
    {
        RemoveFromScheduler();
    }

}
예제 #3
0
// -----------------------------------------------------------------------------
// CVibraTimer::Set(TInt aIntervalInMilliSecs)
// Start the timer to complete after the specified number of microseconds.
// If the duration is zero, then timer is set to predefined maximum value.
// -----------------------------------------------------------------------------
//
TInt CVibraTimer::Set(TInt aIntervalInMilliSecs)
    {
    __ASSERT_ALWAYS(CActiveScheduler::Current()!= NULL, User::Invariant());
    
    if (!IsAdded())
        {
        CActiveScheduler::Add(this);
        }
    
    // If the timer is already running, cancel it... 
    if (IsActive())
        {
        Cancel();
        }
    // And set the new timer... 
    // Convert to uS first -- which is, after all, why this method really exists...
    if ((0 == aIntervalInMilliSecs) || (aIntervalInMilliSecs > iMaximumVibraTimeMs))
        {
        After(iMaximumVibraTimeMs * 1000);
        }
    else
        {    
        After(aIntervalInMilliSecs * 1000);
        }
    return KErrNone;
    }
PVMFLoopbackIOPort::~PVMFLoopbackIOPort()
{
    Disconnect();
    Reset();
    if (IsAdded())
        RemoveFromScheduler();
}
CTLbsX3pTransmitLocWaiter::~CTLbsX3pTransmitLocWaiter()
	{
	if(IsActive())
		Cancel();
	
	if(IsAdded())
		Deque();		
	}
CTLbsX3pRefLocWaiter::~CTLbsX3pRefLocWaiter()
	{
	if(IsActive())
		Cancel();
	
	if(IsAdded())
		Deque();		
	}
/////////////////////////////////////////////////////////////////////////////
// Add AO to the scheduler
/////////////////////////////////////////////////////////////////////////////
OSCL_EXPORT_REF void ThreadSafeCallbackAO::ThreadLogon()
{
    if (!IsAdded())
    {
        AddToScheduler();
    }

    iLogger = PVLogger::GetLoggerObject(iLoggerString);
}
////////////////////////////////////////////////////////////////////////////
// Remove AO from the scheduler
////////////////////////////////////////////////////////////////////////////
OSCL_EXPORT_REF void ThreadSafeCallbackAO::ThreadLogoff()
{
    //thread logoff
    if (IsAdded())
    {
        RemoveFromScheduler();
    }

    iLogger = NULL;
}
예제 #9
0
void CBulkReceiver::BindToCurrentThreadL()
	{
	LOG_FUNC;
	ASSERT_DEBUG(!IsAdded());
	TRAPD(err, DoBindToCurrentThreadL());
	if(err != KErrNone)
		{
		this->Deque();
		LEAVEL(err);
		}
	}
// ---------------------------------------------------------------------------
// ?description_if_needed
// ---------------------------------------------------------------------------
//
void CAlarmRemConEventsHandler::CompleteSelf()
    {
    TRACE_ENTRY_POINT;
    TRequestStatus* pStat = &iStatus;
    User::RequestComplete( pStat, KErrNone );

    if( IsAdded() && !IsActive() )
        {
        SetActive();
        }
    TRACE_EXIT_POINT;
    }
예제 #11
0
void CNaptTimer::StartTimer()
	/**
	*
    * Start Timer & Add it Active Scheduler
    *
    **/
	{
	ASSERT(!IsAdded());
	CActiveScheduler::Add(this);
	//it should be in Micro Seconds..
	CTimer::After(iNaptTableScanInterval*1000000);
	}
예제 #12
0
void CNaptTimer::Cancel()
	/**
	*
	* Remove Timer from Active Scheduler
	*
	**/
	{
	CTimer::DoCancel();
	if (IsAdded())
		{
        Deque();
        }
	}
void LipSyncDummyOutputMIO::QueueCommandResponse(CommandResponse& aResp)
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                    (0, "LipSyncDummyOutputMIO::QueueCommandResponse(), aResp.CmdId is %d ", aResp.iCmdId));
    //queue a command response and schedule processing.
    iCommandResponseQueue.push_back(aResp);

    //schedule the AO.
    if (!IsBusy())
        PendForExec();
    if (IsAdded() && iStatus == OSCL_REQUEST_PENDING)
        PendComplete(OSCL_REQUEST_ERR_NONE);
}
OSCL_EXPORT_REF
PVMIExternalDownloadSimulator::~PVMIExternalDownloadSimulator()
{
    if (iExtensionRefCount != 0)
    {
        OSCL_ASSERT(false);
    }
    Reset();
    if (IsAdded())
    {
        RemoveFromScheduler();
    }
};
TPVSocketEvent OsclSocketMethod::ThreadLogoff()
{
    //make sure there's not already a request
    //in progress
    if (iSocketRequestAO->IsBusy()
            || IsBusy())
        return EPVSocketFailure;

    if (IsAdded())
        RemoveFromScheduler();
    if (iSocketRequestAO->IsAdded())
        iSocketRequestAO->RemoveFromScheduler();

    return EPVSocketSuccess;
}
void OmxDecTestBase::StartTestApp()
{
    if (!IsAdded())
    {
        AddToScheduler();
    }

    RunIfNotReady();

    OsclExecScheduler* sched = OsclExecScheduler::Current();
    if (sched)
    {
        sched->StartScheduler();
    }
}
bool OsclDNSMethod::StartMethod(int32 aTimeoutMsec)
{
    //make sure there's not already a request
    //in progress
    if (IsAdded() || iDNSRequestAO->IsAdded())
        return false;

    AddToScheduler();
    iDNSRequestAO->AddToScheduler();

    //set the timeout
    if (aTimeoutMsec > 0)
        After(aTimeoutMsec*1000);

    iDNSRequestAO->iSocketError = 0;

    return true;
}
예제 #18
0
CDnsSocketWriter::~CDnsSocketWriter()
	{
	// As this class is managed by CDnsSocket, it is impossible
	// to get here if IsActive(), or with requests in any queue.
	// (DeactivateSocket is ALWAYS called before destructor)
	//
	ASSERT(!IsActive());
	ASSERT(iSendQueue.IsEmpty());
	ASSERT(iWaitQueue.IsEmpty());

	delete iReader;

	Cancel();	// should not be needed...
	if (IsAdded())
		Deque();
#ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY		
	iAttachedConn.Close();
#endif	
	LOG(Log::Printf(_L("CDnsSocketWriter[%u]::~CDnsSocketWriter()"), this));
	}
bool OsclSocketMethod::StartMethod(int32 aTimeoutMsec)
{
    //make sure there's not already a request
    //in progress
    if (iSocketRequestAO->IsBusy()
            || IsBusy())
        return false;

    if (!iSocketRequestAO->IsAdded())
        iSocketRequestAO->AddToScheduler();

    //set the timeout if any.  Timeout <= 0 indicates infinite wait.
    if (aTimeoutMsec > 0)
    {
        if (!IsAdded())
            AddToScheduler();
        After(aTimeoutMsec*MSEC_TO_MICROSEC);
    }

    iSocketRequestAO->iSocketError = 0;

    return true;
}
// ---------------------------------------------------------------------------
// ?description_if_needed
// ---------------------------------------------------------------------------
//
void CAlarmRemConEventsHandler::HandleRemConCommand(TInt aCommand)
    {
    TRACE_ENTRY_POINT;
    ASSERT( iState == EStateWaitingCommand && IsAdded() && !IsActive() );

    // there shouldn't be new commands while we're still handling the previous one
    if( iState == EStateWaitingCommand )
        {
        iRemConOperationID = aCommand;

        switch( iRemConOperationID )
            {
            case ERemConExtEndCall:
            case ERemConExtAnswerEnd:
                // handle message (stop the alarm)
                iState = EStateHandleEndCallCommand;
                break;

            case ERemConExtAnswerCall:
            case ERemConExtVoiceDial:
            case ERemConExtLastNumberRedial:
            case ERemConExtDialCall:
            case ERemConExt3WaysCalling:
            case ERemConExtGenerateDTMF:
            case ERemConExtSpeedDial:
                // no event handling...just send the response
                iState = EStateIgnoreCommand;
                break;

            default:
                ASSERT( EFalse );
            }
        // start the AO
        CompleteSelf();
        }
    TRACE_EXIT_POINT;
    }
예제 #21
0
// ------------------------------------------------------------------------
// CDRMConsume:: ActivateL
//
// Calculate the smallest end time based on interval, end time,
// accumulated time & timed count.
// ------------------------------------------------------------------------
//
void CDRMConsume::ActivateL( TBool aSecureTime,
                             const TTime& aTrustedTime  )
{
    DRMLOG( _L( "CDRMConsume::ActivateL" ) );

    __ASSERT_DEBUG( iChild && iCombined, User::Invariant() );
    TTime endTime( Time::MaxTTime() );
    TTimeIntervalSeconds timed( KMaxTInt32 );
    TBool timeUsed( EFalse );
    TBool endTimeUsed( EFalse );

    iCurrentDelay = 0;

    if ( iCombined->iActiveConstraints & EConstraintTimedCounter )
    {
        // Take this, even if timed counts have been updated.
        // This might cause unnecessary RunL's to be called, but it
        // ensures both child & parent will be consumed when needed.
        // If e.g. it would be checked that iTimedCounts == 0xf,
        // either one (child or parent) might not get updated in case of
        // "Child expired, but parent didn't -> find new child".
        PickSmaller( timed, iCombined->iTimedInterval );
        timeUsed = ETrue;
    }

    if ( iCombined->iActiveConstraints & EConstraintAccumulated )
    {
        PickSmaller( timed, iCombined->iAccumulatedTime );
        timeUsed = ETrue;
    }

    if ( iCombined->iActiveConstraints & EConstraintInterval )
    {
        if ( iCombined->iIntervalStart != Time::NullTTime() )
        {
            endTime = iCombined->iIntervalStart;
            endTime += iCombined->iInterval;
            endTimeUsed = ETrue;
        }
        else
        {
            TInt64 tmp( iCombined->iInterval.Int() );

            PickSmaller( timed, tmp );
            timeUsed = ETrue;
        }
    }

    if ( iCombined->iActiveConstraints & EConstraintEndTime )
    {
        PickSmaller( endTime, iCombined->iEndTime );
        endTimeUsed = ETrue;
    }

    // Put the "smallest time" information to "endTime".
    if ( timeUsed )
    {
        TTime current( aTrustedTime );

        current += timed;

        PickSmaller( endTime, current );
        endTimeUsed = ETrue;
    }

    // Interval gets initialised immediately, and so do count constraints.
    // Timed/accumulated won't: those are consumed after the
    // interval if secure time exists.
    Consume( ETrue, ETrue, EFalse, 0,
             aSecureTime,
             aTrustedTime );

    // In case something was modified, update the db also.
    UpdateDBL();

    if ( endTimeUsed )
    {
        // Something exists.
        TTimeIntervalSeconds secs( 0 );
        TTime current( aTrustedTime );
        TInt err( KErrNone );

        // SecondsFrom returns an error if the difference is too great.
        err = endTime.SecondsFrom( current, secs );
        if ( err )
        {
            iCurrentDelay = KConsumeDefaultTimer;
        }
        else if ( secs.Int() < 0 )
        {
            iCurrentDelay = 0; // Already expired.
        }
        else if ( secs.Int() < KConsumeDefaultTimer )
        {
            iCurrentDelay = secs.Int();
        }
        else
        {
            iCurrentDelay = KConsumeDefaultTimer;
        }

        if ( !IsAdded() )
        {
            CActiveScheduler::Add( this );
        }

        DRMLOG2( _L( "CDRMConsume::ActivateL: using interval %d" ),
                 ( TInt )iCurrentDelay );

        // secs -> microsecs. The method sets the AO active.
        After( TTimeIntervalMicroSeconds32( iCurrentDelay * 1000000 ) );

        iTime = current;

        // If we see timed things here, we also have secure time.
        //SETBIT( iMask, KConsumeHasSecureTime );
    }
    else    // For metering we always need to have this:
    {
        iCurrentDelay = KConsumeDefaultTimer;
        iTime = aTrustedTime;

        if ( !IsAdded() )
        {
            CActiveScheduler::Add( this );
        }

        DRMLOG2( _L( "CDRMConsume::ActivateL: using interval %d" ),
                 ( TInt )iCurrentDelay );

        // secs -> microsecs. The method sets the AO active.
        After( TTimeIntervalMicroSeconds32( iCurrentDelay * 1000000 ) );
    }

    // If we see timed things here, we also have secure time.
    if( aTrustedTime != Time::NullTTime())
    {
        SETBIT( iMask, KConsumeHasSecureTime );
    }
    DRMLOG( _L( "CDRMConsume::ActivateL ok" ) );
}
예제 #22
0
TBool CBulkReceiver::InitialisationRequired() const
	{
	LOG_FUNC;
	return IsAdded();
	}
PVMFCommandId PvmfMediaInputNodeOutPort::writeAsync(uint8 format_type, int32 format_index,
        uint8* data, uint32 data_len,
        const PvmiMediaXferHeader& data_header_info,
        OsclAny* context)
{
    if (iState == PvmfMediaInputNodeOutPort::PORT_STATE_STOPPED)
    {
        // In stopped state we are not going to accept any buffers
        OsclError::Leave(OsclErrNotReady);
        LOG_DEBUG((0, "Ignoring PvmfMediaInputNodeOutPort::writeAsync"));
        return -1;
    }
    if (iWriteState == EWriteOK)
    {
        if (PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION == format_type)
        {
            switch (format_index)
            {
                    //added for timed text support
                    //here it handles the configuration information for timed text and passes it to the composernode
                case PVMI_MEDIAXFER_FMT_INDEX_FMT_SPECIFIC_INFO:
                {
                    //we expect media input components to use cap-config to provide
                    //fmt specific info
                    LOG_ERR((0, "Fmt Specific Info over WriteAsync Not Supported"));
                    iNode->ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)NULL);
                    OsclError::Leave(OsclErrGeneral);
                }
                break;
                case PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM:
                {
                    SendEndOfTrackCommand(data_header_info);
                    MediaIOStarted();
                    return iCmdId++;
                }
                break;
                case PVMI_MEDIAXFER_FMT_INDEX_INFO_EVENT:
                case PVMI_MEDIAXFER_FMT_INDEX_ERROR_EVENT:
                {
                    OSCL_ASSERT(iNode);
                    OSCL_ASSERT(iMediaInput);
                    if (!data)
                    {
                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                        (0, "PvmfMediaInputNodeOutPort::writeAsync: Error - data is NULL"));
                        OSCL_LEAVE(OsclErrArgument);
                        return -1;
                    }

                    if (data_len != sizeof(PVMFAsyncEvent))
                    {
                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                        (0, "PvmfMediaInputNodeOutPort::writeAsync: Error - data length is not size of PVMFAsyncEvent"));
                        OSCL_LEAVE(OsclErrArgument);
                        return -1;
                    }

                    PVMFAsyncEvent* event = OSCL_STATIC_CAST(PVMFAsyncEvent*, data);
                    iNode->ReportErrorEvent(event->GetEventType(), event->GetEventData());

                    // Not really processing this asynchronously. Just call writeComplete
                    // synchronously
                    iMediaInput->writeComplete(PVMFSuccess, iMioInfoErrorCmdId, context);
                    return iMioInfoErrorCmdId++;
                }
                break;
                default:
                {
                    LOG_ERR((0, "Ignoring Format Index :%d since not supported\n", format_index));
                    iNode->ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)NULL);
                    OsclError::Leave(OsclErrGeneral);
                }
                break;
            }
        }
        // TODO: Handle incoming data here. Create a media data using PvmiMIOSourceDataBufferAlloc::allocate,
        // save the data there, put the media data to outgoing queue.
        // If the port is started, schedule to send in Run
        else if (PVMI_MEDIAXFER_FMT_TYPE_DATA == format_type)
        {
            //if the outgoing queue is full, we can't accept data
            //now.

            if (IsOutgoingQueueBusy())
            {
                iWriteState = EWriteBusy;
                OsclError::Leave(OsclErrBusy);
            }

            // Create new media data buffer
            PVMFSharedMediaDataPtr mediaData;
            int32 err = 0;

            if (iCmdId == 0x7FFFFFFF)
                iCmdId = 0;
#ifdef _TEST_AE_ERROR_HANDLING

            if (data_header_info.stream_id == iNode->iTrackID)
            {
                uint32 ii = 0;
                while (iNode->iChunkCount > 0)
                {
                    uint32 sz = data_len - 5;

                    for (ii = 0; ii <= sz; ii++)
                    {
                        uint8* ptr = data + ii;
                        *ptr = 0;
                    }

                    iNode->iChunkCount--;
                }

            }
#endif
#ifdef _TEST_AE_ERROR_HANDLING
            if (iNode->iError_No_Memory)
            {
                err = OsclErrBusy;
                if (IsAdded())
                {
                    RunIfNotReady();
                }
            }
            else
            {
                OSCL_TRY(err,
                         OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = iMediaDataAlloc->allocate(iMediaInput, data,
                                 data_len, iCmdId, context);
                         mediaData = PVMFMediaData::createMediaData(mediaDataImpl, iMediaDataMemPool););
            }
#else
            OSCL_TRY(err,
                     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = iMediaDataAlloc->allocate(iMediaInput, data,
                             data_len, iCmdId, context);
                     mediaData = PVMFMediaData::createMediaData(mediaDataImpl, iMediaDataMemPool););
예제 #24
0
CUnifiedCertStore::CUnifiedCertStore(RFs& aFs, TBool aOpenForWrite)
	: CActive(EPriorityNormal), iFs(aFs), iOpenedForWrite(aOpenForWrite), iOrderAttributes()
	{
	CActiveScheduler::Add(this);
	assert(IsAdded());
	}
// Stream-in ctor
CompositionOffsetAtom::CompositionOffsetAtom(MP4_FF_FILE *fp,
        uint32 mediaType,
        uint32 size,
        uint32 type,
        OSCL_wString& filename,
        uint32 parsingMode):
        FullAtom(fp, size, type),
        OsclTimerObject(OsclActiveObject::EPriorityNominal, "CompositionOffsetAtom")
{
    _psampleCountVec = NULL;
    _psampleOffsetVec = NULL;
    MT_SampleCount  = NULL;
    MT_EntryCount  = NULL;
    iMarkerTableCreation = false;
    MT_Table_Size = 0;

    _currGetSampleCount = 0;
    _currGetIndex = -1;
    _currGetTimeOffset = 0;
    _currPeekSampleCount = 0;
    _currPeekIndex = -1;
    _currPeekTimeOffset = 0;

    MT_Counter = 1;
    addSampleCount = 0;
    prevSampleCount = 0;
    entrycountTraversed = 0;
    refSample = MT_SAMPLECOUNT_INCREMENT;
    MT_j = 1;

    _mediaType = mediaType;
    _parsed_entry_cnt = 0;
    _fileptr = NULL;
    _parsing_mode = 0;
    _parsing_mode = parsingMode;


    _stbl_buff_size = CTTS_MIN_SAMPLE_TABLE_SIZE;
    _next_buff_number = 0;
    _curr_buff_number = 0;
    _curr_entry_point = 0;
    _stbl_fptr_vec = NULL;

    iLogger = PVLogger::GetLoggerObject("mp4ffparser");
    iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats");
    iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata");

    iMarkerTableCreation = false;

    /* Add this AO to the scheduler */
    if (OsclExecScheduler::Current() != NULL)
    {
        if (!IsAdded())
        {
            AddToScheduler();
        }
    }

    if (_success)
    {
        if (!AtomUtils::read32(fp, _entryCount))
        {
            _success = false;
        }

        PVMF_MP4FFPARSER_LOGPARSEDINFO((0, "CompositionOffsetAtom::CompositionOffsetAtom- _entryCount =%d", _entryCount));
        uint32 dataSize = _size - (DEFAULT_FULL_ATOM_SIZE + 4);

        uint32 entrySize = (4 + 4);

        if ((_entryCount*entrySize) > dataSize)
        {
            _success = false;
        }

        if (_success)
        {
            if (_entryCount > 0)
            {
                if (parsingMode == 1)
                {
                    // cache size is 4K so that optimization
                    // should work if entry_count is greater than 4K
                    if (_entryCount > _stbl_buff_size)
                    {

                        uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1;

                        PV_MP4_FF_ARRAY_NEW(NULL, uint32, (fptrBuffSize), _stbl_fptr_vec);
                        if (_stbl_fptr_vec == NULL)
                        {
                            _success = false;
                            _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
                            return;
                        }


                        PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleCountVec);
                        if (_psampleCountVec == NULL)
                        {
                            _success = false;
                            _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
                            return;
                        }


                        PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleOffsetVec);
                        if (_psampleOffsetVec == NULL)
                        {
                            PV_MP4_ARRAY_DELETE(NULL, _psampleOffsetVec);
                            _psampleOffsetVec = NULL;
                            _success = false;
                            _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
                            return;
                        }

                        for (uint32 idx = 0; idx < _stbl_buff_size; idx++)  //initialization
                        {
                            _psampleCountVec[idx] = 0;
                            _psampleOffsetVec[idx] = 0;
                        }

                        OsclAny* ptr = (MP4_FF_FILE *)(oscl_malloc(sizeof(MP4_FF_FILE)));
                        if (ptr == NULL)
                        {
                            _success = false;
                            _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
                            return;
                        }

                        _fileptr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE());
                        _fileptr->_fileServSession = fp->_fileServSession;
                        _fileptr->_pvfile.SetCPM(fp->_pvfile.GetCPM());
                        _fileptr->_pvfile.SetFileHandle(fp->_pvfile.iFileHandle);
                        if (AtomUtils::OpenMP4File(filename,
                                                   Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
                                                   _fileptr) != 0)
                        {
                            _success = false;
                            _mp4ErrorCode = FILE_OPEN_FAILED;
                        }

                        _fileptr->_fileSize = fp->_fileSize;

                        int32 _head_offset = AtomUtils::getCurrentFilePosition(fp);
                        AtomUtils::seekFromCurrPos(fp, dataSize);
                        AtomUtils::seekFromStart(_fileptr, _head_offset);

                        return;
                    }
                    else
                    {
                        _parsing_mode = 0;
                        _stbl_buff_size = _entryCount;
                    }
                }
                else
                {
                    _stbl_buff_size = _entryCount;
                }

                PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleCountVec);
                if (_psampleCountVec == NULL)
                {
                    _success = false;
                    _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
                    return;
                }

                PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleOffsetVec);
                if (_psampleOffsetVec == NULL)
                {
                    PV_MP4_ARRAY_DELETE(NULL, _psampleOffsetVec);
                    _psampleOffsetVec = NULL;
                    _success = false;
                    _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
                    return;
                }

                for (uint32 idx = 0; idx < _entryCount; idx++)  //initialization
                {
                    _psampleCountVec[idx] = 0;
                    _psampleOffsetVec[idx] = 0;
                }

                uint32 number = 0;
                uint32 offset = 0;
                for (_parsed_entry_cnt = 0; _parsed_entry_cnt < _entryCount; _parsed_entry_cnt++)
                {
                    if (!AtomUtils::read32(fp, number))
                    {
                        _success = false;
                        break;
                    }
                    if (!AtomUtils::read32(fp, offset))
                    {
                        _success = false;
                        break;
                    }
                    _psampleCountVec[_parsed_entry_cnt] = (number);
                    _psampleOffsetVec[_parsed_entry_cnt] = (offset);
                }
            }
        }

        if (!_success)
        {
            _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED;
        }
    }
    else
    {
        if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
            _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED;
    }
}
예제 #26
0
// -----------------------------------------------------------------------------
// CDRMEventHandler::RegisterEventObserverL
// Adds the new handler to the list of handlers.
// Checks is the handler is already in the list
// Sets the active object active if it is not active yet.
// -----------------------------------------------------------------------------
//
void CDRMEventHandler::RegisterEventObserverL(
    MDRMEventObserver& aObserver,
    const TDRMEventType& aEvent,
    const TDesC8& aContentID )
    {
    TInt count = 0;
    TBool addToServer = ETrue;

    if( iIsDelayed )
        {
        TDelayedObserverData* delayData = new (ELeave) TDelayedObserverData;
        CleanupStack::PushL( delayData);
        delayData->iRequest = KRegisterURIOperation;
        delayData->iObserver = &aObserver;
        delayData->iEventType = aEvent;
        delayData->iContentID = aContentID.AllocLC();
        iDelayedObservers->AppendL( delayData );
        CleanupStack::Pop();    // iContentID;
        CleanupStack::Pop();    // delayData;
        return;
        }

    switch ( aEvent )
        {
        case KEventAddRemove:
            if ( iAddRemoveObservers )
                {
                for ( count = 0; count < iAddRemoveObservers->Count(); ++count )
                    {
                    if ( ( *iAddRemoveObservers )[ count ]->iObserver == &aObserver &&
                         ( *iAddRemoveObservers )[ count ]->iContentID &&
                         !( *iAddRemoveObservers )[ count ]->iContentID->Compare( aContentID ) )
                        {
                        return;
                        }
                    else if( addToServer && 
                        !( *iAddRemoveObservers)[ count ]->iContentID->Compare( aContentID ) ) 
                        {
                        addToServer = EFalse;
                        }
                    }
                }
            break;
        case KEventModify:
            if ( iModifyObservers )
                {
                for ( count = 0; count < iModifyObservers->Count(); ++count )
                    {
                    if ( ( *iModifyObservers )[ count ]->iObserver == &aObserver &&
                         ( *iModifyObservers )[ count ]->iContentID &&
                         !( *iModifyObservers )[ count ]->iContentID->Compare( aContentID ) )
                        {
                        return;
                        }
                    else if( addToServer && 
                        !( *iModifyObservers)[ count ]->iContentID->Compare( aContentID ) ) 
                        {
                        addToServer = EFalse;
                        }
                    }
                }
            break;
        default:
            User::Leave(KErrArgument);
            break;
        }  

    HBufC8* contentID = aContentID.AllocLC();
    struct TObserverData* observer = new (ELeave) TObserverData;
    CleanupStack::PushL(observer);

    observer->iObserver = &aObserver;
    observer->iContentID = contentID;

    switch( aEvent )
        {
        case KEventAddRemove:
            if( this->iAddRemoveObservers ) // coverity check
                {
                iAddRemoveObservers->AppendL( observer );
                }
            break;
        case KEventModify:
            if( this->iModifyObservers ) // coverity check
                {
                iModifyObservers->AppendL( observer );
                }
            break;
        default:
            User::Leave(KErrArgument);
            break;
        }
   
    if ( !IsAdded() )
        {
        CActiveScheduler::Add( this );
        }

    if ( !IsActive() )
        {
        if( iStatus != KRequestPending )
            {
            iStatus = KRequestPending;
            iHandler->WaitForCompletion(iStatus);
            }
        SetActive();
        }

    // Register the type to the server
    if ( addToServer )
        {
        iHandler->RegisterForType(aEvent,contentID);
        }

    CleanupStack::Pop(); // contentID
    CleanupStack::Pop(); // observer;
    }
int32 OsclSocketServI::StartServImp()
{
#if(PV_SOCKET_SERVER_IS_THREAD)

    //setup the loopback socket and/or polling interval.
    iLoopbackSocket.iEnable = false;
    iSelectPollIntervalMsec = 0;

    //check the select timeout in the configuration.
    int32 selectTimeoutMsec = PV_SOCKET_SERVER_SELECT_TIMEOUT_MSEC;
    if (selectTimeoutMsec <= 0)
    {
        //non-polling option selected.
        //create the select cancel pipe.
        iLoopbackSocket.Init(this);

        //if loopback socket isn't available, we must poll.
        if (!iLoopbackSocket.iEnable)
            iSelectPollIntervalMsec = 10;
    }
    else
    {
        //polling option selected.
        iSelectPollIntervalMsec = selectTimeoutMsec;
#if(PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET)
        //create the loopback socket.
        iLoopbackSocket.Init(this);
#endif
    }

    //Start the server thread.
    OsclThread thread;
    OsclProcStatus::eOsclProcError err = thread.Create((TOsclThreadFuncPtr)sockthreadmain,
                                         1024,
                                         (TOsclThreadFuncArg)this);
    if (err != OsclErrNone)
        return OsclErrGeneral;

    thread.SetPriority(PV_SOCKET_SERVER_THREAD_PRIORITY);

    //wait til thread starts
    iStart.Wait();

    return OsclErrNone;

#else//PV_SOCKET_SERVER_IS_THREAD

    //Socket server AO startup.

    iLoopbackSocket.iEnable = false;

    ServerEntry();

    if (!IsAdded())
    {
        AddToScheduler();
    }
    return OsclErrNone;

#endif //PV_SOCKET_SERVER_IS_THREAD
}