I'm using: UBUNTU 14.04 + SDL 2.0.4 + Code::Blocks 13.12 - (C++) - linked to libtheora.a (v.1.1.1)
TARGET: To be able to play (decode) Ogg Theora video in an SDL2 application.
I could use ffmpeg library. But there are licences issues because they use MPEG... etc...
So, I've choose Ogg Theora library from http://www.theora.org since is "patented free".
(They have a simple and very permissive licence, no "proprietary" codecs in use).
I've been searching in the web for a very simple SDL2 + Ogg Theora video play example in C++, no need to decode audio, only video, in my case, and send to SDL2 (to a texture maybe?...). But I cant found anything related. I found only some "messy" code, even so, that doesn't worked.
Anyone can share a code snippet (any solution / any tips / other ideas)?...
The code that I have so far...
(In this testing, I'm using "theoraplay.h" -- https://icculus.org/theoraplay -- at this moment)
// My project linkage:
-lSDL2
-lSDL2_image
-lSDL2_mixer
-logg
-lvorbis
-lvorbisenc
-lvorbisfile
-ltheora
-ltheoraenc
-ltheoradec
// SDL2:
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_mixer.h>
// OGG Library: (The multimedia wrapper)
#include "ogg/ogg.h"
// VORBIS Library: (Audio)
#include "vorbis/codec.h"
#include "vorbis/vorbisenc.h"
#include "vorbis/vorbisfile.h"
// THEORA Library: (Video)
#include "theora/theora.h"
#include "theora/theoraenc.h"
#include "theora/theoradec.h"
// The "framework" for Ogg Theora video play, from: https://icculus.org/theoraplay
// I'm Testing it...
#include "theoraplay.h"
// SDL2 - Objects:
SDL_Surface* surface;
SDL_Texture* texture;
SDL_Rect rectangle;
// THEORAPLAY - Objects:
THEORAPLAY_Decoder* decoder = NULL; // Will return a Link error... Why?...
const THEORAPLAY_VideoFrame* video = NULL; // No issues (Links and runs ok)
const THEORAPLAY_AudioPacket* audio = NULL; // No issues (Links and runs ok)
int main(int args, char* argv[]){
// (SDL2 code to create the window, renderer, events, etc, goes here...)
surface = IMG_Load("images/example.png"); // Load an image.
texture = SDL_CreateTextureFromSurface(renderer, temp); // Pass the image into a texture.
// "ERROR" - LOG says: undefined reference to "THEORAPLAY_startDecodeFile"...
decoder = THEORAPLAY_startDecodeFile("bunny.ogg", 20, THEORAPLAY_VIDFMT_YV12);
// "bunny.ogg" - Ogg video from: https://peach.blender.org/download
// SDL2: Here, will be added the code to pass THEORA frames into a SDL2 streaming texture...
while(!quit){
// Render everything:
SDL_RenderCopy(renderer, texture, NULL, &rectangle);
};
};