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

List:       kde-commits
Subject:    KDE/kdemultimedia/phonon-xine
From:       Matthias Kretz <kretz () kde ! org>
Date:       2007-02-05 20:45:30
Message-ID: 1170708330.114937.1433.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 630593 by mkretz:

make phonon_xine_ui compile again:
- the VideoWidget needs to call XineStream methods, so move that class into the
  shared xineengine lib (and add export macros). As XineStream needs AudioPort
  move that class as well
- implement setParam and eventSend methods in XineStream that call
  xine_set_param and xine_event_send on the xine_stream_t in the xine thread


 M  +3 -3      CMakeLists.txt  
 M  +15 -0     audioport.cpp  
 M  +7 -1      audioport.h  
 A             phononxineexport.h   [License: no copyright]
 M  +2 -3      ui/CMakeLists.txt  
 M  +51 -87    ui/videowidget.cpp  
 M  +0 -5      ui/videowidget.h  
 M  +1 -11     xineengine.h  
 M  +53 -1     xinestream.cpp  
 M  +4 -2      xinestream.h  


--- trunk/KDE/kdemultimedia/phonon-xine/CMakeLists.txt #630592:630593
@@ -1,9 +1,11 @@
-#add_subdirectory(ui)
+add_subdirectory(ui)
 add_subdirectory(kcm)
 #add_subdirectory(xineplugins)
 
 set(xineengine_LIB_SRCS
     xineengine.cpp
+    xinestream.cpp
+    audioport.cpp
    )
 kde4_automoc(${xineengine_LIB_SRCS})
 kde4_add_library(phononxineengine SHARED ${xineengine_LIB_SRCS})
@@ -15,8 +17,6 @@
 ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
 
 set(phonon_xine_PART_SRCS
-    audioport.cpp
-    xinestream.cpp
     abstractmediaproducer.cpp
     abstractaudiooutput.cpp
     audiodataoutput.cpp
--- trunk/KDE/kdemultimedia/phonon-xine/audioport.cpp #630592:630593
@@ -41,6 +41,21 @@
     }
 }
 
+AudioPort::AudioPort(const AudioPort &rhs)
+    : d(rhs.d)
+{
+}
+
+AudioPort &AudioPort::operator=(const AudioPort &rhs)
+{
+    d = rhs.d;
+    return *this;
+}
+
+AudioPort::~AudioPort()
+{
+}
+
 AudioPort::AudioPort(int deviceIndex)
     : d(new AudioPortData)
 {
--- trunk/KDE/kdemultimedia/phonon-xine/audioport.h #630592:630593
@@ -23,6 +23,7 @@
 #include <QSharedDataPointer>
 #include <xine.h>
 #include <QSharedData>
+#include "phononxineexport.h"
 
 class QByteArray;
 class QStringList;
@@ -42,16 +43,21 @@
         xine_audio_port_t *port;
 };
 
-class AudioPort
+class PHONON_XINE_ENGINE_EXPORT AudioPort
 {
     public:
         AudioPort() : d(new AudioPortData) {}
         AudioPort(int deviceIndex);
+
         bool isValid() const;
         bool operator==(const AudioPort& rhs) const;
         bool operator!=(const AudioPort& rhs) const;
         xine_audio_port_t *xinePort() const;
 
+        AudioPort(const AudioPort &);
+        AudioPort &operator=(const AudioPort &);
+        ~AudioPort();
+
     private:
         QSharedDataPointer<AudioPortData> d;
 };
--- trunk/KDE/kdemultimedia/phonon-xine/ui/CMakeLists.txt #630592:630593
@@ -5,7 +5,6 @@
 
 kde4_automoc(${phonon_xineui_PART_SRCS})
 kde4_add_plugin(phonon_xineui ${phonon_xineui_PART_SRCS})
-target_link_libraries(phonon_xineui ${KDE_KDEUI_LIBS} ${KDE4_PHONONUI_LIBS} \
phononxineengine) +target_link_libraries(phonon_xineui ${KDE4_PHONONUI_LIBS} \
phononxineengine)  
-
-install(TARGETS phonon_xineui DESTINATION ${PLUGIN_INSTALL_DIR} )
+install(TARGETS phonon_xineui DESTINATION ${PLUGIN_INSTALL_DIR})
--- trunk/KDE/kdemultimedia/phonon-xine/ui/videowidget.cpp #630592:630593
@@ -24,7 +24,7 @@
 #include <kdebug.h>
 
 #include <QX11Info>
-#include "../xine_engine.h"
+#include "../xineengine.h"
 #include "../abstractmediaproducer.h"
 #include <QApplication>
 
@@ -164,88 +164,59 @@
 
 void VideoWidget::setAspectRatio( Phonon::VideoWidget::AspectRatio aspectRatio )
 {
-	m_aspectRatio = aspectRatio;
-	if( m_path && m_path->producer() && m_path->producer()->stream() )
-	{
-		xine_stream_t* stream = m_path->producer()->stream();
-		switch( m_aspectRatio )
-		{
-			case Phonon::VideoWidget::AspectRatioWidget:
-				xine_set_param( stream, XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_NUM_RATIOS );
-				break;
-			case Phonon::VideoWidget::AspectRatioAuto:
-				xine_set_param( stream, XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_AUTO );
-				break;
-			case Phonon::VideoWidget::AspectRatioSquare:
-				xine_set_param( stream, XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_SQUARE );
-				break;
-			case Phonon::VideoWidget::AspectRatio4_3:
-				xine_set_param( stream, XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_4_3 );
-				break;
-			case Phonon::VideoWidget::AspectRatioAnamorphic:
-				xine_set_param( stream, XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_ANAMORPHIC );
-				break;
-			case Phonon::VideoWidget::AspectRatioDvb:
-				xine_set_param( stream, XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_DVB );
-				break;
-		}
-	}
+    m_aspectRatio = aspectRatio;
+    if (m_path && m_path->producer()) {
+        XineStream &xs = m_path->producer()->stream();
+        switch (m_aspectRatio) {
+            case Phonon::VideoWidget::AspectRatioWidget:
+                xs.setParam(XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_NUM_RATIOS);
+                break;
+            case Phonon::VideoWidget::AspectRatioAuto:
+                xs.setParam(XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_AUTO);
+                break;
+            case Phonon::VideoWidget::AspectRatioSquare:
+                xs.setParam(XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_SQUARE);
+                break;
+            case Phonon::VideoWidget::AspectRatio4_3:
+                xs.setParam(XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_4_3);
+                break;
+            case Phonon::VideoWidget::AspectRatioAnamorphic:
+                xs.setParam(XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_ANAMORPHIC);
+                break;
+            case Phonon::VideoWidget::AspectRatioDvb:
+                xs.setParam(XINE_PARAM_VO_ASPECT_RATIO, XINE_VO_ASPECT_DVB);
+                break;
+        }
+    }
 }
 
-bool VideoWidget::isVideoFullScreen() const
-{
-	return m_fullScreen;
-}
-
-void VideoWidget::setVideoFullScreen( bool newFullScreen )
-{
-	if( m_fullScreen != newFullScreen )
-	{
-		m_fullScreen = newFullScreen;
-		if( m_fullScreen )
-		{
-			QDesktopWidget* dw = QApplication::desktop();
-			QRect screenRect = dw->screenGeometry( parentWidget() );
-			m_fullScreenWindow = XCreateSimpleWindow( m_display, XDefaultRootWindow( \
                m_display ),
-					screenRect.x(), screenRect.y(), screenRect.width(), screenRect.height(), 0, 0, \
                0 );
-
-			m_visual.d = m_fullScreenWindow;
-			xine_port_send_gui_data( m_videoPort, XINE_GUI_SEND_DRAWABLE_CHANGED, \
                reinterpret_cast<void*>( m_visual.d ) );
-		}
-		else
-		{
-			m_visual.d = winId();
-			xine_port_send_gui_data( m_videoPort, XINE_GUI_SEND_DRAWABLE_CHANGED, \
                reinterpret_cast<void*>( m_visual.d ) );
-			XDestroyWindow( m_display, m_fullScreenWindow );
-		}
-	}
-}
-
 bool VideoWidget::event(QEvent *ev)
 {
     switch (ev->type()) {
-        case Xine::NavButtonIn:
+        case Xine::NavButtonInEvent:
             setCursor(QCursor(Qt::PointingHandCursor));
             ev->accept();
             return true;
-        case Xine::NavButtonOut:
+        case Xine::NavButtonOutEvent:
             setCursor(QCursor(Qt::ArrowCursor));
             ev->accept();
             return true;
+        default:
+            return QWidget::event(ev);
     }
 }
 
 void VideoWidget::mouseMoveEvent(QMouseEvent *mev)
 {
-    if (m_path && m_path->producer() && m_path->producer()->stream()) {
-        xine_stream_t *stream = m_path->producer()->stream();
+    if (m_path && m_path->producer()) {
+        XineStream &xs = m_path->producer()->stream();
         if (cursor().shape() == Qt::BlankCursor) {
             setCursor(QCursor(Qt::ArrowCursor));
         }
 
         x11_rectangle_t   rect;
-        xine_event_t      event;
-        xine_input_data_t input;
+        xine_event_t      *event = new xine_event_t;
+        xine_input_data_t *input = new xine_input_data_t;
 
         rect.x = mev->x();
         rect.y = mev->y();
@@ -254,24 +225,24 @@
 
         xine_port_send_gui_data(m_videoPort, XINE_GUI_SEND_TRANSLATE_GUI_TO_VIDEO, \
(void*)&rect);  
-        event.type        = XINE_EVENT_INPUT_MOUSE_MOVE;
-        event.data        = &input;
-        event.data_length = sizeof(input);
-        input.button      = 0;
-        input.x           = rect.x;
-        input.y           = rect.y;
-        xine_event_send(stream, &event);
+        event->type        = XINE_EVENT_INPUT_MOUSE_MOVE;
+        event->data        = input;
+        event->data_length = sizeof(*input);
+        input->button      = 0;
+        input->x           = rect.x;
+        input->y           = rect.y;
+        xs.eventSend(event);
         mev->ignore(); // forward to parent
     }
 }
 
 void VideoWidget::mousePressEvent(QMouseEvent *mev)
 {
-    if (mev->button() == Qt::LeftButton && m_path && m_path->producer() && \
                m_path->producer()->stream()) {
-        xine_stream_t* stream = m_path->producer()->stream();
+    if (mev->button() == Qt::LeftButton && m_path && m_path->producer()) {
+        XineStream &xs = m_path->producer()->stream();
         x11_rectangle_t   rect;
-        xine_event_t      event;
-        xine_input_data_t input;
+        xine_event_t      *event = new xine_event_t;
+        xine_input_data_t *input = new xine_input_data_t;
 
         rect.x = mev->x();
         rect.y = mev->y();
@@ -280,13 +251,13 @@
 
         xine_port_send_gui_data(m_videoPort, XINE_GUI_SEND_TRANSLATE_GUI_TO_VIDEO, \
(void*)&rect);  
-        event.type        = XINE_EVENT_INPUT_MOUSE_BUTTON;
-        event.data        = &input;
-        event.data_length = sizeof(input);
-        input.button      = 1;
-        input.x           = rect.x;
-        input.y           = rect.y;
-        xine_event_send(stream, &event);
+        event->type        = XINE_EVENT_INPUT_MOUSE_BUTTON;
+        event->data        = &input;
+        event->data_length = sizeof(input);
+        input->button      = 1;
+        input->x           = rect.x;
+        input->y           = rect.y;
+        xs.eventSend(event);
         mev->accept(); /* don't send event to parent */
     }
 }
@@ -360,13 +331,6 @@
 	}
 }
 
-xine_stream_t* VideoWidget::stream() const
-{
-	if( m_path && m_path->producer() )
-		return m_path->producer()->stream();
-	return 0;
-}
-
 }} //namespace Phonon::Xine
 
 #include "videowidget.moc"
--- trunk/KDE/kdemultimedia/phonon-xine/ui/videowidget.h #630592:630593
@@ -47,9 +47,6 @@
 			Q_INVOKABLE Phonon::VideoWidget::AspectRatio aspectRatio() const;
 			Q_INVOKABLE void setAspectRatio( Phonon::VideoWidget::AspectRatio aspectRatio );
 
-			Q_INVOKABLE bool isVideoFullScreen() const;
-			Q_INVOKABLE void setVideoFullScreen( bool );
-
 			Q_INVOKABLE QWidget *widget() { return this; }
 
 			xine_video_port_t* videoPort() const { return m_videoPort; }
@@ -76,8 +73,6 @@
 			virtual void changeEvent( QEvent* );
 
 		private:
-			xine_stream_t* stream() const;
-
 			xine_video_port_t* m_videoPort;
 			x11_visual_t m_visual;
 			Phonon::VideoWidget::AspectRatio m_aspectRatio;
--- trunk/KDE/kdemultimedia/phonon-xine/xineengine.h #630592:630593
@@ -20,24 +20,14 @@
 #ifndef XINEENGINE_H
 #define XINEENGINE_H
 
-#include <kdemacros.h>
 #include <xine.h>
 #include <QEvent>
 #include <QString>
 #include <QSet>
 #include <QStringList>
 #include <kconfig.h>
+#include "phononxineexport.h"
 
-#ifdef Q_OS_WIN
-# ifdef MAKE_PHONONXINEENGINE_LIB
-#  define PHONON_XINE_ENGINE_EXPORT KDE_EXPORT
-# else
-#  define PHONON_XINE_ENGINE_EXPORT KDE_IMPORT
-# endif
-#else
-# define PHONON_XINE_ENGINE_EXPORT KDE_EXPORT
-#endif
-
 namespace Phonon
 {
     class AudioDevice;
--- trunk/KDE/kdemultimedia/phonon-xine/xinestream.cpp #630592:630593
@@ -48,9 +48,26 @@
     GaplessSwitch = 2010,
     UpdateTime = 2011,
     SetTickInterval = 2012,
-    SetAboutToFinishTime = 2013
+    SetAboutToFinishTime = 2013,
+    SetParam = 2014,
+    EventSend = 2015
 };
 
+class EventSendEvent : public QEvent
+{
+    public:
+        EventSendEvent(xine_event_t *e) : \
QEvent(static_cast<QEvent::Type>(EventSend)), event(e) {} +        xine_event_t \
*event; +};
+
+class SetParamEvent : public QEvent
+{
+    public:
+        SetParamEvent(int p, int v) : QEvent(static_cast<QEvent::Type>(SetParam)), \
param(p), value(v) {} +        int param;
+        int value;
+};
+
 class MrlChangedEvent : public QEvent
 {
     public:
@@ -348,6 +365,18 @@
 }
 
 // called from main thread
+void XineStream::setParam(int param, int value)
+{
+    QCoreApplication::postEvent(this, new SetParamEvent(param, value));
+}
+
+// called from main thread
+void XineStream::eventSend(xine_event_t *event)
+{
+    QCoreApplication::postEvent(this, new EventSendEvent(event));
+}
+
+// called from main thread
 void XineStream::useGaplessPlayback(bool b)
 {
     if (m_useGaplessPlayback == b) {
@@ -531,6 +560,29 @@
         kDebug(610) << "################################ Event: " << eventName << \
endl;  }
     switch (ev->type()) {
+        case EventSend:
+            ev->accept();
+            {
+                EventSendEvent *e = static_cast<EventSendEvent *>(ev);
+                if (m_stream) {
+                    xine_event_send(m_stream, e->event);
+                }
+                switch (e->event->type) {
+                    case XINE_EVENT_INPUT_MOUSE_MOVE:
+                    case XINE_EVENT_INPUT_MOUSE_BUTTON:
+                        delete static_cast<xine_input_data_t *>(e->event->data);
+                        break;
+                }
+                delete e->event;
+            }
+            return true;
+        case SetParam:
+            ev->accept();
+            if (m_stream) {
+                SetParamEvent *e = static_cast<SetParamEvent *>(ev);
+                xine_set_param(m_stream, e->param, e->value);
+            }
+            return true;
         case Xine::MediaFinishedEvent:
             kDebug(610) << "MediaFinishedEvent m_useGaplessPlayback = " << \
m_useGaplessPlayback << endl;  if (m_useGaplessPlayback) {
--- trunk/KDE/kdemultimedia/phonon-xine/xinestream.h #630592:630593
@@ -30,6 +30,7 @@
 #include <sys/time.h>
 #include <time.h>
 #include "audioport.h"
+#include "phononxineexport.h"
 
 class QTimer;
 
@@ -47,7 +48,7 @@
  *
  * \author Matthias Kretz <kretz@kde.org>
  */
-class XineStream : public QThread
+class PHONON_XINE_ENGINE_EXPORT XineStream : public QThread
 {
     Q_OBJECT
     public:
@@ -66,7 +67,8 @@
         void setTickInterval(qint32 interval);
         void setAboutToFinishTime(qint32 time);
 
-        void setParam(int param, int value) { xine_set_param(m_stream, param, \
value); } +        void setParam(int param, int value);
+        void eventSend(xine_event_t *);
         void useGaplessPlayback(bool);
         void gaplessSwitchTo(const KUrl &url);
         void gaplessSwitchTo(const QByteArray &mrl);


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

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