Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
video_mode.h File Reference

Declares video mode selection helpers. More...

#include <string>
#include <vector>
#include <hal/video.h>
Include dependency graph for video_mode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  startup::VideoModeSelection
 Represents the set of available video modes and the chosen best mode. More...
 

Functions

VIDEO_MODE startup::choose_best_video_mode (const std::vector< VIDEO_MODE > &availableVideoModes)
 Choose the best video mode from an already collected list.
 
VIDEO_MODE startup::choose_default_stream_video_mode (const std::vector< VIDEO_MODE > &availableVideoModes, const VIDEO_MODE &outputVideoMode)
 Choose the default stream-resolution mode from detected Xbox modes.
 
VIDEO_MODE startup::choose_default_stream_video_mode (const VIDEO_MODE &outputVideoMode)
 Choose the default stream-resolution mode for the current output mode.
 
std::vector< VIDEO_MODE > startup::filter_stream_video_modes_for_encoder_settings (const std::vector< VIDEO_MODE > &availableVideoModes, unsigned long encoderSettings)
 Filter detected stream-resolution modes through display-aspect encoder settings.
 
std::vector< std::string > startup::format_video_mode_lines (const VideoModeSelection &selection)
 Return human-readable lines describing the detected and selected video modes.
 
bool startup::is_preferred_video_mode (const VIDEO_MODE &candidateVideoMode, const VIDEO_MODE &currentBestVideoMode)
 Return whether a candidate mode should replace the current best mode.
 
void startup::log_video_modes (const VideoModeSelection &selection)
 Log information about available and selected video modes.
 
VideoModeSelection startup::select_best_video_mode (int bpp=32, int refresh=REFRESH_DEFAULT)
 Detect and choose the best available video mode.
 
std::vector< VIDEO_MODE > startup::stream_resolution_presets (int bpp=32, int refresh=60)
 Return canonical Xbox video modes usable as stream-resolution choices.
 

Detailed Description

Declares video mode selection helpers.

Function Documentation

◆ choose_best_video_mode()

VIDEO_MODE startup::choose_best_video_mode ( const std::vector< VIDEO_MODE > & availableVideoModes)

Choose the best video mode from an already collected list.

Parameters
availableVideoModesThe list of candidate modes to evaluate.
Returns
The preferred mode, or a default-initialized VIDEO_MODE when the input list is empty.

◆ choose_default_stream_video_mode() [1/2]

VIDEO_MODE startup::choose_default_stream_video_mode ( const std::vector< VIDEO_MODE > & availableVideoModes,
const VIDEO_MODE & outputVideoMode )

Choose the default stream-resolution mode from detected Xbox modes.

Parameters
availableVideoModesDetected Xbox video modes exposed in settings.
outputVideoModeActive Xbox output mode selected at startup.
Returns
A detected default mode when possible, otherwise a canonical fallback.

◆ choose_default_stream_video_mode() [2/2]

VIDEO_MODE startup::choose_default_stream_video_mode ( const VIDEO_MODE & outputVideoMode)

Choose the default stream-resolution mode for the current output mode.

The default favors an SD Xbox mode to keep software decoding practical.

Parameters
outputVideoModeActive Xbox output mode selected at startup.
Returns
Default stream-resolution mode for new or missing settings.

◆ filter_stream_video_modes_for_encoder_settings()

std::vector< VIDEO_MODE > startup::filter_stream_video_modes_for_encoder_settings ( const std::vector< VIDEO_MODE > & availableVideoModes,
unsigned long encoderSettings )

Filter detected stream-resolution modes through display-aspect encoder settings.

XVideoListModes() already filters progressive and HD modes through the encoder settings. This helper applies the widescreen flag so SD wide-width modes are only exposed when the console is configured for widescreen.

Parameters
availableVideoModesDetected Xbox video modes from XVideoListModes().
encoderSettingsThe value returned by XVideoGetEncoderSettings().
Returns
Modes suitable for the stream-resolution settings list.

◆ format_video_mode_lines()

std::vector< std::string > startup::format_video_mode_lines ( const VideoModeSelection & selection)

Return human-readable lines describing the detected and selected video modes.

Parameters
selectionVideo-mode selection to describe.
Returns
Formatted diagnostic lines for startup logging or UI display.

◆ is_preferred_video_mode()

bool startup::is_preferred_video_mode ( const VIDEO_MODE & candidateVideoMode,
const VIDEO_MODE & currentBestVideoMode )

Return whether a candidate mode should replace the current best mode.

A candidate must be at least as good as the current best mode in width, height, color depth, and refresh rate, while preferring 720p over 1080i.

Parameters
candidateVideoModeThe mode being evaluated.
currentBestVideoModeThe currently selected best mode.
Returns
true if the candidate should replace the current best mode.

◆ log_video_modes()

void startup::log_video_modes ( const VideoModeSelection & selection)

Log information about available and selected video modes.

Parameters
selectionThe selection object to log.

◆ select_best_video_mode()

VideoModeSelection startup::select_best_video_mode ( int bpp = 32,
int refresh = REFRESH_DEFAULT )

Detect and choose the best available video mode.

Parameters
bppDesired bits-per-pixel color depth. Default is 32.
refreshDesired refresh rate or REFRESH_DEFAULT to accept the default.
Returns
A VideoModeSelection containing the detected modes and the selected best mode.

◆ stream_resolution_presets()

std::vector< VIDEO_MODE > startup::stream_resolution_presets ( int bpp = 32,
int refresh = 60 )

Return canonical Xbox video modes usable as stream-resolution choices.

Runtime code should prefer modes detected by XVideoListModes(). These values are a fallback for code paths without live video-mode detection.

Parameters
bppBits-per-pixel metadata to attach to each mode.
refreshRefresh-rate metadata to attach to each mode.
Returns
Ordered list of canonical stream-resolution modes.