MCPcopy Create free account
hub / github.com/ddnet/ddnet / StartVideo

Method StartVideo

src/engine/client/client.cpp:3660–3703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3658}
3659
3660void 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
3705void CClient::Con_StopVideo(IConsole::IResult *pResult, void *pUserData)
3706{

Callers 1

Con_StartVideoMethod · 0.80

Calls 14

str_timestampFunction · 0.85
str_formatFunction · 0.85
GraphicsFunction · 0.85
StorageFunction · 0.85
PauseAudioDeviceMethod · 0.80
ScreenWidthMethod · 0.80
ScreenHeightMethod · 0.80
UnpauseAudioDeviceMethod · 0.80
InfoMethod · 0.80
SoundFunction · 0.50
WaitForIdleMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected