-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 27 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.h | 4 |
5 files changed, 37 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 0d9a5b8..c230d6f 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -335,43 +335,43 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { // mediaPlayerState->toggleBlank(); break; } } void MediaPlayer::cleanUp() {// this happens on closing Config cfg( "OpiePlayer" ); mediaPlayerState.writeConfig( cfg ); playList.writeDefaultPlaylist( ); // QPEApplication::grabKeyboard(); // QPEApplication::ungrabKeyboard(); } void MediaPlayer::recreateAudioAndVideoWidgets() { delete xineControl; delete audioUI; delete videoUI; audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); - xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); + xineControl = new XineControl( videoUI->vidWidget(), mediaPlayerState ); connect( xineControl, SIGNAL( initialized() ), &mediaPlayerState, SLOT( setBackendInitialized() ) ); } void MediaPlayer::reloadSkins() { audioUI->loadSkin(); videoUI->loadSkin(); } diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 14e71d9..e791c3b 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp @@ -9,82 +9,82 @@ .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qtimer.h> #include <qmessagebox.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> #include "xinecontrol.h" #include "mediaplayerstate.h" +#include "xinevideowidget.h" -XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, +XineControl::XineControl( XineVideoWidget *xineWidget, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) - : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) + : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) { libXine = new XINE::Lib( xineWidget ); - connect ( videoContainerWidget, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); - connect( libXine, SIGNAL( initialized() ), this, SIGNAL( initialized() ) ); + connect( libXine, SIGNAL( initialized() ), this, SLOT( xineInitialized() ) ); disabledSuspendScreenSaver = FALSE; } XineControl::~XineControl() { #if defined(Q_WS_QWS) && !defined(QT_NO_COP) if ( disabledSuspendScreenSaver ) { disabledSuspendScreenSaver = FALSE; // Re-enable the suspend mode QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #endif delete libXine; } void XineControl::play( const QString& fileName ) { hasVideoChannel = FALSE; hasAudioChannel = FALSE; m_fileName = fileName; qDebug("<<FILENAME: " + fileName + ">>>>"); if ( !libXine->play( fileName, 0, 0 ) ) { QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); // toggle stop so the the play button is reset mediaPlayerState.setPlaying( false ); return; } mediaPlayerState.setPlaying( true ); MediaPlayerState::DisplayType displayType; // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); @@ -97,64 +97,72 @@ void XineControl::play( const QString& fileName ) { displayType = MediaPlayerState::Video; qDebug("HAS VIDEO"); libXine->setShowVideo( true ); hasVideoChannel = TRUE; } // determine if slider is shown mediaPlayerState.setIsSeekable( libXine->isSeekable() ); // which gui (video / audio) mediaPlayerState.setDisplayType( displayType ); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) if ( !disabledSuspendScreenSaver ) { disabledSuspendScreenSaver = TRUE; // Stop the screen from blanking and power saving state QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); } #endif length(); position(); } void XineControl::nextMedia() { mediaPlayerState.setNext(); } void XineControl::setGamma( int value ) { libXine->setGamma( value ); } +void XineControl::xineInitialized() +{ + connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); + libXine->resize( xineVideoWidget->videoSize() ); + + emit initialized(); +} + void XineControl::stop( bool isSet ) { if ( !isSet ) { libXine->stop(); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) if ( disabledSuspendScreenSaver ) { disabledSuspendScreenSaver = FALSE; // Re-enable the suspend mode QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #endif } } /** * Pause playback * @isSet */ void XineControl::pause( bool isSet) { libXine->pause( isSet ); } /** * get current time in playback */ long XineControl::currentTime() { // todo: jede sekunde überprüfen m_currentTime = libXine->currentTime(); return m_currentTime; QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); } diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 000529c..085de3f 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h @@ -13,110 +13,114 @@ .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef XINECONTROL_H #define XINECONTROL_H #include "lib.h" #include <qobject.h> #include "mediaplayerstate.h" class XineControl : public QObject { Q_OBJECT public: - XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, + XineControl( XineVideoWidget *xineWidget, MediaPlayerState &_mediaPlayerState, QObject *parent = 0, const char *name =0 ); ~XineControl(); bool hasVideo() const { return hasVideoChannel; } bool hasAudio() const { return hasAudioChannel; } public slots: void play( const QString& fileName ); void stop( bool ); /** * Pause the media stream * @param if pause or not */ void pause( bool ); /** * Set videos fullscreen * @param yes or no */ void setFullscreen( bool ); /** * */ long currentTime(); void seekTo( long ); // get length of media file and set it void length(); long position(); /** * Proceed to the next media file in playlist */ void nextMedia(); /** * Get as much info about the stream from xine as possible */ QString getMetaInfo(); /** * get the error code and "translate" it for the user * */ QString getErrorCode(); void videoResized ( const QSize &s ); /** * Set the gamma value of the video output * @param int value between -100 and 100, 0 is original */ void setGamma( int ); +private slots: + void xineInitialized(); + private: XINE::Lib *libXine; long m_currentTime; long m_position; int m_length; QString m_fileName; bool disabledSuspendScreenSaver : 1; bool hasVideoChannel : 1; bool hasAudioChannel : 1; MediaPlayerState &mediaPlayerState; + XineVideoWidget *xineVideoWidget; signals: void positionChanged( long ); void initialized(); }; #endif diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 1d88cea..791818e 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp @@ -79,64 +79,79 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t st while ( len-- ) { ((char *) src ) -= step; *((short int *) dst )++ = *((short int *) src ); } } XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) { setBackgroundMode ( NoBackground ); m_logo = 0; m_buff = 0; m_bytes_per_line_fb = qt_screen-> linestep ( ); m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; m_rotation = 0; } XineVideoWidget::~XineVideoWidget ( ) { delete m_logo; } void XineVideoWidget::clear ( ) { m_buff = 0; repaint ( false ); } +QSize XineVideoWidget::videoSize() const +{ + QSize s = size(); + bool fs = ( s == qApp->desktop()->size() ); + + // if we are in fullscreen mode, do not rotate the video + // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) + m_rotation = fs ? - qt_screen->transformOrientation() : 0; + + if ( fs && qt_screen->isTransformed() ) + s = qt_screen->mapToDevice( s ); + + return s; +} + void XineVideoWidget::paintEvent ( QPaintEvent * ) { if ( m_buff == 0 ) { QPainter p ( this ); p. fillRect ( rect ( ), black ); if ( m_logo ) p. drawImage ( 0, 0, *m_logo ); } else { // Qt needs to be notified which areas were really updated .. strange QArray <QRect> qt_bug_workaround_clip_rects; { QDirectPainter dp ( this ); int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation uchar *fb = dp. frameBuffer ( ); uchar *frame = m_buff; // where is the video frame in fb coordinates QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { const QRect &clip = dp. rect ( i ); qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb uchar *src = frame; @@ -222,51 +237,41 @@ QImage *XineVideoWidget::logo ( ) const } void XineVideoWidget::setLogo ( QImage* logo ) { delete m_logo; m_logo = logo; } void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) { bool rot90 = (( -m_rotation ) & 1 ); if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height int d = w; w = h; h = d; } m_lastframe = m_thisframe; m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); m_buff = img; m_bytes_per_line_frame = bpl; // only repaint the area that *really* needs to be repainted repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); } void XineVideoWidget::resizeEvent ( QResizeEvent * ) { - QSize s = size ( ); - bool fs = ( s == qApp-> desktop ( )-> size ( )); - - // if we are in fullscreen mode, do not rotate the video - // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) - m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; - - if ( fs && qt_screen-> isTransformed ( )) - s = qt_screen-> mapToDevice ( s ); - - emit videoResized ( s ); + emit videoResized( videoSize() ); } void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) { emit clicked(); } diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h index 33f1470..8b3a3ea 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.h +++ b/noncore/multimedia/opieplayer2/xinevideowidget.h @@ -21,54 +21,56 @@ ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qwidget.h> #include "lib.h" class QImage; class XineVideoWidget : public QWidget { Q_OBJECT public: XineVideoWidget ( QWidget* parent, const char* name ); ~XineVideoWidget ( ); QImage *logo ( ) const; void setLogo ( QImage *image ); void setVideoFrame ( uchar *image, int width, int height, int linestep ); void clear ( ); + QSize videoSize() const; + protected: void paintEvent( QPaintEvent *p ); void resizeEvent ( QResizeEvent *r ); void mouseReleaseEvent ( QMouseEvent *e ); signals: void clicked ( ); void videoResized ( const QSize &s ); private: QRect m_lastframe; QRect m_thisframe; uchar *m_buff; int m_bytes_per_line_fb; int m_bytes_per_line_frame; int m_bytes_per_pixel; QImage *m_logo; - int m_rotation; + mutable int m_rotation; }; |