X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/dd7c0aa4412c01533baff5d0baf47058975a18cb..bcfb71b423699d8f7e1d1e7bb5dc24ad4413a4ae:/lib/service/servicemp3.cpp diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 730c4e7b..c0e4cd5c 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -231,6 +231,11 @@ RESULT eServiceMP3::stop() return 0; } +RESULT eServiceMP3::setTarget(int target) +{ + return -1; +} + RESULT eServiceMP3::pause(ePtr &ptr) { ptr=this; @@ -292,14 +297,38 @@ RESULT eServiceMP3::getLength(pts_t &pts) RESULT eServiceMP3::seekTo(pts_t to) { - /* implement me */ - return -1; + if (!m_gst_pipeline) + return -1; + + /* convert pts to nanoseconds */ + gint64 time_nanoseconds = to * 11111LL; + if (!gst_element_seek (m_gst_pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, + GST_SEEK_TYPE_SET, time_nanoseconds, + GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) + { + eDebug("SEEK failed"); + return -1; + } + return 0; } RESULT eServiceMP3::seekRelative(int direction, pts_t to) { - /* implement me */ - return -1; + if (!m_gst_pipeline) + return -1; + + pause(); + + pts_t ppos; + getPlayPosition(ppos); + ppos += to * direction; + if (ppos < 0) + ppos = 0; + seekTo(ppos); + + unpause(); + + return 0; } RESULT eServiceMP3::getPlayPosition(pts_t &pts) @@ -316,7 +345,6 @@ RESULT eServiceMP3::getPlayPosition(pts_t &pts) return -1; /* len is in nanoseconds. we have 90 000 pts per second. */ - pts = len / 11111; return 0; } @@ -344,6 +372,66 @@ RESULT eServiceMP3::getName(std::string &name) return 0; } +int eServiceMP3::getInfo(int w) +{ + switch (w) + { + case sTitle: + case sArtist: + case sAlbum: + case sComment: + case sTracknumber: + case sGenre: + return resIsString; + + default: + return resNA; + } +} + +std::string eServiceMP3::getInfoString(int w) +{ + gchar *tag = 0; + switch (w) + { + case sTitle: + tag = GST_TAG_TITLE; + break; + case sArtist: + tag = GST_TAG_ARTIST; + break; + case sAlbum: + tag = GST_TAG_ALBUM; + break; + case sComment: + tag = GST_TAG_COMMENT; + break; + case sTracknumber: + tag = GST_TAG_TRACK_NUMBER; + break; + case sGenre: + tag = GST_TAG_GENRE; + break; + default: + return ""; + } + + if (!m_stream_tags || !tag) + return ""; + + gchar *value; + + if (gst_tag_list_get_string(m_stream_tags, tag, &value)) + { + std::string res = value; + g_free(value); + return res; + } + + return ""; +} + + void foreach(const GstTagList *list, const gchar *tag, gpointer user_data) { if (tag) @@ -353,10 +441,14 @@ RESULT eServiceMP3::getName(std::string &name) void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) { + gchar *string = gst_structure_to_string(gst_message_get_structure(msg)); + eDebug("gst_message: %s", string); + g_free(string); + + switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: - eDebug("end of stream!"); m_event((iPlayableService*)this, evEOF); break; case GST_MESSAGE_ERROR: @@ -374,7 +466,6 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) { GstTagList *tags, *result; gst_message_parse_tag(msg, &tags); - eDebug("is tag list: %d", GST_IS_TAG_LIST(tags)); result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_PREPEND); if (result) @@ -384,29 +475,9 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) m_stream_tags = result; } gst_tag_list_free(tags); - - eDebug("listing tags.."); - gst_tag_list_foreach(m_stream_tags, foreach, 0); - eDebug("ok"); - - if (m_stream_tags) - { - gchar *title; - eDebug("is tag list: %d", GST_IS_TAG_LIST(m_stream_tags)); - if (gst_tag_list_get_string(m_stream_tags, GST_TAG_TITLE, &title)) - { - eDebug("TITLE: %s", title); - g_free(title); - } else - eDebug("no title"); - } else - eDebug("no tags"); - - eDebug("tag list updated!"); break; } default: - eDebug("unknown message"); break; } } @@ -433,6 +504,7 @@ void eServiceMP3::gstCBnewPad(GstElement *decodebin, GstPad *pad, gboolean last, return; } + /* check media type */ caps = gst_pad_get_caps (pad); str = gst_caps_get_structure (caps, 0);