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

Implements the Xbox streaming session runtime. More...

#include "src/streaming/session.h"
#include "src/logging/logger.h"
#include "src/os.h"
#include "src/startup/memory_stats.h"
#include "src/streaming/ffmpeg_stream_backend.h"
#include "src/streaming/stats_overlay.h"
#include "third-party/moonlight-common-c/src/Limelight.h"
#include <algorithm>
#include <array>
#include <atomic>
#include <cctype>
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <deque>
#include <mutex>
#include <SDL.h>
#include <SDL_ttf.h>
#include <string>
#include <string_view>
#include <vector>
#include <windows.h>
Include dependency graph for session.cpp:

Functions

std::uint64_t PltGetMicroseconds (void)
 Return the platform monotonic clock value in microseconds.
 
int rand_s (unsigned int *randomValue)
 Fill an integer with cryptographically strong random bytes on nxdk.
 
bool streaming::run_stream_session (SDL_Window *window, const VIDEO_MODE &videoMode, const app::SettingsState &settings, const app::HostRecord &host, const app::HostAppRecord &app, const network::PairingIdentity &clientIdentity, std::string *statusMessage)
 Run one Xbox streaming session for the selected host app.
 

Detailed Description

Implements the Xbox streaming session runtime.

Function Documentation

◆ PltGetMicroseconds()

std::uint64_t PltGetMicroseconds ( void )

Return the platform monotonic clock value in microseconds.

Returns
Microseconds from the platform timer used by moonlight-common-c.

◆ rand_s()

int rand_s ( unsigned int * randomValue)

Fill an integer with cryptographically strong random bytes on nxdk.

Parameters
randomValueOutput integer populated with secure random bits.
Returns
Zero on success, or a non-zero platform error code on failure.

◆ run_stream_session()

bool streaming::run_stream_session ( SDL_Window * window,
const VIDEO_MODE & videoMode,
const app::SettingsState & settings,
const app::HostRecord & host,
const app::HostAppRecord & app,
const network::PairingIdentity & clientIdentity,
std::string * statusMessage )

Run one Xbox streaming session for the selected host app.

The session launches or resumes the selected app on the host, starts the Moonlight transport runtime, decodes H.264 video and Opus audio with FFmpeg, forwards controller input, renders the latest decoded frame with a lightweight overlay, and returns once the user stops streaming or the host terminates the session.

Parameters
windowShared SDL window reused from the shell.
videoModeActive Xbox video mode.
settingsActive shell settings that control stream resolution, bitrate, frame rate, host audio playback, and the optional end-of-stream stats summary.
hostSelected paired host.
appSelected host app.
clientIdentityPaired client identity used for authenticated launch requests.
statusMessageOutput message describing the final session result.
Returns
True when the stream session started successfully.