@ -22,13 +22,13 @@
# include <math.h>
# include <config.h>
# include <dcopclient.h>
# include <qcstring.h>
# include <qtimer.h>
# include <qfile.h>
# include <qurl.h>
# include <qthread.h>
# include <qmutex.h>
# include <qdom.h>
# include <t qcstring.h>
# include <t qtimer.h>
# include <t qfile.h>
# include <t qurl.h>
# include <t qthread.h>
# include <t qmutex.h>
# include <t qdom.h>
# include "kmplayer_backend.h"
# include "kmplayer_callback_stub.h"
# include "kmplayer_callback.h"
@ -48,7 +48,7 @@ static Display *display;
static KGStreamerPlayer * gstapp ;
static KMPlayer : : Callback_stub * callback ;
static Window wid ;
static QMutex mutex ( true ) ;
static T QMutex mutex ( true ) ;
static bool window_created = true ;
static bool wants_config ;
static bool verbose ;
@ -59,15 +59,15 @@ static int movie_height;
static int movie_length ;
static int repeat_count ;
static int screen ;
static const int event_finished = QEvent : : User ;
static const int event_playing = QEvent : : User + 1 ;
static const int event_size = QEvent : : User + 2 ;
static const int event_eos = QEvent : : User + 3 ;
static const int event_progress = QEvent : : User + 4 ;
static const int event_error = QEvent : : User + 5 ;
static const int event_video = QEvent : : User + 6 ;
static QString mrl ;
static QString sub_mrl ;
static const int event_finished = T QEvent: : User ;
static const int event_playing = T QEvent: : User + 1 ;
static const int event_size = T QEvent: : User + 2 ;
static const int event_eos = T QEvent: : User + 3 ;
static const int event_progress = T QEvent: : User + 4 ;
static const int event_error = T QEvent: : User + 5 ;
static const int event_video = T QEvent: : User + 6 ;
static T QString mrl ;
static T QString sub_mrl ;
static const char * ao_driver ;
static const char * vo_driver ;
static const char * playbin_name = " player " ;
@ -75,24 +75,24 @@ static const char *dvd_device;
static const char * vcd_device ;
static GstElement * gst_elm_play ;
static GstBus * gst_bus ;
static unsigned int /*GstMessageType*/ ignore_messages_mask ;
static unsigned int /*GstMessageType*/ ignore_messages_tq mask ;
static GstXOverlay * xoverlay ;
static GstColorBalance * color_balance ;
static gulong gst_bus_sync ;
static gulong gst_bus_async ;
static QString elmentry ( " entry " ) ;
static QString elmitem ( " item " ) ;
static QString attname ( " NAME " ) ;
static QString atttype ( " TYPE " ) ;
static QString attdefault ( " DEFAULT " ) ;
static QString attvalue ( " VALUE " ) ;
static QString attstart ( " START " ) ;
static QString attend ( " END " ) ;
static QString valrange ( " range " ) ;
static QString valnum ( " num " ) ;
static QString valbool ( " bool " ) ;
static QString valenum ( " enum " ) ;
static QString valstring ( " string " ) ;
static T QString elmentry ( " entry " ) ;
static T QString elmitem ( " item " ) ;
static T QString attname ( " NAME " ) ;
static T QString atttype ( " TYPE " ) ;
static T QString attdefault ( " DEFAULT " ) ;
static T QString attvalue ( " VALUE " ) ;
static T QString attstart ( " START " ) ;
static T QString attend ( " END " ) ;
static T QString valrange ( " range " ) ;
static T QString valnum ( " num " ) ;
static T QString valbool ( " bool " ) ;
static T QString valenum ( " enum " ) ;
static T QString valstring ( " string " ) ;
extern " C " {
// nothing yet
@ -111,7 +111,7 @@ cb_error (GstElement * play,
fprintf ( stderr , " cb_error: %s %s \n " , err - > message , debug ) ;
if ( GST_STATE ( play ) = = GST_STATE_PLAYING )
gst_element_set_state ( play , GST_STATE_READY ) ;
QApplication : : postEvent ( gstapp , new QEvent ( ( QEvent : : Type ) event_finished ) ) ;
T QApplication: : postEvent ( gstapp , new T QEvent ( ( T QEvent: : Type ) event_finished ) ) ;
}
// NULL -> READY -> PAUSED -> PLAYING
@ -124,7 +124,7 @@ gstCapsSet (GstPad *pad,
GstCaps * caps = gst_pad_get_negotiated_caps ( pad ) ;
if ( ! caps )
return ;
QApplication : : postEvent ( gstapp , new QEvent ( ( QEvent : : Type ) event_video ) ) ;
T QApplication: : postEvent ( gstapp , new T QEvent ( ( T QEvent: : Type ) event_video ) ) ;
const GstStructure * s = gst_caps_get_structure ( caps , 0 ) ;
if ( s ) {
const GValue * par ;
@ -140,7 +140,7 @@ gstCapsSet (GstPad *pad,
else
movie_height = ( int ) ( ( float ) den * movie_height / num ) ;
}
QApplication : : postEvent ( gstapp , new GstSizeEvent ( movie_length , movie_width , movie_height ) ) ;
T QApplication: : postEvent ( gstapp , new GstSizeEvent ( movie_length , movie_width , movie_height ) ) ;
}
gst_caps_unref ( caps ) ;
}
@ -204,7 +204,7 @@ static void gstGetDuration () {
if ( movie_length ! = len / ( GST_MSECOND * 100 ) ) {
movie_length = len / ( GST_MSECOND * 100 ) ;
fprintf ( stderr , " new length %d \n " , movie_length ) ;
QApplication : : postEvent ( gstapp , new GstSizeEvent ( movie_length , movie_width , movie_height ) ) ;
T QApplication: : postEvent ( gstapp , new GstSizeEvent ( movie_length , movie_width , movie_height ) ) ;
}
}
@ -217,12 +217,12 @@ static void gstTag (const GstTagList *, const gchar *tag, gpointer) {
static void gstBusMessage ( GstBus * , GstMessage * message , gpointer ) {
GstMessageType msg_type = GST_MESSAGE_TYPE ( message ) ;
/* somebody else is handling the message, probably in gstPolForStateChange*/
if ( ignore_messages_mask & msg_type )
if ( ignore_messages_tq mask & msg_type )
return ;
switch ( msg_type ) {
case GST_MESSAGE_ERROR :
fprintf ( stderr , " error msg \n " ) ;
QApplication : : postEvent ( gstapp , new QEvent ( ( QEvent : : Type ) event_error ) ) ;
T QApplication: : postEvent ( gstapp , new T QEvent ( ( T QEvent: : Type ) event_error ) ) ;
if ( gst_elm_play ) {
gst_element_set_state ( gst_elm_play , GST_STATE_NULL ) ;
//gstPollForStateChange (gst_elm_play, GST_STATE_NULL);
@ -246,7 +246,7 @@ static void gstBusMessage (GstBus *, GstMessage * message, gpointer) {
case GST_MESSAGE_BUFFERING : {
gint percent = 0 ;
gst_structure_get_int ( message - > structure , " buffer-percent " , & percent ) ;
QApplication : : postEvent ( gstapp , new GstProgressEvent ( percent ) ) ;
T QApplication: : postEvent ( gstapp , new GstProgressEvent ( percent ) ) ;
//fprintf (stderr, "Buffering message (%u%%)\n", percent);
break ;
}
@ -266,7 +266,7 @@ static void gstBusMessage (GstBus *, GstMessage * message, gpointer) {
if ( old_state = = GST_STATE_PAUSED & &
new_state > = GST_STATE_PLAYING ) {
gstGetDuration ( ) ;
QApplication : : postEvent ( gstapp , new QEvent ( ( QEvent : : Type ) event_playing ) ) ;
T QApplication: : postEvent ( gstapp , new T QEvent ( ( T QEvent: : Type ) event_playing ) ) ;
} else if ( old_state > = GST_STATE_PAUSED & &
new_state < = GST_STATE_READY ) {
if ( repeat_count - - > 0 & &
@ -274,8 +274,8 @@ static void gstBusMessage (GstBus *, GstMessage * message, gpointer) {
gstPollForStateChange ( gst_elm_play , GST_STATE_PAUSED ) ) )
gst_element_set_state ( gst_elm_play , GST_STATE_PLAYING ) ;
else
QApplication : : postEvent ( gstapp ,
new QEvent ( ( QEvent : : Type ) event_finished ) ) ;
T QApplication: : postEvent ( gstapp ,
new T QEvent ( ( T QEvent: : Type ) event_finished ) ) ;
}
}
//g_free (src_name);
@ -310,14 +310,14 @@ static bool gstPollForStateChange (GstElement *element, GstState state, gint64 t
GError * * error = 0L ;
events = GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS ;
saved_events = ignore_messages_mask ;
saved_events = ignore_messages_tq mask ;
if ( element & & element = = gst_elm_play ) {
/* we do want the main handler to process state changed messages for
* playbin as well , otherwise it won ' t hook up the timeout etc . */
ignore_messages_mask | = ( events ^ GST_MESSAGE_STATE_CHANGED ) ;
ignore_messages_tq mask | = ( events ^ GST_MESSAGE_STATE_CHANGED ) ;
} else {
ignore_messages_mask | = events ;
ignore_messages_tq mask | = events ;
}
while ( true ) {
@ -367,14 +367,14 @@ static bool gstPollForStateChange (GstElement *element, GstState state, gint64 t
success :
/* state change succeeded */
fprintf ( stderr , " state change to %s succeeded \n " , gst_element_state_get_name ( state ) ) ;
ignore_messages_mask = saved_events ;
ignore_messages_tq mask = saved_events ;
return true ;
timed_out :
/* it's taking a long time to open -- just tell totem it was ok, this allows
* the user to stop the loading process with the normal stop button */
fprintf ( stderr , " state change to %s timed out, returning success and handling errors asynchroneously \n " , gst_element_state_get_name ( state ) ) ;
ignore_messages_mask = saved_events ;
ignore_messages_tq mask = saved_events ;
return true ;
error :
@ -382,20 +382,20 @@ error:
gst_element_state_get_name ( state ) ,
( error & & * error ) ? ( * error ) - > message : " unknown " ) ;
/* already set *error */
ignore_messages_mask = saved_events ;
QApplication : : postEvent ( gstapp , new QEvent ( ( QEvent : : Type ) event_error ) ) ;
ignore_messages_tq mask = saved_events ;
T QApplication: : postEvent ( gstapp , new T QEvent ( ( T QEvent: : Type ) event_error ) ) ;
return false ;
}
//-----------------------------------------------------------------------------
GstSizeEvent : : GstSizeEvent ( int l , int w , int h )
: QEvent ( ( QEvent : : Type ) event_size ) ,
: T QEvent ( ( T QEvent: : Type ) event_size ) ,
length ( l ) , width ( w ) , height ( h )
{ }
GstProgressEvent : : GstProgressEvent ( const int p )
: QEvent ( ( QEvent : : Type ) event_progress ) , progress ( p )
: T QEvent ( ( T QEvent: : Type ) event_progress ) , progress ( p )
{ }
//-----------------------------------------------------------------------------
@ -403,16 +403,16 @@ GstProgressEvent::GstProgressEvent (const int p)
using namespace KMPlayer ;
Backend : : Backend ( )
: DCOPObject ( QCString ( " Backend " ) ) {
: DCOPObject ( T QCString ( " Backend " ) ) {
}
Backend : : ~ Backend ( ) { }
void Backend : : setURL ( QString url ) {
void Backend : : setURL ( T QString url ) {
mrl = url ;
}
void Backend : : setSubTitleURL ( QString url ) {
void Backend : : setSubTitleURL ( T QString url ) {
sub_mrl = url ;
}
@ -421,7 +421,7 @@ void Backend::play (int repeat) {
}
void Backend : : stop ( ) {
QTimer : : singleShot ( 0 , gstapp , SLOT ( stop ( ) ) ) ;
T QTimer: : singleShot ( 0 , gstapp , TQT_ SLOT ( stop ( ) ) ) ;
}
void Backend : : pause ( ) {
@ -455,10 +455,10 @@ void Backend::volume (int v, bool) {
void Backend : : frequency ( int ) {
}
void Backend : : setAudioLang ( int , QString ) {
void Backend : : setAudioLang ( int , T QString) {
}
void Backend : : setSubtitle ( int , QString ) {
void Backend : : setSubtitle ( int , T QString) {
}
void Backend : : quit ( ) {
@ -467,29 +467,29 @@ void Backend::quit () {
if ( running )
stop ( ) ;
else
QTimer : : singleShot ( 0 , qApp , SLOT ( quit ( ) ) ) ;
T QTimer: : singleShot ( 0 , t qApp, TQT_ SLOT ( quit ( ) ) ) ;
}
bool updateConfigEntry ( const QString & name , const QString & value ) {
bool updateConfigEntry ( const T QString & name , const T QString & value ) {
fprintf ( stderr , " %s=%s \n " , name . ascii ( ) , ( const char * ) value . local8Bit ( ) ) ;
return true ;
}
void Backend : : setConfig ( QByteArray /*data*/ ) {
/*QString err;
void Backend : : setConfig ( T QByteArray /*data*/ ) {
/*T QString err;
int line , column ;
QDomDocument dom ;
T QDomDocument dom ;
if ( dom . setContent ( data , false , & err , & line , & column ) ) {
if ( dom . childNodes ( ) . length ( ) = = 1 ) {
for ( QDomNode node = dom . firstChild ( ) . firstChild ( ) ;
for ( T QDomNode node = dom . firstChild ( ) . firstChild ( ) ;
! node . isNull ( ) ;
node = node . nextSibling ( ) ) {
QDomNamedNodeMap attr = node . attributes ( ) ;
T QDomNamedNodeMap attr = node . attributes ( ) ;
updateConfigEntry ( attr . namedItem ( attname ) . nodeValue ( ) ,
attr . namedItem ( attvalue ) . nodeValue ( ) ) ;
}
} else
err = QString ( " invalid data " ) ;
err = T QString ( " invalid data " ) ;
}
if ( callback )
callback - > errorMessage ( 0 , err ) ; */
@ -503,7 +503,7 @@ bool Backend::isPlaying () {
}
KGStreamerPlayer : : KGStreamerPlayer ( int _argc , char * * _argv )
: QApplication ( _argc , _argv , false ) {
: T QApplication ( _argc , _argv , false ) {
}
void KGStreamerPlayer : : init ( ) {
@ -540,11 +540,11 @@ KGStreamerPlayer::~KGStreamerPlayer () {
gstapp = 0L ;
}
void getConfigEntries ( QByteArray & buf ) {
QDomDocument doc ;
QDomElement root = doc . createElement ( QString ( " document " ) ) ;
void getConfigEntries ( T QByteArray & buf ) {
T QDomDocument doc ;
T QDomElement root = doc . createElement ( T QString ( " document " ) ) ;
doc . appendChild ( root ) ;
QCString exp = doc . toCString ( ) ;
T QCString exp = doc . toCString ( ) ;
buf = exp ;
buf . resize ( exp . length ( ) ) ; // strip terminating \0
}
@ -573,7 +573,7 @@ void KGStreamerPlayer::play (int repeat) {
fprintf ( stderr , " couldn't create playbin \n " ) ;
goto fail ;
}
ignore_messages_mask = 0 ;
ignore_messages_tq mask = 0 ;
gst_bus = gst_element_get_bus ( gst_elm_play ) ;
gst_bus_add_signal_watch ( gst_bus ) ;
@ -634,13 +634,13 @@ void KGStreamerPlayer::play (int repeat) {
if ( GST_STATE ( gst_elm_play ) > GST_STATE_READY )
gst_element_set_state ( gst_elm_play , GST_STATE_READY ) ;
if ( mrl . startsWith ( QChar ( ' / ' ) ) )
mrl = QString ( " file:// " ) + mrl ;
if ( mrl . startsWith ( T QChar ( ' / ' ) ) )
mrl = T QString ( " file:// " ) + mrl ;
uri = g_strdup ( mrl . local8Bit ( ) ) ;
g_object_set ( gst_elm_play , " uri " , uri , NULL ) ;
if ( ! sub_mrl . isEmpty ( ) ) {
if ( sub_mrl . startsWith ( QChar ( ' / ' ) ) )
sub_mrl = QString ( " file:// " ) + sub_mrl ;
if ( sub_mrl . startsWith ( T QChar ( ' / ' ) ) )
sub_mrl = T QString ( " file:// " ) + sub_mrl ;
sub_uri = g_strdup ( sub_mrl . local8Bit ( ) ) ;
g_object_set ( gst_elm_play , " suburi " , sub_uri , NULL ) ;
g_free ( sub_uri ) ;
@ -653,7 +653,7 @@ void KGStreamerPlayer::play (int repeat) {
gstPollForStateChange ( gst_elm_play , GST_STATE_PLAYING ) ;
}
g_free ( uri ) ;
QTimer : : singleShot ( 500 , this , SLOT ( updatePosition ( ) ) ) ;
T QTimer: : singleShot ( 500 , this , TQT_ SLOT ( updatePosition ( ) ) ) ;
return ;
fail :
if ( videosink ) {
@ -665,7 +665,7 @@ fail:
gst_object_unref ( audiosink ) ;
}
mutex . unlock ( ) ;
QApplication : : postEvent ( gstapp , new QEvent ( ( QEvent : : Type ) event_finished ) ) ;
T QApplication: : postEvent ( gstapp , new T QEvent ( ( T QEvent: : Type ) event_finished ) ) ;
}
void KGStreamerPlayer : : pause ( ) {
@ -697,11 +697,11 @@ void KGStreamerPlayer::stop () {
}
mutex . unlock ( ) ;
if ( ! gst_elm_play | | ( gst_elm_play & & ! notified_playing ) )
QApplication : : postEvent ( gstapp , new QEvent ( ( QEvent : : Type ) event_finished ) ) ;
T QApplication: : postEvent ( gstapp , new T QEvent ( ( T QEvent: : Type ) event_finished ) ) ;
}
void KGStreamerPlayer : : finished ( ) {
QTimer : : singleShot ( 10 , this , SLOT ( stop ( ) ) ) ;
T QTimer: : singleShot ( 10 , this , TQT_ SLOT ( stop ( ) ) ) ;
}
static void adjustColorSetting ( const char * channel , int val ) {
@ -770,11 +770,11 @@ void KGStreamerPlayer::updatePosition () {
callback - > moviePosition ( int ( val / ( GST_MSECOND * 100 ) ) ) ;
}
mutex . unlock ( ) ;
QTimer : : singleShot ( 500 , this , SLOT ( updatePosition ( ) ) ) ;
T QTimer: : singleShot ( 500 , this , TQT_ SLOT ( updatePosition ( ) ) ) ;
}
}
bool KGStreamerPlayer : : event ( QEvent * e ) {
bool KGStreamerPlayer : : event ( T QEvent * e ) {
switch ( e - > type ( ) ) {
case event_finished : {
fprintf ( stderr , " event_finished \n " ) ;
@ -797,7 +797,7 @@ bool KGStreamerPlayer::event (QEvent * e) {
if ( callback )
callback - > finished ( ) ;
else
QTimer : : singleShot ( 0 , this , SLOT ( quit ( ) ) ) ;
T QTimer: : singleShot ( 0 , this , TQT_ SLOT ( quit ( ) ) ) ;
break ;
}
//callback->movieParams (se->length/100, se->width, se->height, se->height ? 1.0*se->width/se->height : 1.0);
@ -806,7 +806,7 @@ bool KGStreamerPlayer::event (QEvent * e) {
fprintf ( stderr , " movie parms: %d %d %d \n " , se - > length , se - > width , se - > height ) ;
if ( callback ) {
if ( se - > length < 0 ) se - > length = 0 ;
callback - > movieParams ( se - > length , se - > width , se - > height , se - > height ? 1.0 * se - > width / se - > height : 1.0 , QStringList ( ) , QStringList ( ) ) ;
callback - > movieParams ( se - > length , se - > width , se - > height , se - > height ? 1.0 * se - > width / se - > height : 1.0 , T QStringList ( ) , T QStringList ( ) ) ;
}
if ( window_created & & movie_width > 0 & & movie_height > 0 ) {
XLockDisplay ( display ) ;
@ -832,7 +832,7 @@ bool KGStreamerPlayer::event (QEvent * e) {
break ;
case event_video :
if ( callback )
callback - > statusMessage ( ( int ) KMPlayer : : Callback : : stat_hasvideo , QString ( ) ) ;
callback - > statusMessage ( ( int ) KMPlayer : : Callback : : stat_hasvideo , T QString ( ) ) ;
break ;
default :
return false ;
@ -840,12 +840,12 @@ bool KGStreamerPlayer::event (QEvent * e) {
return true ;
}
void KGStreamerPlayer : : saveState ( QSessionManager & sm ) {
void KGStreamerPlayer : : saveState ( T QSessionManager & sm ) {
if ( callback )
sm . setRestartHint ( QSessionManager : : RestartNever ) ;
sm . setRestartHint ( T QSessionManager: : RestartNever ) ;
}
class XEventThread : public QThread {
class XEventThread : public T QThread {
protected :
void run ( ) {
Time prev_click_time = 0 ;
@ -967,8 +967,8 @@ int main(int argc, char **argv) {
} else if ( ! strcmp ( argv [ i ] , " -loop " ) & & i < argc - 1 ) {
repeat_count = atol ( argv [ + + i ] ) ;
} else if ( ! strcmp ( argv [ i ] , " -cb " ) ) {
QString str = argv [ + + i ] ;
int pos = str . find ( ' / ' ) ;
T QString str = argv [ + + i ] ;
int pos = str . tq find ( ' / ' ) ;
if ( pos > - 1 ) {
fprintf ( stderr , " callback is %s %s \n " , str . left ( pos ) . ascii ( ) , str . mid ( pos + 1 ) . ascii ( ) ) ;
callback = new KMPlayer : : Callback_stub
@ -979,7 +979,7 @@ int main(int argc, char **argv) {
delete gstapp ;
return 1 ;
} else {
mrl = QString : : fromLocal8Bit ( argv [ i ] ) ;
mrl = T QString: : fromLocal8Bit ( argv [ i ] ) ;
}
}
@ -993,12 +993,12 @@ int main(int argc, char **argv) {
gstapp - > init ( ) ;
if ( callback ) {
QByteArray buf ;
T QByteArray buf ;
if ( wants_config )
getConfigEntries ( buf ) ;
callback - > started ( dcopclient . appId ( ) , buf ) ;
} else
QTimer : : singleShot ( 10 , gstapp , SLOT ( play ( int ) ) ) ;
T QTimer: : singleShot ( 10 , gstapp , TQT_ SLOT ( play ( int ) ) ) ;
gstapp - > exec ( ) ;