diff --git a/CMakeLists.txt b/CMakeLists.txt index 455c4b0b4f04fbd1e80f31b4af3cfc96bc5ce3b9..a83ed5f8c9c07b85836bea32f5b3a83a5a1b4c3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,7 @@ cmake_dependent_option( OFF "NOT SRB2_CONFIG_SYSTEM_LIBRARIES" OFF ) +option(SRB2_CONFIG_ENABLE_WEBM_MOVIES "Enable WebM recording support" ON) option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON) option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF) option(SRB2_CONFIG_ERRORMODE "Compile C code with warnings treated as errors." OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9055926d8b3f1efb25d9228264c90107f97686aa..8174dac16e05b9f7bce6d574d28ba455720be326 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,7 +32,6 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 m_aatree.c m_anigif.c m_argv.c - m_avrecorder.cpp m_bbox.c m_cheat.c m_cond.c @@ -136,6 +135,10 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 k_roulette.c ) +if(SRB2_CONFIG_ENABLE_WEBM_MOVIES) + target_sources(SRB2SDL2 PRIVATE m_avrecorder.cpp) +endif() + # This updates the modification time for comptime.c at the # end of building so when the build system is ran next time, # that file gets flagged. comptime.c will always be rebuilt. @@ -232,9 +235,12 @@ target_link_libraries(SRB2SDL2 PRIVATE xmp-lite::xmp-lite) target_link_libraries(SRB2SDL2 PRIVATE glad::glad) target_link_libraries(SRB2SDL2 PRIVATE fmt) target_link_libraries(SRB2SDL2 PRIVATE imgui::imgui) -target_link_libraries(SRB2SDL2 PRIVATE webm::libwebm webm::libvpx) -target_link_libraries(SRB2SDL2 PRIVATE libyuv::libyuv) -target_link_libraries(SRB2SDL2 PRIVATE Vorbis::vorbis Vorbis::vorbisenc) +if(SRB2_CONFIG_ENABLE_WEBM_MOVIES) + target_link_libraries(SRB2SDL2 PRIVATE webm::libwebm webm::libvpx) + target_link_libraries(SRB2SDL2 PRIVATE libyuv::libyuv) + target_link_libraries(SRB2SDL2 PRIVATE Vorbis::vorbis Vorbis::vorbisenc) + target_compile_definitions(SRB2SDL2 PRIVATE -DSRB2_CONFIG_ENABLE_WEBM_MOVIES) +endif() target_link_libraries(SRB2SDL2 PRIVATE acsvm) @@ -552,7 +558,9 @@ if(SRB2_CONFIG_ENABLE_TESTS) add_subdirectory(tests) endif() add_subdirectory(menus) -add_subdirectory(media) +if(SRB2_CONFIG_ENABLE_WEBM_MOVIES) + add_subdirectory(media) +endif() # strip debug symbols into separate file when using gcc. # to be consistent with Makefile, don't generate for OS X. diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 53fe94b64ff1cb6b6ba6bd65ff1b0987381c143d..5e93a4a106eab93288bfd41901ff269eed9eb98d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -62,7 +62,10 @@ #include "deh_tables.h" #include "m_perfstats.h" #include "k_specialstage.h" + +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES #include "m_avrecorder.h" +#endif #ifdef HAVE_DISCORDRPC #include "discord.h" @@ -904,7 +907,11 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_moviemode); CV_RegisterVar(&cv_movie_option); CV_RegisterVar(&cv_movie_folder); + +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES M_AVRecorder_AddCommands(); +#endif + // PNG variables CV_RegisterVar(&cv_zlib_level); CV_RegisterVar(&cv_zlib_memory); @@ -4109,7 +4116,7 @@ void Schedule_Insert(scheduleTask_t *addTask) { schedule_size *= 2; } - + schedule = Z_ReallocAlign( (void*) schedule, sizeof(scheduleTask_t*) * schedule_size, diff --git a/src/hwr2/pass_software.cpp b/src/hwr2/pass_software.cpp index aca51a615fe613e00f58133da7778748c993c9d6..a95576f344ce18d64bfc2e9fe5fcfe75c60b4ca9 100644 --- a/src/hwr2/pass_software.cpp +++ b/src/hwr2/pass_software.cpp @@ -17,7 +17,9 @@ #include "../discord.h" #endif #include "../doomstat.h" +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES #include "../m_avrecorder.h" +#endif #include "../st_stuff.h" #include "../s_sound.h" #include "../st_stuff.h" @@ -59,8 +61,9 @@ static void temp_legacy_finishupdate_draws() } if (cv_mindelay.value && consoleplayer == serverplayer && Playing()) SCR_DisplayLocalPing(); - +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES M_AVRecorder_DrawFrameRate(); +#endif } if (marathonmode) diff --git a/src/m_misc.cpp b/src/m_misc.cpp index f79edb7fb625d8ee0fe1a48d2d16f9c8e818619c..491be3b30fe8d5cb78a8c24539a35bff97b6b5ec 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -45,7 +45,9 @@ #include "command.h" // cv_execversion #include "m_anigif.h" +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES #include "m_avrecorder.h" +#endif // So that the screenshot menu auto-updates... #include "k_menu.h" @@ -1299,6 +1301,9 @@ static inline moviemode_t M_StartMovieGIF(const char *pathname) static inline moviemode_t M_StartMovieAVRecorder(const char *pathname) { +#ifndef SRB2_CONFIG_ENABLE_WEBM_MOVIES + return MM_OFF; +#else const char *ext = M_AVRecorder_GetFileExtension(); const char *freename; @@ -1314,6 +1319,7 @@ static inline moviemode_t M_StartMovieAVRecorder(const char *pathname) } return MM_AVRECORDER; +#endif } void M_StartMovie(void) @@ -1366,11 +1372,13 @@ void M_StartMovie(void) CONS_Printf(M_GetText("Movie mode enabled (%s).\n"), "GIF"); else if (moviemode == MM_SCREENSHOT) CONS_Printf(M_GetText("Movie mode enabled (%s).\n"), "screenshots"); +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES else if (moviemode == MM_AVRECORDER) { CONS_Printf(M_GetText("Movie mode enabled (%s).\n"), M_AVRecorder_GetCurrentFormat()); M_AVRecorder_PrintCurrentConfiguration(); } +#endif //singletics = (moviemode != MM_OFF); #endif @@ -1382,6 +1390,7 @@ void M_SaveFrame(void) // paranoia: should be unnecessary without singletics static tic_t oldtic = 0; +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES if (moviemode == MM_AVRECORDER) { // TODO: replace once hwr2 twodee is finished @@ -1396,6 +1405,7 @@ void M_SaveFrame(void) } return; } +#endif // skip interpolated frames for other modes if (oldtic == I_GetTime()) @@ -1485,9 +1495,11 @@ void M_StopMovie(void) #endif case MM_SCREENSHOT: break; +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES case MM_AVRECORDER: M_AVRecorder_Close(); break; +#endif default: return; } diff --git a/src/sdl/new_sound.cpp b/src/sdl/new_sound.cpp index 228985c8301d69988d9b215ead36694de857c7f5..80f549508c95956a034518aee2ad7927bed1da18 100644 --- a/src/sdl/new_sound.cpp +++ b/src/sdl/new_sound.cpp @@ -21,7 +21,10 @@ #include "../audio/sound_effect_player.hpp" #include "../cxxutil.hpp" #include "../io/streams.hpp" + +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES #include "../m_avrecorder.hpp" +#endif #include "../doomdef.h" #include "../i_sound.h" @@ -58,7 +61,9 @@ static shared_ptr<Gain<2>> gain_music; static vector<shared_ptr<SoundEffectPlayer>> sound_effect_channels; +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES static shared_ptr<srb2::media::AVRecorder> av_recorder; +#endif static void (*music_fade_callback)(); @@ -138,9 +143,10 @@ void audio_callback(void* userdata, Uint8* buffer, int len) std::clamp(float_buffer[i].amplitudes[1], -1.f, 1.f), }; } - +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES if (av_recorder) av_recorder->push_audio_samples(tcb::span {float_buffer, float_len}); +#endif } catch (...) { @@ -758,8 +764,10 @@ boolean I_FadeInPlaySong(UINT32 ms, boolean looping) void I_UpdateAudioRecorder(void) { +#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES // must be locked since av_recorder is used by audio_callback SdlAudioLockHandle _; av_recorder = g_av_recorder; +#endif } diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 6fa5e9687980705457ffa1d815deb6d1c4b45831..0c77d8c1bb059c8aea6b0425b602c13e2954ec20 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -10,14 +10,11 @@ else() endif() if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") -include("cpm-sdl2.cmake") + include("cpm-sdl2.cmake") include("cpm-zlib.cmake") include("cpm-png.cmake") include("cpm-curl.cmake") include("cpm-libgme.cmake") - include("cpm-libvpx.cmake") - include("cpm-ogg.cmake") # libvorbis depends - include("cpm-libvorbis.cmake") endif() include("cpm-rapidjson.cmake") @@ -26,8 +23,14 @@ include("cpm-xmp-lite.cmake") include("cpm-fmt.cmake") include("cpm-imgui.cmake") include("cpm-acsvm.cmake") -include("cpm-libwebm.cmake") -include("cpm-libyuv.cmake") + +if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}" AND SRB2_CONFIG_ENABLE_WEBM_MOVIES) + include("cpm-libvpx.cmake") + include("cpm-ogg.cmake") # libvorbis depends + include("cpm-libvorbis.cmake") + include("cpm-libwebm.cmake") + include("cpm-libyuv.cmake") +endif() add_subdirectory(tcbrindle_span) add_subdirectory(stb_vorbis)