void VideoPlayerPanel::ClearVideo() { if ( m_VideoPlaying ) { StopVideo(); } // Shut down this video, destroy the video material if ( g_pVideo != NULL && m_VideoMaterial != NULL ) { g_pVideo->DestroyVideoMaterial( m_VideoMaterial ); m_VideoMaterial = NULL; } if ( m_VideoFileName != NULL ) { delete[] m_VideoFileName; m_VideoFileName = NULL; } m_pMaterial = NULL; m_VideoLoaded = false; m_VideoPlaying = false; m_VideoPaused = false; m_nPlaybackHeight = 0; m_nPlaybackWidth = 0; m_letterBox = 0; m_flU = 0.0f; m_flV = 0.0f; m_VideoDuration = 0.0f; }
//--------------------------------------------------------------------------------------- EXPORT void CALL RomClosed(void) { #ifdef DEBUGON // _break(); #endif TRACE0("To stop video"); Ini_StoreRomOptions(&g_curRomInfo); #ifdef USING_THREAD if(videoThread) { SetEvent( threadMsg[RSPMSG_CLOSE] ); WaitForSingleObject( threadFinished, INFINITE ); for (int i = 0; i < 5; i++) { if (threadMsg[i]) CloseHandle( threadMsg[i] ); } CloseHandle( threadFinished ); CloseHandle( videoThread ); } videoThread = NULL; #else StopVideo(); #endif TRACE0("Video is stopped"); }
j_result_t CRealPlayObj::StopMedia(j_int32_t nDevid) { JoPlayerFactory->GetPlayer(m_nSocket, m_playerType.c_str())->Stop(); StopVideo(nDevid); return J_OK; }
//----------------------------------------------------------------------------- // Properly shutdown out materials //----------------------------------------------------------------------------- VideoPlayerPanel::~VideoPlayerPanel( void ) { SetParent( (vgui::Panel *) NULL ); StopVideo(); ClearVideo(); }
void ExitApp() { #ifdef TOPORT ShutoffRumble(); #endif StopVideo(); exit(0); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void VideoPlayerPanel::OnClose( void ) { StopVideo(); // enginesound->NotifyEndMoviePlayback(); vgui::surface()->RestrictPaintToSinglePanel( NULL ); SetVisible( false ); MarkForDeletion(); }
int CRealMediaObj::Clearn() { StopVideo(); if (m_pObj) { JoFilterFactory->DelFilter(m_nSocket); m_pObj = NULL; } J_OS::LOGINFO("CRealMediaObj::OnBroken socket = %d broken", m_nSocket.sock); return J_OK; }
//BOOL SwitchToThread(VOID); uint32 VideoThreadProc( LPVOID lpParameter ) { BOOL res; StartVideo(); SetEvent( threadFinished ); while(true) { switch (WaitForMultipleObjects( 5, threadMsg, FALSE, INFINITE )) { case (WAIT_OBJECT_0 + RSPMSG_PROCESSDLIST): ProcessDListStep2(); SetEvent( threadFinished ); break; case (WAIT_OBJECT_0 + RSPMSG_SWAPBUFFERS): //res = SwitchToThread(); //Sleep(1); UpdateScreenStep2(); SetEvent( threadFinished ); break; case (WAIT_OBJECT_0 + RSPMSG_CLOSE): StopVideo(); SetEvent( threadFinished ); return 1; case (WAIT_OBJECT_0 + RSPMSG_CHANGEWINDOW): ChangeWindowStep2(); SetEvent( threadFinished ); break; case (WAIT_OBJECT_0 + RSPMSG_PROCESSRDPLIST): try { RDP_DLParser_Process(); } catch (...) { ErrorMsg("Unknown Error in ProcessRDPList"); //TriggerDPInterrupt(); //TriggerSPInterrupt(); } SetEvent( threadFinished ); break; } } return 0; }
void CFlashMenuObject::StartSingleplayerGame(const char *strDifficulty) { int iDifficulty = 0; if(!strcmp(strDifficulty,"Easy")) { iDifficulty = 1; } else if(!strcmp(strDifficulty,"Normal")) { iDifficulty = 2; } else if(!strcmp(strDifficulty,"Realistic")) { iDifficulty = 3; } else if(!strcmp(strDifficulty,"Delta")) { iDifficulty = 4; } // load configuration from disk if (iDifficulty != 0) LoadDifficultyConfig(iDifficulty); if(m_pPlayerProfileManager) { IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser()); if(pProfile) { pProfile->SetAttribute("Singleplayer.LastSelectedDifficulty",(TFlowInputData)iDifficulty); IPlayerProfileManager::EProfileOperationResult result; m_pPlayerProfileManager->SaveProfile(m_pPlayerProfileManager->GetCurrentUser(), result); } } StopVideo(); m_bDestroyStartMenuPending = true; m_stateEntryMovies = eEMS_GameStart; if(m_pMusicSystem) m_pMusicSystem->EndTheme(EThemeFade_StopAtOnce, 0, true); PlaySound(ESound_MenuAmbience,false); }
int CRealMediaObj::Process(J_AsioDataBase &asioData) { int nRet = J_OK; J_CommandFilter *videoCommand = dynamic_cast<J_CommandFilter *>(m_pObj); if (videoCommand != NULL) { if (asioData.ioCall == J_AsioDataBase::j_read_e) { m_resid = videoCommand->GetResid(); switch (videoCommand->GetCommandType()) { case jo_start_real: nRet = StartVideo(); J_OS::LOGINFO("CRealMediaObj::Process StartVideo socket = %d ret = %d", m_nSocket.sock, nRet); break; case jo_stop_real: { nRet = StopVideo(); J_OS::LOGINFO("CRealMediaObj::Process StopVideo socket = %d ret = %d", m_nSocket.sock, nRet); break; } default: J_OS::LOGINFO("CRealMediaObj::Process CommandType unkown type = %d", videoCommand->GetCommandType()); break; } } else if (asioData.ioCall == J_AsioDataBase::j_write_e) { if (!m_bStart) { J_OS::LOGINFO("CRealMediaObj::Process !m_bStart socket = %d", m_nSocket.sock); return J_OK; } return OnWriteData(asioData); } } return nRet; }
//----------------------------------------------------------------------------- // Purpose: Update and draw the frame //----------------------------------------------------------------------------- void VideoPlayerPanel::Paint( void ) { BaseClass::Paint(); // Get our dimensions int xpos = 0; int ypos = 0; vgui::ipanel()->GetAbsPos( GetVPanel(), xpos, ypos ); // GetPanelPos( xpos, ypos ); int width = GetWide(); int height = GetTall(); // Are we playing the video? Do we even have a video? if ( !m_VideoLoaded || !m_VideoPlaying ) { vgui::surface()->DrawSetColor( 0, 0, 0, 255 ); vgui::surface()->DrawFilledRect( 0, 0, width, height ); return; } if ( m_VideoMaterial == NULL ) return; if ( m_VideoMaterial->Update() == false ) { StopVideo(); return; } // Black out the letterbox ares if we have them if ( m_letterBox != 0 ) { vgui::surface()->DrawSetColor( 0, 0, 0, 255 ); if ( m_letterBox == 1 ) // bars on top, bottom { int excess = ( height - m_nPlaybackHeight ); int top = excess /2; int bot = excess - top; vgui::surface()->DrawFilledRect( 0, 0, width, top ); vgui::surface()->DrawFilledRect( 0, height - bot, width, height ); } if ( m_letterBox == 2 ) // bars on left, right { int excess = ( width - m_nPlaybackWidth ); int left = excess /2; int right = excess - left; vgui::surface()->DrawFilledRect( 0, 0, left, height ); vgui::surface()->DrawFilledRect( width-right, 0, width, height ); } } // Draw the polys to draw this out CMatRenderContextPtr pRenderContext( materials ); pRenderContext->MatrixMode( MATERIAL_VIEW ); pRenderContext->PushMatrix(); pRenderContext->LoadIdentity(); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->PushMatrix(); pRenderContext->LoadIdentity(); pRenderContext->Bind( m_pMaterial, NULL ); CMeshBuilder meshBuilder; IMesh* pMesh = pRenderContext->GetDynamicMesh( true ); meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); float flLeftX = xpos; float flRightX = xpos + ( m_nPlaybackWidth-1 ); float flTopY = ypos; float flBottomY = ypos + ( m_nPlaybackHeight-1 ); // Map our UVs to cut out just the portion of the video we're interested in float flLeftU = 0.0f; float flTopV = 0.0f; // We need to subtract off a pixel to make sure we don't bleed float flRightU = m_flU - ( 1.0f / (float) m_nPlaybackWidth ); float flBottomV = m_flV - ( 1.0f / (float) m_nPlaybackHeight ); // Get the current viewport size int vx, vy, vw, vh; pRenderContext->GetViewport( vx, vy, vw, vh ); // map from screen pixel coords to -1..1 flRightX = FLerp( -1, 1, 0, vw, flRightX ); flLeftX = FLerp( -1, 1, 0, vw, flLeftX ); flTopY = FLerp( 1, -1, 0, vh ,flTopY ); flBottomY = FLerp( 1, -1, 0, vh, flBottomY ); float alpha = ((float)GetFgColor()[3]/255.0f); for ( int corner=0; corner<4; corner++ ) { bool bLeft = (corner==0) || (corner==3); meshBuilder.Position3f( (bLeft) ? flLeftX : flRightX, (corner & 2) ? flBottomY : flTopY, 0.0f ); meshBuilder.Normal3f( 0.0f, 0.0f, 1.0f ); meshBuilder.TexCoord2f( 0, (bLeft) ? flLeftU : flRightU, (corner & 2) ? flBottomV : flTopV ); meshBuilder.TangentS3f( 0.0f, 1.0f, 0.0f ); meshBuilder.TangentT3f( 1.0f, 0.0f, 0.0f ); meshBuilder.Color4f( 1.0f, 1.0f, 1.0f, alpha ); meshBuilder.AdvanceVertex(); } meshBuilder.End(); pMesh->Draw(); pRenderContext->MatrixMode( MATERIAL_VIEW ); pRenderContext->PopMatrix(); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->PopMatrix(); }