gst: Various driver cleanups
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
a4ad0aa79b
commit
955129edce
129
gui/gst.cpp
129
gui/gst.cpp
|
@ -35,48 +35,57 @@ private:
|
||||||
std::string cur_file;
|
std::string cur_file;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
void load(const std::string &filepath)
|
||||||
* Load a track into the gstreamer pipeline.
|
{
|
||||||
* @param filepath The file to be loaded.
|
gchar *uri;
|
||||||
*/
|
|
||||||
void load(const std::string &);
|
|
||||||
|
|
||||||
/**
|
cur_file = filepath;
|
||||||
* Begin playback on the GStreamer pipeline.
|
gst_change_state(GST_STATE_NULL);
|
||||||
* @return True if the state change was successful.
|
uri = gst_filename_to_uri(filepath.c_str(), NULL);
|
||||||
*/
|
g_object_set(G_OBJECT(gst_player), "uri", uri, NULL);
|
||||||
bool play();
|
g_free(uri);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
bool play()
|
||||||
* Pause the GStreamer pipeline.
|
{
|
||||||
* @return True if the state change was successful.
|
return gst_change_state(GST_STATE_PLAYING);
|
||||||
*/
|
}
|
||||||
bool pause();
|
|
||||||
|
|
||||||
/**
|
bool pause()
|
||||||
* Check if the GStreamer pipeline is playing.
|
{
|
||||||
* @return True if the pipeline is playing.
|
return gst_change_state(GST_STATE_PAUSED);
|
||||||
*/
|
}
|
||||||
bool is_playing();
|
|
||||||
|
|
||||||
|
bool is_playing()
|
||||||
|
{
|
||||||
|
GstState state;
|
||||||
|
gst_element_get_state(gst_player, &state, NULL, GST_CLOCK_TIME_NONE);
|
||||||
|
return state == GST_STATE_PLAYING;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
void seek_to(long offset)
|
||||||
* Seek to a specific position in the pipeline.
|
{
|
||||||
* @param offset Offset from the beginning of the pipeline, in nanoseconds.
|
gst_element_seek_simple(gst_player,
|
||||||
*/
|
GST_FORMAT_TIME,
|
||||||
void seek_to(long);
|
GST_SEEK_FLAG_FLUSH,
|
||||||
|
offset);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
long position()
|
||||||
* Find the current playback position of the pipeline.
|
{
|
||||||
* @return The current position of the pipeline, in nanoseconds.
|
long position;
|
||||||
*/
|
if (gst_element_query_position(gst_player, GST_FORMAT_TIME, &position))
|
||||||
long position();
|
return position;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
long duration()
|
||||||
* Find the duration of the pipeline.
|
{
|
||||||
* @return The duration of the pipeline, in nanoseconds.
|
long duration;
|
||||||
*/
|
if (gst_element_query_duration(gst_player, GST_FORMAT_TIME, &duration))
|
||||||
long duration();
|
return duration;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,56 +116,6 @@ static void parse_gst_error(GstMessage *error, const std::string filepath)
|
||||||
g_free(debug);
|
g_free(debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSTDriver :: load(const std::string &filepath)
|
|
||||||
{
|
|
||||||
gchar *uri;
|
|
||||||
|
|
||||||
cur_file = filepath;
|
|
||||||
gst_change_state(GST_STATE_NULL);
|
|
||||||
uri = gst_filename_to_uri(filepath.c_str(), NULL);
|
|
||||||
g_object_set(G_OBJECT(gst_player), "uri", uri, NULL);
|
|
||||||
g_free(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GSTDriver :: play()
|
|
||||||
{
|
|
||||||
return gst_change_state(GST_STATE_PLAYING);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GSTDriver :: pause()
|
|
||||||
{
|
|
||||||
return gst_change_state(GST_STATE_PAUSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GSTDriver :: is_playing()
|
|
||||||
{
|
|
||||||
GstState state;
|
|
||||||
gst_element_get_state(gst_player, &state, NULL, GST_CLOCK_TIME_NONE);
|
|
||||||
return state == GST_STATE_PLAYING;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GSTDriver :: seek_to(long offset)
|
|
||||||
{
|
|
||||||
gst_element_seek_simple(gst_player, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
long GSTDriver :: position()
|
|
||||||
{
|
|
||||||
long position;
|
|
||||||
if (gst_element_query_position(gst_player, GST_FORMAT_TIME, &position))
|
|
||||||
return position;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
long GSTDriver :: duration()
|
|
||||||
{
|
|
||||||
long duration;
|
|
||||||
|
|
||||||
if (gst_element_query_duration(gst_player, GST_FORMAT_TIME, &duration))
|
|
||||||
return duration;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GSTDriver :: on_message(GstMessage *message)
|
void GSTDriver :: on_message(GstMessage *message)
|
||||||
{
|
{
|
||||||
switch (GST_MESSAGE_TYPE(message)) {
|
switch (GST_MESSAGE_TYPE(message)) {
|
||||||
|
|
Loading…
Reference in New Issue