X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fservice%2Fservicemp3.cpp;h=017c58f0abdaa3ed0e58256f5b51acfe15448447;hp=5c882ba21e5f695edbe0a976f0f4f42443fc7124;hb=5a626462406c008da1c81cf304a448d9abd19576;hpb=77923ed4e1caecf4cef7d46bd6979ef700fed7e2 diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 5c882ba..017c58f 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -16,6 +16,7 @@ #include /* for subtitles */ #include +#include // eServiceFactoryMP3 @@ -27,6 +28,7 @@ eServiceFactoryMP3::eServiceFactoryMP3() if (sc) { std::list extensions; + extensions.push_back("mp2"); extensions.push_back("mp3"); extensions.push_back("ogg"); extensions.push_back("mpg"); @@ -174,14 +176,13 @@ int eStaticServiceMP3Info::getLength(const eServiceReference &ref) eServiceMP3::eServiceMP3(const char *filename): m_filename(filename), m_pump(eApp, 1) { + m_seekTimeout = eTimer::create(eApp); m_stream_tags = 0; - m_audioStreams.clear(); - m_subtitleStreams.clear(); m_currentAudioStream = 0; m_currentSubtitleStream = 0; m_subtitle_widget = 0; m_currentTrickRatio = 0; - CONNECT(m_seekTimeout.timeout, eServiceMP3::seekTimeoutCB); + CONNECT(m_seekTimeout->timeout, eServiceMP3::seekTimeoutCB); CONNECT(m_pump.recv_msg, eServiceMP3::gstPoll); GstElement *source = 0; @@ -227,11 +228,29 @@ eServiceMP3::eServiceMP3(const char *filename): m_filename(filename), m_pump(eAp if (!m_gst_pipeline) m_error_message = "failed to create GStreamer pipeline!\n"; - if ( sourceinfo.containertype == ctCDA ) + if ( sourceinfo.is_streaming ) + { + eDebug("play webradio!"); + source = gst_element_factory_make ("neonhttpsrc", "http-source"); + if (source) + { + g_object_set (G_OBJECT (source), "location", filename, NULL); + g_object_set (G_OBJECT (source), "automatic-redirect", TRUE, NULL); + } + else + m_error_message = "GStreamer plugin neonhttpsrc not available!\n"; + } + else if ( sourceinfo.containertype == ctCDA ) { source = gst_element_factory_make ("cdiocddasrc", "cda-source"); if (source) + { g_object_set (G_OBJECT (source), "device", "/dev/cdroms/cdrom0", NULL); + int track = atoi(filename+18); + eDebug("play audio CD track #%i",track); + if (track > 0) + g_object_set (G_OBJECT (source), "track", track, NULL); + } else sourceinfo.containertype = ctNone; } @@ -243,21 +262,6 @@ eServiceMP3::eServiceMP3(const char *filename): m_filename(filename), m_pump(eAp else m_error_message = "GStreamer can't open filesrc " + (std::string)filename + "!\n"; } - else if ( sourceinfo.is_streaming ) - { - source = gst_element_factory_make ("neonhttpsrc", "http-source"); - if (source) - g_object_set (G_OBJECT (source), "automatic-redirect", TRUE, NULL); - else - m_error_message = "GStreamer plugin neonhttpsrc not available!\n"; - } - else - { - int track = atoi(filename+18); - eDebug("play audio CD track #%i",track); - if (track > 0) - g_object_set (G_OBJECT (source), "track", track, NULL); - } if ( sourceinfo.is_video ) { /* filesrc -> mpegdemux -> | queue_audio -> dvbaudiosink @@ -274,31 +278,31 @@ eServiceMP3::eServiceMP3(const char *filename): m_filename(filename), m_pump(eAp queue_audio = gst_element_factory_make("queue", "queue_audio"); queue_video = gst_element_factory_make("queue", "queue_video"); - char demux_type[14]; + std::string demux_type; switch (sourceinfo.containertype) { case ctMPEGTS: - strcat(demux_type, "flutsdemux"); + demux_type = "flutsdemux"; break; case ctMPEGPS: case ctVCD: - strcat(demux_type, "flupsdemux"); + demux_type = "flupsdemux"; break; case ctMKV: - strcat(demux_type, "matroskademux"); + demux_type = "matroskademux"; break; case ctAVI: - strcat(demux_type, "avidemux"); + demux_type = "avidemux"; break; case ctMP4: - strcat(demux_type, "qtdemux"); + demux_type = "qtdemux"; break; default: break; } - videodemux = gst_element_factory_make(demux_type, "videodemux"); + videodemux = gst_element_factory_make(demux_type.c_str(), "videodemux"); if (!videodemux) - m_error_message = "GStreamer plugin " + (std::string)demux_type + " not available!\n"; + m_error_message = "GStreamer plugin " + demux_type + " not available!\n"; switch_audio = gst_element_factory_make ("input-selector", "switch_audio"); if (!switch_audio) @@ -527,9 +531,9 @@ RESULT eServiceMP3::setFastForward(int ratio) { m_currentTrickRatio = ratio; if (ratio) - m_seekTimeout.start(1000, 0); + m_seekTimeout->start(1000, 0); else - m_seekTimeout.stop(); + m_seekTimeout->stop(); return 0; } @@ -543,13 +547,13 @@ void eServiceMP3::seekTimeoutCB() if (ppos < 0) { ppos = 0; - m_seekTimeout.stop(); + m_seekTimeout->stop(); } if (ppos > len) { ppos = 0; stop(); - m_seekTimeout.stop(); + m_seekTimeout->stop(); return; } seekTo(ppos); @@ -941,6 +945,17 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) m_audioStreams.push_back(audio); } + GValue *gv_image = gst_tag_list_get_value_index(tags, GST_TAG_IMAGE, 0); + if ( gv_image ) + { + GstBuffer *buf_image; + buf_image = gst_value_get_buffer (gv_image); + int fd = open("/tmp/.id3coverart", O_CREAT|O_WRONLY|O_TRUNC, 0644); + int ret = write(fd, GST_BUFFER_DATA(buf_image), GST_BUFFER_SIZE(buf_image)); + close(fd); + m_event((iPlayableService*)this, evUser+13); + } + gst_tag_list_free(tags); m_event((iPlayableService*)this, evUpdatedInfo); break; @@ -981,7 +996,7 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) { if ( gst_is_missing_plugin_message(msg) ) { - gchar *description = gst_missing_plugin_message_get_description(msg); + gchar *description = gst_missing_plugin_message_get_description(msg); if ( description ) { m_error_message = "GStreamer plugin " + (std::string)description + " not available!\n"; @@ -1330,7 +1345,7 @@ PyObject *eServiceMP3::getSubtitleList() ePyObject l = PyList_New(0); int stream_count[sizeof(subtype_t)]; - for ( int i = 0; i < sizeof(subtype_t); i++ ) + for ( unsigned int i = 0; i < sizeof(subtype_t); i++ ) stream_count[i] = 0; for (std::vector::iterator IterSubtitleStream(m_subtitleStreams.begin()); IterSubtitleStream != m_subtitleStreams.end(); ++IterSubtitleStream)