Esempio n. 1
0
void XAPlaySessionImpl::setAspectRatioMode(Qt::AspectRatioMode aspectRatioMode)
{
    if( !mbScalable ||
            (mCurrAspectRatioMode == aspectRatioMode)) {
        return;
    }

    XAuint32 scaleOptions;;
    XAuint32 backgrndColor = 1;
    XAuint32 renderingHints = 1;

    switch(aspectRatioMode) {
    case Qt::IgnoreAspectRatio:
        scaleOptions = XA_VIDEOSCALE_STRETCH;
        break;
    case Qt::KeepAspectRatio:
        scaleOptions = XA_VIDEOSCALE_FIT;
        break;
    case Qt::KeepAspectRatioByExpanding:
        scaleOptions = XA_VIDEOSCALE_CROP;
        break;
    default:
        return;
    }

    XAresult xaRes = (*mVideoPostProcessingItf)->SetScaleOptions(mVideoPostProcessingItf, \
                     scaleOptions, backgrndColor, renderingHints);
    if(mapError(xaRes, ETrue) == KErrNone)
        xaRes = (*mVideoPostProcessingItf)->Commit(mVideoPostProcessingItf);

    if(mapError(xaRes, ETrue) == KErrNone)
        mCurrAspectRatioMode = aspectRatioMode;
}
Esempio n. 2
0
TInt XAPlaySessionImpl::stop()
{
    TInt retVal(KErrGeneral);
    XAresult xaRes;
    XAuint32 state;

#ifdef USE_VIDEOPLAYERUTILITY
    mVideoPlayUtil->Stop();
    return 0;
#endif

    if (!mMOPlayer || !mPlayItf)
        return retVal;

    xaRes = (*mPlayItf)->GetPlayState(mPlayItf, &state);
    retVal = mapError(xaRes, ETrue);
    RET_ERR_IF_ERR(retVal);

    if ((state == XA_PLAYSTATE_PAUSED) ||
            (state == XA_PLAYSTATE_PLAYING)) {
        xaRes = (*mPlayItf)->SetPlayState(mPlayItf, XA_PLAYSTATE_STOPPED);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);
        mCurPosition += KPlayPosUpdatePeriod;
        mParent.cbPositionChanged(mCurPosition);
    }

    return retVal;
}
Esempio n. 3
0
TInt XAPlaySessionImpl::pause()
{
    TInt retVal(KErrGeneral);
    XAresult xaRes;
    XAuint32 state;

#ifdef USE_VIDEOPLAYERUTILITY
    TRAPD(err, mVideoPlayUtil->PauseL());
    return 0;
#endif

    if (!mMOPlayer || !mPlayItf)
        return retVal;

    xaRes = (*mPlayItf)->GetPlayState(mPlayItf, &state);
    retVal = mapError(xaRes, ETrue);
    RET_ERR_IF_ERR(retVal);

    if ((state == XA_PLAYSTATE_STOPPED) ||
            (state == XA_PLAYSTATE_PLAYING)) {
        xaRes = (*mPlayItf)->SetPlayState(mPlayItf, XA_PLAYSTATE_PAUSED);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);
    }

    return retVal;
}
Esempio n. 4
0
TInt XAPlaySessionImpl::postConstruct()
{
    TInt retVal;
    XAresult xaRes;
    XAEngineOption engineOption[] = {     (XAuint32) XA_ENGINEOPTION_THREADSAFE,
                                          (XAuint32) XA_BOOLEAN_TRUE
                                    };
    XAEngineItf engineItf;

    mNativeDisplay.locatorType = XA_DATALOCATOR_NATIVEDISPLAY;
    mNativeDisplay.hWindow = NULL;
    mNativeDisplay.hDisplay = NULL;
    mVideoSink.pLocator = (void*)&mNativeDisplay;
    mVideoSink.pFormat = NULL;

    // Create and realize Engine object
    xaRes = xaCreateEngine (&mEOEngine, 1, engineOption, 0, NULL, NULL);
    retVal = mapError(xaRes, ETrue);
    RET_ERR_IF_ERR(retVal);
    xaRes = (*mEOEngine)->Realize(mEOEngine, XA_BOOLEAN_FALSE);
    retVal = mapError(xaRes, ETrue);
    RET_ERR_IF_ERR(retVal);

    // Create and realize Output Mix object to be used by player
    xaRes = (*mEOEngine)->GetInterface(mEOEngine, XA_IID_ENGINE, (void**) &engineItf);
    retVal = mapError(xaRes, ETrue);
    RET_ERR_IF_ERR(retVal);

    TRAP(retVal, mWAVMime = HBufC8::NewL(K8WAVMIMETYPE().Length() + 1));
    RET_ERR_IF_ERR(retVal);
    TPtr8 ptr = mWAVMime->Des();
    ptr = K8WAVMIMETYPE(); // copy uri name into local variable
    ptr.PtrZ(); // append zero terminator to end of URI

#ifdef USE_VIDEOPLAYERUTILITY
    TRAP(retVal, mVideoPlayUtil =
             CVideoPlayerUtility2::NewL( *this,
                                         EMdaPriorityNormal,
                                         EMdaPriorityPreferenceTimeAndQuality)
        );
    mActiveSchedulerWait = new CActiveSchedulerWait;
#endif

    return retVal;
}
Esempio n. 5
0
TInt XAPlaySessionImpl::setVolume(TInt v)
{
    if(mbVolEnabled) {
        XAresult res = (*mNokiaLinearVolumeItf)->SetVolumeLevel(mNokiaLinearVolumeItf, (XAuint32*)&v);
        return mapError(res, ETrue);
    }

    return KErrNotFound;
}
Esempio n. 6
0
TInt XAPlaySessionImpl::setMute(TBool bMute)
{
    if(mbMuteEnabled) {
        XAresult res = (*mNokiaVolumeExtItf)->SetMute(mNokiaVolumeExtItf, (XAboolean)bMute);
        return mapError(res, ETrue);
    }

    return KErrNotFound;

}
Esempio n. 7
0
TInt XAPlaySessionImpl::getMute(TBool& bIsMute)
{
    if(mbMuteEnabled) {
        XAboolean xaMute;
        XAresult res = (*mNokiaVolumeExtItf)->GetMute(mNokiaVolumeExtItf, &xaMute);
        bIsMute = xaMute;
        return mapError(res, ETrue);
    }

    return KErrNotFound;
}
Esempio n. 8
0
TInt XAPlaySessionImpl::setupMetaData()
{
    XAresult res;
    if(mMetadataExtItf) {
        XAuint32 numItems = 0;
        res = (*mMetadataExtItf)->GetItemCount(mMetadataExtItf, &numItems);
        RET_ERR_IF_ERR(mapError(res, ETrue));

        for(int i=0; i<numItems; ++i) {
            XAuint32 keySize;
            res = (*mMetadataExtItf)->GetKeySize(mMetadataExtItf, i, &keySize);
            RET_ERR_IF_ERR(mapError(res, ETrue));

            XAMetadataInfo *key = (XAMetadataInfo *)calloc(keySize,1);
            if(key) {
                res = (*mMetadataExtItf)->GetKey(mMetadataExtItf, i, keySize, key);
                RET_ERR_IF_ERR(mapError(res, ETrue));

                if(key->encoding == XA_CHARACTERENCODING_ASCII) { //only handle ASCII keys ignore others
                    QtMultimediaKit::MetaData qtKey;
                    if(mapMetaDataKey((const char*)key->data, qtKey) == KErrNone)//qt metadata
                        keyMap[qtKey] = i;
                    else //extended metadata
                        extendedKeyMap[(const char*)key->data] = i;
                }

                free(key);
            }
        }

        //check for seek property to generate seekable signal
        QVariant var = extendedMetaData("Seekable");
        if(!var.isValid() || (var.toString() == "1"))
            mParent.cbSeekableChanged(ETrue);
        else
            mParent.cbSeekableChanged(EFalse);

    }

    return KErrGeneral;
}
Esempio n. 9
0
TInt XAPlaySessionImpl::streamType(TUint index, QMediaStreamsControl::StreamType& type)
{
    TInt ret = KErrNotFound;
    type = QMediaStreamsControl::UnknownStream;
    if(mbStreamInfoAvailable) {
        XAuint32 strType;
        XAresult res = (*mStreamInformationItf)->QueryStreamType(mStreamInformationItf, (XAuint32)(index+1), &strType);
        ret = mapError(res, ETrue);
        if(ret == KErrNone)
            type = mapStreamType(strType);
    }
    return ret;
}
Esempio n. 10
0
TInt XAPlaySessionImpl::numMediaStreams(TUint& numStreams)
{
    TInt ret = KErrNotFound;
    numStreams = 0;
    if(mbStreamInfoAvailable) {
        XAMediaContainerInformation mediaContainerInfo;
        XAresult res = (*mStreamInformationItf)->QueryMediaContainerInformation(mStreamInformationItf, &mediaContainerInfo);
        ret = mapError(res, ETrue);
        if(ret == KErrNone)
            numStreams = mediaContainerInfo.numStreams;
    }
    return ret;
}
Esempio n. 11
0
TInt XAPlaySessionImpl::bufferStatus(TInt &bs)
{
    TInt ret = KErrNotFound;

    if(mbPrefetchStatusChange) {
        XApermille satusPerThousand;
        XAresult res = (*mPrefetchStatusItf)->GetFillLevel(mPrefetchStatusItf, &satusPerThousand);
        ret = mapError(res, ETrue);
        if(ret == KErrNone)
            bs = satusPerThousand/10.0; //convert to parts per hundred
    }
    return ret;
}
Esempio n. 12
0
TInt XAPlaySessionImpl::seek(TInt64 pos)
{
    TInt retVal(KErrGeneral);
    XAresult xaRes;

    if (!mMOPlayer || !mSeekItf)
        return retVal;

    xaRes = (*mSeekItf)->SetPosition(mSeekItf, (XAmillisecond)pos, XA_SEEKMODE_FAST);
    retVal = mapError(xaRes, ETrue);
    RET_ERR_IF_ERR(retVal);
    mCurPosition = pos;

    return retVal;
}
Esempio n. 13
0
TInt XAPlaySessionImpl::isStreamActive(TUint index, TBool& isActive)
{
    TUint numStreams;
    TInt ret = numMediaStreams(numStreams);
    if((ret == KErrNone) && (index < numStreams)) {
        isActive = EFalse;
        if(numStreams > 0)     {
            //create array of bools
            XAboolean *activeStreams = new XAboolean[numStreams+1];
            XAresult res = (*mStreamInformationItf)->QueryActiveStreams(mStreamInformationItf, (XAuint32*)&numStreams, activeStreams);
            ret = mapError(res, ETrue);
            if(ret == KErrNone)
                isActive = activeStreams[index+1];
            delete[] activeStreams;
        }
    }
    return ret;
}
Esempio n. 14
0
void                          Map::setMap(int const x, int const y, square const square)
{
  if (x < 0 || x >= this->width || y < 0 || y >= this->height)
    throw mapError(INVALID_COORD);
  this->MapSnake[y][x] = square;
}
Esempio n. 15
0
TInt XAPlaySessionImpl::load(const TDesC& aURI)
{
    TInt retVal;
    XAresult xaRes;
    XAEngineItf engineItf;
    XADynamicSourceItf dynamicSourceItf;
    XAboolean required[MAX_NUMBER_INTERFACES];
    XAInterfaceID iidArray[MAX_NUMBER_INTERFACES];
    XAuint32 noOfInterfaces = 0;
    TInt i;

    XAmillisecond dur(0);
    TPtr8 uriPtr(0,0,0);
    TPtr8 mimeTypePtr(0,0,0);

#ifdef USE_VIDEOPLAYERUTILITY
    TRAP(m_VPError, mVideoPlayUtil->OpenFileL(_L("C:\\data\\test.3gp")));
    if (m_VPError)
        return 0;

    if(!mActiveSchedulerWait->IsStarted())
        mActiveSchedulerWait->Start();

    if (m_VPError)
        return 0;

    mVideoPlayUtil->Prepare();

    if(!mActiveSchedulerWait->IsStarted())
        mActiveSchedulerWait->Start();

    return 0;
#endif

    delete mURIName;
    mURIName = NULL;
    TRAP(retVal, mURIName = HBufC8::NewL(aURI.Length()+1));
    RET_ERR_IF_ERR(retVal);
    uriPtr.Set(mURIName->Des());

    // This has to be done here since we can not destroy the Player
    // in the Resource Lost callback.
    if (mbMediaPlayerUnrealized) {
        if (mMOPlayer) {
            (*mMOPlayer)->Destroy(mMOPlayer);
            mMOPlayer = NULL;
        }
    }

    //py uri name into local variable
    //TODO fix copy issue from 16 bit to 8 bit
    uriPtr.Copy(aURI);

    //If media player object already exists, just switch source
    //using dynamic source interface
    if (mMOPlayer && mPlayItf) {
        dynamicSourceItf = NULL;
        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_DYNAMICSOURCE, &dynamicSourceItf);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);

        //Setup the data source
        //TODO Hard coded locator type
        mUri.locatorType = XA_DATALOCATOR_URI;

        //append zero terminator to end of URI
        mUri.URI = (XAchar*) uriPtr.PtrZ();

        //TODO Hard coded locator type
        mMime.containerType = XA_CONTAINERTYPE_WAV;

        //TODO Hard coded locator type
        mMime.formatType = XA_DATAFORMAT_MIME;
        mimeTypePtr.Set(mWAVMime->Des());
        mMime.mimeType = (XAchar*)mimeTypePtr.Ptr();
        mDataSource.pFormat = (void*)&mMime;
        mDataSource.pLocator = (void*)&mUri;

        xaRes = (*dynamicSourceItf)->SetSource(dynamicSourceItf, &mDataSource);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);
    }
    else { // Create media player object

        // Setup the data source
        // TODO Hard coded locator type
        mUri.locatorType = XA_DATALOCATOR_URI;

        //append zero terminator to end of URI
        mUri.URI = (XAchar*) uriPtr.PtrZ();

        //TODO Hard coded locator type
        mMime.containerType = XA_CONTAINERTYPE_WAV;

        //TODO Hard coded locator type
        mMime.formatType = XA_DATAFORMAT_MIME;
        mimeTypePtr.Set(mWAVMime->Des());
        mMime.mimeType = (XAchar*)mimeTypePtr.Ptr();
        mDataSource.pFormat = (void*)&mMime;
        mDataSource.pLocator = (void*)&mUri;

        //Setup the audio data sink
        mLocatorOutputDevice.locatorType = XA_DATALOCATOR_IODEVICE;
        mLocatorOutputDevice.deviceType = 6;
        mAudioSink.pLocator = (void*) &mLocatorOutputDevice;
        mAudioSink.pFormat = NULL;

        //Init arrays required[] and iidArray[]
        for (i = 0; i < MAX_NUMBER_INTERFACES; i++) {
            required[i] = XA_BOOLEAN_FALSE;
            iidArray[i] = XA_IID_NULL;
        }

        noOfInterfaces = 0;
        required[noOfInterfaces] = XA_BOOLEAN_FALSE;
        iidArray[noOfInterfaces] = XA_IID_SEEK;
        noOfInterfaces++;
        required[noOfInterfaces] = XA_BOOLEAN_FALSE;
        iidArray[noOfInterfaces] = XA_IID_DYNAMICSOURCE;
        noOfInterfaces++;
        required[noOfInterfaces] = XA_BOOLEAN_FALSE;
        iidArray[noOfInterfaces] = XA_IID_METADATAEXTRACTION;
        noOfInterfaces++;
        required[noOfInterfaces] = XA_BOOLEAN_FALSE;
        iidArray[noOfInterfaces] = XA_IID_NOKIALINEARVOLUME;
        noOfInterfaces++;
        required[noOfInterfaces] = XA_BOOLEAN_FALSE;
        iidArray[noOfInterfaces] = XA_IID_NOKIAVOLUMEEXT;
        noOfInterfaces++;
        required[noOfInterfaces] = XA_BOOLEAN_FALSE;
        iidArray[noOfInterfaces] = XA_IID_PREFETCHSTATUS;
        noOfInterfaces++;
        required[noOfInterfaces] = XA_BOOLEAN_FALSE;
        iidArray[noOfInterfaces] = XA_IID_STREAMINFORMATION;
        noOfInterfaces++;
        required[noOfInterfaces] = XA_BOOLEAN_FALSE;
        iidArray[noOfInterfaces] = XA_IID_PLAYBACKRATE;
        noOfInterfaces++;
        required[noOfInterfaces] = XA_BOOLEAN_FALSE;
        iidArray[noOfInterfaces] = XA_IID_VIDEOPOSTPROCESSING;
        noOfInterfaces++;

        xaRes = (*mEOEngine)->GetInterface(mEOEngine, XA_IID_ENGINE, (void**) &engineItf);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);

        xaRes = (*engineItf)->CreateMediaPlayer(engineItf,
                                                &mMOPlayer,
                                                &mDataSource,
                                                NULL,
                                                &mAudioSink,
                                                &mVideoSink,
                                                NULL,
                                                NULL,
                                                noOfInterfaces,
                                                iidArray,
                                                required);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);

        xaRes = (*mMOPlayer)->Realize(mMOPlayer, XA_BOOLEAN_FALSE);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);

        mbMediaPlayerUnrealized = FALSE;

        xaRes = (*mMOPlayer)->RegisterCallback(mMOPlayer, MediaPlayerCallback, (void*)this);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);

        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_PLAY, &mPlayItf);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);

        xaRes = (*mPlayItf)->RegisterCallback(mPlayItf, PlayItfCallback, (void*)this);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);

        xaRes = (*mPlayItf)->SetPositionUpdatePeriod(mPlayItf, (XAmillisecond)KPlayPosUpdatePeriod);
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);

        xaRes = (*mPlayItf)->SetCallbackEventsMask(    mPlayItf,
                ( XA_PLAYEVENT_HEADATEND |
                  XA_PLAYEVENT_HEADATNEWPOS |
                  XA_PLAYEVENT_HEADMOVING )
                                                  );
        retVal = mapError(xaRes, ETrue);
        RET_ERR_IF_ERR(retVal);

        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_SEEK, &mSeekItf);
        retVal = mapError(xaRes, ETrue);

        //Metadata
        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_METADATAEXTRACTION, &mMetadataExtItf);
        if(mapError(xaRes, ETrue)==KErrNone) {
            mbMetadataAvailable = ETrue;
            setupALKeyMap(); //done only once at creation of meadia player
        }

        //volume
        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_NOKIALINEARVOLUME, &mNokiaLinearVolumeItf);
        if(mapError(xaRes, ETrue)==KErrNone)
            mbVolEnabled = ETrue;

        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_NOKIAVOLUMEEXT, &mNokiaVolumeExtItf);
        if(mapError(xaRes, ETrue)==KErrNone)
            mbMuteEnabled = ETrue;

        //buffer status
        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_PREFETCHSTATUS, &mPrefetchStatusItf);
        if(mapError(xaRes, ETrue)==KErrNone) {
            mbPrefetchStatusChange = ETrue;
            (*mPrefetchStatusItf)->RegisterCallback(mPrefetchStatusItf, PrefetchItfCallback, (void*)this);
            (*mPrefetchStatusItf)->SetCallbackEventsMask(mPrefetchStatusItf, XA_PREFETCHEVENT_FILLLEVELCHANGE);
        }

        //stream information
        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_STREAMINFORMATION, &mStreamInformationItf);
        if(mapError(xaRes, ETrue)==KErrNone) {
            mbStreamInfoAvailable = ETrue;
            mParent.cbStreamInformation(ETrue); //indicate first time
            (*mStreamInformationItf)->RegisterStreamChangeCallback(mStreamInformationItf, StreamInformationItfCallback, (void*)this);
        }

        //playback rate
        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_PLAYBACKRATE, &mPlaybackRateItf);
        if(mapError(xaRes, ETrue)==KErrNone)
            mbPlaybackRateItfAvailable = ETrue;


        //videopostprocessing
        xaRes = (*mMOPlayer)->GetInterface(mMOPlayer, XA_IID_VIDEOPOSTPROCESSING, &mVideoPostProcessingItf);
        if(mapError(xaRes, ETrue)==KErrNone)
            mbScalable = ETrue;

    }

    if(mbMetadataAvailable) {
        keyMap.clear();
        extendedKeyMap.clear();
        setupMetaData(); //done every time source is changed
    }
    else { //send signal for seekable
        mParent.cbSeekableChanged(ETrue);
    }

    mCurPosition = 0;
    mParent.cbPositionChanged(mCurPosition);

    xaRes = (*mPlayItf)->GetDuration(mPlayItf, &dur);
    retVal = mapError(xaRes, ETrue);
    RET_ERR_IF_ERR(retVal);

    mDuration = dur;
    mParent.cbDurationChanged(mDuration);

    return retVal;
}