[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdereview/phonon/gstreamer
From:       Thiago Macieira <thiago () kde ! org>
Date:       2008-02-05 16:40:38
Message-ID: 1202229638.248054.3501.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 771266 by thiago:

Update changes by Jens.

Matches Perforce revision 295237.


 M  +3 -1      CMakeLists.txt  
 M  +45 -3     mediaobject.cpp  
 M  +1 -0      mediaobject.h  


--- trunk/kdereview/phonon/gstreamer/CMakeLists.txt #771265:771266
@@ -32,6 +32,8 @@
      abstractvideowidget.cpp
      videowidget.cpp
      qwidgetvideosink.cpp
+     streamreader.cpp
+     phononsrc.cpp
      message.cpp
      audioeffect.cpp
      xvideowidget.cpp
@@ -42,7 +44,7 @@
     target_link_libraries(phonon_gstreamer
         ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY}
         ${KDE4_PHONON_LIBS} ${OPENGL_gl_LIBRARY}
-	${GSTREAMER_LIBRARIES} ${GSTREAMER_INTERFACE_LIBRARY}
+	${GSTREAMER_LIBRARIES} ${GSTREAMER_BASE_LIBRARY} ${GSTREAMER_INTERFACE_LIBRARY}
 	${GSTREAMER_PLUGIN_VIDEO_LIBRARIES}
 	${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES})
     install(TARGETS phonon_gstreamer DESTINATION \
                ${PLUGIN_INSTALL_DIR}/plugins/phonon_backend)
--- trunk/kdereview/phonon/gstreamer/mediaobject.cpp #771265:771266
@@ -22,6 +22,8 @@
 #include "videowidget.h"
 #include "message.h"
 #include "backend.h"
+#include "streamreader.h"
+#include "phononsrc.h"
 
 #include <QtCore>
 #include <QtCore/QTimer>
@@ -281,6 +283,36 @@
     return true;
 }
 
+/**
+ * Create a media source from a media stream
+ *
+ * returns true if successful
+ */
+bool MediaObject::createPipefromStream(const MediaSource &source)
+{
+    // Remove any existing data source
+    if (m_datasource) {
+        gst_bin_remove(GST_BIN(m_pipeline), m_datasource);
+        // m_pipeline has the only ref to datasource
+        m_datasource = 0;
+    }
+
+    m_datasource = GST_ELEMENT(g_object_new(phonon_src_get_type(), NULL));
+    if (!m_datasource)
+        return false;
+
+    StreamReader *streamReader = new StreamReader(source);
+    g_object_set (G_OBJECT (m_datasource), "iodevice", streamReader, NULL);
+
+    // Link data source into pipeline
+    gst_bin_add(GST_BIN(m_pipeline), m_datasource);
+    if (!gst_element_link(m_datasource, m_decodebin)) {
+        gst_bin_remove(GST_BIN(m_pipeline), m_datasource);
+        return false;
+    }
+    return true;
+}
+
 void MediaObject::createPipeline()
 {
     m_pipeline = gst_pipeline_new (NULL);
@@ -661,8 +693,12 @@
     // We have to reset the state completely here, otherwise
     // remnants of the old pipeline can result in strangenes
     // such as failing duration queries etc
-    if (gst_element_set_state(m_pipeline, GST_STATE_NULL) != \
                GST_STATE_CHANGE_SUCCESS) {
-        setError(tr("Unable to flush pipeline"));
+    GstState state;
+    gst_element_set_state(m_pipeline, GST_STATE_NULL);    
+    gst_element_get_state (m_pipeline, &state, NULL, 2000);
+    if (state != GST_STATE_NULL) {
+        setError(tr("Unable to flush media pipeline"));
+        return;
     }
     m_source = source;
     emit currentSourceChanged(m_source);
@@ -719,8 +755,14 @@
         setError(tr("Source type invalid"), Phonon::NormalError);
         break;
 
+    case MediaSource::Stream:
+        if (!createPipefromStream(source)) {
+            setError(tr("Could not open stream."));
+            return;
+        }
+        break;
+
     case MediaSource::Disc: // CD tracks can be specified by setting the url in the \
                following way uri=cdda:4
-    case MediaSource::Stream:
     default:
         m_backend->logMessage("Source type not currently supported", \
Backend::Warning, this);  setError(tr("Source type not supported"), \
                Phonon::NormalError);
--- trunk/kdereview/phonon/gstreamer/mediaobject.h #771265:771266
@@ -169,6 +169,7 @@
     void changeState(State);
     void setError(const QString &errorString, Phonon::ErrorType error = \
NormalError);  bool createPipefromURL(const QString &url);
+    bool createPipefromStream(const MediaSource &);
 
 private Q_SLOTS:
     void getStreamInfo();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic