I got fed up how difficult it is to display a video in an SDL application. So I've come up with a solution, an stb-style header wrapper that starts a decoder thread and provides easily integratable data. Very small (ca. 300 SLoC in a single file) and GPL licensed. It relies on SDL2 mixer's header file (but only for one struct definition).
https://gitlab.com/bztsrc/sdlogv
There's an example fully featured OGG / OGV player in about 100 SLoC. Easy to follow, easy to understand code with lots and lots of comments.
Audio
The audio is provided in SDL2 mixer's format (Mix_Chunk), and the whole player is just a few lines using callbacks! You can use the usual mixer stuff with it (pause, resume, change volume, positioning effect etc.)
Audio integration example:
- {l Code}: {l Select All Code}
static void callback(int channel)
{
Mix_Chunk *audio = theora_audio(&ctx);
if(audio) Mix_PlayChannel(channel, audio, 0);
}
Mix_ChannelFinished(callback);
callback(0);
Video
For the video, it is similarly simple. You just need a streaming texture that you render somewhere (same as you would do with any other textures). Then there's a function to get the next frame from dragon land, and another to update the texture with it when the time comes.
And video integration example:
- {l Code}: {l Select All Code}
if(!video) video = theora_video(&ctx);
if(video && video->playms <= now) { theora_yuv2texture(video, texture, ctx.w, ctx.h); video = NULL; }
SDL_RenderCopy(renderer, texture, NULL, &rect);
Hope this will be useful to you. If GPL is an issue for someone, let me know and I'll reconsider dual licensing under MIT.
Cheer,
bzt