|
102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
|
#include <dttr_pcdogs.h>#include "../graphics/graphics_private.h"#include "hooks_private.h"#include "movies_private.h"#include "sidecar_private.h"#include <dttr_log.h>#include <dttr_path.h>#include <sds.h>#include <SDL3/SDL.h>#include <libavcodec/avcodec.h>#include <libavformat/avformat.h>#include <libavutil/channel_layout.h>#include <libavutil/error.h>#include <libavutil/samplefmt.h>#include <libswresample/swresample.h>#include <libswscale/swscale.h>#include <stdbool.h>#include <stdint.h>#include <stdlib.h>Go to the source code of this file.
Data Structures | |
| struct | movie_state |
Macros | |
| #define | AUDIO_CHANNELS 2 |
| #define | AUDIO_FORMAT AV_SAMPLE_FMT_S16 |
| #define | AUDIO_QUEUE_LIMIT_MS 500 |
| #define | AUDIO_DRAIN_LIMIT_MS 750 |
Functions | |
| static BOOL | movie_play_file_detour (const char *movie_path, char use_alt_video_rect) |
| static void | reset_movie_state (dttr_movie_result result) |
| static const char * | movie_error_string (const int err) |
| static void | reset_video_buffer () |
| static void | close_audio () |
| static void | close_movie () |
| static AVCodecContext * | open_codec (const AVStream *stream) |
| static bool | prepare_audio () |
| static bool | open_movie (const char *path) |
| static double | video_pts_seconds (const int64_t pts) |
| static void | set_next_video_time (const double pts) |
| static double | frame_pts_seconds (const AVFrame *frame) |
| static double | packet_pts_seconds (const AVPacket *packet) |
| static bool | queue_video_frame (const AVFrame *frame) |
| static bool | queue_audio_frame (const AVFrame *frame) |
| static bool | receive_video_frame () |
| static void | receive_audio_frames () |
| static bool | drain_eof () |
| static void | send_packet () |
| static bool | decode_until_video_frame () |
| void | dttr_movies_init () |
| bool | dttr_movies_hooks_init (const DTTR_Mods_Context *ctx) |
| void | dttr_movies_hooks_cleanup (const DTTR_Mods_Context *) |
| void | dttr_movies_cleanup () |
| void | dttr_movies_start (const char *path) |
| void | dttr_movies_tick () |
| bool | dttr_movies_handle_event (const SDL_Event *event) |
| dttr_movie_result | dttr_movies_stop () |
| bool | dttr_movies_is_playing () |
| int32_t | dttr_movies_hook_movie_play_file_callback (const char *path, const int32_t use_alt_rect) |
Variables | |
| static DTTR_Core_PatchGroup * | movie_patch_group |
| static movie_state | movie |
| static AVFrame * | video_frame = NULL |
| static AVFrame * | audio_frame = NULL |
| static AVPacket * | packet = NULL |
| #define AUDIO_CHANNELS 2 |
Definition at line 35 of file movies.c.
Referenced by prepare_audio(), and queue_audio_frame().
| #define AUDIO_DRAIN_LIMIT_MS 750 |
Definition at line 38 of file movies.c.
Referenced by drain_eof().
| #define AUDIO_FORMAT AV_SAMPLE_FMT_S16 |
Definition at line 36 of file movies.c.
Referenced by prepare_audio(), and queue_audio_frame().
| #define AUDIO_QUEUE_LIMIT_MS 500 |
Definition at line 37 of file movies.c.
Referenced by queue_audio_frame().
|
static |
|
static |
Definition at line 118 of file movies.c.
References close_audio(), movie, reset_movie_state(), and reset_video_buffer().
Referenced by dttr_movies_cleanup(), dttr_movies_start(), and dttr_movies_stop().
|
static |
Definition at line 570 of file movies.c.
References drain_eof(), DTTR_LOG_ERROR, DTTR_MOVIE_ENDED, DTTR_MOVIE_PLAYING, movie, movie_error_string(), packet, receive_audio_frames(), receive_video_frame(), and send_packet().
Referenced by dttr_movies_tick().
|
static |
Definition at line 502 of file movies.c.
References AUDIO_DRAIN_LIMIT_MS, DTTR_LOG_WARN, DTTR_MOVIE_ENDED, movie, NULL, and receive_audio_frames().
Referenced by decode_until_video_frame().
| void dttr_movies_cleanup | ( | ) |
Definition at line 635 of file movies.c.
References audio_frame, close_movie(), DTTR_LOG_INFO, packet, and video_frame.
Referenced by cleanup_runtime().
| bool dttr_movies_handle_event | ( | const SDL_Event * | event | ) |
Definition at line 705 of file movies.c.
References DTTR_MOVIE_ENDED, DTTR_MOVIE_ESCAPE, DTTR_MOVIE_PLAYING, DTTR_MOVIE_QUIT, event, and movie.
Referenced by dttr_sidecar_handle_sdl_event().
| int32_t dttr_movies_hook_movie_play_file_callback | ( | const char * | path, |
| const int32_t | use_alt_rect ) |
Definition at line 753 of file movies.c.
References dttr_movies_is_playing(), dttr_movies_start(), dttr_movies_stop(), dttr_movies_tick(), and dttr_sidecar_poll_sdl_events().
Referenced by movie_play_file_detour().
| void dttr_movies_hooks_cleanup | ( | const DTTR_Mods_Context * | ctx | ) |
Definition at line 630 of file movies.c.
References DTTR_Core_PatchGroupRelease(), and movie_patch_group.
Referenced by cleanup_runtime().
| bool dttr_movies_hooks_init | ( | const DTTR_Mods_Context * | ctx | ) |
Definition at line 616 of file movies.c.
References ctx, DTTR_ARRAY_COUNT, DTTR_PCDOGS_F_Video_PlayMovieFile, dttr_sidecar_install_pcdogs_patch_group(), movie_patch_group, movie_play_file_detour(), and NULL.
Referenced by install_required_sidecar_hooks().
| void dttr_movies_init | ( | ) |
Definition at line 606 of file movies.c.
References audio_frame, DTTR_LOG_ERROR, packet, and video_frame.
Referenced by install_required_sidecar_hooks().
| bool dttr_movies_is_playing | ( | ) |
Definition at line 748 of file movies.c.
References DTTR_MOVIE_PLAYING, and movie.
Referenced by attempt_play_startup_movies(), dttr_movies_hook_movie_play_file_callback(), and tick_main_loop().
| void dttr_movies_start | ( | const char * | path | ) |
Definition at line 644 of file movies.c.
References audio_frame, close_movie(), dttr_game_data_resolve_media_path(), DTTR_LOG_ERROR, DTTR_LOG_INFO, DTTR_MOVIE_ENDED, DTTR_MOVIE_PLAYING, movie, open_movie(), packet, and video_frame.
Referenced by attempt_play_startup_movies(), and dttr_movies_hook_movie_play_file_callback().
| dttr_movie_result dttr_movies_stop | ( | ) |
Definition at line 741 of file movies.c.
References close_movie(), DTTR_LOG_INFO, and movie.
Referenced by attempt_play_startup_movies(), and dttr_movies_hook_movie_play_file_callback().
| void dttr_movies_tick | ( | ) |
Definition at line 668 of file movies.c.
References decode_until_video_frame(), dttr_graphics_present_video_frame_bgra(), DTTR_LOG_WARN, DTTR_MOVIE_PLAYING, and movie.
Referenced by dttr_movies_hook_movie_play_file_callback(), and tick_main_loop().
|
static |
Definition at line 315 of file movies.c.
References video_pts_seconds().
Referenced by queue_video_frame().
|
static |
Definition at line 89 of file movies.c.
Referenced by decode_until_video_frame(), open_codec(), open_movie(), prepare_audio(), queue_audio_frame(), receive_audio_frames(), receive_video_frame(), and send_packet().
|
static |
Definition at line 28 of file movies.c.
References BOOL, and dttr_movies_hook_movie_play_file_callback().
Referenced by dttr_movies_hooks_init().
|
static |
Definition at line 130 of file movies.c.
References ctx, DTTR_LOG_ERROR, movie_error_string(), and NULL.
Referenced by open_movie().
|
static |
Definition at line 228 of file movies.c.
References DTTR_LOG_ERROR, movie, movie_error_string(), NULL, open_codec(), and prepare_audio().
Referenced by dttr_movies_start().
|
static |
Definition at line 320 of file movies.c.
References packet, and video_pts_seconds().
Referenced by send_packet().
|
static |
Definition at line 168 of file movies.c.
References AUDIO_CHANNELS, AUDIO_FORMAT, DTTR_LOG_ERROR, movie, movie_error_string(), and NULL.
Referenced by open_movie().
|
static |
Definition at line 388 of file movies.c.
References AUDIO_CHANNELS, AUDIO_FORMAT, AUDIO_QUEUE_LIMIT_MS, DTTR_LOG_ERROR, movie, movie_error_string(), and NULL.
Referenced by receive_audio_frames().
|
static |
Definition at line 325 of file movies.c.
References DTTR_LOG_DEBUG, DTTR_LOG_ERROR, frame_pts_seconds(), h, movie, NULL, set_next_video_time(), size, stride, and w.
Referenced by receive_video_frame().
|
static |
Definition at line 475 of file movies.c.
References audio_frame, DTTR_LOG_WARN, movie, movie_error_string(), and queue_audio_frame().
Referenced by decode_until_video_frame(), and drain_eof().
|
static |
Definition at line 451 of file movies.c.
References DTTR_LOG_ERROR, DTTR_MOVIE_ENDED, movie, movie_error_string(), queue_video_frame(), and video_frame.
Referenced by decode_until_video_frame().
|
static |
|
static |
|
static |
Definition at line 536 of file movies.c.
References DTTR_LOG_ERROR, DTTR_LOG_WARN, DTTR_MOVIE_ENDED, movie, movie_error_string(), packet, packet_pts_seconds(), and set_next_video_time().
Referenced by decode_until_video_frame().
|
static |
Definition at line 299 of file movies.c.
References movie.
Referenced by queue_video_frame(), and send_packet().
|
static |
Definition at line 288 of file movies.c.
References movie.
Referenced by frame_pts_seconds(), and packet_pts_seconds().
|
static |
Definition at line 75 of file movies.c.
Referenced by dttr_movies_cleanup(), dttr_movies_init(), dttr_movies_start(), and receive_audio_frames().
|
static |
Definition at line 67 of file movies.c.
Referenced by close_audio(), close_movie(), decode_until_video_frame(), drain_eof(), dttr_movies_handle_event(), dttr_movies_is_playing(), dttr_movies_start(), dttr_movies_stop(), dttr_movies_tick(), open_movie(), prepare_audio(), queue_audio_frame(), queue_video_frame(), receive_audio_frames(), receive_video_frame(), reset_movie_state(), reset_video_buffer(), send_packet(), set_next_video_time(), and video_pts_seconds().
|
static |
Definition at line 25 of file movies.c.
Referenced by dttr_movies_hooks_cleanup(), and dttr_movies_hooks_init().
|
static |
Definition at line 76 of file movies.c.
Referenced by decode_until_video_frame(), dttr_movies_cleanup(), dttr_movies_init(), dttr_movies_start(), packet_pts_seconds(), and send_packet().
|
static |
Definition at line 74 of file movies.c.
Referenced by dttr_movies_cleanup(), dttr_movies_init(), dttr_movies_start(), and receive_video_frame().