Walter-Correa/SampAudioStream
A high-performance, asynchronous C++20 universal audio streaming plugin and native component engineered specifically for SA-MP and Open.MP.
Instalar com o sampctl
sampctl package install Walter-Correa/SampAudioStream
Execute na pasta do seu projeto. O sampctl baixa o pacote e as dependências dele.
Adiciona os arquivos de include dele, com as bibliotecas de que depende, ao compilador Pawn no seu navegador, prontos para incluir num script.
Depende de 1 pacote
- sampctl/samp-stdlibnão está neste diretório
README.md
SampAudioStream
SampAudioStream is a high-performance, asynchronous C++20 universal audio streaming plugin and native component engineered specifically for San Andreas Multiplayer (SA-MP) and open.mp.
It allows Pawn developers to play audio from YouTube, SoundCloud, Twitch, Kick, Vimeo, TikTok, and hundreds of other video/audio platforms—as well as live broadcasts, Shoutcast/Icecast online radios, HLS streams, and direct MP3/OGG/WAV/FLAC links—with no installation on Windows and a single package on Linux (32-bit libcurl), zero ffmpeg dependency, built-in in-memory MP3 transcoding, spatial 3D/world/interior filtering, time-synchronized radius playback, asynchronous in-game music search, and synchronized multi-player radio channels.
Extending Standard SA-MP / open.mp AudioStream
| Feature / Capability | Standard PlayAudioStreamForPlayer | SampAudioStream |
|---|---|---|
| Platform Architecture | Built-in server native | ✅ Unified dual-runtime binary: native open.mp Component + SA-MP Plugin (32-bit x86) |
| Server Dependencies | None | ✅ Windows: none · Linux: 32-bit libcurl only (the server log prints the exact install command); static CRT (/MT & -static-libstdc++), embedded codecs, auto-provisioned yt-dlp + quickjs-ng |
| Transcoding Engine | Client plays direct HTTP audio only | ✅ Embedded static C++ pipeline (libopus, libogg, fdk-aac, mp3lame, dr_libs, stb_vorbis) + ICY StreamTitle framing |
| Video, Audio & Live Sites | Direct .mp3/.ogg/Shoutcast only | ✅ YouTube (videos & lives incl. RFC 8216 ADTS/fMP4), SoundCloud, Twitch, Kick, Vimeo, TikTok, HLS (.m3u8 / MPEG-TS), extensionless Shoutcast/Icecast & more |
| Drop-In Compatibility | Native behavior | ✅ Transparently hooks PlayAudioStreamForPlayer & StopAudioStreamForPlayer, LAN-aware local URLs, CP1252 Pawn encoding default + full SA_* API |
| World / Interior / Volume | Global usepos only; no server volume scaling | ✅ Native worldid, interiorid, and volume (0.0–200.0) parameters |
| Radius Time Synchronization | Static URL starts from beginning per player | ✅ SA_PlayAudioStream paces finite tracks at 1x real-time so latecomers entering the radius hear the current timestamp |
| In-Game Music Search | ❌ None | ✅ Non-blocking SA_SearchAudioStream returning structured results via callbacks for interactive Pawn dialogs |
| Dynamic 3D Attachment | Static coordinates only | ✅ SA_AttachAudioStreamToPlayer & SA_AttachAudioStreamToVehicle |
| Synchronized Radio Channels | ❌ None | ✅ SA_CreateAudioStreamChannel, SA_QueueChannelAudioStream, SA_SkipChannelAudioStream, 3D positional/vehicle/player channels, queue manipulation & loop modes, elapsed/listener queries, creator ownership, passwords, destroy policies, and atomic JSON disk persistence |
| Caching & Memory Footprint | Uncached client HTTP requests | ✅ In-memory LRU+TTL metadata/search cache + ~30s sliding ring buffers (zero MP3 disk bloat) |
Documentation Hub
Modular guides and exhaustive API documentation are available in the docs/ directory:
| Guide | Description |
|---|---|
| 📖 Getting Started | Requirements, installation for SA-MP & open.mp, firewall setup, first startup log, config.json reference, troubleshooting, and FAQ. |
| 🔊 Playback, Hooking & Spatial Audio | SA_PlayAudioStreamForPlayer vs. SA_PlayAudioStream, radius time sync, live streams, volume, pause, and 3D entity attachment. |
| 🔎 Music Search & Synced Channels | Asynchronous SA_SearchAudioStream dialog workflows and synchronized multi-player radio stations with passwords, creator lifecycle, and queues. |
| ⚙️ Architecture, Transcoding & Caching | Internal C++20 worker pool, embedded codecs, HLS/MPEG-TS live decoding, LRU RAM cache, and ~30s ring buffers. |
| 📚 Complete API Reference | Exhaustive reference for all 91 SA_* natives, hooked vanilla natives, 20 callbacks, enums, constants, and helpers (plus optional audio.normalize_volume equalization for transcoded/proxy streams and live broadcasts, excluding direct passthrough). |
| ⚠️ Important Notes | Extractor (yt-dlp) dependency notice, server owner content responsibility, and non-affiliation disclaimer. |
Important Notes
- Platform Extractor Dependency (
yt-dlp): Platform streams (YouTube, SoundCloud, Twitch, etc.) are resolved byyt-dlp, which the plugin downloads and keeps updated automatically. When a platform changes its internals, extraction may fail temporarily until a newyt-dlprelease is published and picked up by the automatic update. Direct audio URLs and internet radios do not depend onyt-dlp. See Troubleshooting for how to force an update and the YouTube Cookies Guide if YouTube challenges your VPS IP with "Sign in to confirm you're not a bot". - Content Responsibility: SampAudioStream does not host, store, or distribute any media. It only relays audio that the server owner (or players, through your scripts) chooses to play. Server owners are solely responsible for ensuring they have the rights to broadcast the content played on their servers and for complying with the terms of service of the platforms they stream from.
- No Affiliation: SampAudioStream is an independent community project and is not affiliated with, endorsed by, or sponsored by YouTube, Google, SoundCloud, Twitch, Take-Two Interactive, Rockstar Games, the SA-MP team, or the open.mp team. All trademarks belong to their respective owners.
Quick Start & Installation
Follow these 5 steps to install SampAudioStream and play your first track:
Download the release archive for your server OS: download
SampAudioStream-Windows.ziporSampAudioStream-Linux.zipfrom GitHub Releases (matching the server host OS). Verify the archive containsplugins/,components/,include/SampAudioStream.inc, andfilterscripts/FS_SampAudioStream_Demo.{pwn,amx}. (Full details)Check host dependencies: Windows requires nothing extra; Linux requires 32-bit
libcurl(libcurl.so.4). Iflibcurlis missing on Linux, the server log prints the exact install command for your distribution. (Distribution commands)Copy the binary folder and include file: copy only one binary folder (
plugins/orcomponents/— never both) plusinclude/SampAudioStream.incintopawno/include/(SA-MP) orqawno/include/(open.mp). (Installation guide)Server Runtime Binary Folder Config Edit Required? SA-MP 0.3.7 plugins/Yes, add plugins SampAudioStream.dll(or.so) inserver.cfgopen.mp (recommended) components/No (loaded automatically) open.mp legacy mode plugins/Yes, add "SampAudioStream"underpawn.legacy_pluginsinconfig.json[!IMPORTANT] Copy only one binary folder (
plugins/orcomponents/). Loading both in the same server process is rejected.Open the streaming TCP port: allow inbound TCP traffic on every port of
network.http_port(default7778-7785, the first free one is used) in your OS firewall and VPS security group (note: LAN players automatically receive local/loopback URLs whenlan_aware_urlsistrue, while remote players require port-forwarding). Start the server and confirmHTTP audio streaming server listening on ...appears in the console log. (Firewall & verification steps)Include
<SampAudioStream>in your Pawn script and compile: place#include <SampAudioStream>after<open.mp>or<a_samp>, then recompile and start playing audio. Confirmyt-dlp ... downloaded and SHA-256 verifiedandQuickJS-ng downloaded and SHA-256 verifiedappear on first boot. (First startup log)
#include <open.mp> // Or <a_samp>
#include <SampAudioStream>
CMD:play(playerid, params[])
{
if (isnull(params)) return SendClientMessage(playerid, -1, "Usage: /play <URL or song name>");
// Works with YouTube, SoundCloud, Twitch, direct MP3, radios, or plain search text
SA_PlayAudioStreamForPlayer(playerid, params, 0.0, 0.0, 0.0, 50.0, false, -1, -1, 90.0);
return 1;
}
CMD:zone(playerid, params[])
{
if (isnull(params)) return SendClientMessage(playerid, -1, "Usage: /zone <URL or song name>");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
// Everyone entering the 35m radius hears the song synchronized at its current timestamp
SA_PlayAudioStream(params, x, y, z, 35.0, true, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), 85.0);
return 1;
}
See FS_SampAudioStream_Demo.pwn for a complete plug-and-play English showcase filterscript (/audiomenu / /sa) demonstrating all 91 SA_* natives, hooked vanilla functions, player mute/source tracking, global pause, stream listing/stats, playlist import, seeking, queue item moving, listener skip voting, previous-track history, live radio text inspection/overrides, boombox/vehicle attachment, volume/position/distance controls, local music library browsing, channel playlist mode, sound effects, on-screen stream text toggle, persistent or temporary channels, and synchronized radio channels.
Complete API Reference
All 91 SA_* natives, hooked vanilla functions, 20 callbacks, constants, and enums are documented with signatures and examples in docs/api-reference.md:
- Playback & Control:
SA_PlayAudioStreamForPlayer,SA_PlayAudioStream,SA_StopAudioStreamForPlayer,SA_StopAudioStream,SA_PauseAudioStreamForPlayer,SA_PauseAudioStream,SA_SeekAudioStream,SA_SetPlayerAudioStreamMuted,SA_IsPlayerAudioStreamMuted,SA_SetPlayerAudioStreamGroupMuted,SA_IsPlayerAudioStreamGroupMuted,SA_GetPlayerAudioStreamSource,SA_SetPlayerAudioStreamVolume,SA_SetAudioStreamVolume,SA_SetPlayerAudioStreamDistance,SA_SetAudioStreamDistance,SA_SetPlayerAudioStreamPos,SA_SetAudioStreamPos - Spatial & Entity Attachment:
SA_AttachAudioStreamToPlayer,SA_AttachAudioStreamToVehicle - Asynchronous Music Search:
SA_SearchAudioStream,SA_CancelAudioStreamSearch - Synchronized Radio Channels:
SA_CreateAudioStreamChannel,SA_DestroyAudioStreamChannel,SA_SetAudioStreamChannelName,SA_GetAudioStreamChannelLiveTitle,SA_SetAudioStreamChannelLiveTitle,SA_PlayChannelAudioStream,SA_QueueChannelAudioStream,SA_QueueChannelAudioStreamPlaylist,SA_SeekChannelAudioStream,SA_RemoveAudioStreamChannelQueue,SA_InsertAudioStreamChannelQueue,SA_ReplaceAudioStreamChannelQueue,SA_MoveAudioStreamChannelQueue,SA_ShuffleAudioStreamChannelQueue,SA_SkipChannelAudioStream,SA_StopChannelAudioStream,SA_PauseChannelAudioStream,SA_SetChannelAudioStreamVolume,SA_SetAudioStreamChannelLoop,SA_GetAudioStreamChannelLoop,SA_SetAudioStreamChannelPos,SA_ClearAudioStreamChannelPos,SA_SetAudioStreamChannelGroup,SA_GetAudioStreamChannelGroup,SA_AttachAudioStreamChannelToPlayer,SA_AttachAudioStreamChannelToVehicle,SA_JoinAudioStreamChannel,SA_LeaveAudioStreamChannel,SA_IsPlayerInAudioStreamChannel,SA_GetPlayerAudioStreamChannel,SA_SetAudioStreamChannelPass,SA_CheckAudioStreamChannelPass,SA_SetAudioStreamChannelCreator,SA_SetAudioStreamChannelDestroy,SA_GetAudioStreamChannelDestroy,SA_SetAudioStreamChannelIdleSuspend,SA_GetAudioStreamChannelIdleSuspend,SA_GetAudioStreamChannelCount,SA_GetAudioStreamChannelID,SA_GetAudioStreamChannelInfo,SA_GetAudioStreamChannelTrack,SA_GetAudioStreamChannelElapsed,SA_GetAudioStreamChannelListener,SA_GetAudioStreamChannelQueue,SA_GetAudioStreamChannelQueueLabel,SA_SetAudioStreamChannelQueueLabel,SA_SetAudioStreamChannelDescription,SA_GetAudioStreamChannelDescription,SA_SetAudioStreamChannelQueueDescription,SA_GetAudioStreamChannelQueueDescription,SA_GetAudioStreamChannelTrackDescription,SA_FindAudioStreamChannelQueue,SA_ClearAudioStreamChannelQueue - Diagnostics & Metadata:
SA_GetPlayerAudioStreamID,SA_GetAudioStreamCount,SA_GetAudioStreamID,SA_GetAudioStreamOwner,SA_GetAudioStreamElapsed,SA_GetAudioStreamURL,SA_GetAudioStreamStats,SA_GetAudioStreamInfo,SA_GetAudioStreamLiveTitle,SA_SetAudioStreamLiveTitle,SA_IsAudioStreamExtractorReady,SA_GetAudioStreamHttpPort - Hooked Vanilla Natives:
PlayAudioStreamForPlayer,StopAudioStreamForPlayer - Callbacks:
OnAudioStreamProcessing,OnAudioStreamWaiting,OnAudioStreamReady,OnAudioStreamStart,OnAudioStreamFinished,OnAudioStreamError,OnAudioStreamLiveTitleChange,OnPlayerAudioStreamSourceChange,OnPlayerAudioStreamNoConnect,OnAudioStreamSearchResults,OnAudioStreamSearchResultItem,OnAudioStreamChannelDestroyed,OnAudioStreamChannelTrackWaiting,OnAudioStreamChannelTrackStart,OnAudioStreamChannelQueueEnd,OnAudioStreamChannelError,OnAudioStreamChannelRestored,OnAudioStreamChannelPlaylistQueued,OnAudioStreamChannelLiveTitleChange
Building from Source
Prerequisites
- CMake 3.20+ and Git (dependencies
nlohmann_json,asio,ogg,opus,fdk-aac,mp3lame_static,dr_libs, andstbare fetched automatically via CMakeFetchContent) - Windows: Visual Studio 2022 (Desktop C++ workload)
- Linux: GCC 10+ / Clang with
gcc-multilib g++-multilib(for-m32x86 builds) - SDKs in
deps/:
The commits used by official builds are pinned ingit clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/openmultiplayer/open.mp-sdk.git deps/open.mp-sdk git clone --depth 1 https://github.com/maddinat0r/samp-plugin-sdk.git deps/samp-plugin-sdkcmake/sdk-pins.txt.
Compiling on Windows (1-Click Script)
Run the automated MSVC build script:
build_msvc.bat
(Automatically configures CMake for Win32, compiles Release binaries, runs core_tests, and builds dist/SampAudioStream-Windows.zip.)
Compiling on Linux
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=cmake/linux-x86.cmake
cmake --build build --parallel
ctest --test-dir build -R core_tests --output-on-failure
Version history
Show the version history
Unreleased
- Updated Libraries:
- nlohmann/json 3.12.0, asio 1.39.0, libogg 1.3.6, libopus 1.6.1, fdk-aac 3.0.0,
stb_vorbis1.25 (stricter checks on malformed Ogg files) and the latestdr_libs(dr_flac,dr_wavanddr_mp3fixes for malformed files).
- nlohmann/json 3.12.0, asio 1.39.0, libogg 1.3.6, libopus 1.6.1, fdk-aac 3.0.0,
- Fixes:
- open.mp reported the component as version 2.2.0; it now reports the real version.
- Maintenance Automation (repository only):
- A weekly workflow opens pull requests for new Deno / QuickJS-ng releases (with recomputed download hashes) and new open.mp / SA-MP SDK commits, and keeps an issue listing newer library releases; each says whether a new release is needed. See docs/maintenance.md.
- Changes waiting for a release are listed under "Unreleased" in this version history. The Release workflow asks for the version type (patch, minor or major), sets the version in every file, turns "Unreleased" into the new version and publishes it.
3d-audioaudioaudio-streamingmusicopen-mpopenmppawnradiosa-mpsampsamp-pluginsoundstreaming
Esta página é montada com o que o GitHub publica sobre o repositório. O samp.directory não hospeda o código. Avisar de um problema com esta página