| 3658 | } |
| 3659 | |
| 3660 | void CClient::StartVideo(const char *pFilename, bool WithTimestamp) |
| 3661 | { |
| 3662 | if(State() != IClient::STATE_DEMOPLAYBACK) |
| 3663 | { |
| 3664 | log_error("videorecorder", "Video can only be recorded in demo player."); |
| 3665 | return; |
| 3666 | } |
| 3667 | |
| 3668 | if(IVideo::Current()) |
| 3669 | { |
| 3670 | log_error("videorecorder", "Already recording."); |
| 3671 | return; |
| 3672 | } |
| 3673 | |
| 3674 | char aFilename[IO_MAX_PATH_LENGTH]; |
| 3675 | if(WithTimestamp) |
| 3676 | { |
| 3677 | char aTimestamp[20]; |
| 3678 | str_timestamp(aTimestamp, sizeof(aTimestamp)); |
| 3679 | str_format(aFilename, sizeof(aFilename), "videos/%s_%s.mp4", pFilename, aTimestamp); |
| 3680 | } |
| 3681 | else |
| 3682 | { |
| 3683 | str_format(aFilename, sizeof(aFilename), "videos/%s.mp4", pFilename); |
| 3684 | } |
| 3685 | |
| 3686 | // wait for idle, so there is no data race |
| 3687 | Graphics()->WaitForIdle(); |
| 3688 | // pause the sound device while creating the video instance |
| 3689 | Sound()->PauseAudioDevice(); |
| 3690 | new CVideo(Graphics(), Sound(), Storage(), Graphics()->ScreenWidth(), Graphics()->ScreenHeight(), aFilename); |
| 3691 | Sound()->UnpauseAudioDevice(); |
| 3692 | if(!IVideo::Current()->Start()) |
| 3693 | { |
| 3694 | log_error("videorecorder", "Failed to start recording to '%s'", aFilename); |
| 3695 | m_DemoPlayer.Stop("Failed to start video recording. See local console for details."); |
| 3696 | return; |
| 3697 | } |
| 3698 | if(m_DemoPlayer.Info()->m_Info.m_Paused) |
| 3699 | { |
| 3700 | IVideo::Current()->Pause(true); |
| 3701 | } |
| 3702 | log_info("videorecorder", "Recording to '%s'", aFilename); |
| 3703 | } |
| 3704 | |
| 3705 | void CClient::Con_StopVideo(IConsole::IResult *pResult, void *pUserData) |
| 3706 | { |
no test coverage detected