00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "mmsmedia/mmsvideo.h"
00034
00035 MMS_CREATEERROR(MMSVideoError);
00036
00037 #ifdef __HAVE_GSTREAMER__
00038 #endif
00039 #ifdef __HAVE_XINE__
00040
00041
00042
00043
00044
00045
00046 static void queue_cb(void *userData, const xine_event_t *event) {
00047 MMSVideo *mmsvideo = (MMSVideo*)userData;
00048
00049 switch(event->type) {
00050 case XINE_EVENT_UI_MESSAGE: {
00051 xine_ui_message_data_t *msg = (xine_ui_message_data_t*)event->data;
00052 if(msg->explanation)
00053 mmsvideo->onError->emit(string((char*)msg + msg->parameters));
00054 break;
00055 }
00056 case XINE_EVENT_MRL_REFERENCE_EXT: {
00057 xine_mrl_reference_data_ext_t *mrl_ref = (xine_mrl_reference_data_ext_t*)event->data;
00058 DEBUGMSG("MMSVideo", "new mrl: %s\n", mrl_ref->mrl);
00059 mmsvideo->add2Playlist(mrl_ref->mrl);
00060 break;
00061 }
00062 case XINE_EVENT_PROGRESS: {
00063 xine_progress_data_t *prog = (xine_progress_data_t*)event->data;
00064 DEBUGMSG("MMSVideo", "event: %s (%d%%)", prog->description, prog->percent);
00065 if(mmsvideo) mmsvideo->onProgressChange.emit(prog->percent);
00066 break;
00067 }
00068 case XINE_EVENT_UI_PLAYBACK_FINISHED:
00069 try {
00070 mmsvideo->playNext();
00071 } catch(MMSError &e) {
00072 DEBUGMSG("MMSVideo", "Error playing stream: " + e.getMessage());
00073 mmsvideo->onError->emit(e.getMessage());
00074 }
00075 break;
00076 default:
00077 DEBUGMSG("MMSVideo", "Unhandled event: %d", event->type);
00078 break;
00079 }
00080 }
00081 #endif
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 MMSVideo::MMSVideo(MMSWindow *window, const bool verbose) {
00093 MMSAV::initialize(verbose, window);
00094 }
00095
00096
00097
00098
00099 MMSVideo::~MMSVideo() {
00100 }
00101
00102 #ifdef __HAVE_GSTREAMER__
00103 #endif
00104 #ifdef __HAVE_XINE__
00105
00106
00107
00108 void MMSVideo::xineOpen() {
00109 MMSAV::xineOpen(queue_cb, (void*)this);
00110 }
00111 #endif
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 void MMSVideo::startPlaying(const string file, const bool cont) {
00125
00126 #ifdef __HAVE_XINE__
00127 this->xineOpen();
00128 #endif
00129
00130
00131 string::size_type loc = file.find( "://", 0 );
00132 if( loc != string::npos ) {
00133
00134 MMSAV::startPlaying(file, cont);
00135 }
00136 else {
00137
00138 MMSAV::startPlaying("file://" + file, cont);
00139 }
00140 }
00141
00142
00143
00144
00145
00146
00147 void MMSVideo::add2Playlist(const string file) {
00148 playlist.push(file);
00149 }
00150
00151
00152
00153
00154
00155
00156 void MMSVideo::playNext() {
00157 if(!playlist.empty()) {
00158 string file = playlist.front();
00159 playlist.pop();
00160 startPlaying(file, false);
00161 }
00162 }