X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fservice%2Fservicemp3.cpp;h=0aaaaaa737bf937250d050065a82c81c6e1ec07d;hp=2332e9fdb7e71b25b2610aa706c7d7b676643c77;hb=045c47f76723e0aea8d9ed8394f2dee06df28856;hpb=c07285203f9efae521154626c2e05442f88e5634 diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp old mode 100644 new mode 100755 index 2332e9f..0aaaaaa --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -222,13 +222,15 @@ eServiceMP3::eServiceMP3(eServiceReference ref) m_stream_tags = 0; m_currentAudioStream = -1; m_currentSubtitleStream = 0; - m_audioStream_manually_changed = FALSE; m_subtitle_widget = 0; m_currentTrickRatio = 0; m_subs_to_pull = 0; m_buffer_size = 1*1024*1024; m_prev_decoder_time = -1; m_decoder_time_valid_state = 0; + m_errorInfo.missing_codec = ""; + //vuplus + m_is_hls_stream = 0; CONNECT(m_seekTimeout->timeout, eServiceMP3::seekTimeoutCB); CONNECT(m_subtitle_sync_timer->timeout, eServiceMP3::pushSubtitles); @@ -284,7 +286,7 @@ eServiceMP3::eServiceMP3(eServiceReference ref) m_sourceinfo.containertype = ctVCD; m_sourceinfo.is_video = TRUE; } - 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 || (strncmp(filename, "rtspt://", 7)) == 0 ) + if ( strstr(filename, "://") ) m_sourceinfo.is_streaming = TRUE; gchar *uri; @@ -328,7 +330,7 @@ eServiceMP3::eServiceMP3(eServiceReference ref) m_gst_playbin = gst_element_factory_make("playbin2", "playbin"); if (!m_gst_playbin) - m_error_message = "failed to create GStreamer pipeline!\n"; + m_errorInfo.error_message = "failed to create GStreamer pipeline!\n"; g_object_set (G_OBJECT (m_gst_playbin), "uri", uri, NULL); @@ -372,7 +374,7 @@ eServiceMP3::eServiceMP3(eServiceReference ref) if (m_gst_playbin) gst_object_unref(GST_OBJECT(m_gst_playbin)); - eDebug("eServiceMP3::sorry, can't play: %s",m_error_message.c_str()); + eDebug("eServiceMP3::sorry, can't play: %s",m_errorInfo.error_message.c_str()); m_gst_playbin = 0; } @@ -936,7 +938,7 @@ std::string eServiceMP3::getInfoString(int w) tag = "channel-mode"; break; case sUser+12: - return m_error_message; + return m_errorInfo.error_message; default: return ""; } @@ -1056,7 +1058,6 @@ RESULT eServiceMP3::selectTrack(unsigned int i) if (ppos < 0) ppos = 0; - m_audioStream_manually_changed = TRUE; int ret = selectAudioStream(i); if (!ret) { /* flush */ @@ -1167,18 +1168,18 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) return; gchar *sourceName; GstObject *source; - source = GST_MESSAGE_SRC(msg); + if (!GST_IS_OBJECT(source)) + return; sourceName = gst_object_get_name(source); #if 0 + gchar *string; if (gst_message_get_structure(msg)) - { - gchar *string = gst_structure_to_string(gst_message_get_structure(msg)); - eDebug("eServiceMP3::gst_message from %s: %s", sourceName, string); - g_free(string); - } + string = gst_structure_to_string(gst_message_get_structure(msg)); else - eDebug("eServiceMP3::gst_message from %s: %s (without structure)", sourceName, GST_MESSAGE_TYPE_NAME(msg)); + string = g_strdup(GST_MESSAGE_TYPE_NAME(msg)); + eDebug("eTsRemoteSource::gst_message from %s: %s", sourceName, string); + g_free(string); #endif switch (GST_MESSAGE_TYPE (msg)) { @@ -1188,7 +1189,15 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) case GST_MESSAGE_STATE_CHANGED: { if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_gst_playbin)) + { + //vuplus + if(!strncmp(sourceName, "hls", 3)) + { + //eDebug("HLS Protocol detected : source [%s]", sourceName); + m_is_hls_stream = 1; + } break; + } GstState old_state, new_state; gst_message_parse_state_changed(msg, &old_state, &new_state, NULL); @@ -1242,7 +1251,7 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) GError *err; gst_message_parse_error (msg, &err, &debug); g_free (debug); - eWarning("Gstreamer error: %s (%i) from %s", err->message, err->code, sourceName ); + eWarning("Gstreamer error: %s (domain:%i, code:%i) from %s", err->message, err->domain, err->code, sourceName ); if ( err->domain == GST_STREAM_ERROR ) { if ( err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND ) @@ -1250,21 +1259,14 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) if ( g_strrstr(sourceName, "videosink") ) m_event((iPlayableService*)this, evUser+11); else if ( g_strrstr(sourceName, "audiosink") ) - { - if ( getNumberOfTracks() == 1 || m_audioStream_manually_changed == TRUE ) - { - m_event((iPlayableService*)this, evUser+10); - } - else - { - int next_track = getCurrentTrack() + 1; - if ( next_track >= getNumberOfTracks() ) - next_track = 0; - selectAudioStream(next_track); - } - } + m_event((iPlayableService*)this, evUser+10); } } + else //if( err->domain == 1232 ) + { + if ( err->code == 5 ) + m_event((iPlayableService*)this, evUser+20); + } g_error_free(err); break; } @@ -1332,7 +1334,6 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) m_audioStreams.clear(); m_subtitleStreams.clear(); - m_audioStream_manually_changed = FALSE; for (i = 0; i < n_audio; i++) { @@ -1392,45 +1393,58 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) g_free (g_lang); } m_event((iPlayableService*)this, evUpdatedEventInfo); + + if ( m_errorInfo.missing_codec != "" ) + { + if ( m_errorInfo.missing_codec.find("video/") == 0 || ( m_errorInfo.missing_codec.find("audio/") == 0 && getNumberOfTracks() == 0 ) ) + m_event((iPlayableService*)this, evUser+12); + } break; } case GST_MESSAGE_ELEMENT: { - if ( gst_is_missing_plugin_message(msg) ) + if (const GstStructure *msgstruct = gst_message_get_structure(msg)) { - gchar *description = gst_missing_plugin_message_get_description(msg); - - if ( description ) - { - m_error_message = "GStreamer plugin " + (std::string)description + " not available!\n"; - g_free(description); - m_event((iPlayableService*)this, evUser+12); - } - } - else if (const GstStructure *msgstruct = gst_message_get_structure(msg)) - { - const gchar *eventname = gst_structure_get_name(msgstruct); - if ( eventname ) + if ( gst_is_missing_plugin_message(msg) ) { - if (!strcmp(eventname, "eventSizeChanged") || !strcmp(eventname, "eventSizeAvail")) - { - gst_structure_get_int (msgstruct, "aspect_ratio", &m_aspect); - gst_structure_get_int (msgstruct, "width", &m_width); - gst_structure_get_int (msgstruct, "height", &m_height); - if (strstr(eventname, "Changed")) - m_event((iPlayableService*)this, evVideoSizeChanged); - } - else if (!strcmp(eventname, "eventFrameRateChanged") || !strcmp(eventname, "eventFrameRateAvail")) + GstCaps *caps; + gst_structure_get (msgstruct, "detail", GST_TYPE_CAPS, &caps, NULL); + std::string codec = (const char*) gst_caps_to_string(caps); + gchar *description = gst_missing_plugin_message_get_description(msg); + if ( description ) { - gst_structure_get_int (msgstruct, "frame_rate", &m_framerate); - if (strstr(eventname, "Changed")) - m_event((iPlayableService*)this, evVideoFramerateChanged); + eDebug("eServiceMP3::m_errorInfo.missing_codec = %s", codec.c_str()); + m_errorInfo.error_message = "GStreamer plugin " + (std::string)description + " not available!\n"; + m_errorInfo.missing_codec = codec.substr(0,(codec.find_first_of(','))); + g_free(description); } - else if (!strcmp(eventname, "eventProgressiveChanged") || !strcmp(eventname, "eventProgressiveAvail")) + gst_caps_unref(caps); + } + else + { + const gchar *eventname = gst_structure_get_name(msgstruct); + if ( eventname ) { - gst_structure_get_int (msgstruct, "progressive", &m_progressive); - if (strstr(eventname, "Changed")) - m_event((iPlayableService*)this, evVideoProgressiveChanged); + if (!strcmp(eventname, "eventSizeChanged") || !strcmp(eventname, "eventSizeAvail")) + { + gst_structure_get_int (msgstruct, "aspect_ratio", &m_aspect); + gst_structure_get_int (msgstruct, "width", &m_width); + gst_structure_get_int (msgstruct, "height", &m_height); + if (strstr(eventname, "Changed")) + m_event((iPlayableService*)this, evVideoSizeChanged); + } + else if (!strcmp(eventname, "eventFrameRateChanged") || !strcmp(eventname, "eventFrameRateAvail")) + { + gst_structure_get_int (msgstruct, "frame_rate", &m_framerate); + if (strstr(eventname, "Changed")) + m_event((iPlayableService*)this, evVideoFramerateChanged); + } + else if (!strcmp(eventname, "eventProgressiveChanged") || !strcmp(eventname, "eventProgressiveAvail")) + { + gst_structure_get_int (msgstruct, "progressive", &m_progressive); + if (strstr(eventname, "Changed")) + m_event((iPlayableService*)this, evVideoProgressiveChanged); + } } } } @@ -1467,7 +1481,13 @@ void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg) g_object_set (G_OBJECT (owner), "timeout", HTTP_TIMEOUT, NULL); eDebug("eServiceMP3::GST_STREAM_STATUS_TYPE_CREATE -> setting timeout on %s to %is", name, HTTP_TIMEOUT); } - + //vuplus + else if (m_is_hls_stream && !strncmp(name, "queue", 5)) + { + m_streamingsrc_timeout->stop(); + m_is_hls_stream = 0; + //eDebug("Stoped response timeout!! : HLS"); + } } if ( GST_IS_PAD(source) ) gst_object_unref(owner);