X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fservice%2Fservicemp3.cpp;h=fd3587aff5d12f1818630838d642b631912f6c95;hp=79098f2c81eae0d2f91b2332fd766ef25deee6a9;hb=65fdd1a9bcf67c1f63501a13f12b4aff5a2d46b7;hpb=946fb003e4be2e1485308d7fc5bb7274732751a3 diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 79098f2..fd3587a 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -17,6 +17,12 @@ /* for subtitles */ #include +#ifndef GST_SEEK_FLAG_SKIP +#warning Compiling for legacy gstreamer, things will break +#define GST_SEEK_FLAG_SKIP 0 +#define GST_TAG_HOMEPAGE "" +#endif + // eServiceFactoryMP3 eServiceFactoryMP3::eServiceFactoryMP3() @@ -244,7 +250,7 @@ eServiceMP3::eServiceMP3(const char *filename, const char *title): m_filename(fi sourceinfo.containertype = ctVCD; sourceinfo.is_video = TRUE; } - if ( (strncmp(filename, "http://", 7)) == 0 || (strncmp(filename, "udp://", 6)) == 0 || (strncmp(filename, "rtsp://", 7)) == 0 ) + if ( (strncmp(filename, "http://", 7)) == 0 || (strncmp(filename, "udp://", 6)) == 0 || (strncmp(filename, "rtp://", 6)) == 0 || (strncmp(filename, "https://", 8)) == 0 || (strncmp(filename, "mms://", 6)) == 0 || (strncmp(filename, "rtsp://", 7)) == 0 ) sourceinfo.is_streaming = TRUE; gchar *uri; @@ -603,7 +609,7 @@ RESULT eServiceMP3::getName(std::string &name) int eServiceMP3::getInfo(int w) { - gchar *tag = 0; + const gchar *tag = 0; switch (w) { @@ -702,9 +708,9 @@ int eServiceMP3::getInfo(int w) std::string eServiceMP3::getInfoString(int w) { - if ( !m_stream_tags ) + if ( !m_stream_tags && w < sUser && w > 26 ) return ""; - gchar *tag = 0; + const gchar *tag = 0; switch (w) { case sTagTitle: @@ -800,7 +806,6 @@ std::string eServiceMP3::getInfoString(int w) case sTagChannelMode: tag = "channel-mode"; break; - case sUser+12: return m_error_message; default: @@ -820,7 +825,7 @@ std::string eServiceMP3::getInfoString(int w) PyObject *eServiceMP3::getInfoObject(int w) { - gchar *tag = 0; + const gchar *tag = 0; bool isBuffer = false; switch (w) { @@ -991,13 +996,49 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) else eDebug("eServiceMP3::gst_message from %s: %s (without structure)", sourceName, GST_MESSAGE_TYPE_NAME(msg)); #endif - if ( GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STATE_CHANGED ) - return; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: m_event((iPlayableService*)this, evEOF); break; + case GST_MESSAGE_STATE_CHANGED: + { + if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_gst_playbin)) + return; + + GstState old_state, new_state; + gst_message_parse_state_changed(msg, &old_state, &new_state, NULL); + + if(old_state == new_state) + return; + + eDebug("eServiceMP3::state transition %s -> %s", gst_element_state_get_name(old_state), gst_element_state_get_name(new_state)); + + GstStateChange transition = (GstStateChange)GST_STATE_TRANSITION(old_state, new_state); + + switch(transition) + { + case GST_STATE_CHANGE_NULL_TO_READY: + { + } break; + case GST_STATE_CHANGE_READY_TO_PAUSED: + { + } break; + case GST_STATE_CHANGE_PAUSED_TO_PLAYING: + { + } break; + case GST_STATE_CHANGE_PLAYING_TO_PAUSED: + { + } break; + case GST_STATE_CHANGE_PAUSED_TO_READY: + { + } break; + case GST_STATE_CHANGE_READY_TO_NULL: + { + } break; + } + break; + } case GST_MESSAGE_ERROR: { gchar *debug; @@ -1039,7 +1080,7 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) GstTagList *tags, *result; gst_message_parse_tag(msg, &tags); - result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_PREPEND); + result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_REPLACE); if (result) { if (m_stream_tags) @@ -1058,7 +1099,6 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) eDebug("eServiceMP3::/tmp/.id3coverart %d bytes written ", ret); m_event((iPlayableService*)this, evUser+13); } - gst_tag_list_free(tags); m_event((iPlayableService*)this, evUpdatedInfo); break; @@ -1086,6 +1126,8 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) GstPad* pad = 0; g_signal_emit_by_name (m_gst_playbin, "get-audio-pad", i, &pad); GstCaps* caps = gst_pad_get_negotiated_caps(pad); + if (!caps) + continue; GstStructure* str = gst_caps_get_structure(caps, 0); gchar *g_type; g_type = gst_structure_get_name(str); @@ -1098,6 +1140,7 @@ eDebug("AUDIO STRUCT=%s", g_type); { gst_tag_list_get_string(tags, GST_TAG_AUDIO_CODEC, &g_codec); gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &g_lang); + gst_tag_list_free(tags); } audio.language_code = std::string(g_lang); audio.codec = std::string(g_codec); @@ -1105,6 +1148,7 @@ eDebug("AUDIO STRUCT=%s", g_type); m_audioStreams.push_back(audio); g_free (g_lang); g_free (g_codec); + gst_caps_unref(caps); } for (i = 0; i < n_text; i++) @@ -1128,6 +1172,7 @@ eDebug("AUDIO STRUCT=%s", g_type); g_free (g_lang); // g_free (g_type); } + m_event((iPlayableService*)this, evUpdatedEventInfo); } case GST_MESSAGE_ELEMENT: { @@ -1166,6 +1211,7 @@ eDebug("AUDIO STRUCT=%s", g_type); if (strstr(eventname, "Changed")) m_event((iPlayableService*)this, evVideoProgressiveChanged); } + g_free(eventname); } } } @@ -1277,20 +1323,21 @@ void eServiceMP3::pushSubtitles() ePangoSubtitlePage page; GstClockTime base_time; pts_t running_pts; - GstElement *appsink = gst_bin_get_by_name(GST_BIN(m_gst_playbin),"subtitle_sink"); + GstElement *syncsink; + g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &syncsink, NULL); GstClock *clock; - clock = gst_element_get_clock (appsink); + clock = gst_element_get_clock (syncsink); while ( !m_subtitle_pages.empty() ) { page = m_subtitle_pages.front(); - base_time = gst_element_get_base_time (appsink); - running_pts = ( gst_clock_get_time (clock) - base_time ) / 11111L; + base_time = gst_element_get_base_time (syncsink); + running_pts = gst_clock_get_time (clock) / 11111L; gint64 diff_ms = ( page.show_pts - running_pts ) / 90; -// eDebug("eServiceMP3::pushSubtitles show_pts = %lld running_pts = %lld diff = %lld", page.show_pts, running_pts, diff_ms); +// eDebug("eServiceMP3::pushSubtitles show_pts = %lld running_pts = %lld diff = %lld", page.show_pts, running_pts, diff_ms); if ( diff_ms > 20 ) { -// eDebug("m_subtitle_sync_timer->start(%lld,1)", diff_ms); +// eDebug("m_subtitle_sync_timer->start(%lld,1)", diff_ms); m_subtitle_sync_timer->start(diff_ms, 1); break; } @@ -1299,9 +1346,9 @@ void eServiceMP3::pushSubtitles() m_subtitle_widget->setPage(page); m_subtitle_pages.pop_front(); } - } ; - + } gst_object_unref (clock); + gst_object_unref (syncsink); } RESULT eServiceMP3::enableSubtitles(eWidget *parent, ePyObject tuple) @@ -1354,7 +1401,6 @@ RESULT eServiceMP3::disableSubtitles(eWidget *parent) PyObject *eServiceMP3::getCachedSubtitle() { - eDebug("eServiceMP3::getCachedSubtitle"); Py_RETURN_NONE; }