ocarina/include/driver.h

92 lines
1.4 KiB
C++

/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <string>
static const unsigned long O_SECOND = 1000000000;
class Driver {
protected:
void (*on_eos)();
void (*on_error)();
public:
Driver();
~Driver();
virtual void init(int *, char ***, void (*)(), void (*)()) = 0;
virtual void load(const std::string &) = 0;
virtual bool play() = 0;
virtual bool pause() = 0;
virtual bool is_playing() = 0;
virtual void seek_to(long) = 0;
virtual long position() = 0;
virtual long duration() = 0;
};
#ifdef CONFIG_TEST
class TestDriver : public Driver
{
public:
bool playing;
long cur_pos;
long cur_duration;
std::string cur_file;
TestDriver();
~TestDriver();
void init(int *, char ***, void (*)(), void (*)());
void load(const std::string &);
bool play();
bool pause();
bool is_playing();
void seek_to(long);
long position();
long duration();
void eos();
void error();
};
#else /* !CONFIG_TEST */
#include <gst/gst.h>
class GSTDriver : public Driver
{
private:
GstElement *player;
std::string cur_file;
bool change_state(GstState state);
public:
GSTDriver();
~GSTDriver();
void init(int *, char ***, void (*)(), void (*)());
void load(const std::string &);
bool play();
bool pause();
bool is_playing();
void seek_to(long);
long position();
long duration();
void on_message(GstMessage *);
};
#endif /* CONFIG_TEST */
namespace driver
{
Driver *get_driver();
}