// ----------------------------------------------------------------------------- // CAMMSPriorityControl::StateChanged // Called when player state is changed. // ----------------------------------------------------------------------------- void CAMMSPriorityControl::StateChanged(TInt aState) { LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSPriorityControl::StateChanged +, state = %d", aState); // If the state was changed to PREFETCHED, set the buffered priority to // MMF. Set a new priority only if it differs from the previous one. if ((aState == CMMAPlayer::EPrefetched) && (iActualPriority != iVisiblePriority)) { TRAPD(err, SetPriorityToMmfL(iVisiblePriority)); ELOG1( EJavaAMMS, "AMMS::CAMMSPriorityControl::StateChanged, err = %d", err); if (err != KErrNone) { TBuf<KErrorMessageSize> errorMessage; errorMessage.Format(KErrPriorityError, err); iPlayer->PostStringEvent(CMMAPlayerEvent::EError, errorMessage); } } LOG( EJavaAMMS, EInfo, "AMMS::CAMMSPriorityControl::StateChanged -"); }
// --------------------------------------------------------------------------- // CMMACameraWindow::UIStartViewFinder // Creates UI Camera. // This CCamera instance is duplicated from handle given to the constructor. // Have to be called from the thread which UI Camera will be controlled from. // --------------------------------------------------------------------------- // void CMMACameraWindow::UIStartViewFinder( RWsSession &aWs, CWsScreenDevice &aScreenDevice, RWindowBase &aWindow) { LOG(EJavaMMAPI,EInfo,"MMA::CMMACameraWindow::UIStartViewFinder"); iWs = &aWs; iScreenDevice = &aScreenDevice; iWindow = &aWindow; if (!iUICamera) { TRAPD(error, iUICamera = CCamera::NewDuplicateL(*this, iCameraHandle)); ELOG1(EJavaMMAPI, "MMA::CMMACameraWindow::UIStartViewFinder - NewDuplicateL %d", error); if (error == KErrNone) { iUICamera->Reserve(); } } }
int main(int argc, char **argv[]) { JELOG2(EJavaSystemAMS); CTrapCleanup* cleanupStack = CTrapCleanup::New(); // Pass 'iad' argument if it has been given TInt err(KErrNone); TBool iadStart(EFalse); for (TInt nInd = 0; nInd < argc; nInd++) { char **tmp = argv[nInd]; char *curArg = (char *)tmp; if (!strcmp(curArg, "iad")) { iadStart = ETrue; } } if (iadStart) { LOG(EJavaSystemAMS, EInfo, "systemams.exe started with iad param"); } else { LOG(EJavaSystemAMS, EInfo, "systemams.exe started without iad param"); } TRAP(err, CSystemAMSTrader::StartL(iadStart)); if (KErrNone != err) { ELOG1(EJavaSystemAMS, "systemams.exe: StartL leaved with error %d", err); } delete cleanupStack; }
// --------------------------------------------------------------------------- // From class MCameraObserver // CMMACameraWindow::PowerOnComplete // // --------------------------------------------------------------------------- // void CMMACameraWindow::PowerOnComplete(TInt aError) { ELOG1(EJavaMMAPI, "MMA::CMMACameraWindow::PowerOnComplete %d", aError); if (aError == KErrNone) { iCameraPowerOn = ETrue; SetViewFinderVisibility(ETrue); } }
// CommsListener void Test2Runtime::processMessage(CommsMessage& aMessage) { JELOG4(EJavaCaptain, EInfoHeavyLoad); switch (aMessage.getMessageId()) { default: ELOG1(EJavaCaptain, "Unknown message forwarded to Test2Runtime %d", aMessage.getMessageId()); } }
/** * Reset the SID */ void MOS6581::Reset(void) { for (int i=0; i<32; i++) regs[i] = 0; last_sid_byte = 0; // Reset the renderer if (the_renderer != NULL) the_renderer->Reset(); ELOG1(_L8("SID reset\n")); }
void CMMAMMFPlayerBase::StopL(TBool aPostEvent) { if (iState == EStarted) { TInt64 time; GetMediaTime(&time); iStartedEventTime = time; TInt err = KErrNone; // AAC controller does not support multiple // calls to pause but leave with KErrNotReady. // That error is dismissed as player should // be paused already in that case. if (time == 0) { LOG(EJavaMMAPI, EInfo, "CMMAMMFPlayerBase::StopL: Position is zero, stopping"); // Normally pause would be called, but if // current time is zero, Stop is called instead. // This is done because video playback breaks // if pause is called between events // KMMFEventCategoryVideoLoadingStarted and // KMMFEventCategoryVideoLoadingCompleted // (no wurther events are delivered altough // playback continues fine). // However calling Stop is tolerated in that // situation. err = iController.Stop(); if (err == KErrNone) { err = iController.Prime(); } } else { LOG(EJavaMMAPI, EInfo, "CMMAMMFPlayerBase::StopL: Position not zero, pausing"); err = iController.Pause(); } if ((err != KErrNone) && (err != KErrNotReady)) { ELOG1(EJavaMMAPI, "CMMAMMFPlayerBase::StopL: pause/stop failed %d, leaving", err); User::Leave(err); } if (aPostEvent) { PostLongEvent(CMMAPlayerEvent::EStopped, time); } // go back to prefetched state ChangeState(EPrefetched); } }
/* * Class: com_nokia_mj_impl_media_AudioOutputControl * Method: _setAudioOutputObject * Signature: (IILjava/lang/Object;)I */ JNIEXPORT jint JNICALL Java_com_nokia_mid_impl_media_AudioOutputControl__1setAudioOutputObject (JNIEnv *jni, jclass, jint aEventSource, jint aControl, jobject audioOutputObj) { MMAFunctionServer* eventSource = reinterpret_cast< MMAFunctionServer* >(aEventSource); CAMMSAudioOutputControl* control = static_cast< CAMMSAudioOutputControl* >( reinterpret_cast< CAMMSControl* >(aControl)); __ASSERT_DEBUG(control, User::Invariant()); jobject obj = jni->NewWeakGlobalRef(audioOutputObj); TInt err = eventSource->ExecuteTrap(SetJavaAudioOutputObj,control ,obj); ELOG1( EJavaAMMS, "AMMS::AudioOutputControl_JNI::setAudioOutputObject = %d", err); return err; }
void CMMAVideoPlayer::PrepareDisplay() { LOG(EJavaMMAPI, EInfo, "CMMAVideoPlayer::PrepareDisplay +"); // construction should have leaved if iSurfaceWindow does not exist __ASSERT_DEBUG(iSurfaceWindow, User::Panic(_L("CMMVideoPlayer::iSurfaceWindow is null"), KErrArgument)); //First place where we are certain that source size can be fetched TSize sourceSize; TInt err = iVideoControllerCustomCommands.GetVideoFrameSize(sourceSize); ELOG1(EJavaMMAPI, "MID::CMMAVideoPlayer::PrepareDisplay: GetVideoFrameSize err = %d", err); // Still we did not get the size of video if ((err != KErrNone) || (sourceSize.iWidth <= 0) || (sourceSize.iHeight <= 0)) { LOG(EJavaMMAPI, EInfo, "MID::CMMAVideoPlayer::PrepareDisplay: No sourcesize found, using SurfaceWindow size"); // setting size to window size (client rect) sourceSize = iSurfaceWindow->WindowSize(); } // If 1x1 was got (the default size of form), it must be replaced // with a valid size as controller will not accept 1x1. if ((sourceSize.iWidth < KMMAVideoMinDimension) || (sourceSize.iHeight < KMMAVideoMinDimension)) { LOG(EJavaMMAPI, EInfo, "MID::CMMAVideoPlayer::PrepareDisplay: Unacceptable source size, using failsafe"); // This is a special case and ought to be used only in // the rare case that real size is not got from stream. sourceSize = TSize(KMMAVideoMinDimension, KMMAVideoMinDimension); } iSourceSize = sourceSize; // If init has been already done if (iDisplay) { LOG(EJavaMMAPI, EInfo, "MID::CMMAVideoPlayer::PrepareDisplay: display exists, changing source size"); SourceSizeChanged(); } // Setting (in)visible if something has changed the DSA state // (e.g. prepare). If initDisplayMode is not called, this will always // set visibility to false. iSurfaceWindow->SetVisible(iSurfaceWindow->IsVisible(), EFalse); LOG(EJavaMMAPI, EInfo, "CMMAVideoPlayer::PrepareDisplay -"); }
// ----------------------------------------------------------------------------- // CAMMSEMCReverbEnvironmentalPresetUtility::PrepareEmptyReverbUtilitiesL // Creates utilities that can be used to obtain preset names and preset data. // (other items were commented in a header). // ----------------------------------------------------------------------------- TInt CAMMSEMCReverbEnvironmentalPresetUtility::PrepareEmptyReverbUtilitiesL() { LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCReverbEnvironmentalPresetUtility::PrepareEmptyReverbUtilitiesL +"); //Calling base class function to create and initialize the CMMFDevSound TInt err = CreateAndInitializeDevSoundL(); ELOG1( EJavaAMMS, "AMMS::CAMMSEMCReverbEnvironmentalPresetUtility::PrepareEmptyReverbUtilitiesL err = %d",err); if (!iEmptyEnvironmentalReverbUtility && (err == KErrNone)) { iEmptyEnvironmentalReverbUtility = CEnvironmentalReverbUtility::NewL(*iMMFDevSound); } LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCReverbEnvironmentalPresetUtility::PrepareEmptyReverbUtilitiesL -"); return err; }
JNIEXPORT jint JNICALL Java_com_nokia_mid_impl_media_AudioOutputControl__1getCurrent( JNIEnv*, jclass, jint aEventSource, jint aControl) { MMAFunctionServer* eventSource = reinterpret_cast< MMAFunctionServer* >(aEventSource); CAMMSAudioOutputControl* control = static_cast< CAMMSAudioOutputControl* >( reinterpret_cast< CAMMSControl* >(aControl)); __ASSERT_DEBUG(control, User::Invariant()); TInt err = eventSource->ExecuteTrap(GetCurrent, control); ELOG1( EJavaAMMS, "AMMS::AudioOutputControl_JNI::getCurrent = %d", err); return err; }
/* * Class: Java_com_nokia_mj_impl_media_AudioOutputControl * Method: _setOutputMode * */ JNIEXPORT jint JNICALL Java_com_nokia_mid_impl_media_AudioOutputControl__1setOutputMode( JNIEnv*, jclass, jint aEventSource, jint aControl, jint aPreference) { MMAFunctionServer* eventSource = reinterpret_cast< MMAFunctionServer* >(aEventSource); CAMMSAudioOutputControl* control = static_cast< CAMMSAudioOutputControl* >( reinterpret_cast< CAMMSControl* >(aControl)); __ASSERT_DEBUG(control, User::Invariant()); TInt error = eventSource->Execute( &SetPreference, control, (TInt) aPreference); ELOG1( EJavaAMMS, "AMMS::AudioOutputControl_JNI::setOutputMode = %d", error); return error; }
void CMMAVideoPlayer::CompletePrefetch(TInt aError) { ELOG1(EJavaMMAPI, "CMMAVideoPlayer::CompletePrefetch + error = %d",aError); // Post KNotCompleteVideoError as KErrNone to the Java side, because // video can be played. if (aError == KNotCompleteVideoError) { LOG(EJavaMMAPI, EInfo, "CMMAVideoPlayer::CompletePrefetch KNotCompleteVideoError "); // release java PostActionCompleted(KErrNone); } else { LOG(EJavaMMAPI, EInfo, "CMMAVideoPlayer::CompletePrefetch CompleteVideoError "); // release java PostActionCompleted(aError); } if (aError == KErrNone || aError == KNotCompleteVideoError) { ChangeState(EPrefetched); } LOG(EJavaMMAPI, EInfo, "CMMAVideoPlayer::CompletePrefetch - "); }
// --------------------------------------------------------------------------- // CMMACameraWindow::SetViewFinderVisibility // If UI Camera have been created, it starts/hides the DirectViewFinder. // Have to be called from UI thread in which iUICamera instance was created. // --------------------------------------------------------------------------- // void CMMACameraWindow::SetViewFinderVisibility(TBool aVisible) { LOG1(EJavaMMAPI, EInfo, "MMA::CMMACameraWindow::SetViewFinderVisibility - %d", aVisible); if (!iUICamera || !iCameraPowerOn || iViewFinderVisible == aVisible) { return; } if (aVisible) { // Viewfinder is going to start if (!iVisible || !iStarted) { return; } iViewFinderVisible = ETrue; if (!iStarterTimer) { // If starter timer haven't been created yet, create an instance TRAPD( timerErr, iStarterTimer = CPeriodic::NewL(CActive::EPriorityIdle)); if (timerErr != KErrNone) { ELOG1(EJavaMMAPI, "MMA::CMMACameraWindow::SetViewFinderVisibility - timer error = %d", timerErr); __ASSERT_DEBUG(EFalse, User::Invariant()); } } if (!iStarterTimer->IsActive()) { iStarterTimer->Start( KStarterTimeout, 0, TCallBack(StarterTimerCallback, this)); } } else { // Viewfinder is going to be cancelled LOG(EJavaMMAPI,EInfo, "MMA::CMMACameraWindow::SetViewFinderVisibility - Stopping VF"); if (iStarterTimer && iStarterTimer->IsActive()) { // Cancel the running starter timer iStarterTimer->Cancel(); } if (iUICamera->ViewFinderActive()) { iUICamera->StopViewFinder(); } if (iDirectAccess->IsActive()) { iDirectAccess->Cancel(); } iViewFinderVisible = EFalse; } }
void CMMAVideoPlayer::HandleEvent(const TMMFEvent& aEvent) { LOG1(EJavaMMAPI, EInfo, "MMA:CMMAVideoPlayer::HandleEvent %d", aEvent.iEventType.iUid); // event KMMFEventCategoryPlaybackComplete is handled by both Video // and Audio players. first it should be handled by Video player if (aEvent.iEventType == KMMFEventCategoryPlaybackComplete) { iSurfaceWindow->RemoveSurface(); } // KNotCompleteVideoError can be notified when video is not complete // ( missing sound ) but still can be played. Because // CMMAAudioPlayer::HandleEvent fails with all negative error codes, // do not call it with KNotCompleteVideoError error when preparing. if ((aEvent.iErrorCode != KNotCompleteVideoError) || (aEvent.iEventType != KMMFEventCategoryVideoPrepareComplete)) { CMMAAudioPlayer::HandleEvent(aEvent); } if (aEvent.iEventType == KMMFEventCategoryVideoSurfaceCreated) { if (aEvent.iErrorCode == KErrNone) { TSurfaceId surfaceId; TRect cropRect; TVideoAspectRatio pixelAspectRatio; iVideoPlaySurfaceSupportCustomCommands.GetSurfaceParameters(surfaceId, cropRect, pixelAspectRatio); if (iMMASurface.iPrevSurfaceAvailable) { // free Surface TInt error = iVideoPlaySurfaceSupportCustomCommands.SurfaceRemoved(iMMASurface.iPrevSurfaceId); if (KErrNone != error) { ELOG1(EJavaMMAPI, "CMMAVideoPlayer::HandleEvent:SurfaceRemoved error, %d", aEvent.iErrorCode); } } iMMASurface.iPrevSurfaceId = surfaceId; iMMASurface.iPrevSurfaceAvailable = ETrue; iSurfaceWindow->SetSurfaceParameters(surfaceId, cropRect, pixelAspectRatio); LOG(EJavaMMAPI, EInfo, "CMMAVideoPlayer::HandleEvent: KMMFEventCategoryVideoSurfaceCreated, surface parameters set"); } else { ELOG1(EJavaMMAPI, "CMMAVideoPlayer::HandleEvent: error getting surface parameters, %d", aEvent.iErrorCode); } } else if (aEvent.iEventType == KMMFEventCategoryVideoSurfaceParametersChanged) { if (aEvent.iErrorCode == KErrNone) { TSurfaceId surfaceId; TRect cropRect; TVideoAspectRatio pixelAspectRatio; iVideoPlaySurfaceSupportCustomCommands.GetSurfaceParameters(surfaceId, cropRect, pixelAspectRatio); if (iMMASurface.iPrevSurfaceAvailable) { // free Surface TInt error = iVideoPlaySurfaceSupportCustomCommands.SurfaceRemoved(iMMASurface.iPrevSurfaceId); if (KErrNone != error) { LOG1(EJavaMMAPI, EInfo, "CMMAVideoPlayer::HandleEvent:SurfaceRemoved error, %d", aEvent.iErrorCode); } } iMMASurface.iPrevSurfaceAvailable = ETrue; iMMASurface.iPrevSurfaceId = surfaceId; iSurfaceWindow->SetChangedSurfaceParameters(surfaceId, cropRect, pixelAspectRatio); LOG(EJavaMMAPI, EInfo, "CMMAVideoPlayer::HandleEvent: KMMFEventCategoryVideoSurfaceParametersChanged"); } else { ELOG1(EJavaMMAPI, "CMMAVideoPlayer::HandleEvent: surface parameters changed error, %d", aEvent.iErrorCode); } } else if (aEvent.iEventType == KMMFEventCategoryVideoRemoveSurface) { if (aEvent.iErrorCode == KErrNone) { if (iMMASurface.iPrevSurfaceAvailable) { // free Surface TInt error = iVideoPlaySurfaceSupportCustomCommands.SurfaceRemoved(iMMASurface.iPrevSurfaceId); if (KErrNone != error) { ELOG1(EJavaMMAPI, "CMMAVideoPlayer::HandleEvent:SurfaceRemoved error, %d", aEvent.iErrorCode); } iMMASurface.iPrevSurfaceAvailable = EFalse; } } else { ELOG1(EJavaMMAPI, "CMMAVideoPlayer::HandleEvent:KMMFEventCategoryVideoRemoveSurface error, %d", aEvent.iErrorCode); } } // video opened, preparing else if (aEvent.iEventType == KMMFEventCategoryVideoOpenComplete) { if (aEvent.iErrorCode == KErrNone) { TInt error = iVideoPlaySurfaceSupportCustomCommands.UseSurfaces(); ELOG1(EJavaMMAPI, "MMA::CMMAVideoPlayer::HandleEvent::After UseSurfaces(), error = %d", error); TInt prepareError(iVideoPlayControllerCustomCommands.Prepare()); if (prepareError != KErrNone) { // opening failed, notifying java PostActionCompleted(prepareError); } } else { // opening failed, notifying java PostActionCompleted(aEvent.iErrorCode); } } // final state of prefetch ( prepare completed ) else if (aEvent.iEventType == KMMFEventCategoryVideoPrepareComplete) { // This callback must be handled differently depending on whether // player is created for a file locator or for a stream. When file // locator is used, this callback is made in realized state. For // stream it is made in prefetched state. PrepareDisplay(); if (iFileName) { LOG(EJavaMMAPI, EInfo, "CMMAVideoPlayer::HandleEvent: Using filename, change state to REALIZED"); // If there is an error condition, then the player state is not // changed, which indicates the error condition to StartL when // the ActiveSchedulerWait returns. KNotCompleteVideoError is not // considered as an error condition, instead it indicates that some // elements of the media cannot be played (e.g. video OR audio) if (aEvent.iErrorCode == KErrNone || aEvent.iErrorCode == KNotCompleteVideoError) { ChangeState(ERealized); } __ASSERT_DEBUG(iActiveSchedulerWait->IsStarted(), User::Invariant()); iActiveSchedulerWait->AsyncStop(); } else { LOG(EJavaMMAPI, EInfo, "CMMAVideoPlayer::HandleEvent: Not using filename, change state to PREFETCHED"); CompletePrefetch(aEvent.iErrorCode); } } else // in case of any other event { if (aEvent.iErrorCode != KErrNone) { PostActionCompleted(aEvent.iErrorCode); //some other error } } }
void CMMAMMFPlayerBase::SetMediaTimeL(TInt64* aTime) { LOG(EJavaMMAPI, EInfo, "CMMAMMFPlayerBase::SetMediaTimeL"); // Negative values are not checked here // because it's done already in Java side. // Get clip duration TTimeIntervalMicroSeconds duration; User::LeaveIfError(iController.GetDuration(duration)); LOG1(EJavaMMAPI, EInfo, "CMMAMMFPlayerBase::SetMediaTimeL iController.GetDuration=%d", duration.Int64()); TTimeIntervalMicroSeconds position; // If the desired media time is beyond the duration, // the time is set to the end of the media. if (*aTime > duration.Int64()) { position = duration; } else { position = *aTime; } TBool paused = EFalse; TInt err = KErrNone; if (iState == EStarted) { paused = ETrue; User::LeaveIfError(err = iController.Pause()); ELOG1(EJavaMMAPI, "CMMAMMFPlayerBase::SetMediaTimeL after iController.Pause = %d", err); } if (err == KErrNone) { // The controller must be in the PRIMED or PLAYING state User::LeaveIfError(err = iController.SetPosition(position)); ELOG1(EJavaMMAPI, "CMMAMMFPlayerBase::SetMediaTimeL iController.SetPosition() = %d", err); } // Reset cached media time, because actual set position may be // something else than aTime. iMediaTime = KTimeUnknown; // Inform about the position change to the StateListeners ChangeState(iState); // Get the actual media time GetMediaTime(aTime); iStartedEventTime = iMediaTime; if (err == KErrNone) { if (paused == (TBool)ETrue) { User::LeaveIfError(err = iController.Play()); ELOG1(EJavaMMAPI, "CMMAMMFPlayerBase::SetMediaTimeL iController.Play() = %d", err); } } if (err != KErrNone) { User::Leave(err); } }