summaryrefslogtreecommitdiffstats
path: root/mpeglib/example
diff options
context:
space:
mode:
Diffstat (limited to 'mpeglib/example')
-rw-r--r--mpeglib/example/Makefile.am3
-rw-r--r--mpeglib/example/cddaplay/Makefile.am33
-rw-r--r--mpeglib/example/cddaplay/cddaplay.cpp75
-rw-r--r--mpeglib/example/mpgplay/Makefile.am32
-rw-r--r--mpeglib/example/mpgplay/mpgplay.cpp74
-rw-r--r--mpeglib/example/splay/Makefile.am41
-rw-r--r--mpeglib/example/splay/mp3framing.cpp274
-rw-r--r--mpeglib/example/splay/splay.cpp64
-rw-r--r--mpeglib/example/tplay/Makefile.am32
-rw-r--r--mpeglib/example/tplay/tplay.cpp66
-rw-r--r--mpeglib/example/yaf/Makefile.am15
-rw-r--r--mpeglib/example/yaf/README4
-rw-r--r--mpeglib/example/yaf/yafcdda/Makefile.am35
-rw-r--r--mpeglib/example/yaf/yafcdda/cdda_control.cpp184
-rw-r--r--mpeglib/example/yaf/yafcore/Makefile.am44
-rw-r--r--mpeglib/example/yaf/yafcore/PROTOCOL.v01243
-rw-r--r--mpeglib/example/yaf/yafcore/README27
-rw-r--r--mpeglib/example/yaf/yafcore/buffer.cpp156
-rw-r--r--mpeglib/example/yaf/yafcore/buffer.h64
-rw-r--r--mpeglib/example/yaf/yafcore/commandLine.cpp86
-rw-r--r--mpeglib/example/yaf/yafcore/commandLine.h60
-rw-r--r--mpeglib/example/yaf/yafcore/commandTable.cpp256
-rw-r--r--mpeglib/example/yaf/yafcore/commandTable.h82
-rw-r--r--mpeglib/example/yaf/yafcore/commandTableYAF.cpp36
-rw-r--r--mpeglib/example/yaf/yafcore/commandTableYAF.h36
-rw-r--r--mpeglib/example/yaf/yafcore/inputDecoder.cpp237
-rw-r--r--mpeglib/example/yaf/yafcore/inputDecoder.h80
-rw-r--r--mpeglib/example/yaf/yafcore/inputInterface.cpp195
-rw-r--r--mpeglib/example/yaf/yafcore/inputInterface.h102
-rw-r--r--mpeglib/example/yaf/yafcore/lineStack.cpp95
-rw-r--r--mpeglib/example/yaf/yafcore/lineStack.h55
-rw-r--r--mpeglib/example/yaf/yafcore/multiReader.cpp206
-rw-r--r--mpeglib/example/yaf/yafcore/multiReader.h88
-rw-r--r--mpeglib/example/yaf/yafcore/outputDecoder.cpp144
-rw-r--r--mpeglib/example/yaf/yafcore/outputDecoder.h52
-rw-r--r--mpeglib/example/yaf/yafcore/outputInterface.cpp85
-rw-r--r--mpeglib/example/yaf/yafcore/outputInterface.h60
-rw-r--r--mpeglib/example/yaf/yafcore/parser.cpp152
-rw-r--r--mpeglib/example/yaf/yafcore/parser.h55
-rw-r--r--mpeglib/example/yaf/yafcore/runtimeTableYAF.cpp34
-rw-r--r--mpeglib/example/yaf/yafcore/runtimeTableYAF.h35
-rw-r--r--mpeglib/example/yaf/yafcore/yafCommand.defs89
-rw-r--r--mpeglib/example/yaf/yafcore/yafRuntime.defs67
-rw-r--r--mpeglib/example/yaf/yafcore/yaf_control.cpp81
-rw-r--r--mpeglib/example/yaf/yafcore/yaf_control.h26
-rw-r--r--mpeglib/example/yaf/yafmpgplay/Makefile.am34
-rw-r--r--mpeglib/example/yaf/yafmpgplay/mpg_control.cpp197
-rw-r--r--mpeglib/example/yaf/yafmpgplay/stresstest24
-rw-r--r--mpeglib/example/yaf/yafsplay/Makefile.am35
-rw-r--r--mpeglib/example/yaf/yafsplay/splay_control.cpp161
-rw-r--r--mpeglib/example/yaf/yafsplay/stresstest23
-rw-r--r--mpeglib/example/yaf/yaftplay/Makefile.am32
-rw-r--r--mpeglib/example/yaf/yaftplay/tplay_control.cpp135
-rw-r--r--mpeglib/example/yaf/yafvorbis/Makefile.am33
-rw-r--r--mpeglib/example/yaf/yafvorbis/vorbis_control.cpp150
-rw-r--r--mpeglib/example/yaf/yafxplayer/Makefile.am37
-rw-r--r--mpeglib/example/yaf/yafxplayer/README30
-rw-r--r--mpeglib/example/yaf/yafxplayer/commandTableXPlayer.cpp35
-rw-r--r--mpeglib/example/yaf/yafxplayer/commandTableXPlayer.h36
-rw-r--r--mpeglib/example/yaf/yafxplayer/inputDecoderXPlayer.cpp239
-rw-r--r--mpeglib/example/yaf/yafxplayer/inputDecoderXPlayer.h117
-rw-r--r--mpeglib/example/yaf/yafxplayer/inputDecoderYAF.cpp220
-rw-r--r--mpeglib/example/yaf/yafxplayer/inputDecoderYAF.h51
-rw-r--r--mpeglib/example/yaf/yafxplayer/runtimeTableXPlayer.cpp37
-rw-r--r--mpeglib/example/yaf/yafxplayer/runtimeTableXPlayer.h40
-rw-r--r--mpeglib/example/yaf/yafxplayer/xplayerCommand.defs84
-rw-r--r--mpeglib/example/yaf/yafxplayer/xplayerRuntime.defs123
-rw-r--r--mpeglib/example/yaf/yafxplayer/xplayer_control.cpp44
-rw-r--r--mpeglib/example/yaf/yafxplayer/xplayer_control.h25
-rw-r--r--mpeglib/example/yaf/yafxplayer/yafOutputStream.cpp307
-rw-r--r--mpeglib/example/yaf/yafxplayer/yafOutputStream.h140
-rw-r--r--mpeglib/example/yaf/yafyuv/Makefile.am37
-rw-r--r--mpeglib/example/yaf/yafyuv/yuv_control.cpp207
73 files changed, 6593 insertions, 0 deletions
diff --git a/mpeglib/example/Makefile.am b/mpeglib/example/Makefile.am
new file mode 100644
index 00000000..f5fcf06d
--- /dev/null
+++ b/mpeglib/example/Makefile.am
@@ -0,0 +1,3 @@
+
+SUBDIRS = mpgplay splay tplay cddaplay yaf
+
diff --git a/mpeglib/example/cddaplay/Makefile.am b/mpeglib/example/cddaplay/Makefile.am
new file mode 100644
index 00000000..49f42a2a
--- /dev/null
+++ b/mpeglib/example/cddaplay/Makefile.am
@@ -0,0 +1,33 @@
+# splay-yaf - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+# EXTRA_DIST = stresstest
+
+noinst_PROGRAMS = cddaplay
+
+cddaplay_SOURCES = cddaplay.cpp
+
+noinst_HEADERS =
+
+cddaplay_LDFLAGS = $(all_libraries)
+
+
+cddaplay_LDADD = ../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/cddaplay/cddaplay.cpp b/mpeglib/example/cddaplay/cddaplay.cpp
new file mode 100644
index 00000000..ecf46e74
--- /dev/null
+++ b/mpeglib/example/cddaplay/cddaplay.cpp
@@ -0,0 +1,75 @@
+/*
+ * main.c --
+ *
+ * Example program for mpegplay library.
+
+
+ */
+
+
+#include "../../lib/decoder/cddaPlugin.h"
+#include "../../lib/input/inputPlugin.h"
+
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv) {
+
+
+ if (argc <= 1) {
+ printf("Usage:\n\n");
+ printf("%s \"cdda://dev/<device> track:<nr>.cdda\n\n",argv[0]);
+ exit(0);
+ }
+ //
+ // The order is important !!!!
+ // 1. construct
+ // 2. set Output
+ // 3. open input
+ // 4. set input
+ //
+ // you cannot set the input _before_ the output
+ // in fact you can, but this gives you a segfault!
+
+ CDDAPlugin* plugin=new CDDAPlugin();
+ OutputStream* out=OutPlugin::createOutputStream(_OUTPUT_LOCAL);
+ InputStream* in= InputPlugin::createInputStream(argv[1]);
+
+
+
+ // The plugin does not do "open"
+ in->open(argv[1]);
+
+
+
+
+
+ // watch the order!
+ plugin->setOutputPlugin(out);
+ plugin->setInputPlugin(in);
+ //plugin->seek(1950);
+ cout << "hello 1 -s"<<endl;
+
+
+ plugin->play();
+ cout << "hello 1 -e"<<endl;
+
+
+ while(1) {
+ if (plugin->getStreamState() != _STREAM_STATE_EOF) {
+ cout << "******* plugin->getStreamState() continue"<<endl;
+ sleep(3);
+ continue;
+ }
+ break;
+ }
+ cout << "********************plugin eof"<<endl;
+ plugin->close();
+
+ delete plugin;
+ delete in;
+ delete out;
+
+}
+
diff --git a/mpeglib/example/mpgplay/Makefile.am b/mpeglib/example/mpgplay/Makefile.am
new file mode 100644
index 00000000..c76bd4d1
--- /dev/null
+++ b/mpeglib/example/mpgplay/Makefile.am
@@ -0,0 +1,32 @@
+# mpegplay-yaf - Makefile.am
+
+INCLUDES = $(all_includes)
+
+EXTRA_DIST =
+
+noinst_PROGRAMS = mpgplay
+
+mpgplay_SOURCES = mpgplay.cpp
+
+noinst_HEADERS =
+
+mpgplay_LDFLAGS = $(all_libraries)
+
+mpgplay_LDADD = ../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/mpgplay/mpgplay.cpp b/mpeglib/example/mpgplay/mpgplay.cpp
new file mode 100644
index 00000000..c5c1d82c
--- /dev/null
+++ b/mpeglib/example/mpgplay/mpgplay.cpp
@@ -0,0 +1,74 @@
+/*
+ * main.c --
+ *
+ * Example program for mpegplay library.
+
+
+ */
+
+#include "../../lib/decoder/mpgPlugin.h"
+#include "../../lib/util/timeWrapper.h"
+
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv) {
+
+
+ if (argc <= 1) {
+ printf("Usage:\n\n");
+ printf("%s filename\n\n",argv[0]);
+ exit(0);
+ }
+ //
+ // The order is important !!!!
+ // 1. construct
+ // 2. set Output
+ // 3. open input
+ // 4. set input
+ //
+ // you cannot set the input _before_ the output
+ // in fact you can, but this gives you a segfault!
+
+ MpgPlugin* plugin=new MpgPlugin();
+ OutputStream* out=OutPlugin::createOutputStream(_OUTPUT_LOCAL,true);
+ InputStream* in=InputPlugin::createInputStream(argv[1],true);
+
+
+
+ // The plugin does not do "open"
+ in->open(argv[1]);
+
+
+
+
+
+ // watch the order!
+ plugin->setOutputPlugin(out);
+ plugin->setInputPlugin(in);
+ //plugin->seek(1950);
+ cout << "hello 1 -s"<<endl;
+
+
+ plugin->play();
+ cout << "hello 1 -e"<<endl;
+
+
+ while(1) {
+ if (plugin->getStreamState() != _STREAM_STATE_EOF) {
+ cout << "******* plugin->getStreamState() continue"<<endl;
+ TimeWrapper::sleep(3);
+ continue;
+ }
+ break;
+ }
+ cout << "********************plugin eof"<<endl;
+ plugin->close();
+
+ delete plugin;
+ delete in;
+ delete out;
+ return(0);
+}
+
diff --git a/mpeglib/example/splay/Makefile.am b/mpeglib/example/splay/Makefile.am
new file mode 100644
index 00000000..76e04cff
--- /dev/null
+++ b/mpeglib/example/splay/Makefile.am
@@ -0,0 +1,41 @@
+# splay-yaf - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+EXTRA_DIST =
+
+noinst_PROGRAMS = splay mp3framing
+
+splay_SOURCES = splay.cpp
+
+mp3framing_SOURCES = mp3framing.cpp
+
+noinst_HEADERS =
+
+splay_LDFLAGS = $(all_libraries)
+
+splay_LDADD = ../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+mp3framing_LDFLAGS = $(all_libraries)
+mp3framing_LDADD = ../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/splay/mp3framing.cpp b/mpeglib/example/splay/mp3framing.cpp
new file mode 100644
index 00000000..586899a3
--- /dev/null
+++ b/mpeglib/example/splay/mp3framing.cpp
@@ -0,0 +1,274 @@
+/*
+
+ Example how frame creation works.
+
+ For the input we have std. file input.
+ We convert it to mpeg I encoded frames (mpegAudioFrame's job)
+
+ The decoded pcmFrames are stores in a queue.
+
+ If the queue if full, we "stream" the packets to /dev/dsp.
+ (The difference between directly playing the packets and "streaming"
+ is, that while streaming you can say: I want x bytes I don't care
+ about frame boundaries)
+ This is audioFrameQueue's job.
+
+
+ */
+
+
+#include "../../lib/splay/mpegAudioFrame.h"
+#include "../../lib/splay/splayDecoder.h"
+#include "../../lib/util/audio/dspWrapper.h"
+#include "../../lib/frame/audioFrameQueue.h"
+
+#include <iostream>
+
+using namespace std;
+
+// used for getopt
+#include <unistd.h>
+
+#define INPUT_SIZE 8192
+#define _QUEUE_FLOAT 1
+#define _QUEUE_INT 2
+
+
+void usage() {
+ printf("Usage:\n\n");
+ printf("mp3framing [hf] filename\n\n");
+ printf(" -f use float queue\n");
+ printf(" -c [samples] checkout samples\n");
+}
+
+
+void initDSP(DSPWrapper* dsp) {
+ if (dsp->openDevice()==false) {
+ cout << "cannot open /dev/dsp"<<endl;
+ exit(-1);
+ }
+}
+
+
+
+int main(int argc, char** argv) {
+ int queueType=_QUEUE_INT;
+ int samples=8192;
+
+ PCMFrame* outFrame;
+
+ while(1) {
+ int c = getopt (argc, argv, "hfc:");
+ if (c == -1) break;
+ switch(c) {
+ case 'h': {
+ usage();
+ exit(-1);
+ break;
+ }
+ case 'f': {
+ queueType=_QUEUE_FLOAT;
+ break;
+ }
+ case 'c': {
+ samples=atoi(optarg);
+ cout << "checking out samples:samples"<<endl;
+ break;
+ }
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ exit(-1);
+ }
+ }
+ // if we have nothing left, there is no filename
+ if (optind >= argc ) {
+ usage();
+ exit(-1);
+ }
+ FILE* file=fopen(argv[optind],"r");
+ if (file == NULL) {
+ cout << "cannot open:"<<argv[1]<<endl;
+ exit(-1);
+ }
+ DSPWrapper* dsp=new DSPWrapper();
+ outFrame=new PCMFrame(samples);
+
+ float* left=new float[samples];
+ float* right=new float[samples];
+
+
+ // create queue with 500 frames. We want output to dsp(later)
+ // so we need a _FRAME_AUDIO_PCM type and we need
+ // for splay at least MP3FRAMESIZE
+ AudioFrameQueue* frameQueue;
+ if (queueType == _QUEUE_INT) {
+ frameQueue=new AudioFrameQueue(500,MP3FRAMESIZE,_FRAME_AUDIO_PCM);
+ }
+ if (queueType == _QUEUE_FLOAT) {
+ frameQueue=new AudioFrameQueue(100,MP3FRAMESIZE,_FRAME_AUDIO_FLOAT);
+ }
+
+
+ initDSP(dsp);
+ SplayDecoder* splay=new SplayDecoder();
+
+
+ //
+ // MpegAudioFrame has the ability to convert "raw" file
+ // data into mpeg I frames. These are "valid" frames,
+ // which means: header is ok, and the packet has the
+ // correct length. splay decodes these frames _at once_
+ // so we need no callbacks for the decoder.
+ MpegAudioFrame* frame=new MpegAudioFrame();
+
+
+ // Note: The inputbuffer must NOT NOT NOT be on the stack!
+ // correction: it should not be corrupted by allocation
+ // on the stack. This is true, if allocation+decoding
+ // or in the _same_ function.
+ unsigned char inputbuffer[INPUT_SIZE];
+
+
+ int cnt=0;
+ // we proceed until eof, or our "queue" is full.
+ while( (feof(file) == false) && (frameQueue->dataQueueCanWrite() == true) ) {
+
+ //
+ // This switch/case statement "partitions" the fileinput
+ // into mp3frames. We directly decode them to pcmFrames.
+ //
+
+ //
+ // There are three states. One is "I want Input, give me input"
+ // The other is "I have enough input, dont' bother me and let
+ // me do my work"
+ // The last ist "I have a frame here, take care of this, or
+ // I will continue with my work"
+
+ int state=frame->getState();
+ switch(state) {
+ case FRAME_NEED: {
+ int bytes=frame->canStore();
+ int read=fread(inputbuffer,1,bytes,file);
+ if (read != bytes) {
+ // read error. reset framer
+ frame->reset();
+ continue;
+ }
+ frame->store(inputbuffer,bytes);
+ break;
+ }
+ case FRAME_WORK:
+ frame->work();
+ break;
+ case FRAME_HAS:{
+ AudioFrame* emptyFrame= frameQueue->emptyQueueDequeue();
+ splay->decode(frame->outdata(),frame->len(),emptyFrame);
+ frameQueue->dataQueueEnqueue(emptyFrame);
+ cout << "storing decodec frame:"<<cnt<<endl;
+ cnt++;
+ break;
+ }
+ default:
+ cout << "unknown state in mpeg audio framing"<<endl;
+ exit(0);
+ }
+ }
+
+
+ //
+ // Fine we put all decoded frames in the buffer.
+ // Now we want to "stream" from this buffer.
+ //
+
+ //
+ // create our "local" stream
+ short int playbuf[INPUT_SIZE];
+
+ //
+ // we need to setup the dsp manually, when we do not play pcmFrames directly
+ //
+ if (queueType == _QUEUE_INT) {
+ AudioFrame* audioFrame=frameQueue->getCurrent();
+ dsp->audioSetup(audioFrame);
+ }
+
+ if (queueType == _QUEUE_FLOAT) {
+ AudioFrame* audioFrame=frameQueue->getCurrent();
+ dsp->audioSetup(audioFrame->getStereo(),16,
+ audioFrame->getSigned(),
+ audioFrame->getBigEndian(),
+ audioFrame->getFrequenceHZ());
+ outFrame->setFrameFormat(audioFrame->getStereo(),
+ audioFrame->getFrequenceHZ());
+ }
+
+
+
+ //
+ // read from stream demo:
+ //
+
+ while(frameQueue->getLen() > 0) {
+ int hasLen= frameQueue->getLen();
+
+ cout << "hasLen:"<<hasLen<<endl;
+ int hasRead;
+ if (hasLen < samples) {
+ samples=hasLen;
+ }
+
+
+
+ if (queueType == _QUEUE_INT) {
+ cout << "reading :"<<samples<<" data"<<endl;
+ hasRead=frameQueue->copy(outFrame->getData(),samples);
+ dsp->audioPlay((char*)outFrame->getData(),hasRead*sizeof(short int));
+ frameQueue->forwardStreamSingle(hasRead);
+ }
+
+
+ if (queueType == _QUEUE_FLOAT) {
+ int n;
+
+ hasRead=frameQueue->copy(left,right,samples);
+ frameQueue->forwardStreamDouble(hasRead);
+ n=hasRead;
+
+ /*
+ FloatFrame* floatFrame=( FloatFrame*) frameQueue->dataQueueDequeue();
+ float* left=floatFrame->getData();
+ n=floatFrame->getLen();
+ */
+
+ int i=0;
+ while(i<n) {
+ int val=(int)(32768.0*left[i]);
+ if (val > 32767) val=32767;
+ if (val < -32768) val=-32768;
+ dsp->audioPlay((char*)&val,2);
+
+ if (outFrame->getStereo()) {
+ val=(int)(32768.0*right[i]);
+ if (val > 32767) val=32767;
+ if (val < -32768) val=-32768;
+ dsp->audioPlay((char*)&val,2);
+ }
+
+ i++;
+ }
+
+ }
+ }
+
+
+ delete frameQueue;
+ delete splay;
+ delete frame;
+ delete dsp;
+ delete left;
+ delete right;
+ delete outFrame;
+ return(0);
+}
+
diff --git a/mpeglib/example/splay/splay.cpp b/mpeglib/example/splay/splay.cpp
new file mode 100644
index 00000000..75254360
--- /dev/null
+++ b/mpeglib/example/splay/splay.cpp
@@ -0,0 +1,64 @@
+/*
+
+ Example how the plugin interface works.(LINUX Open Sound System only!)
+
+
+ */
+
+
+#include "../../lib/decoder/splayPlugin.h"
+#include "../../lib/decoder/tplayPlugin.h"
+#include "../../lib/decoder/vorbisPlugin.h"
+#include "../../lib/input/bufferInputStream.h"
+#include "../../lib/output/avSyncer.h"
+
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv) {
+
+
+
+ if (argc <= 1) {
+ printf("Usage:\n\n");
+ printf("%s filename\n\n",argv[0]);
+ exit(0);
+ }
+
+ //
+ // The order is important !!!!
+ // 1. construct
+ // 2. set Output
+ // 3. open input
+ // 4. set input
+ //
+ // you cannot set the input _before_ the output
+ // in fact you can, but this gives you a segfault!
+
+ SplayPlugin* plugin=new SplayPlugin();
+ OutputStream* out=OutPlugin::createOutputStream(_OUTPUT_LOCAL,true);
+ InputStream* in=InputPlugin::createInputStream(argv[1],true);
+
+ in->open(argv[1]);
+ // watch the order!
+ plugin->setOutputPlugin(out);
+ plugin->setInputPlugin(in);
+ plugin->play();
+
+ while(plugin->getStreamState() != _STREAM_STATE_EOF) {
+ cout << "check state"<<endl;
+ TimeWrapper::sleep(1);
+
+ }
+
+ cout << "****************plugin eof"<<endl;
+ //out->audioClose();
+ plugin->close();
+
+ delete plugin;
+ delete in;
+ delete out;
+ return(0);
+}
+
diff --git a/mpeglib/example/tplay/Makefile.am b/mpeglib/example/tplay/Makefile.am
new file mode 100644
index 00000000..c79a2805
--- /dev/null
+++ b/mpeglib/example/tplay/Makefile.am
@@ -0,0 +1,32 @@
+# tplay-yaf - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+EXTRA_DIST =
+
+noinst_PROGRAMS = tplay
+
+tplay_SOURCES = tplay.cpp
+
+noinst_HEADERS =
+
+tplay_LDFLAGS = $(all_libraries)
+
+
+tplay_LDADD = ../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/tplay/tplay.cpp b/mpeglib/example/tplay/tplay.cpp
new file mode 100644
index 00000000..324c6c17
--- /dev/null
+++ b/mpeglib/example/tplay/tplay.cpp
@@ -0,0 +1,66 @@
+/*
+
+ Example how the plugin interface works.(LINUX Open Sound System only!)
+
+
+
+
+
+ */
+
+
+#include "../../lib/decoder/tplayPlugin.h"
+#include "../../lib/decoder/nukePlugin.h"
+
+
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv) {
+
+
+ if (argc <= 1) {
+ printf("Usage:\n\n");
+ printf("%s filename\n\n",argv[0]);
+ exit(0);
+ }
+
+ //
+ // The order is important !!!!
+ // 1. construct
+ // 2. set Output
+ // 3. open input
+ // 4. set input
+ //
+ // you cannot set the input _before_ the output
+ // in fact you can, but this gives you a segfault!
+
+ DecoderPlugin* plugin=new TplayPlugin();
+ //DecoderPlugin* plugin=new NukePlugin();
+ OutputStream* out=OutPlugin::createOutputStream(_OUTPUT_LOCAL,true);
+ InputStream* in=InputPlugin::createInputStream(argv[1],true);
+
+ // The plugin does not do "open"
+ in->open(argv[1]);
+
+ // watch the order!
+ plugin->setOutputPlugin(out);
+ plugin->setInputPlugin(in);
+
+
+
+ plugin->play();
+
+ while(plugin->getStreamState() != _STREAM_STATE_EOF) {
+ TimeWrapper::sleep(1);
+ }
+ cout << "plugin eof"<<endl;
+ plugin->close();
+
+ delete plugin;
+ delete in;
+ delete out;
+ return(0);
+}
+
diff --git a/mpeglib/example/yaf/Makefile.am b/mpeglib/example/yaf/Makefile.am
new file mode 100644
index 00000000..7144955a
--- /dev/null
+++ b/mpeglib/example/yaf/Makefile.am
@@ -0,0 +1,15 @@
+# yaflib - Makefile.am
+
+SUBDIRS = yafcore yafxplayer yafsplay yafmpgplay \
+ yaftplay yafvorbis yafyuv yafcdda
+
+
+
+EXTRA_DIST = README
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/README b/mpeglib/example/yaf/README
new file mode 100644
index 00000000..4fe128b0
--- /dev/null
+++ b/mpeglib/example/yaf/README
@@ -0,0 +1,4 @@
+
+Someday this directory will be replaced with a simple readline
+interface.
+
diff --git a/mpeglib/example/yaf/yafcdda/Makefile.am b/mpeglib/example/yaf/yafcdda/Makefile.am
new file mode 100644
index 00000000..2930f348
--- /dev/null
+++ b/mpeglib/example/yaf/yafcdda/Makefile.am
@@ -0,0 +1,35 @@
+# splay-yaf - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+
+bin_PROGRAMS = yaf-cdda
+
+yaf_cdda_SOURCES = cdda_control.cpp
+
+
+noinst_HEADERS =
+
+yaf_cdda_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+
+yaf_cdda_LDADD = ../yafxplayer/libyafxplayer.la \
+ ../yafcore/libyafcore.la \
+ ../../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafcdda/cdda_control.cpp b/mpeglib/example/yaf/yafcdda/cdda_control.cpp
new file mode 100644
index 00000000..5bac58e2
--- /dev/null
+++ b/mpeglib/example/yaf/yafcdda/cdda_control.cpp
@@ -0,0 +1,184 @@
+/*
+ generic interactive controller
+ Copyright (C) 2000 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+// Set for local include
+#define DIRECT_INCLUDE
+
+#include "../yafcore/yaf_control.h"
+#include "../yafxplayer/inputDecoderYAF.h"
+
+
+
+
+
+
+#include <iostream>
+using namespace std;
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#if defined(HAVE_GETOPT_H)
+#include <getopt.h>
+#endif
+
+// we include our plugin here
+#include "../../../lib/decoder/cddaPlugin.h"
+
+#if defined(HAVE_GETOPT_H)
+#include <getopt.h>
+#endif
+
+
+
+
+
+void control_divx(InputInterface* input,OutputInterface* output,
+ InputDecoder* decoder) {
+
+
+ cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
+ cout<< "Command:0 Msg:implements xplayer" << endl;
+ cout<< "Command:0 Msg:decoder cdparanoia " << endl;
+ cout<< "Command:0 Msg:mimetypes audio/cdda;" << endl;
+ cout<< "Command:0 Msg:comment cdparanoia by Monty <xiphmont@mit.edu>" << endl;
+ cout<< "Command:0 Msg:comment yaf port by mvogt@rhrk.uni-kl.de"<<endl;
+ cout<< "Command:0 Msg:comment based on sources from audiocd"<<endl;
+ cout<< "Command:0 Msg:comment enter 'help' " << endl;
+
+
+
+
+
+ yaf_control(input,output,decoder);
+}
+
+
+void usage() {
+ cout << "yaf-cdda is a interactive frontend for the cdda decoder"<<endl;
+ cout << "Usage : yaf-cdda [ahy] [url]"<<endl;
+ cout << endl;
+ cout << "-a : no internal audio device"<<endl;
+ cout << "-h : help"<<endl;
+ cout << "-y : autoplay off"<<endl;
+ cout << endl;
+ cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
+ << "USE AT YOUR OWN RISK!"<<endl;
+ cout << endl;
+ cout << "for more help type 'help' in interactive mode"<<endl;
+}
+
+
+
+
+int main(int argc, char** argv) {
+ int c;
+ int lInternalAudio=true;
+
+ pow(6.0,3.0); // fixes bug in __math.h
+ InputInterface input;
+ OutputInterface output(&cout);
+
+
+ YafOutputStream* yafOutput=new YafOutputStream(&input);
+ CDDAPlugin* plugin=new CDDAPlugin();
+
+ plugin->setOutputPlugin(yafOutput);
+ InputDecoderYAF decoder(plugin,yafOutput);
+
+
+
+ while(1) {
+ c = getopt (argc, argv, "2al:L:scb:mhpywd:");
+ if (c == -1) break;
+ switch(c) {
+ case 'a': {
+ lInternalAudio=false;
+ break;
+ }
+ case 'h': {
+ usage();
+ exit(0);
+ }
+ case 'y': {
+ decoder.setAutoPlay(false);
+ break;
+ }
+ case '2': {
+ plugin->config("-2","true",NULL);
+ break;
+ }
+ case 'm': {
+ plugin->config("-m","true",NULL);
+ break;
+ }
+ case 'c': {
+ plugin->config("-c","true",NULL);
+ break;
+ }
+ case 'w': {
+ plugin->config("-w","true",NULL);
+ break;
+ }
+ case 's': {
+ yafOutput->config("-s","true",NULL);
+ break;
+ }
+ case 'b': {
+ yafOutput->config("-b",optarg,NULL);
+ break;
+ }
+ case 'd': {
+ yafOutput->config("yufDump",optarg,NULL);
+ break;
+ }
+ case 'p': {
+ yafOutput->config("-p",optarg,NULL);
+ break;
+ }
+ case 'l': {
+ plugin->config("AudioLayer",optarg,NULL);
+ cout << "trying to configure" << endl;
+ break;
+ }
+ case 'L': {
+ plugin->config("VideoLayer",optarg,NULL);
+ break;
+ }
+
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ usage();
+ exit(-1);
+ }
+ }
+
+ if (optind < argc ) {
+ Buffer buffer(300);
+ buffer.append("open ");
+ buffer.append(argv[optind]);
+ buffer.append("\n");
+ input.addInputLine(&buffer);
+
+ }
+ yafOutput->internalDevice(lInternalAudio);
+ control_divx(&input,&output,&decoder);
+ delete plugin;
+ delete yafOutput;
+
+}
+
+
diff --git a/mpeglib/example/yaf/yafcore/Makefile.am b/mpeglib/example/yaf/yafcore/Makefile.am
new file mode 100644
index 00000000..95119cb5
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/Makefile.am
@@ -0,0 +1,44 @@
+# libyafshared - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+EXTRA_DIST = PROTOCOL.v01 yafCommand.defs yafRuntime.defs
+
+
+lib_LTLIBRARIES = libyafcore.la
+
+noinst_HEADERS = commandTableYAF.h multiReader.h \
+ runtimeTableYAF.h \
+ outputDecoder.h \
+ commandLine.h \
+ commandTable.h lineStack.h \
+ parser.h
+
+
+libyafcore_la_SOURCES = buffer.cpp \
+ lineStack.cpp \
+ commandLine.cpp \
+ parser.cpp \
+ outputInterface.cpp \
+ inputInterface.cpp \
+ commandTable.cpp \
+ commandTableYAF.cpp \
+ runtimeTableYAF.cpp \
+ inputDecoder.cpp \
+ outputDecoder.cpp \
+ yaf_control.cpp \
+ multiReader.cpp
+
+libyafcore_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) \
+ -no-undefined -avoid-version
+
+libyafcore_la_LIBADD = -lkdefakes $(THIS_LIB_LIBS)
+
+
+
+
+yafcoredir = $(includedir)/$(THIS_LIB_NAME)/util/yaf/yafcore
+
+yafcore_HEADERS = inputInterface.h outputInterface.h \
+ buffer.h inputDecoder.h yaf_control.h
+
diff --git a/mpeglib/example/yaf/yafcore/PROTOCOL.v01 b/mpeglib/example/yaf/yafcore/PROTOCOL.v01
new file mode 100644
index 00000000..fce6f1c5
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/PROTOCOL.v01
@@ -0,0 +1,243 @@
+
+This text describes how the interactive interface for mpg123 works.
+******************************************************************
+
+
+Interaction means, that the user can enters commands during
+the mpg123 decoder is running.
+For example, he can stops decoding and can jump to a special
+framenumber.
+
+The current frontends (e.g. tk3play) already allow this, but they are
+a bit difficult for a user because he must enter
+numbers for special command instead of a more
+readable command like "open xyz.mp3"
+
+Then the tk3 interface can't produce return codes for the commands
+In this interface every command the user
+sends to the decoder produces a return Message.
+(for now this messages always defaults to "success")
+
+Why the return codes?
+This allows a controlling GUI (which is a "user" in some way)
+to get a notification if e.g. the file cannot be opened
+by the decoder (wrong format, etc...)
+
+How does it work?
+****************
+Every command the user enters on stdin (cin) produces a return code.
+Thus if the user (or a GUI) sends "open xyz" he gets
+a message whether this succeded or not.
+
+
+E.g:
+
+The user starts mpg123 in interacive mode and enters the first command:
+
+>open foo.mp3
+
+This command and is internally converted to the string:
+
+"Command:101 Msg:open foo.mp3"
+
+The control then writes to stdout :
+"Command:101 Ret:(file not found) Msg:open foo.mp3"
+
+
+The brackets behind "Ret:" belongs to the protocol
+they are delimeters for the return string.
+
+Or, in the case the command was successfull, the user enters :
+play
+
+is translated to
+"Command:102 Msg:play"
+return is:
+"Command:102 Ret:(ok) Msg:play"
+
+
+For what is the "Command:xyz" string good for?
+**********************************************
+
+This string is the current Command number. If a controlling
+GUI sends "Command:x Msg:open foo.mp3" it can search the outout
+from mpg123 for a string : "Command:x ........" This
+ist the return value of the decoder for the command "open foo.mp3"
+
+The command-number must be unique >= 40.
+All Command < 40 are runtime Commands.
+Runtime Commands always have the format :
+
+Command:<nr> Msg: <...>
+
+Example for runtime Commands:
+++++++++++++++++++++++++++++
+
+In the output stream of mpg123 there may be different message.
+For example mpg123 produces runtime information (time, currentframe or
+something like this).
+
+"Command:0 Msg:info1 p I 2.0 III 22050 Joint-Stereo 2 64 209"
+"Command:0 Msg:info1 p I 2.0 III 22050 Joint-Stereo 2 64 209"
+"Command:0 Msg:info1 p I 2.0 III 22050 Joint-Stereo 2 64 209"
+
+The Command number zero means that this output does not belong
+to any special input command.(The part after Msg: is decoder specific)
+
+There are more pre-definied Command Numbers:
+Nr Description Example
+
+0 : Runtime info in general Command:0 Msg:live long and prosper->SIGSEV
+1 : Debug info Command:1 Msg:search the bug
+
+Note:
+The debug Command is the only command which has *no* identifer
+after Msg: All other Commands < 40 needs a Message-identifer after
+Msg.
+In the example for Command 0 the Message identifer is "life"
+and the "real" Message is "long and prosper->SIGSEV".
+This mechanism allows to extend the runtime info sytem only
+with identifiers and not with numbers
+Why?
+Because the protocol should be easy to read.
+(One of the ideas behind this protocol)
+Eg:
+
+Command:0 Msg:currentFrame 23
+is more "readable" than an extension with numbers
+eg:
+Command:0 Msg:2 23
+
+In this example "2" mean that the 23 is the currentFrame Number.
+
+
+
+
+Runtime Commands may be processed by the frontend:
++++++++++++++++++++++++++++++++++++++++++++++++++
+
+Maybe there are errors during playing:
+
+"Command:0 Msg:exception p internal error- ignoring RIFF Header"
+
+The frontend checks the kind of runtime command:
+
+Frontend knows that there was an error(exception) but the status says (p)
+that the decoder continues playing (p)
+and for a more precise description (for the user)
+"error- ignoring RIFF Header"
+
+
+Back to the question:
+++++++++++++++++++++
+The frontend cannot be sure that the next message by the decoder
+is the return message of the previous sended command "open foo.mp3"
+This is the reason for the command number. They synchonise the
+input (open foo.mp3) with the output.
+With a command number the GUI can filter the output for the return code.
+
+
+
+Restriction of the proctocol:
+****************************
+You cannot send binary data because a "\n" is interpreted as
+something like "end of input"
+This means that you cannot open a file in the mpg decoder
+which has "\n" in its name.
+Hm. Is this a restriction? Yes.
+An alternative would be to extend the Protocol to something
+like :
+
+Size:<Integer> Command:... Msg....
+
+(Maybe in the future)
+
+
+
+How is this implemented?
+*************************
+
+
+In the source there are two classes:
+
+* InputInterface
+* OutputInterface
+
+
+First Example
+*************
+
+Let's say we want to write a Command-Line-Frontend for mpg123,
+which is included in the mpg123 source.
+(see the file: mpg123_control.c)
+
+What we must do?
+The Input for the decoder is the command by the user and
+the output is the output by the decoder.
+
+The user should not have to write the real syntax of the
+protocol. Thus he should not write:
+
+Command:1 Msg:open file.mp3
+
+But simply : open file.mp3
+
+The Inputinterface must translate the wrong input
+(in the view of the protocol) into the right
+protocolSyntax.
+(here: Command:<xyz> Msg:open file.mp3)
+
+This input is then passed to the decoder.
+The decoder translates the part after "Msg:" and
+trys to open file.mp3, but in this example he cannot find it.
+Now he can send the return value with the valid Command number.
+Command:<xyz> Ret:(file not found) Msg:open file.mp3
+
+When the decoder returns from the "translations"
+we send the return-Msg (stored in the decoder)
+to the outputstream.
+For this we set in the Outputinterface the current Command number
+And then we send the return message and again the command
+which produced the return message.
+
+"Command:<Number> Ret:(file not found) Msg:eopn foo.mp3"
+
+Second Example
+**************
+
+Write a Gui frontend which starts mpg123 as a seperate process
+(how kmpg does).
+kmpg starts a new mpg123 with the compiled in yaf-interface.
+the yaf-interface is a commandline interface, but this is
+not what we want. We need another behaviour.
+mpg123 must expect protocol data and not "user written" inputs.
+Thus kmpg must set the mpg123 frontend in another internal state
+which expects protocol data.
+The first command which kmpg sends to the mpg123 frontend
+is : "protocol"
+This sets the InputInterface of mpg123 in a protocol-raw-modus.
+A user can type this on the command line as well, but
+then he must also generate the right protocol syntax.
+
+Then kmpg opens a file and send
+e.g:
+Command:1 Msg:open abc.mp3
+
+Then the mpg123 output is sent back:
+
+Command:1 Ret:(ok) Msg:open abc.mp3
+
+
+DEBUGGING
+*********
+
+In the file InputInterface and OutputInterface are debug switches.
+If they are set the incoming/outgoing
+stream is copied to the files
+instream.dbg
+outstream.dbg
+
+tail -f instream.dbg outstream.dbg
+
+monitors the interaction between a frontend and the decoder.
+
diff --git a/mpeglib/example/yaf/yafcore/README b/mpeglib/example/yaf/yafcore/README
new file mode 100644
index 00000000..c3cfd130
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/README
@@ -0,0 +1,27 @@
+
+yaf - <y>et <a>nother <f>rontend
+
+yaf is a simple protocol for communication over streams.
+
+Its purpose is to offer an extensible interface
+for the communitcation between the kmpg GUI and the mpg123 decoder.
+
+
+DESCRIPTION
+
+The basic idea is, that the GUI and the decoder (splay) work
+together over their file streams (cin,cout)
+This means, that kmpg sends string-messages to "stdout"
+and splay receive these messages as "stdin".
+The results of splay (runtime Information, error
+codes) are send to "stdout" and kmpg receive them as "stdin"
+
+The protocol is "human readable" just enter "help"
+or "help <command>" on the prompt and you will see.
+These directory includes classes for dealing with this
+text protocol. In normal developement you can completly
+ingore these classe.
+
+For more info look in the file PROTOCOL
+
+
diff --git a/mpeglib/example/yaf/yafcore/buffer.cpp b/mpeglib/example/yaf/yafcore/buffer.cpp
new file mode 100644
index 00000000..3c58f0ee
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/buffer.cpp
@@ -0,0 +1,156 @@
+/*
+ This class implements a dynamic string buffer
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#include "buffer.h"
+
+
+
+Buffer::Buffer(int size) {
+ nSize=size;
+ msg=(char*) malloc(sizeof(char)*(nSize+1));
+ msg[nSize]='\0';
+ clear();
+
+}
+
+
+Buffer::~Buffer() {
+ free (msg);
+}
+
+
+void Buffer::clear() {
+ msg[0]='\0';
+}
+
+void Buffer::append(int value) {
+ Buffer buf(30);
+ sprintf(buf.getData(),"%d",value);
+ append(buf.getData());
+}
+
+
+
+
+void Buffer::append(char* appendMsg) {
+ char* appendPos=getAppendPos();
+ int nlen=strlen(appendMsg);
+ if (appendPos == NULL) return;
+
+ append(appendMsg,nlen);
+}
+
+
+void Buffer::append(const char* appendMsg) {
+ append((char*)appendMsg);
+}
+
+
+void Buffer::append(char* buffer,int buflen) {
+ int nlen=len();
+ int nBedarf;
+
+ if (buflen+nlen <= nSize) {
+ char* appendPos=getAppendPos();
+ strncpy(appendPos,buffer,buflen);
+ appendPos[buflen]='\0';
+ return;
+ }
+ nBedarf=(nlen+buflen)-nSize;
+ grow(nBedarf);
+ append(buffer,buflen);
+}
+
+char* Buffer::getAppendPos() {
+ int i;
+ // this Array has nSize+1 entries!
+ // and it *is* granted that msg[nSize]=0; (think so)
+ for (i=0;i<=nSize;i++) {
+ if (msg[i] == '\0') return &(msg[i]);
+ }
+ // should never reach this point
+ return NULL;
+}
+
+
+void Buffer::setData(char* msg) {
+ if (strlen(msg) == 0) {
+ clear();
+ return;
+ }
+ clear();
+ append(msg);
+}
+
+char* Buffer::getData() {
+ return msg;
+}
+
+
+int Buffer::len() {
+ return strlen(msg);
+}
+
+int Buffer::getSize() {
+ return nSize;
+}
+
+void Buffer::grow(int size) {
+ int i;
+ int newSize=nSize+size;
+ char* tmp=(char*) malloc(sizeof(char)*(newSize+1));
+ tmp[newSize]='\0';
+ for(i=0;i<=nSize;i++) {
+ tmp[i]=msg[i];
+ }
+
+ nSize=newSize;
+ free(msg);
+ msg=tmp;
+
+}
+
+
+int Buffer::find(char zeichen) {
+ int i;
+ int nlen=len();
+ for(i=0;i<nlen;i++) {
+ if (msg[i] == zeichen) return i;
+ }
+ return -1;
+}
+
+
+
+void Buffer::forward(int bytes) {
+ int i;
+ int aktPos;
+ int nlen=len();
+ if (bytes > nlen) {
+ bytes=nlen;
+ }
+ i=0;
+ aktPos=bytes;
+ while(aktPos <= nlen) {
+ msg[i]=msg[aktPos];
+ i++;
+ aktPos++;
+ }
+}
+
+
+
+void Buffer::print() {
+ printf("Buffer:%s\n",msg);
+}
diff --git a/mpeglib/example/yaf/yafcore/buffer.h b/mpeglib/example/yaf/yafcore/buffer.h
new file mode 100644
index 00000000..7c1a3d5c
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/buffer.h
@@ -0,0 +1,64 @@
+/*
+ This class implements a static string buffer
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __BUFFER_H
+#define __BUFFER_H
+
+
+extern "C" {
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+ }
+#include <kdemacros.h>
+
+class KDE_EXPORT Buffer {
+
+ char* msg;
+ int nSize;
+
+ public:
+ Buffer(int size);
+ ~Buffer();
+
+ void clear();
+ void append(int value); // appends values as string
+ void append(char* msg);
+ void append(const char* msg);
+
+ void append(char* buffer,int buflen);
+
+ int find(char zeichen);
+ int len();
+
+ void setData(char* msg);
+ char* getData();
+
+ int getSize();
+ void grow(int size);
+
+ void forward(int bytes);
+ void print();
+ private:
+ char* getAppendPos();
+ void read(FILE stream);
+
+};
+
+
+#endif
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/commandLine.cpp b/mpeglib/example/yaf/yafcore/commandLine.cpp
new file mode 100644
index 00000000..e3ae8252
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/commandLine.cpp
@@ -0,0 +1,86 @@
+/*
+ An abstraction of a Command-Line
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#include "commandLine.h"
+#include <iostream>
+using namespace std;
+
+CommandLine::CommandLine(){
+ int i;
+ for (i=0; i < 10; i++) {
+ command[i].identifier=new Buffer(20);
+ command[i].value=new Buffer(100);
+ }
+ commandCount=0;
+
+}
+
+CommandLine::~CommandLine(){
+
+ int i;
+ for (i=0; i < 10; i++) {
+ delete command[i].value;
+ delete command[i].identifier;
+
+ }
+
+}
+
+
+int CommandLine::getCommandCount() {
+ return commandCount;
+}
+
+void CommandLine::setCommandCount(int commandCount){
+ this->commandCount=commandCount;
+}
+
+
+char* CommandLine::getIdentifier(int i){
+ return (command[i].identifier)->getData();
+}
+
+void CommandLine::clear() {
+ int i;
+ for (i=0; i < 10; i++) {
+ command[i].identifier->clear();
+ command[i].value->clear();
+ }
+ commandCount=0;
+}
+
+char* CommandLine::getValue(int i) {
+ return (command[i].value)->getData();
+}
+
+void CommandLine::setIdentifier(int i,char* identifier){
+ (command[i].identifier)->setData(identifier);
+}
+
+
+void CommandLine::setValue(int i,char* value) {
+ (command[i].value)->setData(value);
+}
+
+void CommandLine::printCommand() {
+ int i;
+ for(i=0;i<commandCount;i++) {
+ cout << "Command:" << i << "\n";
+ cout << "identifier:" << (command[i].identifier)->getData() << "\n";
+ cout << "value:" << (command[i].value)->getData() << "\n";
+ }
+}
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/commandLine.h b/mpeglib/example/yaf/yafcore/commandLine.h
new file mode 100644
index 00000000..677c1018
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/commandLine.h
@@ -0,0 +1,60 @@
+/*
+ An abstraction of a Command-Line
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+
+#ifndef __BASICMESSAGE_H
+#define __BASICMESSAGE_H
+
+
+#include "buffer.h"
+
+
+struct BasicMessageStruct {
+
+ Buffer* identifier;
+ Buffer* value;
+
+};
+
+typedef struct BasicMessageStruct tBasicMessage;
+
+
+class CommandLine {
+
+
+ int commandCount;
+ tBasicMessage command[40];
+
+ public:
+
+ CommandLine();
+ ~CommandLine();
+
+ int getCommandCount();
+ void setCommandCount(int commandCount);
+
+ char* getIdentifier(int i);
+ char* getValue(int i);
+
+ void setIdentifier(int i,char* identifier);
+ void setValue(int i,char* value);
+
+ void printCommand();
+ void clear();
+};
+
+#endif
+
+
diff --git a/mpeglib/example/yaf/yafcore/commandTable.cpp b/mpeglib/example/yaf/yafcore/commandTable.cpp
new file mode 100644
index 00000000..10e36dc3
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/commandTable.cpp
@@ -0,0 +1,256 @@
+/*
+ valid Commands for Input/Output
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#include "commandTable.h"
+#include <iostream>
+
+using namespace std;
+
+
+CommandTable::CommandTable(){
+ nCommandDesc=0;
+}
+
+CommandTable::~CommandTable(){
+}
+
+
+const char* CommandTable::getCommand(int nr) {
+ int i;
+ const char* back="";
+ for(i=0;i<nCommandDesc;i++) {
+ if (commandDesc[i].number == nr) {
+ return commandDesc[i].longName;
+ }
+ }
+ return back;
+}
+
+
+const char* CommandTable::getCommand(const char* name) {
+ int i;
+ int comp;
+ unsigned int nlen;
+ const char* back="";
+ for(i=0;i<nCommandDesc;i++) {
+ nlen=strlen(commandDesc[i].longName);
+ comp=strncmp(commandDesc[i].longName,name,nlen);
+ if (comp == 0) {
+ if (strlen(name) == nlen) {
+ return commandDesc[i].longName;
+ } else if ((strlen(name) > nlen) && (name[nlen]==' ')) {
+ return commandDesc[i].longName;
+ }
+ }
+
+ if (strlen(commandDesc[i].shortName) > 0) {
+ nlen=strlen(commandDesc[i].shortName);
+ comp=strncmp(commandDesc[i].shortName,name,nlen);
+
+ if (comp == 0) {
+ if (strlen(name) == nlen) {
+ return commandDesc[i].shortName;
+ } else if ((strlen(name) > nlen) && (name[nlen]==' ')) {
+ return commandDesc[i].shortName;
+ }
+ }
+ }
+ }
+ return back;
+}
+
+
+int CommandTable::getNr(const char* command) {
+ int i;
+ int comp;
+ int back=-1;
+ unsigned int nlen;
+ for(i=0;i<nCommandDesc;i++) {
+ nlen=strlen(commandDesc[i].longName);
+ comp=strncmp(commandDesc[i].longName,command,nlen);
+ if (comp == 0) {
+ if (strlen(command) == nlen) {
+ return commandDesc[i].number;
+ } else if ((strlen(command) > nlen) && (command[nlen]==' ')) {
+ return commandDesc[i].number;
+ }
+ }
+
+ if (strlen(commandDesc[i].shortName) > 0) {
+ nlen=strlen(commandDesc[i].shortName);
+ comp=strncmp(commandDesc[i].shortName,command,nlen);
+
+ if (comp == 0) {
+ if (strlen(command) == nlen) {
+ return commandDesc[i].number;
+ } else if((strlen(command) > nlen) && (command[nlen]==' ')){
+ return commandDesc[i].number;
+ }
+ }
+ }
+ }
+ return back;
+}
+
+
+const char* CommandTable::getArgs(const char* command,const char* wholeLine) {
+ unsigned int i;
+ unsigned int n;
+ const char* back;
+ back=wholeLine;
+ n=strlen(command);
+ if (n==0) return back;
+ for(i=0;i<n;i++) {
+ back++;
+ }
+ // we must take care that after every command there may be a
+ // space
+ if (strlen(wholeLine) > n) {
+ back++;
+ }
+ return back;
+}
+
+
+
+void CommandTable::print() {
+ int i;
+ cout << "internal Help System V. 0.2\n";
+ cout << "known commands are :\n\n";
+ for(i=0;i<nCommandDesc;i++) {
+ print(commandDesc[i].number,false);
+ }
+}
+
+
+int CommandTable::getPos(int commandNr) {
+ int i;
+ int pos=-1;
+ for (i=0;i<nCommandDesc;i++) {
+ if (commandDesc[i].number == commandNr) {
+ pos=i;
+ break;
+ }
+ }
+ return pos;
+}
+
+void CommandTable::print (int command,int lWithHelp) {
+ int i=getPos(command);
+ if (i<0) {
+ cout << "unknown Command\n";
+ return;
+ }
+ if (commandDesc[i].lexternalUse == false) return;
+
+ cout << commandDesc[i].longName << "(" ;
+ if (strlen(commandDesc[i].shortName) == 0) {
+ cout << "No";
+ } else {
+ cout << commandDesc[i].shortName;
+ }
+ cout << ") Nr :" << commandDesc[i].number <<" ";
+ if (lWithHelp==true) {
+ cout << commandDesc[i].help ;
+ }
+ cout <<"\n";
+}
+
+
+
+CommandDescription* CommandTable::getCommandDescription(int i) {
+ return &(commandDesc[i]);
+}
+
+
+
+int CommandTable::getCommandCounter() {
+ return nCommandDesc;
+}
+
+
+void CommandTable::join(CommandTable* table) {
+ int i;
+ int n=table->getCommandCounter();
+ CommandDescription* cmdDesc;
+
+ for (i=0;i<n;i++) {
+ cmdDesc=table->getCommandDescription(i);
+ insert(cmdDesc);
+
+ }
+
+}
+
+
+
+
+
+
+
+void CommandTable::insert(CommandDescription* cmdDesc) {
+ const char* lNameTest;
+ const char* sNameTest;
+ int pos=getPos(cmdDesc->number);
+
+ if (pos != -1) {
+ cout << "number "<< cmdDesc->number
+ << " for command "<< cmdDesc->longName << " already defined!" << endl;
+ }
+
+ lNameTest=getCommand(cmdDesc->longName);
+ if (strlen(lNameTest) > 0) {
+ cout << "longName "<< cmdDesc->longName << " already defined."
+ << "Previous definition has number : "
+ << getNr(cmdDesc->longName) << endl;
+ }
+
+ sNameTest=getCommand(cmdDesc->shortName);
+ if (strlen(sNameTest) > 0) {
+ cout << "shortName "<< cmdDesc->shortName << " already defined."
+ << "Previous definition has number : "
+ << getNr(cmdDesc->shortName) << endl;
+
+ }
+
+
+ commandDesc[nCommandDesc].lexternalUse=cmdDesc->lexternalUse;
+ commandDesc[nCommandDesc].lReturn=cmdDesc->lReturn;
+ commandDesc[nCommandDesc].longName=cmdDesc->longName;
+ commandDesc[nCommandDesc].shortName=cmdDesc->shortName;
+ commandDesc[nCommandDesc].number=cmdDesc->number;
+ commandDesc[nCommandDesc].help=cmdDesc->help;
+ nCommandDesc++;
+}
+
+
+int CommandTable::getReturnFlag(int cmdNr) {
+ int i=getPos(cmdNr);
+ CommandDescription* cmdDesc;
+ if (i == -1) {
+ return -1;
+ }
+ cmdDesc=getCommandDescription(i);
+ return cmdDesc->lReturn;
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/commandTable.h b/mpeglib/example/yaf/yafcore/commandTable.h
new file mode 100644
index 00000000..75dd4325
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/commandTable.h
@@ -0,0 +1,82 @@
+/*
+ valid Commands for Input/Output
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#ifndef __COMMANDTABLE_H
+#define __COMMANDTABLE_H
+
+
+extern"C" {
+#include <string.h>
+#include <stdio.h>
+}
+
+#include <kdemacros.h>
+
+#define _CT_START 40
+
+
+
+
+
+
+struct CommandDescriptionStruct {
+
+ int lexternalUse; // written when user enters "help"
+
+ // this field can be used to deliver a delayed return msg
+ int lReturn; // true generate ret-msg automatically
+
+ const char* longName;
+ const char* shortName;
+ int number;
+ const char* help;
+};
+
+
+typedef struct CommandDescriptionStruct CommandDescription;
+
+
+class KDE_EXPORT CommandTable {
+
+ int nCommandDesc;
+ CommandDescription commandDesc[50];
+
+ public:
+ CommandTable();
+ virtual ~CommandTable();
+ void insert(CommandDescription* cmdDesc);
+
+
+ int getNr(const char* name);
+ const char* getCommand(const char* name);
+ const char* getCommand(int nr);
+ const char* getArgs(const char* command,const char* wholeLine);
+
+ int getReturnFlag(int cmdNr);
+ void print();
+ void print (int i,int lWithHelp);
+
+ int getCommandCounter();
+ void join(CommandTable* table); // join two tables (no deep join!)
+
+ private:
+ CommandDescription* getCommandDescription(int i);
+ int getPos(int commandNr);
+};
+
+
+#endif
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/commandTableYAF.cpp b/mpeglib/example/yaf/yafcore/commandTableYAF.cpp
new file mode 100644
index 00000000..d071817b
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/commandTableYAF.cpp
@@ -0,0 +1,36 @@
+/*
+ valid Commands for yaf (basic yaf commands)
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+#define _USE_YAF_STRUC
+
+#include "commandTableYAF.h"
+
+
+CommandTableYAF::CommandTableYAF(){
+ init();
+}
+
+CommandTableYAF::~CommandTableYAF(){
+}
+
+void CommandTableYAF::init() {
+
+
+ int i;
+ for (i=0;i<YAFCOMMANDS_SIZE;i++) {
+ insert(&yafCommands[i]);
+ }
+
+
+}
+
diff --git a/mpeglib/example/yaf/yafcore/commandTableYAF.h b/mpeglib/example/yaf/yafcore/commandTableYAF.h
new file mode 100644
index 00000000..fe12793d
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/commandTableYAF.h
@@ -0,0 +1,36 @@
+/*
+ valid Commands for yaf (basic yaf commands)
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __COMMAND_YAF_H
+#define __COMMAND_YAF_H
+
+#include "commandTable.h"
+#include "yafCommand.defs"
+
+
+
+
+
+class CommandTableYAF : public CommandTable {
+
+ public:
+ CommandTableYAF();
+ ~CommandTableYAF();
+ void init();
+
+};
+
+#endif
+
diff --git a/mpeglib/example/yaf/yafcore/inputDecoder.cpp b/mpeglib/example/yaf/yafcore/inputDecoder.cpp
new file mode 100644
index 00000000..e24b7758
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/inputDecoder.cpp
@@ -0,0 +1,237 @@
+/*
+ process Messages on the decoder
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+#include "inputDecoder.h"
+
+#include "commandTable.h"
+#include "commandTableYAF.h"
+#include "yafRuntime.defs"
+#include "commandLine.h"
+#include <iostream>
+
+using namespace std;
+
+InputDecoder::InputDecoder() {
+ commandTable=new CommandTable();
+ yafCommands=new CommandTableYAF();
+ appendCommandTable(yafCommands);
+ status=_DECODER_STATUS_IDLE;
+ lRuntimeInfo=true;
+ returnBuffer= new Buffer(200);
+ returnLine= new Buffer(200);
+
+ commandCounter=-1;
+ commandCounter=-1;
+ commandId=-1;
+ commandCounterString=NULL;
+
+}
+
+
+InputDecoder::~InputDecoder(){
+ delete yafCommands;
+ delete returnBuffer;
+ delete returnLine;
+ delete commandTable;
+}
+
+
+
+void InputDecoder::setRuntimeInfo(int lRuntimeInfo) {
+ this->lRuntimeInfo=lRuntimeInfo;
+}
+
+
+int InputDecoder::getRuntimeInfo() {
+ return lRuntimeInfo;
+}
+
+
+void InputDecoder::appendCommandTable(CommandTable* table){
+ commandTable->join(table);
+}
+
+
+
+
+void InputDecoder::processCommandLine(CommandLine* commandLine){
+ CommandTable* ct=commandTable; // "ct" is shorter
+ commandId=-1;
+
+ // The number of the command (unique for every command)
+ commandCounterString=commandLine->getValue(0);
+ commandCounter=atoi(commandCounterString);
+
+ // the command (longName or shortName )
+ if (commandLine->getCommandCount() == 0) {
+ clearReturnBuffer();
+ appendReturnBuffer("no Msg");
+ }
+ commandMsg=ct->getCommand(commandLine->getValue(1));
+ if ((commandMsg == NULL) || (strlen(commandMsg) == 0)) {
+ clearReturnBuffer();
+ appendReturnBuffer("unknown Command");
+ commandMsg=commandLine->getValue(1);
+
+ return ;
+ }
+
+ // the int value of the command (faster for compare)
+ commandId=ct->getNr(commandMsg);
+
+ // the Arguments of the command
+ commandArgs=ct->getArgs(commandMsg,(const char*) commandLine->getValue(1));
+
+ retString=processCommand(commandId,commandArgs);
+
+ if ((retString == NULL) || (strlen(retString) == 0)) {
+ retString=(char*)"ok";
+ }
+ clearReturnBuffer();
+ appendReturnBuffer(retString);
+}
+
+
+const char* InputDecoder::processCommand(int command,const char* args){
+
+ if (command == _YAF_I_HELP) {
+ if (strlen(args)==0) {
+ commandTable->print();
+ } else {
+ commandTable->print(commandTable->getNr(args),true);
+ }
+ return "";
+ }
+ if (command == _YAF_I_RUNTIME) {
+ if (strcmp("off",args)==0) {
+ setRuntimeInfo(false);
+ return "";
+ }
+ setRuntimeInfo(true);
+ return "";
+ }
+ if (command == _YAF_I_QUIT) {
+ ::exit(0);
+ return "";
+ }
+ if (command == _YAF_I_WHATIS) {
+ cout << "Yaf <y>et <a>nother <f>rontend" << endl;
+ cout << endl;
+ cout << "Yaf is an interactive command line oriented shell for decoders." \
+ << endl;
+ cout << endl;
+ cout << "Copyright (C) 1998,1999 Martin Vogt <mvogt@rhrk.uni-kl.de>"\
+ <<endl;
+ cout << "This program is free software; you can redistribute "\
+ << "it and/or modify"<<endl;
+ cout << "it under the terms of the GNU Library General Public License "\
+ << "as published by"<<endl;
+ cout << "the Free Software Foundation." <<endl;
+
+ cout << "For more information look at the file COPYRIGHT in "\
+ << "this package" <<endl;
+ cout << endl;
+ cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
+ << "USE AT YOUR OWN RISK!"<<endl;
+ return "";
+ }
+
+
+ if (command == _YAF_I_PING) {
+ return "";
+ }
+ if (command == _YAF_I_PROTOCOL) {
+ return "";
+ }
+ if (command == _YAF_I_NOPROTOCOL) {
+ return "";
+ }
+
+ return "unknown Command";
+}
+
+
+/**
+ These two functions are entered by the decoder
+ thread [START]
+*/
+
+
+void InputDecoder::doSomething(){
+ cout << "did something"<<endl;
+}
+
+
+
+int InputDecoder::getDecoderStatus() {
+ return status;
+}
+
+
+
+void InputDecoder::setDecoderStatus(int newState) {
+
+ // First start a new thread with start()!
+ // Their is no recovery if the thread status is set to exit!
+ if (status == _DECODER_STATUS_EXIT) {
+ return;
+ }
+ status=newState;
+}
+
+
+
+void InputDecoder::clearReturnBuffer() {
+ returnBuffer->clear();
+}
+
+
+void InputDecoder::appendReturnBuffer(const char* str) {
+ returnBuffer->append(str);
+}
+
+
+
+const char* InputDecoder::getReturnCode() {
+ // now we send back the return code
+
+ if ((commandId != -1) && (commandTable->getReturnFlag(commandId)==false)) {
+ return "";
+ }
+
+ returnLine->clear();
+ returnLine->append("Command:");
+
+
+ // The number of the command (unique for every command)
+ // 0: the command nr
+ returnLine->append(commandCounterString);
+ returnLine->append(" Ret:(");
+ returnLine->append(returnBuffer->getData());
+ returnLine->append(") Msg:");
+
+
+ // now get the part after Msg: (in the inputLine)
+
+ returnLine->append(commandMsg);
+ returnLine->append(" ");
+ returnLine->append(commandArgs);
+
+
+
+ return (const char*)returnLine->getData();
+
+}
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/inputDecoder.h b/mpeglib/example/yaf/yafcore/inputDecoder.h
new file mode 100644
index 00000000..0a5623a0
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/inputDecoder.h
@@ -0,0 +1,80 @@
+/*
+ process Messages on the decoder
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __INPUTDECODER_H
+#define __INPUTDECODER_H
+#include <pthread.h>
+
+#include "outputInterface.h"
+#include <strings.h>
+#include <kdemacros.h>
+
+#define _DECODER_STATUS_IDLE 1
+#define _DECODER_STATUS_WORKING 2
+#define _DECODER_STATUS_EXIT 3
+
+class CommandTable;
+class CommandTableYAF;
+class CommandLine;
+
+class KDE_EXPORT InputDecoder {
+
+ int status;
+ CommandTable* commandTable;
+ CommandTableYAF* yafCommands;
+ Buffer* returnBuffer;
+ Buffer* returnLine;
+ int lRuntimeInfo;
+
+
+
+
+ public:
+ InputDecoder();
+ virtual ~InputDecoder();
+
+ void processCommandLine(CommandLine*);
+ virtual const char* processCommand(int command,const char* args);
+ virtual void doSomething();
+
+ virtual void setDecoderStatus(int status);
+ int getDecoderStatus();
+
+ const char* getReturnCode();
+
+ void appendCommandTable(CommandTable* table);
+
+ void setRuntimeInfo(int lRuntimeInfo);
+ int getRuntimeInfo();
+
+
+ private:
+
+ void clearReturnBuffer();
+ void appendReturnBuffer(const char* msg);
+
+
+ int commandCounter;
+ int commandId;
+ const char* commandMsg;
+ const char* commandArgs;
+ const char* retString;
+ char* commandCounterString;
+
+
+};
+
+#endif
+
diff --git a/mpeglib/example/yaf/yafcore/inputInterface.cpp b/mpeglib/example/yaf/yafcore/inputInterface.cpp
new file mode 100644
index 00000000..455ddd40
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/inputInterface.cpp
@@ -0,0 +1,195 @@
+/*
+ This class can wait for an input by the user
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+#include <config.h>
+
+#include "inputInterface.h"
+#include "multiReader.h"
+#include <iostream>
+
+using namespace std;
+
+InputInterface::InputInterface(){
+
+ currentLine= new Buffer(300);
+ rawLine=new Buffer(300);
+ loopback=new Buffer(300);
+ protocolSyntax=false;
+ currentCommandNumber=42;
+ multiReader=new MultiReader();
+ yafInput=new ifstream("yaf.script");
+ if (yafInput->fail() == false) {
+ cout << "Command:0 Msg:comment found yaf.script. Parsing first"<<endl;
+ insertYafScript(yafInput);
+ }
+ yafInput->close();
+
+}
+
+InputInterface::~InputInterface(){
+ delete yafInput;
+ delete multiReader;
+ delete currentLine;
+ delete rawLine;
+ delete loopback;
+}
+
+
+int InputInterface::addFileDescriptor(int fd) {
+ int back;
+ back=multiReader->add(fd);
+ return back;
+}
+
+
+void InputInterface::removeFileDescriptor(int fd) {
+ multiReader->remove(fd);
+}
+
+
+int InputInterface::getCurrentCommandNumber() {
+ int back=0;
+ back=currentCommandNumber;
+ return back;
+}
+
+void InputInterface::increaseCurrentCommandNumber(){
+ currentCommandNumber++;
+}
+
+int InputInterface::write(int fd,const char* txt) {
+ int back=0;
+
+ int len;
+ loopback->clear();
+ if (protocolSyntax == true) {
+ snprintf(loopback->getData(),300,
+ "Command:41 Msg:%s",txt);
+ } else {
+ strlcpy(loopback->getData(),txt, loopback->getSize());
+ }
+ len =loopback->len();
+ back=::write(fd,loopback->getData(),len);
+
+ return back;
+}
+
+
+
+void InputInterface::waitForLine() {
+
+ while(multiReader->hasLine() == false) {
+ multiReader->waitForLine();
+ }
+ multiReader->getLine(rawLine);
+ makeValidLine(rawLine->getData());
+
+}
+
+void InputInterface::setProtocolSyntax (int proto) {
+ protocolSyntax=proto;
+}
+
+
+
+void InputInterface::makeValidLine(char* line) {
+
+ int len;
+ len=strlen(line);
+ if (len >= 1) {
+ if (line[len-1] == '\n') {
+ line[len-1]='\0';
+ }
+ }
+ if (strncmp("noprotocol",line,10) == 0){
+ setProtocolSyntax(false);
+ clearLine();
+ increaseCurrentCommandNumber();
+ snprintf(currentLine->getData(),300,
+ "Command:%d Msg:%s",currentCommandNumber,line);
+ return;
+ }
+ if (strncmp("protocol",line,8) == 0 ){
+ setProtocolSyntax(true);
+ clearLine();
+ increaseCurrentCommandNumber();
+ snprintf(currentLine->getData(),300,
+ "Command:%d Msg:%s",currentCommandNumber,line);
+ return;
+ }
+
+ // Now the part if we do _not_ bypass the protocol-state
+
+ if (protocolSyntax == false) {
+ clearLine();
+ increaseCurrentCommandNumber();
+ snprintf(currentLine->getData(),300,
+ "Command:%d Msg:%s",currentCommandNumber,line);
+ } else {
+ increaseCurrentCommandNumber();
+ strlcpy(currentLine->getData(),line, currentLine->getSize());
+ }
+
+ return;
+}
+
+
+void InputInterface::addInputLine(struct Buffer* buffer) {
+ multiReader->add(buffer);
+}
+
+
+void InputInterface::insertYafScript(ifstream* stream) {
+ char bst;
+ int nBytes=0;
+ Buffer yafScriptBuffer(300);
+
+ if (stream->fail()) return;
+ while (stream->eof()==false) {
+ stream->get(bst);
+ if (stream->eof()) break;
+
+ yafScriptBuffer.append(&bst,1);
+ }
+ nBytes=(yafScriptBuffer.len()-1); // EOF is a character we dont want
+
+ addInputLine(&yafScriptBuffer);
+}
+
+
+
+int InputInterface::hasLine() {
+ if (currentLine->len() == 0) return 0;
+ return 1;
+}
+
+void InputInterface::clearLine() {
+ currentLine->clear();
+}
+
+
+char* InputInterface::getLine() {
+ char* back=NULL;
+
+ back=currentLine->getData();
+#ifdef _DEBUG_INPUT
+ ofstream infile("instream.dbg",ios::app);
+ infile << back <<endl;
+ infile.close();
+#endif
+
+
+ return back;
+}
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/inputInterface.h b/mpeglib/example/yaf/yafcore/inputInterface.h
new file mode 100644
index 00000000..f3ea0065
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/inputInterface.h
@@ -0,0 +1,102 @@
+/*
+ This class can wait for an input by the user
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#ifndef __INPUTINTERFACE_H
+#define __INPUTINTERFACE_H
+
+
+#include "buffer.h"
+#include <fstream>
+#include <kdemacros.h>
+
+extern "C" {
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <stdio.h>
+}
+
+// uncomment this for debugging the input stream
+// (written to file instream.dbg)
+//#define _DEBUG_INPUT
+
+#define _TIMEOUT_MS 2000
+
+class MultiReader;
+
+class KDE_EXPORT InputInterface {
+
+ int currentCommandNumber;
+
+ int protocolSyntax;
+ Buffer* currentLine;
+ Buffer* rawLine;
+ MultiReader* multiReader;
+ Buffer* loopback;
+ Buffer* yafScript;
+ std::ifstream* yafInput;
+
+
+ public:
+
+ InputInterface();
+ ~InputInterface();
+
+ int addFileDescriptor(int fd);
+ void removeFileDescriptor(int fd);
+ int write(int fd,const char* txt);
+
+ /**
+ waits until a complete Line is entered
+ */
+ void waitForLine();
+
+ /**
+ returns true if a complete new InputLine is avaiable
+ */
+
+ int hasLine();
+
+ int getCurrentCommandNumber();
+
+ void increaseCurrentCommandNumber();
+
+ /**
+ clears the input Line
+ */
+ void clearLine();
+
+
+ /**
+ returns the new Line
+ */
+ char* getLine();
+
+
+ void setProtocolSyntax(int proto);
+ void addInputLine(struct Buffer* buffer);
+
+ private:
+ void makeValidLine(char* line);
+ void insertYafScript(std::ifstream* stream);
+
+
+};
+
+#endif
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/lineStack.cpp b/mpeglib/example/yaf/yafcore/lineStack.cpp
new file mode 100644
index 00000000..871665ed
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/lineStack.cpp
@@ -0,0 +1,95 @@
+/*
+ a class which scans a string and converts it into commandLines
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#include "lineStack.h"
+#include <iostream>
+
+using namespace std;
+
+
+LineStack::LineStack() {
+ stack=new Buffer(1);
+}
+
+
+LineStack::~LineStack() {
+ delete stack;
+}
+
+
+int LineStack::hasLine() {
+ int nPos;
+ nPos=stack->find('\n');
+ if (nPos == -1) return false;
+ return true;
+
+}
+
+
+
+void LineStack::nextLine(Buffer* nextLine) {
+ int nPos;
+ char* retPos;
+ int restLen;
+ char* data=stack->getData();
+ int nSize=stack->getSize();
+
+ nPos=stack->find('\n');
+ if (nPos == -1) {
+ nextLine->clear();
+ return;
+ }
+ retPos=&(data[nPos]);
+ (*retPos)='\0';
+ nextLine->clear();
+ nextLine->setData(data);
+ retPos++;
+ restLen=nSize+1-(nPos+1);
+ if (strlen(retPos) > 0) {
+ strncpy(data,retPos,restLen);
+ } else{
+ stack->clear();
+ }
+}
+
+
+void LineStack::appendBottom(char* buffer) {
+ int n=strlen(buffer);
+ appendBottom(buffer,n);
+}
+
+
+
+void LineStack::appendBottom(char* buffer, int buflen) {
+
+ stack->append(buffer,buflen);
+
+}
+
+void LineStack::appendBottom(LineStack* lStack) {
+ char* data;
+ int len;
+ data=lStack->stack->getData();
+ len=lStack->stack->len();
+ appendBottom(data,len);
+}
+
+
+
+void LineStack::print(char* name) {
+ cout << "LineStack:"<<name<<endl;
+ stack->print();
+}
+
+
diff --git a/mpeglib/example/yaf/yafcore/lineStack.h b/mpeglib/example/yaf/yafcore/lineStack.h
new file mode 100644
index 00000000..aea1f686
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/lineStack.h
@@ -0,0 +1,55 @@
+/*
+ a class which scans a string and converts it into commandLines
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+
+#ifndef __LINESTACK_H
+#define __LINESTACK_H
+
+
+#include "buffer.h"
+
+/*
+ This class is a hack because I have problems with
+ the io-streams. Why these stupid things cannot buffer
+ a whole line?
+ They behave strange, I hate them.
+*/
+
+
+
+class LineStack {
+
+ public:
+ LineStack();
+ ~LineStack();
+
+ void appendBottom(char* buffer);
+ void appendBottom(char* buffer,int buflen);
+ void appendBottom(LineStack* stack);
+
+ int hasLine();
+ void nextLine(Buffer* nextLine);
+
+ void print(char* name);
+ private:
+ char* getReturnPos();
+
+ Buffer* stack;
+};
+
+
+#endif
+
+
diff --git a/mpeglib/example/yaf/yafcore/multiReader.cpp b/mpeglib/example/yaf/yafcore/multiReader.cpp
new file mode 100644
index 00000000..41a62263
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/multiReader.cpp
@@ -0,0 +1,206 @@
+/*
+ This class can waits for input on different istreams
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#include "multiReader.h"
+
+
+
+MultiReader::MultiReader() {
+ int i;
+
+ buffer=new Buffer(201);
+ for(i=0;i<_MAX_INPUT;i++) {
+ lineInputArray[i]=new LineInput;
+ lineInputArray[i]->tmpLineStack=new LineStack();
+ lineInputArray[i]->empty=true;
+ }
+ script=new LineStack();
+}
+
+
+
+MultiReader::~MultiReader() {
+ int i;
+ for(i=0;i<_MAX_INPUT;i++) {
+ delete lineInputArray[i]->tmpLineStack;
+ delete lineInputArray[i];
+ }
+ delete script;
+}
+
+
+
+int MultiReader::add(int fd) {
+ int nPos;
+ nPos=getEmptySlot();
+
+ if (nPos == -1) {
+ return -1;
+ }
+ lineInputArray[nPos]->fd=fd;
+ lineInputArray[nPos]->empty=false;
+ return nPos;
+}
+
+void MultiReader::add(LineStack* aScript) {
+ script->appendBottom(aScript);
+}
+
+
+void MultiReader::add(Buffer* aScript) {
+ script->appendBottom(aScript->getData(),aScript->len());
+}
+
+
+
+
+void MultiReader::remove (int fd) {
+ int nPos;
+ nPos=getSlot(fd);
+
+ if (nPos == -1) {
+ return ;
+ }
+ lineInputArray[nPos]->empty=true;
+}
+
+
+
+void MultiReader::waitForLine() {
+ while(hasLine() == false) {
+ doSelect(NULL);
+ }
+}
+
+
+void MultiReader::poll(struct timeval* timeout) {
+ doSelect(timeout);
+}
+
+
+
+void MultiReader::doSelect(struct timeval* timeout) {
+ int i;
+ int ret;
+ fd_set readfds;
+ int nBytes;
+ int maxFd=0;
+
+ FD_ZERO(&readfds);
+ for(i=0;i<_MAX_INPUT;i++) {
+ if (lineInputArray[i]->empty == false) {
+ FD_SET(lineInputArray[i]->fd,&readfds);
+ if (lineInputArray[i]->fd > maxFd) {
+ maxFd=lineInputArray[i]->fd;
+ }
+ }
+ }
+ ret=select(maxFd+1,&readfds,NULL,NULL,timeout);
+ if (ret < 0) {
+ if (errno < 0) {
+ perror("nach select multireader:");
+ exit(0);
+ }
+ }
+ if (ret == 0) return;
+
+ for(i=0;i<_MAX_INPUT;i++) {
+ if (lineInputArray[i]->empty == false) {
+ if (FD_ISSET(lineInputArray[i]->fd,&readfds)) {
+ nBytes=read(lineInputArray[i]->fd,buffer->getData(),200);
+ if (nBytes == 0) {
+ perror("MultiReader:read error!");
+ exit(-1);
+ }
+ (buffer->getData())[nBytes]='\0';
+
+ lineInputArray[i]->tmpLineStack->appendBottom(buffer->getData(),
+ nBytes);
+ FD_CLR(lineInputArray[i]->fd,&readfds);
+ }
+ }
+ }
+}
+
+
+
+int MultiReader::hasLine() {
+ int i;
+ LineStack* lineStack; // owned by class
+
+ if (script->hasLine() == true) {
+ return true;
+ }
+
+ for(i=0;i<_MAX_INPUT;i++) {
+ if (lineInputArray[i]->empty == false) {
+ lineStack=lineInputArray[i]->tmpLineStack;
+ if (lineStack->hasLine()) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+
+void MultiReader::getLine(Buffer* buffer) {
+ int i;
+ LineStack* lineStack; // owned by class
+ buffer->clear();
+
+ if (script->hasLine()==true) {
+ script->nextLine(buffer);
+ } else {
+ for(i=0;i<_MAX_INPUT;i++) {
+ if (lineInputArray[i]->empty == false) {
+ lineStack=lineInputArray[i]->tmpLineStack;
+
+ if (lineStack->hasLine()) {
+ lineStack->nextLine(buffer);
+ return;
+ }
+ }
+ }
+ }
+ buffer->append("\n");
+}
+
+
+
+
+int MultiReader::getEmptySlot() {
+ int i;
+
+ for(i=0;i<_MAX_INPUT;i++) {
+ if (lineInputArray[i]->empty == true) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+
+int MultiReader::getSlot(int fd) {
+ int i;
+
+ for(i=0;i<_MAX_INPUT;i++) {
+ if (lineInputArray[i]->empty == false) {
+ if (lineInputArray[i]->fd == fd) {
+ return i;
+ }
+ }
+ }
+ return -1;
+}
diff --git a/mpeglib/example/yaf/yafcore/multiReader.h b/mpeglib/example/yaf/yafcore/multiReader.h
new file mode 100644
index 00000000..79f7dd8b
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/multiReader.h
@@ -0,0 +1,88 @@
+/*
+ This class can waits for input on different istreams
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __MULTIREADER_H
+#define __MULTIREADER_H
+
+#include "lineStack.h"
+#include "buffer.h"
+
+extern "C" {
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+#include <strings.h>
+#include <string.h>
+ }
+
+/**
+ The purpose of this class is to have a thread safe input method
+ for yaf command.
+ <p>
+ Sometime the decoder thread must send data to the control thread.
+ E.g. the Stream has ended. The decoder thread must inform the
+ control thread that the player should go into the "off" state.
+ A direct call is not thread safe and this is why the decoder
+ thread must use this class. For the control thread it looks
+ like the user has typed "off".
+
+*/
+
+#define _MAX_INPUT 5
+
+typedef struct {
+ LineStack* tmpLineStack; // owned by class
+ int fd; // filedescriptor for input
+ int empty;
+} LineInput;
+
+
+class MultiReader {
+
+ Buffer* buffer;
+ LineInput* lineInputArray[_MAX_INPUT];
+ LineStack* script;
+
+ public:
+ MultiReader();
+ ~MultiReader();
+
+ int add(int fd);
+ void add(LineStack* aScript);
+ void add(Buffer* aScript);
+ void remove (int fd);
+
+ void waitForLine();
+ void poll(struct timeval* timeout);
+
+ int hasLine();
+ void getLine(Buffer* buffer);
+
+ private:
+
+ void doSelect(struct timeval *timeout);
+
+ int getEmptySlot();
+ int getSlot(int fd);
+
+
+};
+
+
+
+
+
+#endif
diff --git a/mpeglib/example/yaf/yafcore/outputDecoder.cpp b/mpeglib/example/yaf/yafcore/outputDecoder.cpp
new file mode 100644
index 00000000..0993add0
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/outputDecoder.cpp
@@ -0,0 +1,144 @@
+/*
+ Default output decoder
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+#include "outputDecoder.h"
+#include <iostream>
+
+using namespace std;
+
+#define DEBUG cout << "Command:1 Msg:"
+
+
+OutputDecoder::OutputDecoder() {
+ yafCommands=new CommandTableYAF();
+ yafRuntime=new RuntimeTableYAF();
+
+ appendCommandTable(yafCommands);
+ appendRuntimeTable(yafRuntime);
+
+}
+
+
+
+OutputDecoder::~OutputDecoder() {
+ delete yafCommands;
+ delete yafRuntime;
+}
+
+
+
+void OutputDecoder::appendCommandTable(CommandTable* table) {
+ commandTable.join(table);
+}
+
+
+void OutputDecoder::appendRuntimeTable(CommandTable* table) {
+ runtimeTable.join(table);
+}
+
+
+
+CommandTable* OutputDecoder::getCommandTable() {
+ return &commandTable;
+}
+
+
+CommandTable* OutputDecoder::getRuntimeTable() {
+ return &runtimeTable;
+}
+
+
+
+
+void OutputDecoder::processCommandLine(CommandLine* commandLine){
+ CommandTable* ct=&commandTable; // ct , rt are shorter..
+ CommandTable* rt=&runtimeTable;
+
+
+ int command;
+ int commandNr;
+ const char* commandStr;
+ const char* retString;
+ const char* args;
+
+
+ // The number of the command (unique for every command)
+ commandNr=atoi(commandLine->getValue(0));
+
+ // if commandNr is greater zero then we have a return command from decoder
+ if (commandNr >= 40) {
+
+ // the command (longName or shortName )
+ commandStr=ct->getCommand(commandLine->getValue(2));
+ // the int value of the command (faster for compare)
+ command=ct->getNr(commandStr);
+
+ // the Arguments of the command
+ args=ct->getArgs(commandStr,commandLine->getValue(2));
+ retString=commandLine->getValue(1);
+
+ processReturnCommand(commandNr,command,retString,args);
+ return;
+ }
+
+ // if commandNr < 40 then we have a runtime command from decoder
+
+ if (commandNr < 40) {
+ // the command (longName or shortName )
+ commandStr=rt->getCommand(commandLine->getValue(1));
+ // the int value of the command (faster for compare)
+ command=rt->getNr(commandStr);
+
+ // here I make a hack because it cannot be expected
+ // that during debugging every debug-info has its clean
+ // installed debug-identifer.
+ // hack:
+ // if the commandNr==1 (debug) and we have NO defined
+ // debug identifier then we do not send -1 (as in all other case)
+ // but the number 1 itsself.
+
+ if ((commandNr == 1) && (command == -1)) {
+ args=rt->getArgs(commandStr,commandLine->getValue(1));
+ processRuntimeCommand(1,args);
+ return;
+ }
+
+ // in *all* other cases the developer should
+ // implement a clean protokoll with identifiers
+ // (this leads to well defined interfaces :-)
+
+ // the Arguments of the command
+ args=rt->getArgs(commandStr,commandLine->getValue(1));
+
+ processRuntimeCommand(command,args);
+ return;
+ }
+
+
+}
+
+
+
+int OutputDecoder::processRuntimeCommand(int command,const char* args){
+ cout << command <<" * "<< args <<" * "<< endl;
+ return false;
+}
+
+int OutputDecoder::processReturnCommand(int cmdNr,int cmdId,
+ const char* ret,const char* args){
+ cout << cmdNr <<" * "<< cmdId<<" * "<< ret<<" * " << args << endl;
+ return false;
+}
+
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/outputDecoder.h b/mpeglib/example/yaf/yafcore/outputDecoder.h
new file mode 100644
index 00000000..1448258b
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/outputDecoder.h
@@ -0,0 +1,52 @@
+/*
+ Default output decoder
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#ifndef __OUTPUTDECODER_H
+#define __OUTPUTDECODER_H
+
+#include "commandLine.h"
+
+#include "runtimeTableYAF.h"
+#include "commandTableYAF.h"
+
+
+class OutputDecoder {
+
+ public:
+ OutputDecoder();
+ virtual ~OutputDecoder();
+
+ void processCommandLine(CommandLine*);
+ virtual int processRuntimeCommand(int command,const char* args);
+ virtual int processReturnCommand(int cmdNr,int cmdId,
+ const char* ret,const char* args);
+
+ void appendCommandTable(CommandTable* table);
+ void appendRuntimeTable(CommandTable* table);
+
+ CommandTable* getRuntimeTable();
+ CommandTable* getCommandTable();
+
+ private:
+ CommandTable* yafCommands;
+ CommandTable* yafRuntime;
+
+ CommandTable commandTable;
+ CommandTable runtimeTable;
+
+
+};
+
+
+#endif
diff --git a/mpeglib/example/yaf/yafcore/outputInterface.cpp b/mpeglib/example/yaf/yafcore/outputInterface.cpp
new file mode 100644
index 00000000..b57563fd
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/outputInterface.cpp
@@ -0,0 +1,85 @@
+/*
+ This class sends an output to the outputstream
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#include "outputInterface.h"
+#include <iostream>
+
+using namespace std;
+
+OutputInterface::OutputInterface(ostream* out) {
+ protocolSyntax=false;
+ this->out=out;
+ outBuffer=new Buffer(250);
+ setlinebuf(stdout);
+ pthread_mutex_init(&writeOutMut,NULL);
+}
+
+
+OutputInterface::~OutputInterface() {
+ delete outBuffer;
+}
+
+void OutputInterface::flushBuffer() {
+ if (protocolSyntax) {
+ (*out) << outBuffer->getData() << endl;
+#ifdef _DEBUG_OUTPUT
+ ofstream outfile("outstream.dbg",ios::app);
+ outfile << outBuffer->getData() << endl;
+ outfile.flush();
+ outfile.close();
+#endif
+ return;
+ } else {
+ (*out) << "Command:" << nr << " Msg:" << outBuffer->getData() << endl;
+#ifdef _DEBUG_OUTPUT
+ ofstream outfile("outstream.dbg",ios::app);
+ outfile << "Command:" << nr << " Msg:" << outBuffer->getData() << endl;
+ outfile.flush();
+ outfile.close();
+#endif
+ }
+ fflush(NULL);
+}
+
+
+
+void OutputInterface::setProtocolSyntax(int proto) {
+ protocolSyntax=proto;
+}
+
+
+void OutputInterface::setNr(int nr) {
+ this->nr=nr;
+}
+
+void OutputInterface::clearBuffer() {
+ outBuffer->clear();
+}
+
+
+void OutputInterface::appendBuffer(const char* msg) {
+ outBuffer->append(msg);
+}
+
+
+
+void OutputInterface::lock() {
+ pthread_mutex_lock(&writeOutMut);
+}
+
+
+void OutputInterface::unlock() {
+ pthread_mutex_unlock(&writeOutMut);
+}
+
diff --git a/mpeglib/example/yaf/yafcore/outputInterface.h b/mpeglib/example/yaf/yafcore/outputInterface.h
new file mode 100644
index 00000000..0a24fd92
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/outputInterface.h
@@ -0,0 +1,60 @@
+/*
+ This class sends an output to the outputstream
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+
+
+#ifndef __OUTPUTINTERFACE_H
+#define __OUTPUTINTERFACE_H
+
+#include <pthread.h>
+#include <fstream>
+#include "buffer.h"
+#include <kdemacros.h>
+
+// uncomment this for debugging the output stream
+// (written to file outstream.dbg)
+//#define _DEBUG_OUTPUT
+
+
+class KDE_EXPORT OutputInterface {
+
+ int protocolSyntax;
+ int nr;
+ Buffer* outBuffer;
+ std::ostream* out;
+ pthread_mutex_t writeOutMut;
+
+
+ public:
+
+ OutputInterface(std::ostream* out);
+ ~OutputInterface();
+
+
+ void flushBuffer();
+ void setProtocolSyntax(int proto);
+ void setNr(int nr);
+ void clearBuffer();
+ void appendBuffer(const char* msg);
+
+ // make this interface threadsafe
+ void lock();
+ void unlock();
+
+};
+
+
+
+#endif
diff --git a/mpeglib/example/yaf/yafcore/parser.cpp b/mpeglib/example/yaf/yafcore/parser.cpp
new file mode 100644
index 00000000..21b27c6b
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/parser.cpp
@@ -0,0 +1,152 @@
+/*
+ Checks if a valid Command Line is avaiable
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+#include "parser.h"
+
+
+Parser::Parser() {
+ commandLine=new CommandLine();
+ parseString=new Buffer(200);
+}
+
+
+Parser::~Parser() {
+ delete commandLine;
+ delete parseString;
+}
+
+void Parser::setParseString(char* parseString){
+ (this->parseString)->setData(parseString);
+ // clear everything in commandline
+ commandLine->clear();
+}
+
+void Parser::parse() {
+ int commandCounter=0;
+
+ parse(parseString->getData(),&commandCounter);
+ commandLine->setCommandCount(commandCounter);
+}
+
+
+void Parser::parse(char* strStart,int* nCommand){
+ char* doppelPkt;
+ char* current;
+ char* space;
+
+ if (strlen(strStart) == 0) return;
+
+ doppelPkt=strchr(strStart,':');
+ if (doppelPkt == NULL) return;
+ (*doppelPkt)='\0';
+ commandLine->setIdentifier(*nCommand,strStart);
+ strStart=++doppelPkt;
+ current=strStart;
+
+ // Now two possibilities:
+ // a command with Msg : means the rest ist the value
+ // a command different from Msg means: further processing
+
+ if (strcmp("Msg",commandLine->getIdentifier(*nCommand)) == 0) {
+ commandLine->setValue((*nCommand),current);
+ (*nCommand)++;
+ return;
+ }
+
+ // Now two possibilities:
+ // a command with "Ret:" means string until the the ")" is the value
+ // a command different from "Ret:" means: the string until the first space
+ // ist the value
+ if (strcmp("Ret",commandLine->getIdentifier(*nCommand)) == 0) {
+ char* seperator;
+ seperator=strchr(current,')');
+ if (seperator == NULL) {
+ commandLine->setValue((*nCommand),current);
+ (*nCommand)++;
+ return;
+ } else {
+ (*seperator)='\0';
+ current++;
+ commandLine->setValue((*nCommand),current);
+ (*nCommand)++;
+ seperator++;
+ if (strlen(seperator) == 0) return;
+ parse(++seperator,&(*nCommand));
+ return;
+ }
+ }
+
+ space=strchr(current,' ');
+ if (space == NULL) {
+ commandLine->setValue((*nCommand),current);
+ (*nCommand)++;
+ return;
+ }
+ (*space)='\0';
+ commandLine->setValue((*nCommand),current);
+ parse(++space,&(++(*nCommand)));
+}
+
+
+
+
+int Parser::isOK(){
+ // a Commandline ist valid when it contains :
+
+ // * 2 * (identifer/value)
+ // * first identifier ist "Command"
+ // * second identifier is "Msg"
+
+
+ // or:
+ // 3 identifier
+ // first: "Command"
+ // second "Ret"
+ // third: "Msg"
+
+ if (commandLine->getCommandCount() == 2){
+ if (strcmp("Command",commandLine->getIdentifier(0)) != 0) return 0;
+ if (strcmp("Msg",commandLine->getIdentifier(1)) != 0) return 0;
+ return 1;
+ }
+
+ if (commandLine->getCommandCount() == 3){
+ if (strcmp("Command",commandLine->getIdentifier(0)) != 0) return 0;
+ if (strcmp("Ret",commandLine->getIdentifier(1)) != 0) return 0;
+ if (strcmp("Msg",commandLine->getIdentifier(2)) != 0) return 0;
+ return 1;
+ }
+
+ return 0;
+}
+
+CommandLine* Parser::getCommandLine(){
+ return commandLine;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/parser.h b/mpeglib/example/yaf/yafcore/parser.h
new file mode 100644
index 00000000..d9c46211
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/parser.h
@@ -0,0 +1,55 @@
+/*
+ Checks if a valid Command Line is avaiable
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+
+#ifndef __PARSER_H
+#define __PARSER_H
+
+#include "buffer.h"
+#include "commandLine.h"
+
+extern "C" {
+#include <string.h>
+ }
+
+class Parser {
+
+
+ Buffer* parseString;
+ CommandLine* commandLine;
+
+ public:
+
+ Parser();
+ ~Parser();
+
+ void setParseString(char* parseString);
+ void parse();
+ int isOK();
+ CommandLine* getCommandLine();
+
+
+ private:
+ void parse(char* currentPos,int* nCommand);
+
+};
+
+
+#endif
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/runtimeTableYAF.cpp b/mpeglib/example/yaf/yafcore/runtimeTableYAF.cpp
new file mode 100644
index 00000000..987c10ae
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/runtimeTableYAF.cpp
@@ -0,0 +1,34 @@
+/*
+ basic runtime command (fits for every decoder)
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+#define _USE_RUNTIME_YAF_STRUC
+
+#include "runtimeTableYAF.h"
+
+
+RuntimeTableYAF::RuntimeTableYAF(){
+ init();
+}
+
+RuntimeTableYAF::~RuntimeTableYAF(){
+}
+
+void RuntimeTableYAF::init() {
+
+ int i;
+ for (i=0;i<YAFRUNTIME_SIZE;i++) {
+ insert(&yafRuntime[i]);
+ }
+
+}
+
diff --git a/mpeglib/example/yaf/yafcore/runtimeTableYAF.h b/mpeglib/example/yaf/yafcore/runtimeTableYAF.h
new file mode 100644
index 00000000..6a77467a
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/runtimeTableYAF.h
@@ -0,0 +1,35 @@
+/*
+ basic runtime command (fits for every decoder)
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#ifndef __RUNTIME_TABLEYAF_H
+#define __RUNTIME_TABLEYAF_H
+
+#include "commandTable.h"
+#include "yafRuntime.defs"
+
+
+
+
+class RuntimeTableYAF : public CommandTable {
+
+ public:
+ RuntimeTableYAF();
+ ~RuntimeTableYAF();
+ void init();
+
+};
+
+#endif
+
+
diff --git a/mpeglib/example/yaf/yafcore/yafCommand.defs b/mpeglib/example/yaf/yafcore/yafCommand.defs
new file mode 100644
index 00000000..ab2559df
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/yafCommand.defs
@@ -0,0 +1,89 @@
+/*
+ definition file for basic yaf commands
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __YAF_COMMAND_DEFS
+#define __YAF_COMMAND_DEFS
+
+#include "commandTable.h" // defines CommandDesc-Struct...
+
+// Command Numbers
+
+#define _YAF_I_COMMAND 1
+#define _YAF_I_MSG 2
+#define _YAF_I_HELP 3
+#define _YAF_I_RUNTIME 4
+#define _YAF_I_QUIT 5
+#define _YAF_I_PING 6
+#define _YAF_I_PROTOCOL 7
+#define _YAF_I_NOPROTOCOL 8
+#define _YAF_I_WHATIS 9
+#define _YAF_I_SELECT_A_LAYER 10
+#define _YAF_I_SELECT_V_LAYER 11
+#define _YAF_I_PLAYTIME 12
+#define _YAF_I_WRITE 13
+
+
+
+
+
+
+
+
+#define _YAF_START 40
+
+
+
+// The commands as String. The Syntax is :
+//
+
+// { lexternalUse,lReturnMsg,longName,shortName,number,helpText }
+//
+// lexternal use ist true when the text should be written when
+// user enters "help"
+
+
+#ifdef _USE_YAF_STRUC
+
+static struct CommandDescriptionStruct yafCommands[]={
+
+ {0,1,"Command","",_YAF_I_COMMAND,"internal identifier"},
+ {0,1,"Msg","",_YAF_I_MSG,"identifier for unstructured String"},
+ {1,1,"help","h",_YAF_I_HELP,"show this help"},
+ {1,1,"ping","",_YAF_I_PING,"command tests if client is alive"},
+ {1,1,"runtime","r",_YAF_I_RUNTIME,"runtime [on|off] shows runtime infos"},
+ {1,1,"protocol","",_YAF_I_NOPROTOCOL,"internal protocol wrapper on [def]"},
+ {1,1,"noprotocol","",_YAF_I_PROTOCOL,"internal protocol wrapper off"},
+ {1,1,"whatis" ,"",_YAF_I_WHATIS,"gives a short introduction" },
+ {1,1,"audioLayer","", _YAF_I_SELECT_A_LAYER,
+ "selects audio layer from stream [0..31]"},
+ {1,1,"videoLayer" ,"", _YAF_I_SELECT_V_LAYER,
+ "selects video layer from stream [0..15]" },
+ {1,1,"playtime","", _YAF_I_PLAYTIME,
+ "retrives the current playtime" },
+ {1,1,"write","", _YAF_I_WRITE,
+ "writes stream to disk [on|off] default[off]" },
+ {1,1,"quit","q",_YAF_I_QUIT,"ends program"}
+
+};
+#endif
+
+
+// How much Commands are in the Array :
+#define YAFCOMMANDS_SIZE 13
+
+
+
+#endif
+
diff --git a/mpeglib/example/yaf/yafcore/yafRuntime.defs b/mpeglib/example/yaf/yafcore/yafRuntime.defs
new file mode 100644
index 00000000..2918d178
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/yafRuntime.defs
@@ -0,0 +1,67 @@
+/*
+ basic Runtime definitions for yaf
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __YAF_RUNTIME_DEFS
+#define __YAF_RUNTIME_DEFS
+
+#include "../yafcore/commandTable.h" // defines CommandDesc-Struct...
+
+// Command Numbers
+
+// define the YAF debug -its not a real command, but I know
+// what I'm doing (see: outputDecoder.cpp)
+
+#define _YAF_DEBUG 1
+
+
+// For all other commands use the following schema:
+
+#define _YAF_RUN_COMMENT _CT_START+1
+#define _YAF_RUN_DECODER _CT_START+2
+#define _YAF_RUN_PROTOCOL _CT_START+3
+#define _YAF_RUN_IMPLEMENTS _CT_START+4
+#define _YAF_RUN_EXIT _CT_START+5
+
+
+#define _YAF_RUN_START _CT_START+100
+
+
+
+// The commands as String. The Syntax is :
+//
+
+// { lexternalUse,lReturnMsg,longName,shortName,number,helpText }
+//
+// lexternal use ist true when the text should be written when
+// user enters "help"
+#ifdef _USE_RUNTIME_YAF_STRUC
+static struct CommandDescriptionStruct yafRuntime[]={
+
+ { 0,1,"comment","",_YAF_RUN_COMMENT,"commands should not be interpreted"},
+ { 0,1,"decoder", "",_YAF_RUN_DECODER, "Name of decoder"},
+ { 0,1,"implements", "",_YAF_RUN_IMPLEMENTS, "basic behaviour"},
+ { 0,1,"exit", "",_YAF_RUN_EXIT, "yaf protocol terminated"},
+ { 0,1,"protocol", "",_YAF_RUN_PROTOCOL, "yaf protocol version"}
+
+};
+#endif
+
+// How much Commands are in the Array :
+#define YAFRUNTIME_SIZE 5
+
+
+
+#endif
+
diff --git a/mpeglib/example/yaf/yafcore/yaf_control.cpp b/mpeglib/example/yaf/yafcore/yaf_control.cpp
new file mode 100644
index 00000000..6e789588
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/yaf_control.cpp
@@ -0,0 +1,81 @@
+/*
+ generic interactive controller
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#include "yaf_control.h"
+#include "parser.h"
+#include <iostream>
+
+using namespace std;
+
+
+void yaf_control(InputInterface* input,
+ OutputInterface* output,
+ InputDecoder* decoder) {
+
+ Parser parser;
+ CommandLine* commandLine;
+ struct timeval timeout;
+ const char* retCode;
+ int status;
+
+ timeout.tv_sec=0;
+ timeout.tv_usec=0;
+
+ output->setProtocolSyntax(true); // we send "raw" protocol data
+ input->addFileDescriptor(0);
+
+ while(1) {
+
+ status=decoder->getDecoderStatus();
+
+ if (status == _DECODER_STATUS_EXIT) {
+ break;
+ }
+ input->waitForLine();
+
+ if (input->hasLine()) {
+ parser.setParseString(input->getLine());
+ parser.parse();
+
+ if (parser.isOK()){
+
+
+ commandLine=parser.getCommandLine();
+
+ decoder->processCommandLine(commandLine);
+ retCode=decoder->getReturnCode();
+
+ // now get the part after Msg: (in the inputLine)
+
+ output->lock();
+ output->clearBuffer();
+ output->appendBuffer(retCode);
+ output->flushBuffer();
+ output->unlock();
+ } else {
+ cout << "Error parsing input:"<<input->getLine()<<endl;
+ }
+
+ input->clearLine();
+ } else {
+ cout << "no line"<<endl;
+ }
+ }
+ input->removeFileDescriptor(0);
+
+}
+
+
+
+
diff --git a/mpeglib/example/yaf/yafcore/yaf_control.h b/mpeglib/example/yaf/yafcore/yaf_control.h
new file mode 100644
index 00000000..890a1bb8
--- /dev/null
+++ b/mpeglib/example/yaf/yafcore/yaf_control.h
@@ -0,0 +1,26 @@
+
+
+#ifndef __YAF_CONTROL_H
+#define __YAF_CONTROL_H
+
+
+
+#include "inputInterface.h"
+#include "outputInterface.h"
+#include "inputDecoder.h"
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <kdemacros.h>
+
+
+// prototypes
+
+//extern "C" void control_xplayer();
+KDE_EXPORT void yaf_control(InputInterface* input,
+ OutputInterface* output,
+ InputDecoder* decoder);
+
+#endif
diff --git a/mpeglib/example/yaf/yafmpgplay/Makefile.am b/mpeglib/example/yaf/yafmpgplay/Makefile.am
new file mode 100644
index 00000000..c9fd9b55
--- /dev/null
+++ b/mpeglib/example/yaf/yafmpgplay/Makefile.am
@@ -0,0 +1,34 @@
+# mpegplay-yaf - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+EXTRA_DIST = stresstest
+
+bin_PROGRAMS = yaf-mpgplay
+
+yaf_mpgplay_SOURCES = mpg_control.cpp
+
+noinst_HEADERS =
+
+
+yaf_mpgplay_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+
+yaf_mpgplay_LDADD = ../yafcore/libyafcore.la \
+ ../yafxplayer/libyafxplayer.la \
+ ../../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafmpgplay/mpg_control.cpp b/mpeglib/example/yaf/yafmpgplay/mpg_control.cpp
new file mode 100644
index 00000000..ee080a73
--- /dev/null
+++ b/mpeglib/example/yaf/yafmpgplay/mpg_control.cpp
@@ -0,0 +1,197 @@
+/*
+ generic interactive controller
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+// Set for local include
+#define DIRECT_INCLUDE
+
+#include "../yafcore/yaf_control.h"
+#include "../yafxplayer/inputDecoderYAF.h"
+
+
+
+
+#include <iostream>
+using namespace std;
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#if defined(HAVE_GETOPT_H)
+#include <getopt.h>
+#endif
+
+// we include our plugin here
+#include "../../../lib/decoder/mpgPlugin.h"
+
+#if defined(HAVE_GETOPT_H)
+#include <getopt.h>
+#endif
+
+
+
+
+
+void control_mpgplay(InputInterface* input,OutputInterface* output,
+ InputDecoder* decoder) {
+
+
+ cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
+ cout<< "Command:0 Msg:implements xplayer" << endl;
+ cout<< "Command:0 Msg:decoder splay Version:0.8.2" << endl;
+ cout<< "Command:0 Msg:decoder mpeg_play Version:2.4.0" << endl;
+ cout<< "Command:0 Msg:mimetypes video/mpeg;" << endl;
+ cout<< "Command:0 Msg:comment splay by Woo-jae Jung" << endl;
+ cout<< "Command:0 Msg:comment mpeg_play by University of California" << endl;
+ cout<< "Command:0 Msg:comment yaf port by mvogt@rhrk.uni-kl.de"<<endl;
+ cout<< "Command:0 Msg:comment based on sources from mpeg_play and splay"<<endl;
+ cout<< "Command:0 Msg:comment enter 'help' " << endl;
+
+
+
+
+
+ yaf_control(input,output,decoder);
+}
+
+
+void usage() {
+ cout << "yaf-mpgplay is a interactive frontend for the mpeg I decoder"<<endl;
+ cout << "Usage : yaf-mpgplay [2al:L:scb:mhpywd:] [url]"<<endl;
+ cout << endl;
+ cout << "-2 : playing with half frequency."<<endl;
+ cout << "-m : force to mono."<<endl;
+ cout << "-a : no internal audio device"<<endl;
+ cout << "-c : no time calculation"<<endl;
+ cout << "-s : no audio/video sync"<<endl;
+ cout << "-b : audio buffer delay (bytes)[65535 byte]"<<endl;
+ cout << "-p : measure performance (audio is decoded, but not played)"<<endl;
+ cout << "-l : select audio Layer [0]"<<endl;
+ cout << "-L : select video Layer [0]"<<endl;
+ cout << "-w : write streams to disk [demultiplex]"<<endl;
+ cout << "-y : autoplay off"<<endl;
+ cout << "-d : [1..2] dump yuv images 1: single images 2: as stream"<<endl;
+ cout << endl;
+ cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
+ << "USE AT YOUR OWN RISK!"<<endl;
+ cout << endl;
+ cout << "for more help type 'help' in interactive mode"<<endl;
+}
+
+
+
+
+int main(int argc, char** argv) {
+ int c;
+ int lInternalAudio=true;
+
+ pow(6.0,3.0); // fixes bug in __math.h
+ InputInterface input;
+ OutputInterface output(&cout);
+
+
+
+
+
+ YafOutputStream* yafOutput=new YafOutputStream(&input);
+ MpgPlugin* plugin=new MpgPlugin();
+
+ plugin->setOutputPlugin(yafOutput);
+ InputDecoderYAF decoder(plugin,yafOutput);
+
+
+
+ while(1) {
+ c = getopt (argc, argv, "2al:L:scb:mhpywd:");
+ if (c == -1) break;
+ switch(c) {
+ case 'a': {
+ lInternalAudio=false;
+ break;
+ }
+ case 'h': {
+ usage();
+ exit(0);
+ }
+ case 'y': {
+ decoder.setAutoPlay(false);
+ break;
+ }
+ case '2': {
+ plugin->config("-2","true",NULL);
+ break;
+ }
+ case 'm': {
+ plugin->config("-m","true",NULL);
+ break;
+ }
+ case 'c': {
+ plugin->config("-c","true",NULL);
+ break;
+ }
+ case 'w': {
+ plugin->config("-w","true",NULL);
+ break;
+ }
+ case 's': {
+ yafOutput->config("-s","true",NULL);
+ break;
+ }
+ case 'b': {
+ yafOutput->config("-b",optarg,NULL);
+ break;
+ }
+ case 'd': {
+ yafOutput->config("yufDump",optarg,NULL);
+ break;
+ }
+ case 'p': {
+ yafOutput->config("-p",optarg,NULL);
+ break;
+ }
+ case 'l': {
+ plugin->config("AudioLayer",optarg,NULL);
+ cout << "trying to configure" << endl;
+ break;
+ }
+ case 'L': {
+ plugin->config("VideoLayer",optarg,NULL);
+ break;
+ }
+
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ usage();
+ exit(-1);
+ }
+ }
+
+ if (optind < argc ) {
+ Buffer buffer(300);
+ buffer.append("open ");
+ buffer.append(argv[optind]);
+ buffer.append("\n");
+ input.addInputLine(&buffer);
+
+ }
+ yafOutput->internalDevice(lInternalAudio);
+ control_mpgplay(&input,&output,&decoder);
+ delete plugin;
+ delete yafOutput;
+
+}
+
+
diff --git a/mpeglib/example/yaf/yafmpgplay/stresstest b/mpeglib/example/yaf/yafmpgplay/stresstest
new file mode 100644
index 00000000..1d73ad92
--- /dev/null
+++ b/mpeglib/example/yaf/yafmpgplay/stresstest
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+declare -i zahl=100
+declare -i zahl1=3
+rm -f jumptable
+echo "sleep 5" >>jumptable
+
+while [ 0 -le $zahl ] ; do
+ echo "j $zahl" >>jumptable
+ echo "sleep 0" >>jumptable
+ echo "j $zahl1" >>jumptable
+ echo "sleep 0" >>jumptable
+
+ zahl=$[zahl-7]
+ zahl1=$[zahl1+7]
+done
+echo "sleep 20" >>jumptable
+echo "quit" >>jumptable
+
+for i in "/mnt/diskD/mpeg"/* ; do
+ echo "open $i" >yaf.script
+ ./yaf-mpgplay <jumptable
+ sleep 5
+done
diff --git a/mpeglib/example/yaf/yafsplay/Makefile.am b/mpeglib/example/yaf/yafsplay/Makefile.am
new file mode 100644
index 00000000..463ec7db
--- /dev/null
+++ b/mpeglib/example/yaf/yafsplay/Makefile.am
@@ -0,0 +1,35 @@
+# splay-yaf - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+EXTRA_DIST = stresstest
+
+bin_PROGRAMS = yaf-splay
+
+yaf_splay_SOURCES = splay_control.cpp
+
+
+noinst_HEADERS =
+
+yaf_splay_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+
+yaf_splay_LDADD = ../yafxplayer/libyafxplayer.la \
+ ../yafcore/libyafcore.la \
+ ../../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafsplay/splay_control.cpp b/mpeglib/example/yaf/yafsplay/splay_control.cpp
new file mode 100644
index 00000000..82be9c11
--- /dev/null
+++ b/mpeglib/example/yaf/yafsplay/splay_control.cpp
@@ -0,0 +1,161 @@
+/*
+ generic interactive controller
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+// Set for local include
+#define DIRECT_INCLUDE
+
+#include "../yafcore/yaf_control.h"
+#include "../yafxplayer/inputDecoderYAF.h"
+
+#include <iostream>
+using namespace std;
+
+#include <math.h>
+
+
+
+// we include our plugin here
+#include "../../../lib/decoder/splayPlugin.h"
+
+#if defined(HAVE_GETOPT_H)
+#include <getopt.h>
+#endif
+
+
+void control_splay(InputInterface* input,OutputInterface* output,
+ InputDecoder* decoder) {
+
+
+ cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
+ cout<< "Command:0 Msg:implements xplayer" << endl;
+ cout<< "Command:0 Msg:decoder splay Version:0.8.2" << endl;
+ cout<< "Command:0 Msg:mimetypes audio/mpg1;audio/mpg2;audio/mp3;" << endl;
+ cout<< "Command:0 Msg:comment splay by Woo-jae Jung" << endl;
+ cout<< "Command:0 Msg:comment yaf port by mvogt@rhrk.uni-kl.de"<<endl;
+ cout<< "Command:0 Msg:comment based on sources from eMusic and splay"<<endl;
+ cout<< "Command:0 Msg:comment enter 'help' " << endl;
+
+
+
+ yaf_control(input,output,decoder);
+}
+
+
+void usage() {
+ cout << "yaf-splay is a interactive frontend for the splay decoder"<<endl;
+ cout << "Usage : yaf-splay [-2am] [url]"<<endl;
+ cout << endl;
+ cout << "-2 : playing with half frequency."<<endl;
+ cout << "-m : force to mono."<<endl;
+ cout << "-r : autoupdate musicinfo"<<endl;
+ cout << "-a : no internal audio device"<<endl;
+ cout << "-c : no time calculation"<<endl;
+ cout << "-y : autoplay off"<<endl;
+ cout << "-d : only decode"<<endl;
+ cout << endl;
+ cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
+ << "USE AT YOUR OWN RISK!"<<endl;
+ cout << endl;
+ cout << "for more help type 'help' in interactive mode"<<endl;
+}
+
+
+
+int main(int argc, char** argv) {
+ int c;
+ int lInternalAudio=true;
+
+
+ pow(6.0,3.0); // fixes bug in __math.h
+
+
+
+
+ InputInterface* input=new InputInterface();
+
+ OutputInterface output(&cout);
+
+ YafOutputStream* yafOutput=new YafOutputStream(input);
+
+
+ SplayPlugin* plugin=new SplayPlugin();
+
+ plugin->setOutputPlugin(yafOutput);
+ InputDecoderYAF decoder(plugin,yafOutput);
+
+
+
+ while(1) {
+ c = getopt (argc, argv, "2yamhd");
+ if (c == -1) break;
+ switch(c) {
+ case 'a': {
+ lInternalAudio=false;
+ break;
+ }
+ case 'h': {
+ usage();
+ exit(0);
+ }
+ case '2': {
+ plugin->config("-2","true",NULL);
+ break;
+ }
+ case 'y': {
+ decoder.setAutoPlay(false);
+ break;
+ }
+ case 'm': {
+ plugin->config("-m","true",NULL);
+ break;
+ }
+ case 'r': {
+ plugin->config("runtime","on",NULL);
+ break;
+ }
+ case 'd': {
+ plugin->config("-d","on",NULL);
+ break;
+ }
+ case 'c': {
+ plugin->config("-c","true",NULL);
+ break;
+ }
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ usage();
+ exit(-1);
+ }
+ }
+ if (optind < argc ) {
+ Buffer buffer(300);
+ buffer.append("open ");
+ buffer.append(argv[optind]);
+ buffer.append("\n");
+
+ input->addInputLine(&buffer);
+
+ }
+
+
+
+ yafOutput->internalDevice(lInternalAudio);
+ control_splay(input,&output,&decoder);
+ delete plugin;
+ delete yafOutput;
+ delete input;
+
+}
+
+
diff --git a/mpeglib/example/yaf/yafsplay/stresstest b/mpeglib/example/yaf/yafsplay/stresstest
new file mode 100644
index 00000000..caeba598
--- /dev/null
+++ b/mpeglib/example/yaf/yafsplay/stresstest
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+declare -i zahl=150
+declare -i zahl1=3
+rm -f jumptable
+
+while [ 0 -le $zahl ] ; do
+ echo "j $zahl" >>jumptable
+ echo "sleep 1" >>jumptable
+ echo "j $zahl1" >>jumptable
+ echo "sleep 1" >>jumptable
+
+ zahl=$[zahl-7]
+ zahl1=$[zahl1+7]
+done
+
+echo "quit" >>jumptable
+
+for i in "/mnt/diskD/rh/mp3/neu3"/* ; do
+ echo "open $i" >yaf.script
+ ./yaf-splay <jumptable
+ sleep 5
+done
diff --git a/mpeglib/example/yaf/yaftplay/Makefile.am b/mpeglib/example/yaf/yaftplay/Makefile.am
new file mode 100644
index 00000000..2d82700d
--- /dev/null
+++ b/mpeglib/example/yaf/yaftplay/Makefile.am
@@ -0,0 +1,32 @@
+# tplay-yaf - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+
+bin_PROGRAMS = yaf-tplay
+
+yaf_tplay_SOURCES = tplay_control.cpp
+
+noinst_HEADERS =
+
+yaf_tplay_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+
+yaf_tplay_LDADD = ../yafcore/libyafcore.la \
+ ../yafxplayer/libyafxplayer.la \
+ ../../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yaftplay/tplay_control.cpp b/mpeglib/example/yaf/yaftplay/tplay_control.cpp
new file mode 100644
index 00000000..6203c727
--- /dev/null
+++ b/mpeglib/example/yaf/yaftplay/tplay_control.cpp
@@ -0,0 +1,135 @@
+/*
+ generic interactive controller
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+// Set for local include
+#define DIRECT_INCLUDE
+
+#include "../yafcore/yaf_control.h"
+#include "../yafxplayer/inputDecoderYAF.h"
+
+#include <iostream>
+using namespace std;
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+// we include our plugin here
+#include "../../../lib/decoder/tplayPlugin.h"
+
+
+#if defined(HAVE_GETOPT_H)
+#include <getopt.h>
+#endif
+
+
+void control_tplay(InputInterface* input,OutputInterface* output,
+ InputDecoder* decoder) {
+
+
+ cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
+ cout<< "Command:0 Msg:implements xplayer" << endl;
+ cout<< "Command:0 Msg:decoder tplay Version:0.5.5" << endl;
+ cout<< "Command:0 Msg:mimetypes audio/wav;audio/au;" << endl;
+ cout<< "Command:0 Msg:comment tplay by Ilkka Karvinen" << endl;
+ cout<< "Command:0 Msg:comment yaf port by mvogt@rhrk.uni-kl.de"<<endl;
+ cout<< "Command:0 Msg:comment based on sources from eMusic and tplay"<<endl;
+ cout<< "Command:0 Msg:comment enter 'help' " << endl;
+
+
+
+
+
+ yaf_control(input,output,decoder);
+}
+
+
+void usage() {
+ cout << "yaf-tplay is a interactive frontend for the tplay decoder"<<endl;
+ cout << "Usage : yaf-tplay [-a] [url]"<<endl;
+ cout << endl;
+ cout << "-a : no internal audio device"<<endl;
+ cout << "-y : autoplay off"<<endl;
+ cout << endl;
+ cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
+ << "USE AT YOUR OWN RISK!"<<endl;
+ cout << endl;
+ cout << "for more help type 'help' in interactive mode"<<endl;
+}
+
+
+
+int main(int argc, char** argv) {
+ int c;
+ int lInternalAudio=true;
+
+ pow(6.0,3.0); // fixes bug in __math.h
+ InputInterface input;
+ OutputInterface output(&cout);
+
+
+
+
+
+ YafOutputStream* yafOutput=new YafOutputStream(&input);
+ TplayPlugin* plugin=new TplayPlugin();
+
+ plugin->setOutputPlugin(yafOutput);
+ InputDecoderYAF decoder(plugin,yafOutput);
+
+
+
+ while(1) {
+ c = getopt (argc, argv, "2yamh");
+ if (c == -1) break;
+ switch(c) {
+ case 'a': {
+ lInternalAudio=false;
+ break;
+ }
+ case 'y': {
+ decoder.setAutoPlay(false);
+ break;
+ }
+ case 'h': {
+ usage();
+ exit(0);
+ }
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ usage();
+ exit(-1);
+ }
+ }
+ if (optind < argc ) {
+ Buffer buffer(300);
+ buffer.append("open ");
+ buffer.append(argv[optind]);
+ buffer.append("\n");
+
+ input.addInputLine(&buffer);
+
+ }
+
+ yafOutput->internalDevice(lInternalAudio);
+ control_tplay(&input,&output,&decoder);
+ delete plugin;
+ delete yafOutput;
+
+}
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafvorbis/Makefile.am b/mpeglib/example/yaf/yafvorbis/Makefile.am
new file mode 100644
index 00000000..f0a01965
--- /dev/null
+++ b/mpeglib/example/yaf/yafvorbis/Makefile.am
@@ -0,0 +1,33 @@
+# splay-yaf - Makefile.am
+
+INCLUDES = -I../../include -I../../include/vorbis/include $(all_includes)
+
+EXTRA_DIST =
+
+bin_PROGRAMS = yaf-vorbis
+
+yaf_vorbis_SOURCES = vorbis_control.cpp
+
+noinst_HEADERS =
+
+yaf_vorbis_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+yaf_vorbis_LDADD = \
+ ../yafcore/libyafcore.la \
+ ../yafxplayer/libyafxplayer.la \
+ ../../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafvorbis/vorbis_control.cpp b/mpeglib/example/yaf/yafvorbis/vorbis_control.cpp
new file mode 100644
index 00000000..1e8c2b09
--- /dev/null
+++ b/mpeglib/example/yaf/yafvorbis/vorbis_control.cpp
@@ -0,0 +1,150 @@
+/*
+ generic interactive controller
+ Copyright (C) 2000 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+// Set for local include
+#define DIRECT_INCLUDE
+
+#include "../yafcore/yaf_control.h"
+#include "../yafxplayer/inputDecoderYAF.h"
+
+
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+// for dynamic loading
+#include <dlfcn.h>
+
+#include "../../../lib/decoder/vorbisPlugin.h"
+
+#if defined(HAVE_GETOPT_H)
+#include <getopt.h>
+#endif
+
+using namespace std;
+
+void control_vorbis(InputInterface* input,OutputInterface* output,
+ InputDecoder* decoder) {
+
+
+ cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
+ cout<< "Command:0 Msg:implements xplayer" << endl;
+ cout<< "Command:0 Msg:decoder vorbis Version:20000223" << endl;
+ cout<< "Command:0 Msg:mimetypes audio/ogg;" << endl;
+ cout<< "Command:0 Msg:comment vorbis by Monty http://www.xiph.org/" << endl;
+ cout<< "Command:0 Msg:comment yaf port by mvogt@rhrk.uni-kl.de"<<endl;
+ cout<< "Command:0 Msg:comment based on sources from vorbis"<<endl;
+ cout<< "Command:0 Msg:comment enter 'help' " << endl;
+
+
+
+
+
+ yaf_control(input,output,decoder);
+}
+
+
+void usage() {
+ cout << "yaf-vorbis is a interactive frontend for the vorbis decoder"<<endl;
+ cout << "Usage : yaf-vorbis [url]"<<endl;
+ cout << endl;
+ cout << "-a : no internal audio device"<<endl;
+ cout << "-y : autoplay off"<<endl;
+ cout << endl;
+ cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
+ << "USE AT YOUR OWN RISK!"<<endl;
+ cout << endl;
+ cout << "for more help type 'help' in interactive mode"<<endl;
+}
+
+
+
+int main(int argc, char** argv) {
+ int c;
+ int lInternalAudio=true;
+
+
+ pow(6.0,3.0); // fixes bug in __math.h
+ InputInterface* input=new InputInterface();
+ OutputInterface output(&cout);
+
+ YafOutputStream* yafOutput=new YafOutputStream(input);
+
+
+ VorbisPlugin* plugin=new VorbisPlugin();
+
+ plugin->setOutputPlugin(yafOutput);
+ InputDecoderYAF decoder(plugin,yafOutput);
+
+
+
+ while(1) {
+ c = getopt (argc, argv, "2amhy");
+ if (c == -1) break;
+ switch(c) {
+ case 'a': {
+ lInternalAudio=false;
+ break;
+ }
+ case 'h': {
+ usage();
+ exit(0);
+ }
+ case '2': {
+ plugin->config("-2","true",NULL);
+ break;
+ }
+ case 'y': {
+ decoder.setAutoPlay(false);
+ break;
+ }
+ case 'm': {
+ plugin->config("-m","true",NULL);
+ break;
+ }
+ case 'r': {
+ plugin->config("runtime","on",NULL);
+ break;
+ }
+ case 'c': {
+ plugin->config("-c","true",NULL);
+ break;
+ }
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ usage();
+ exit(-1);
+ }
+ }
+ if (optind < argc ) {
+ Buffer buffer(300);
+ buffer.append("open ");
+ buffer.append(argv[optind]);
+ buffer.append("\n");
+
+ input->addInputLine(&buffer);
+
+ }
+
+
+
+ yafOutput->internalDevice(lInternalAudio);
+ control_vorbis(input,&output,&decoder);
+ delete plugin;
+ delete yafOutput;
+
+}
+
+
diff --git a/mpeglib/example/yaf/yafxplayer/Makefile.am b/mpeglib/example/yaf/yafxplayer/Makefile.am
new file mode 100644
index 00000000..e49e999e
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/Makefile.am
@@ -0,0 +1,37 @@
+# libxplayer - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+AM_CPPFLAGS = -DDIRECT_INCLUDE
+
+EXTRA_DIST = xplayerCommand.defs xplayerRuntime.defs
+
+lib_LTLIBRARIES = libyafxplayer.la
+
+
+noinst_HEADERS = commandTableXPlayer.h runtimeTableXPlayer.h \
+ xplayer_control.h
+
+
+libyafxplayer_la_SOURCES = commandTableXPlayer.cpp \
+ inputDecoderXPlayer.cpp \
+ xplayer_control.cpp \
+ runtimeTableXPlayer.cpp \
+ inputDecoderYAF.cpp yafOutputStream.cpp
+
+
+libyafxplayer_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) \
+ -no-undefined -avoid-version
+
+libyafxplayer_la_LIBADD = ../../../lib/libmpeg.la \
+ ../yafcore/libyafcore.la \
+ $(THIS_LIB_LIBS)
+
+
+
+yafxplayerdir = $(includedir)/$(THIS_LIB_NAME)/util/yaf/yafxplayer
+
+yafxplayer_HEADERS = inputDecoderYAF.h \
+ inputDecoderXPlayer.h \
+ yafOutputStream.h
+
diff --git a/mpeglib/example/yaf/yafxplayer/README b/mpeglib/example/yaf/yafxplayer/README
new file mode 100644
index 00000000..3eb486c4
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/README
@@ -0,0 +1,30 @@
+
+This directory contains a generic player frontend.
+Use this as a start if you add new decoder support
+to yaf.
+
+The first step is to build the generic frontend.
+Uncomment in xplayer_control.c the "main" part
+and link the *.o fails againt yafcore.
+
+g++ -o xplayer *.o ../yafcore.a
+
+
+This should build ./xplayer
+
+
+If you implement a new player ans you have to change all the names,
+the following script is *very* usefull
+
+
+for i in *.cpp; do
+sed s\/XPlayer\/helloName\/g $i >$i.x
+mv $i.x $i
+done
+
+which replaces all occurances of "XPlayer" in all .cpp files
+to "helloName"
+
+(usefull, isn't it)
+
+
diff --git a/mpeglib/example/yaf/yafxplayer/commandTableXPlayer.cpp b/mpeglib/example/yaf/yafxplayer/commandTableXPlayer.cpp
new file mode 100644
index 00000000..31d3a454
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/commandTableXPlayer.cpp
@@ -0,0 +1,35 @@
+/*
+ valid Commands for generic cd player
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+#define _USE_XPLAYER_STRUC
+
+#include "commandTableXPlayer.h"
+
+
+CommandTableXPlayer::CommandTableXPlayer(){
+ init();
+}
+
+CommandTableXPlayer::~CommandTableXPlayer(){
+}
+
+void CommandTableXPlayer::init() {
+
+
+ int i;
+ for (i=0;i<XPLAYERCOMMANDS_SIZE;i++) {
+ insert(&xplayerCommands[i]);
+ }
+
+
+}
+
diff --git a/mpeglib/example/yaf/yafxplayer/commandTableXPlayer.h b/mpeglib/example/yaf/yafxplayer/commandTableXPlayer.h
new file mode 100644
index 00000000..2bc23094
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/commandTableXPlayer.h
@@ -0,0 +1,36 @@
+/*
+ valid Commands for generic cd player
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __COMMAND_TABLEXPLAYER_H
+#define __COMMAND_TABLEXPLAYER_H
+
+#include "../yafcore/commandTable.h"
+#include "xplayerCommand.defs"
+
+
+
+
+
+class CommandTableXPlayer : public CommandTable {
+
+ public:
+ CommandTableXPlayer();
+ ~CommandTableXPlayer();
+ void init();
+
+};
+
+#endif
+
diff --git a/mpeglib/example/yaf/yafxplayer/inputDecoderXPlayer.cpp b/mpeglib/example/yaf/yafxplayer/inputDecoderXPlayer.cpp
new file mode 100644
index 00000000..4b3bf3b3
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/inputDecoderXPlayer.cpp
@@ -0,0 +1,239 @@
+/*
+ generic Implementation of a cd-player
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#include "inputDecoderXPlayer.h"
+#include "commandTableXPlayer.h"
+#include <iostream>
+using namespace std;
+
+#define DEBUG cout << "Command:1 Msg:"
+
+
+InputDecoderXPlayer::InputDecoderXPlayer(YafOutputStream* yafOutput) :
+ InputDecoder() {
+
+ output=new OutputInterface(&cout);
+ output->setProtocolSyntax(true);
+ this->yafOutput=yafOutput;
+ ct=new CommandTableXPlayer();
+
+ setDecoderStatus(_DECODER_STATUS_IDLE);
+ appendCommandTable(ct);
+ majorMode=_PLAYER_MAJOR_MODE_OFF;
+ setRuntimeInfo(false);
+ // As default we expect a user which does not want to know
+ // about the player status.
+ // This is *not* true if the user is a controlling GUI.
+ // A GUI should alwas send :
+ // "MajorModeInfo on"
+ setMajorModeInfo(true); // as default we don't inform about the state!
+ isOn=false;
+}
+
+InputDecoderXPlayer::~InputDecoderXPlayer(){
+ delete ct;
+ delete output;
+}
+
+void InputDecoderXPlayer::setMajorModeInfo(int lDisplayMajorMode) {
+ this->lDisplayMajorMode=lDisplayMajorMode;
+}
+
+int InputDecoderXPlayer::getMajorModeInfo() {
+ return lDisplayMajorMode;
+}
+
+
+
+int InputDecoderXPlayer::getOn() {
+ return isOn;
+}
+
+
+void InputDecoderXPlayer::setOn(int lOn) {
+ isOn=lOn;
+}
+
+
+
+
+
+void InputDecoderXPlayer::setMajorMode(int mode) {
+ const char* ptr;
+ majorMode=mode;
+
+ if (lDisplayMajorMode==false) {
+ cout << "lDisplayMajorMode false"<<endl;
+ return;
+ }
+ output->lock();
+ output->clearBuffer();
+ output->appendBuffer("Command:0 Msg:player-status ");
+ if (majorMode == _PLAYER_MAJOR_MODE_OFF) {
+ ptr="off";
+ } else if (majorMode == _PLAYER_MAJOR_MODE_ON) {
+ ptr="on";
+ } else if (majorMode == _PLAYER_MAJOR_MODE_OPEN_TRACK) {
+ ptr="open";
+ } else if (majorMode == _PLAYER_MAJOR_MODE_CLOSE_TRACK) {
+ ptr="close";
+ } else if (majorMode == _PLAYER_MAJOR_MODE_PLAYING) {
+ ptr="playing";
+ } else if (majorMode == _PLAYER_MAJOR_MODE_PAUSE) {
+ ptr="pause";
+ } else {
+ ptr="unknown";
+ }
+ output->appendBuffer(ptr);
+ if (majorMode == _PLAYER_MAJOR_MODE_OFF) {
+ char val[40];
+ long bytes=yafOutput->getBytesCounter();
+ long allWrite=yafOutput->getAllWriteCounter();
+
+ snprintf(val,40,"%ld %ld",bytes,allWrite);
+ output->appendBuffer(" ");
+ output->appendBuffer(val);
+ }
+ output->flushBuffer();
+ output->unlock();
+}
+
+
+
+int InputDecoderXPlayer::getMajorMode() {
+ return majorMode;
+}
+
+
+
+void InputDecoderXPlayer::doSomething(){
+ DEBUG << "Decoder did something" << endl;
+ // after decoding is ready we close the file
+
+ InputDecoder::doSomething();
+}
+
+
+
+const char* InputDecoderXPlayer::processCommand(int command,const char* args){
+
+ if (command == _PLAYER_OFF) {
+ if (isOn == true) {
+ isOn=false;
+ processCommand(_PLAYER_PAUSE,"");
+ processCommand(_PLAYER_CLOSE,"");
+
+ setMajorMode(_PLAYER_MAJOR_MODE_OFF);
+ yafOutput->setBytesCounter(0);
+ }
+ return"";
+ }
+
+ if (command == _PLAYER_ON) {
+ if (isOn == false) {
+ setMajorMode(_PLAYER_MAJOR_MODE_ON);
+ isOn=true;
+ }
+ return"";
+ }
+
+
+ if (command == _PLAYER_OPEN) {
+ setMajorMode(_PLAYER_MAJOR_MODE_OPEN_TRACK);
+ return"";
+ }
+
+ if (command == _PLAYER_CLOSE) {
+ setMajorMode(_PLAYER_MAJOR_MODE_CLOSE_TRACK);
+ return"";
+ }
+
+ if (command == _PLAYER_PLAY) {
+ setDecoderStatus(_DECODER_STATUS_WORKING);
+ setMajorMode(_PLAYER_MAJOR_MODE_PLAYING);
+ return"";
+ }
+
+ if (command == _PLAYER_PAUSE) {
+ setMajorMode(_PLAYER_MAJOR_MODE_PAUSE);
+ return"";
+ }
+
+ if (command == _PLAYER_VERBOSE) {
+ if (strcmp(args,"off")==0) {
+ setMajorModeInfo(false);
+ } else {
+ setMajorModeInfo(true);
+ }
+ return"";
+ }
+
+ if (command == _PLAYER_OUTPUTFILE) {
+ int ret;
+ if (yafOutput->isOpenStream() == true) {
+ return "already output file selected";
+ }
+ yafOutput->setStreamFile(args);
+ // now we have set the fifo. But we must say the parent
+ // process that we start with waiting
+
+ cout << "Command:0 Msg:fileopen before"<<endl;
+ ret=yafOutput->openStream();
+ cout << "Command:0 Msg:fileopen after"<<endl;
+
+ if (ret < 0) {
+ return "cannot open outfile";
+ }
+ return "";
+ }
+ if (command == _PLAYER_CLOSEOUTPUTFILE) {
+ if (yafOutput->isOpenStream() == false) {
+ return "no output file selected";
+ }
+ yafOutput->closeStream();
+ return "";
+ }
+
+ if (command == _PLAYER_INTERNALAUDIO) {
+ if (strcmp("on",args)==0) {
+ yafOutput->internalDevice(true);
+ return "";
+ }
+ yafOutput->internalDevice(false);
+ return "";
+ }
+
+ if (command == _PLAYER_SLEEP) {
+ int nSec;
+ sscanf(args,"%d",&nSec); // convert string to int
+ sleep(nSec);
+ return "";
+ }
+ if (command == _PLAYER_CLEAR) {
+ yafOutput->setBytesCounter(0);
+ return "";
+ }
+
+ return InputDecoder::processCommand(command,args);
+}
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafxplayer/inputDecoderXPlayer.h b/mpeglib/example/yaf/yafxplayer/inputDecoderXPlayer.h
new file mode 100644
index 00000000..e6602b52
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/inputDecoderXPlayer.h
@@ -0,0 +1,117 @@
+/*
+ generic Implementation of a cd-player
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __INPUTDECODERXPLAYER_H
+#define __INPUTDECODERXPLAYER_H
+
+
+#include "../yafcore/inputDecoder.h"
+#include "yafOutputStream.h"
+
+
+
+/**
+ major modes . it should be not necessary to define
+ new modes.
+ What are "major modes"?
+ <p>
+ The idea of the major modes, is that this is a very
+ general description of an abstract cd player.
+ When the decoder works yaf send these
+ major modes to the frontend.
+ <p>
+ These Major modes describes the basic commands which
+ every yaf-decoder implementation should support:
+ <pre>
+ on/off
+ open/close
+ pause/play
+ </pre>
+ Thus it is possible that a frontend works with
+ a decoder even if the frontend does not fully support all
+ the commands (e.g: switch to mono etc...)
+
+ <pre>
+ If you think you have a new "mode" its almost a "feature"
+ eg: You have a command "jump" but this is not a "mode"
+ because you can press "jump" on your cd player even
+ if the cd player is off OR on OR playing OR paused
+ In all these cases the command does not affect the
+ state of your cd-player. Or do you have a player
+ which switches itself on if you press e.g. "Track 1" ?
+ </pre>
+*/
+
+#define _PLAYER_MAJOR_MODE_OFF 1
+#define _PLAYER_MAJOR_MODE_ON 2
+#define _PLAYER_MAJOR_MODE_OPEN_TRACK 3
+#define _PLAYER_MAJOR_MODE_CLOSE_TRACK 4
+#define _PLAYER_MAJOR_MODE_PLAYING 5
+#define _PLAYER_MAJOR_MODE_PAUSE 6
+
+
+/*
+ off: the cd player is switched off (/dev/dsp is unlocked)
+
+
+ on : (you may play the inserte cd) (/dev/dsp is locked)
+
+ playing: cd player plays something (player is switched on)
+ pause: does not play "
+
+ open track : think of it that you "select a track" you
+ can only open a track if the player is "ON"
+
+ close track: eject the cd from player.
+ (This does not necessarily mean that /dev/dsp is unlocked)
+*/
+
+
+class CommandTableXPlayer;
+
+class InputDecoderXPlayer : public InputDecoder {
+
+
+ public:
+ InputDecoderXPlayer(YafOutputStream* yafOutput);
+ ~InputDecoderXPlayer();
+
+ const char* processCommand(int command,const char* args);
+ void doSomething();
+
+ void setMajorMode(int mode);
+ int getMajorMode();
+
+ void setMajorModeInfo(int lDisplayMajorMode);
+ int getMajorModeInfo();
+
+ int getOn();
+ void setOn(int lOn);
+
+ private:
+
+ int majorMode;
+ CommandTableXPlayer* ct;
+ int lDisplayMajorMode;
+ OutputInterface* output;
+ YafOutputStream* yafOutput;
+
+ int isOn;
+};
+
+
+#endif
+
+
diff --git a/mpeglib/example/yaf/yafxplayer/inputDecoderYAF.cpp b/mpeglib/example/yaf/yafxplayer/inputDecoderYAF.cpp
new file mode 100644
index 00000000..b4b6a317
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/inputDecoderYAF.cpp
@@ -0,0 +1,220 @@
+/*
+ base Implementation of a yaf decoder
+ Copyright (C) 1999 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#define DEBUG cout << "Command:1 Msg:"
+
+#include "inputDecoderYAF.h"
+#include "xplayerCommand.defs"
+#include "../yafcore/yafCommand.defs"
+#include <iostream>
+
+using namespace std;
+
+InputDecoderYAF::InputDecoderYAF(DecoderPlugin* plugin,
+ YafOutputStream* output)
+ : InputDecoderXPlayer(output) {
+
+ this->plugin=plugin;
+ this->output=output;
+ input=NULL;
+
+ lAutoPlay=true;
+ lFileSelected=false;
+ songPath=new Buffer(256);
+}
+
+
+InputDecoderYAF::~InputDecoderYAF(){
+ delete songPath;
+}
+
+
+/**
+ This method is entered by the global loop. (xplayer_control.c)
+ This method should never (!) block or it
+ is unpossible to read commands on stdin!
+
+
+ Note: YAF is not a threaded player this is why we need
+ this doSomething method. Other player may already be threaded and
+ offer a "control"/"working" channel.
+ These players won't need this loop.
+
+*/
+
+
+void InputDecoderYAF::doSomething(){
+
+}
+
+
+const char* InputDecoderYAF::processCommand(int command,const char* args){
+
+ if (command == _PLAYER_UPDATE) {
+ int state=plugin->getStreamState();
+ if (state == _STREAM_STATE_EOF) {
+ if (getMajorMode() != _PLAYER_MAJOR_MODE_OFF) {
+ return processCommand(_PLAYER_OFF,"");
+ }
+ }
+ return "";
+ }
+
+
+ if (command == _PLAYER_OPEN) {
+ if (strlen(args) == 0) {
+ return "no file";
+ }
+ if (lFileSelected == true) {
+ processCommand(_PLAYER_CLOSE,"");
+ }
+
+ if (getOn() == true) {
+ processCommand(_PLAYER_OFF,"");
+ }
+
+ if (getOn() == false) {
+ processCommand(_PLAYER_ON,"");
+ }
+ output->setBytesCounter(0);
+
+ input=InputPlugin::createInputStream(args,_INPUT_THREADSAFE);
+ if (input == NULL) {
+ cout << "createInputStream failed"<<endl;
+ return processCommand(_PLAYER_OFF,"");
+ }
+ lFileSelected=true;
+ setMajorMode(_PLAYER_MAJOR_MODE_OPEN_TRACK);
+ input->open(args);
+ if (plugin->setInputPlugin(input) == false) {
+ return processCommand(_PLAYER_OFF,"");
+ }
+ songPath->clear();
+ songPath->append(args);
+ if (lAutoPlay) {
+ return processCommand(_PLAYER_PLAY,"");
+ }
+ return "";
+ }
+
+ if (command == _PLAYER_CLOSE) {
+ if (lFileSelected) {
+ processCommand(_PLAYER_PAUSE,"");
+ plugin->close();
+
+ delete input;
+ input=NULL;
+ setMajorMode(_PLAYER_MAJOR_MODE_CLOSE_TRACK);
+ lFileSelected=false;
+ }
+ return "";
+ }
+
+
+ if (command == _PLAYER_PLAY) {
+ if (lFileSelected) {
+ setMajorMode(_PLAYER_MAJOR_MODE_PLAYING);
+ plugin->play();
+ return "";
+ }
+ return "no file";
+ }
+
+ if (command == _PLAYER_PAUSE) {
+ int mode=getMajorMode();
+ if (mode == _PLAYER_MAJOR_MODE_PLAYING) {
+ plugin->pause();
+ setMajorMode(_PLAYER_MAJOR_MODE_PAUSE);
+ }
+
+ return "";
+ }
+
+ if (command == _YAF_I_PLAYTIME) {
+ int current=plugin->getTime(true);
+ int total=plugin->getTime(false);
+
+ cout << "Command:0 Msg:playtime current:"<<current<<" total:"<<total<<endl;
+ return "";
+ }
+
+ // another YAF part:
+ if (command == _PLAYER_JUMP) {
+ if (lFileSelected) {
+ int nSec=0;
+ int mode=getMajorMode();
+ processCommand(_PLAYER_PAUSE,"");
+ sscanf(args,"%d",&nSec); // convert string to int
+ /* if the value is signed, do a relative jump */
+ if(index(args, '-') || index(args, '+')) {
+ nSec += plugin->getTime(true);
+ }
+ // nPos is the time in seconds!!!!
+ plugin->seek(nSec);
+ output->setBytesCounter(0);
+
+ if (mode == _PLAYER_MAJOR_MODE_PLAYING) {
+ processCommand(_PLAYER_PLAY,"");
+ }
+ return "";
+ }
+ return "no file";
+ }
+
+
+ if (command == _YAF_I_RUNTIME) {
+ if (strcmp("off",args)==0) {
+ plugin->config("runtime","off",NULL);
+ } else {
+ plugin->config("runtime","on",NULL);
+ }
+ }
+ if (command == _PLAYER_MUSICINFO) {
+ PluginInfo* plugInfo=plugin->getPluginInfo();
+ output->writeInfo(plugInfo);
+ return "";
+ }
+
+ if (command == _YAF_I_SELECT_A_LAYER) {
+ plugin->config("AudioLayer",args,NULL);
+ return "";
+ }
+ if (command == _YAF_I_SELECT_V_LAYER) {
+ plugin->config("VideoLayer",args,NULL);
+ return "";
+ }
+
+ if (command == _YAF_I_WRITE) {
+ if (strcmp(args,"on")==0) {
+ plugin->config("-w","true",NULL);
+ } else {
+ plugin->config("-w","false",NULL);
+ }
+ return "";
+ }
+
+
+ return (InputDecoderXPlayer::processCommand(command,args));
+}
+
+
+
+
+int InputDecoderYAF::getAutoPlay() {
+ return lAutoPlay;
+}
+
+void InputDecoderYAF::setAutoPlay(int lAutoPlay) {
+ this->lAutoPlay=lAutoPlay;
+}
diff --git a/mpeglib/example/yaf/yafxplayer/inputDecoderYAF.h b/mpeglib/example/yaf/yafxplayer/inputDecoderYAF.h
new file mode 100644
index 00000000..2002dc58
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/inputDecoderYAF.h
@@ -0,0 +1,51 @@
+/*
+ base Implementation of a yaf decoder
+ Copyright (C) 1999 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __INPUTDECODERYAF_H
+#define __INPUTDECODERYAF_H
+
+#include <pthread.h>
+
+#include "inputDecoderXPlayer.h"
+#include "yafOutputStream.h"
+#include <kdemacros.h>
+
+
+class KDE_EXPORT InputDecoderYAF : public InputDecoderXPlayer {
+
+ DecoderPlugin* plugin;
+ YafOutputStream* output;
+ InputStream* input;
+ int lAutoPlay;
+
+ public:
+ InputDecoderYAF(DecoderPlugin* plugin,YafOutputStream* output);
+ ~InputDecoderYAF();
+
+ const char* processCommand(int command,const char* args);
+ void doSomething();
+
+ int getAutoPlay();
+ void setAutoPlay(int lAutoPlay);
+
+ private:
+
+ int lFileSelected;
+ Buffer* songPath;
+};
+
+
+#endif
+
diff --git a/mpeglib/example/yaf/yafxplayer/runtimeTableXPlayer.cpp b/mpeglib/example/yaf/yafxplayer/runtimeTableXPlayer.cpp
new file mode 100644
index 00000000..792d0d45
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/runtimeTableXPlayer.cpp
@@ -0,0 +1,37 @@
+/*
+ valid runtime commands for generic player
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+#define _USE_RUNTIME_XPLAYER_STRUC
+
+#include "runtimeTableXPlayer.h"
+
+
+RuntimeTableXPlayer::RuntimeTableXPlayer(){
+ init();
+}
+
+RuntimeTableXPlayer::~RuntimeTableXPlayer(){
+}
+
+void RuntimeTableXPlayer::init() {
+
+
+ int i;
+ for (i=0;i<XPLAYERRUNTIME_SIZE;i++) {
+ insert(&xplayerRuntime[i]);
+ }
+
+
+}
+
+
diff --git a/mpeglib/example/yaf/yafxplayer/runtimeTableXPlayer.h b/mpeglib/example/yaf/yafxplayer/runtimeTableXPlayer.h
new file mode 100644
index 00000000..8f3ad2d0
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/runtimeTableXPlayer.h
@@ -0,0 +1,40 @@
+/*
+ valid runtime commands for generic player
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+
+#ifndef __RUNTIME_TABLEXPLAYER_H
+#define __RUNTIME_TABLEXPLAYER_H
+
+#include "../yafcore/commandTable.h"
+#include "xplayerRuntime.defs"
+
+
+
+
+
+class RuntimeTableXPlayer : public CommandTable {
+
+ public:
+ RuntimeTableXPlayer();
+ ~RuntimeTableXPlayer();
+ void init();
+
+};
+
+#endif
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafxplayer/xplayerCommand.defs b/mpeglib/example/yaf/yafxplayer/xplayerCommand.defs
new file mode 100644
index 00000000..853eb2eb
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/xplayerCommand.defs
@@ -0,0 +1,84 @@
+/*
+ definition file for generic decoder commands
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+#ifndef __XPLAYER_COMMAND_DEFS
+#define __XPLAYER_COMMAND_DEFS
+
+#include "../yafcore/commandTable.h" // defines CommandDesc-Struct...
+
+// Command Numbers
+
+#define _PLAYER_ON _CT_START+1
+#define _PLAYER_OFF _CT_START+2
+#define _PLAYER_OPEN _CT_START+3
+#define _PLAYER_CLOSE _CT_START+4
+
+#define _PLAYER_PLAY _CT_START+5
+#define _PLAYER_PAUSE _CT_START+6
+#define _PLAYER_VERBOSE _CT_START+7
+#define _PLAYER_JUMP _CT_START+8
+
+
+#define _PLAYER_OUTPUTFILE _CT_START+9
+#define _PLAYER_CLOSEOUTPUTFILE _CT_START+10
+#define _PLAYER_INTERNALAUDIO _CT_START+11
+#define _PLAYER_SLEEP _CT_START+12
+#define _PLAYER_UPDATE _CT_START+13
+#define _PLAYER_CLEAR _CT_START+14
+#define _PLAYER_MUSICINFO _CT_START+15
+
+
+#define _XPLAYER_START _CT_START+100
+
+
+// The commands as String. The Syntax is :
+//
+
+// { lexternalUse,lReturnMsg,longName,shortName,number,helpText }
+//
+// lexternal use ist true when the text should be written when
+// user enters "help"
+
+#ifdef _USE_XPLAYER_STRUC
+static struct CommandDescriptionStruct xplayerCommands[]={
+
+ { 1,1,"on","",_PLAYER_ON,"turn decoder ON"},
+ { 1,1,"off","",_PLAYER_OFF,"turn it OFF"},
+ { 1,1,"open","o",_PLAYER_OPEN,"open <filename>"},
+ { 1,1,"close","c",_PLAYER_CLOSE,"closes current file "},
+ { 1,1,"play" ,"p",_PLAYER_PLAY,"plays the mpeg file" },
+ { 1,1,"verbose" ,"v",_PLAYER_VERBOSE,"verbose [on|off] info about player" },
+ { 1,1,"jump" ,"j",_PLAYER_JUMP,"jump [+|-]<second>" },
+ { 1,1,"pause" ,"a",_PLAYER_PAUSE,"pauses playing mpeg file"},
+ { 1,1,"update" ,"",_PLAYER_UPDATE,"checks state of plugin"},
+ { 1,1,"clear" ,"",_PLAYER_CLEAR,"usefull loopback for frontends"},
+ { 1,1,"musicinfo" ,"",_PLAYER_MUSICINFO,"print useful info about stream"},
+ { 1,1,"outputfile" ,"",_PLAYER_OUTPUTFILE,"outputfile foo.txt" },
+ { 1,1,"closeoutputfile" ,"",_PLAYER_CLOSEOUTPUTFILE,
+ "closes the outputfile " },
+ { 1,1,"sleep" ,"",_PLAYER_SLEEP,"sleep for x seconds"},
+ {1,1,"audio" ,"",_PLAYER_INTERNALAUDIO,
+ "audio [on|off] for internal audiodevice" }
+
+};
+#endif
+
+
+// How much Commands are in the Array :
+#define XPLAYERCOMMANDS_SIZE 15
+
+
+
+#endif
+
+
diff --git a/mpeglib/example/yaf/yafxplayer/xplayerRuntime.defs b/mpeglib/example/yaf/yafxplayer/xplayerRuntime.defs
new file mode 100644
index 00000000..34402881
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/xplayerRuntime.defs
@@ -0,0 +1,123 @@
+/*
+ Runtime definitions from generic player
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+#ifndef __XPLAYER_RUNTIME_DEFS
+#define __XPLAYER_RUNTIME_DEFS
+
+#include "../yafcore/commandTable.h" // defines CommandDesc-Struct...
+#include "../yafcore/yafRuntime.defs"
+
+// Command Numbers
+
+#define _PLAYER_RUN_PLAYER_STATUS _YAF_RUN_START+1
+
+#define _PLAYER_RUN_STREAMINFO_START _YAF_RUN_START+2
+#define _PLAYER_RUN_STREAMINFO_CHANNELS _YAF_RUN_START+3
+#define _PLAYER_RUN_STREAMINFO_SAMPLESIZE _YAF_RUN_START+4
+#define _PLAYER_RUN_STREAMINFO_SPEED _YAF_RUN_START+5
+#define _PLAYER_RUN_STREAMINFO_END _YAF_RUN_START+6
+
+#define _PLAYER_RUN_FILEOPEN _YAF_RUN_START+7
+
+#define _PLAYER_RUN_MUSICINFO_START _YAF_RUN_START+8
+#define _PLAYER_RUN_MUSICINFO_SONG_FILENAME _YAF_RUN_START+10
+#define _PLAYER_RUN_MUSICINFO_SONG_NAME _YAF_RUN_START+11
+#define _PLAYER_RUN_MUSICINFO_SONG_LEN _YAF_RUN_START+12
+#define _PLAYER_RUN_MUSICINFO_SONG_JUMPS _YAF_RUN_START+13
+#define _PLAYER_RUN_MUSICINFO_END _YAF_RUN_START+14
+#define _PLAYER_RUN_ID3_INFO_START _YAF_RUN_START+15
+#define _PLAYER_RUN_ID3_NAME _YAF_RUN_START+16
+#define _PLAYER_RUN_ID3_ARTIST _YAF_RUN_START+17
+#define _PLAYER_RUN_ID3_ALBUM _YAF_RUN_START+18
+#define _PLAYER_RUN_ID3_YEAR _YAF_RUN_START+19
+#define _PLAYER_RUN_ID3_COMMENT _YAF_RUN_START+20
+#define _PLAYER_RUN_ID3_GENRE _YAF_RUN_START+21
+#define _PLAYER_RUN_ID3_INFO_END _YAF_RUN_START+22
+#define _PLAYER_RUN_MP3_INFO_START _YAF_RUN_START+23
+#define _PLAYER_RUN_MP3_BPS _YAF_RUN_START+24
+#define _PLAYER_RUN_MP3_INFO_END _YAF_RUN_START+25
+
+
+
+
+
+#define _XPLAYER_RUN_START _YAF_RUN_START+100
+
+
+typedef struct {
+ int channels; //2 = stereo 1=mono
+ int nStreamPos; // Position in Stream on which this Info becomes "true"
+} ChannelInfo;
+
+
+typedef struct {
+ int samplesize; // 16 for 16 Bit
+ int nStreamPos; // Position in Stream on which this Info becomes "true"
+} SampleSizeInfo;
+
+
+typedef struct {
+ int channels; //2 = stereo 1=mono
+ int nStreamPos; // Position in Stream on which this Info becomes "true"
+} SpeedInfo;
+
+
+
+
+// The commands as String. The Syntax is :
+//
+// { lexternalUse,lReturnMsg,longName,shortName,number,helpText }
+//
+// lexternal use ist true when the text should be written when
+// user enters "help"
+#ifdef _USE_RUNTIME_XPLAYER_STRUC
+static struct CommandDescriptionStruct xplayerRuntime[]={
+
+ { 0,1,"player-status","",_PLAYER_RUN_PLAYER_STATUS,"state of cdplayer"},
+ { 0,1,"streamInfo-Start","",_PLAYER_RUN_STREAMINFO_START,"StreamInfo start"},
+ { 0,1,"streamInfo-Channels","",_PLAYER_RUN_STREAMINFO_CHANNELS,
+ "ChannelInfo"},
+ { 0,1,"streamInfo-SampleSize","",_PLAYER_RUN_STREAMINFO_SAMPLESIZE,
+ "SampleSizeInfo"},
+ { 0,1,"streamInfo-Speed","",_PLAYER_RUN_STREAMINFO_SPEED,"SpeedInfo"},
+ { 0,1,"streamInfo-End","",_PLAYER_RUN_STREAMINFO_END,"StreamInfo end"},
+ { 0,1,"musicinfo-Start","",_PLAYER_RUN_MUSICINFO_START,"begin block"},
+ { 0,1,"song_filename","",_PLAYER_RUN_MUSICINFO_SONG_FILENAME,
+ "filename to the song"},
+ { 0,1,"song_name","",_PLAYER_RUN_MUSICINFO_SONG_NAME,"name of the song"},
+ { 0,1,"song_len","",_PLAYER_RUN_MUSICINFO_SONG_LEN,"length in secs"},
+ { 0,1,"song_jumps","",_PLAYER_RUN_MUSICINFO_SONG_JUMPS,"jump entities in song"},
+ { 0,1,"musicinfo-End","",_PLAYER_RUN_MUSICINFO_END,"end block"},
+ { 0,1,"id3Info-Start","",_PLAYER_RUN_ID3_INFO_START,"ID3Info start"},
+ { 0,1,"id3Name","",_PLAYER_RUN_ID3_NAME,"ID3 Name"},
+ { 0,1,"id3Artist","",_PLAYER_RUN_ID3_ARTIST,"ID3 Artist"},
+ { 0,1,"id3Album","",_PLAYER_RUN_ID3_ALBUM,"ID3 Album"},
+ { 0,1,"id3Year","",_PLAYER_RUN_ID3_YEAR,"ID3 Year"},
+ { 0,1,"id3Comment","",_PLAYER_RUN_ID3_COMMENT,"ID3 Comment"},
+ { 0,1,"id3Genre","",_PLAYER_RUN_ID3_GENRE,"ID3 Genre"},
+ { 0,1,"id3Info-End","",_PLAYER_RUN_ID3_INFO_END,"ID3Info start"},
+ { 0,1,"mp3Info-Start","",_PLAYER_RUN_MP3_INFO_START,"MP3Info start"},
+ { 0,1,"mp3BitsPerSec","",_PLAYER_RUN_MP3_BPS,"Samplebits per second"},
+ { 0,1,"mp3Info-End","",_PLAYER_RUN_MP3_INFO_END,"MP3Info end"},
+ { 0,1,"fileopen", "",_PLAYER_RUN_FILEOPEN,
+ "sended before yaf tries to open outputfile"}
+
+};
+#endif
+
+// How much Commands are in the Array :
+#define XPLAYERRUNTIME_SIZE 24
+
+
+
+#endif
diff --git a/mpeglib/example/yaf/yafxplayer/xplayer_control.cpp b/mpeglib/example/yaf/yafxplayer/xplayer_control.cpp
new file mode 100644
index 00000000..c09b2cbd
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/xplayer_control.cpp
@@ -0,0 +1,44 @@
+/*
+ generic interactive controller
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#include "xplayer_control.h"
+#include <iostream>
+
+using namespace std;
+
+
+extern "C" void control_xplayer() {
+ InputInterface input;
+ OutputInterface output(&cout);
+ YafOutputStream yafOutput(&input);
+ InputDecoderXPlayer decoder(&yafOutput);
+
+
+ cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
+ cout<< "Command:0 Msg:decoder generic player demo Version:0.1" << endl;
+ cout<< "Command:0 Msg:comment enter 'help' for list of commands" << endl;
+
+
+ yaf_control(&input,&output,&decoder);
+}
+
+
+/*
+
+int main() {
+ control_xplayer();
+}
+
+
+*/
diff --git a/mpeglib/example/yaf/yafxplayer/xplayer_control.h b/mpeglib/example/yaf/yafxplayer/xplayer_control.h
new file mode 100644
index 00000000..771e8ee4
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/xplayer_control.h
@@ -0,0 +1,25 @@
+
+
+#ifndef __XPLAYER_CONTROL_H
+#define __XPLAYER_CONTROL_H
+
+
+
+#include "../yafcore/inputInterface.h"
+#include "../yafcore/outputInterface.h"
+#include "inputDecoderXPlayer.h"
+#include "../yafcore/parser.h"
+
+#include "../yafcore/yaf_control.h"
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+
+
+// prototypes
+
+
+#endif
diff --git a/mpeglib/example/yaf/yafxplayer/yafOutputStream.cpp b/mpeglib/example/yaf/yafxplayer/yafOutputStream.cpp
new file mode 100644
index 00000000..95e61d05
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/yafOutputStream.cpp
@@ -0,0 +1,307 @@
+/*
+ concret OutputClass for yaf text consol player
+ Copyright (C) 1999 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+#include "yafOutputStream.h"
+#include <iostream>
+
+using namespace std;
+
+#define _AUDIO_DELAY_STAMPS 200
+
+
+
+
+YafOutputStream::YafOutputStream(InputInterface* input) {
+ lInternalDevice=false;
+ bytes=0;
+ allWrite=0;
+ writeToBuffer=0;
+ lOpen=false;
+ directOutput=OutPlugin::createOutputStream(_OUTPUT_LOCAL,_OUTPUT_THREADSAFE);
+
+
+ this->input=input;
+ ::pipe(fd);
+
+ if (errno < 0) {
+ perror("YafOutputStream pipe");
+ exit(0);
+ }
+ input->addFileDescriptor(fd[0]);
+}
+
+
+YafOutputStream::~YafOutputStream() {
+ delete directOutput;
+}
+
+
+int YafOutputStream::audioSetup(int frequency,int stereo,
+ int sign,int big,int bits) {
+
+ cout << "Command:0 Msg:streamInfo-Start"<<endl;
+ cout << "Command:0 Msg:streamInfo-Channels "<<stereo+1<<endl;
+
+ cout << "Command:0 Msg:streamInfo-SampleSize "<<bits<<endl;
+ cout << "Command:0 Msg:streamInfo-Speed "<<frequency<<endl;
+ cout << "Command:0 Msg:streamInfo-End"<<endl;
+
+ directOutput->audioSetup(frequency,stereo,sign,big,bits);
+
+ return true;
+}
+
+void YafOutputStream::audioOpen() {
+ if (lInternalDevice) {
+ directOutput->audioOpen();
+ }
+}
+
+void YafOutputStream::audioClose(void) {
+ if (lInternalDevice) {
+ // never close internal audio, because
+ // its not possible to open it again fast enough
+ //directOutput->audioClose();
+ } else {
+ directOutput->audioClose();
+ }
+}
+
+
+int YafOutputStream::audioPlay(TimeStamp* startStamp,
+ TimeStamp* endStamp,char *buffer, int size) {
+
+ int ret=0;
+ if (lInternalDevice) {
+ directOutput->audioPlay(startStamp,endStamp,buffer,size);
+ }
+
+
+
+ if (lOpen) {
+ // if we are doing video, we even have to sync
+ // audio writing.
+ // Because yaf sends the audio data to another process
+ // but the video data _not_ the audio data is directly
+ // flushed here, but maybe stay on the other side
+ // in a very big buffer
+ // until the protocol has no better handle
+ // for this, we must make sure to
+ // dont get the buffer on the other
+ // side too big.
+ // we sleep some time until we write the next sample
+
+
+
+
+ directOutput->audioPlay(startStamp,endStamp,buffer,size);
+
+
+ ret=::send(sd,buffer,size,0);
+
+
+
+
+
+
+ if (ret < 0) {
+
+ closeStream();
+ cout << "fifo error in streamWriter";
+ perror("writeStream");
+ exit(-1);
+ return ret;
+ }
+
+ bytes=bytes+size;
+ allWrite+=size;
+ return size;
+ }
+
+
+
+
+ bytes=bytes+size;
+ allWrite+=size;
+ return size;
+}
+
+
+void YafOutputStream::audioFlush() {
+ // notify command line, that plugin state changed
+ input->write(fd[1],"update\n");
+
+ if (lInternalDevice) {
+ directOutput->audioFlush();
+ }
+}
+
+int YafOutputStream::getPreferredDeliverSize() {
+ return directOutput->getPreferredDeliverSize();
+}
+
+
+
+
+int YafOutputStream::openWindow(int width, int height,const char *title) {
+ return directOutput->openWindow(width,height,title);
+}
+
+
+void YafOutputStream::closeWindow() {
+ directOutput->closeWindow();
+}
+
+void YafOutputStream::flushWindow() {
+ directOutput->flushWindow();
+}
+
+PictureArray* YafOutputStream::lockPictureArray() {
+ return directOutput->lockPictureArray();
+}
+
+
+void YafOutputStream::unlockPictureArray(PictureArray* pictureArray) {
+ directOutput->unlockPictureArray(pictureArray);
+}
+
+
+int YafOutputStream::getFrameusec() {
+ return directOutput->getFrameusec();
+}
+
+
+
+int YafOutputStream::getOutputInit() {
+ return directOutput->getOutputInit();
+}
+
+
+void YafOutputStream::setOutputInit(int lInit) {
+ directOutput->setOutputInit(lInit);
+}
+
+
+
+
+void YafOutputStream::writeInfo(PluginInfo* pluginInfo) {
+ char* url=pluginInfo->getUrl();
+ const char* nameStart=strrchr(url,'/');
+
+ if (nameStart==NULL) {
+ nameStart="noname";
+ } else {
+ nameStart++;
+ if (strlen(nameStart) == 0) {
+ nameStart="noname";
+ }
+ }
+
+ cout << "Command:0 Msg:musicinfo-Start"<<endl;
+ cout << "Command:0 Msg:song_filename "<<pluginInfo->getUrl()<<endl;
+ cout << "Command:0 Msg:song_name "<<nameStart<<endl;
+ cout << "Command:0 Msg:song_len "<<pluginInfo->getLength()<<endl;
+ cout << "Command:0 Msg:song_jumps 0"<<endl;
+ cout << "Command:0 Msg:musicinfo-End"<<endl;
+}
+
+
+
+
+
+
+void YafOutputStream::setBytesCounter(long value) {
+ bytes=value;
+ writeToBuffer=value;
+}
+
+
+
+int YafOutputStream::isOpenStream() {
+ return lOpen;
+}
+
+
+void YafOutputStream::setStreamFile(const char* filename) {
+ if (lOpen == true) {
+ closeStream();
+ }
+ this->filename=filename;
+}
+
+
+int YafOutputStream::openStream() {
+ if (lOpen == true) {
+ cout << "stream already open! call ignored"<<endl;
+ return sd;
+ }
+ sd=::socket(AF_UNIX,SOCK_STREAM,0);
+ if (sd < 0) {
+ perror("sd-Socket StreamWriter");exit(1);
+ }
+
+ unsigned int i=0;
+ sockad.sun_family=AF_UNIX;
+
+ while(i<strlen(filename)) {
+ sockad.sun_path[i]=filename[i];
+ i++;
+ }
+ sockad.sun_path[i]=0;
+ if (::connect(sd,(sockaddr*)&sockad,strlen(filename)+2)<0) {
+ perror("connect StreamWriter");exit(1);
+ }
+ if (sd > 0) {
+ lOpen=true;
+ }
+ return sd;
+}
+
+
+int YafOutputStream::closeStream() {
+ int ret=0;
+ if (lOpen) {
+ ret=close(sd);
+ lOpen=false;
+ filename=NULL;
+ } else {
+ cout << "stream already closed. call ignored!"<<endl;
+ }
+ return ret;
+}
+
+
+void YafOutputStream::internalDevice(int lInternal){
+ lInternalDevice=lInternal;
+}
+
+
+
+long YafOutputStream::getBytesCounter() {
+ return bytes;
+}
+
+
+long YafOutputStream::getAllWriteCounter() {
+ return allWrite;
+}
+
+
+
+void YafOutputStream::config(const char* key,const char* value,
+ void* user_data) {
+
+ directOutput->config(key,value,user_data);
+
+}
+
diff --git a/mpeglib/example/yaf/yafxplayer/yafOutputStream.h b/mpeglib/example/yaf/yafxplayer/yafOutputStream.h
new file mode 100644
index 00000000..bb7df423
--- /dev/null
+++ b/mpeglib/example/yaf/yafxplayer/yafOutputStream.h
@@ -0,0 +1,140 @@
+/*
+ concret OutputClass for yaf text consol player
+ Copyright (C) 1999 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+#ifndef __YAFOUTPUTSTREAM_H
+#define __YAFOUTPUTSTREAM_H
+
+
+
+//
+// If we build mpeglib we include the path absolute
+// otherwise we must have installed the includes (eg /usr/include/mpeglib)
+//
+
+#ifdef DIRECT_INCLUDE
+#include "../../../lib/output/avSyncer.h"
+#include "../../../lib/output/pluginInfo.h"
+#include "../../../lib/decoder/decoderPlugin.h"
+#include "../../../lib/input/inputPlugin.h"
+#include "../../../lib/output/outPlugin.h"
+#else
+#include <mpeglib/output/avSyncer.h>
+#include <mpeglib/output/pluginInfo.h>
+#include <mpeglib/decoder/decoderPlugin.h>
+#include <mpeglib/input/inputPlugin.h>
+#include <mpeglib/output/outPlugin.h>
+#endif
+
+#include <sys/un.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <kdemacros.h>
+
+// If you get compile errors when using mpeglib
+// simply remove the yaf dependencies
+#include "../yafcore/inputInterface.h"
+
+
+
+class KDE_EXPORT YafOutputStream : public OutputStream {
+
+
+ long bytes;
+ int lInternalDevice;
+ long allWrite;
+ int lOpen;
+ int sd;
+ struct sockaddr_un sockad;
+ const char* filename;
+ OutputStream* directOutput;
+ int fd[2];
+ InputInterface* input;
+
+ int writeToBuffer;
+
+
+
+
+ public:
+ // to the filedescriptor we write status messages from
+ // the thread. This makes it thread safe
+ YafOutputStream(InputInterface* input);
+ ~YafOutputStream();
+
+ // Audio Output
+
+ int audioSetup(int frequency,int stereo,int sign,int big,int sixteen);
+ void audioClose(void);
+ int audioPlay(TimeStamp* startStamp,
+ TimeStamp* endStamp,char *buffer, int size);
+
+ void audioFlush();
+ void audioOpen();
+
+ int getPreferredDeliverSize();
+
+
+ // Video part (no yaf protocol for this)
+ // Maybe in a future version we distribute this interface
+ // over shared mem or something, but for now
+ // a video player must include the mpeg video lib directly
+ // we forward the calls to the direct output
+
+
+ int openWindow(int width, int height,const char *title);
+ void closeWindow();
+ void flushWindow();
+
+ PictureArray* lockPictureArray();
+ void unlockPictureArray(PictureArray* pictureArray);
+
+ int getFrameusec();
+
+ int getDepth();
+ int getOutputInit();
+ void setOutputInit(int lInit);
+
+
+ // Info Output
+ void writeInfo(PluginInfo* pluginInfo);
+
+ void config(const char* key,const char* value,void* user_data);
+
+
+ // additional functionality (needed for the yaf-protocol)
+ void setBytesCounter(long value);
+
+
+ int isOpenStream();
+ void setStreamFile(const char* filename);
+ int openStream();
+ int closeStream();
+
+ void internalDevice(int lInternal);
+ long getBytesCounter();
+ long getAllWriteCounter();
+
+
+
+
+
+
+
+};
+
+
+
+#endif
diff --git a/mpeglib/example/yaf/yafyuv/Makefile.am b/mpeglib/example/yaf/yafyuv/Makefile.am
new file mode 100644
index 00000000..3400a34c
--- /dev/null
+++ b/mpeglib/example/yaf/yafyuv/Makefile.am
@@ -0,0 +1,37 @@
+# splay-yaf - Makefile.am
+
+INCLUDES = -I../../include $(all_includes)
+
+EXTRA_DIST =
+
+bin_PROGRAMS = yaf-yuv
+
+yaf_yuv_SOURCES = yuv_control.cpp
+
+
+noinst_HEADERS =
+
+yaf_yuv_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+
+yaf_yuv_LDADD = ../yafxplayer/libyafxplayer.la \
+ ../yafcore/libyafcore.la \
+ ../../../lib/libmpeg.la \
+ $(THIS_LIB_LIBS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mpeglib/example/yaf/yafyuv/yuv_control.cpp b/mpeglib/example/yaf/yafyuv/yuv_control.cpp
new file mode 100644
index 00000000..b62e50cf
--- /dev/null
+++ b/mpeglib/example/yaf/yafyuv/yuv_control.cpp
@@ -0,0 +1,207 @@
+/*
+ generic interactive controller
+ Copyright (C) 1998 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+
+// Set for local include
+#define DIRECT_INCLUDE
+
+#include "../yafcore/yaf_control.h"
+#include "../yafxplayer/inputDecoderYAF.h"
+
+#include <iostream>
+using namespace std;
+
+#include <math.h>
+
+
+
+// we include our plugin here
+#include "../../../lib/yuv/yuvPlugin.h"
+
+#if defined(HAVE_GETOPT_H)
+#include <getopt.h>
+#endif
+
+
+void control_yuv(InputInterface* input,OutputInterface* output,
+ InputDecoder* decoder) {
+
+
+ cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
+ cout<< "Command:0 Msg:implements xplayer" << endl;
+ cout<< "Command:0 Msg:decoder yuv Version:0.0.2" << endl;
+ cout<< "Command:0 Msg:mimetypes vide/yuv1;" << endl;
+ cout<< "Command:0 Msg:comment yuv Plugin by Martin Vogt" << endl;
+ cout<< "Command:0 Msg:comment yaf port by mvogt@rhrk.uni-kl.de"<<endl;
+ cout<< "Command:0 Msg:comment enter 'help' " << endl;
+
+
+
+ yaf_control(input,output,decoder);
+}
+
+
+void usage() {
+ cout << "yaf-yuv is a interactive frontend for the still image decoder"
+ <<endl;
+ cout << "Usage : yaf-yuv [w:g:y:f:hr:] <file.raw> [url]"<<endl;
+ cout << endl;
+ cout << "-w : width of raw yuv stream in pixel"<<endl;
+ cout << "-g : height of raw yuv stream in pixel"<<endl;
+ cout << "-h : help"<<endl;
+ cout << "-y : set image Format:"<<endl;
+ cout << " 1 : yuv lum/Cr/Cb"<<endl;
+ cout << " 2 : yuv lum/Cb/Cr"<<endl;
+ cout << " 3 : rgb 24 BIT"<<endl;
+ cout << " 4 : rgb 24 BIT (flipped)"<<endl;
+
+ cout << "-f : [1..n] frames per second"<<endl;
+
+ cout << endl;
+ cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
+ << "USE AT YOUR OWN RISK!"<<endl;
+ cout << endl;
+ cout << "for more help type 'help' in interactive mode"<<endl;
+}
+
+
+int readFormat(int* w,int* h,char* filename) {
+ char formatFileName[100];
+ FILE* file=NULL;
+ snprintf(formatFileName,100,"%s.format",filename);
+ cout << "open:"<<formatFileName<<endl;
+ file=fopen(formatFileName,"r");
+ if (file == NULL) {
+ cout << "no format file found"<<endl;
+ return false;
+ }
+
+ if (fscanf(file,"Version 0.1\nw:%dh:%d\n",w,h)==2) {
+ cout << "read ! w:"<<*w<<"h:"<<*h<<endl;
+ return true;
+ }
+
+
+ cout << "format file mismatch"<<endl;
+ return false;
+}
+
+
+int main(int argc, char** argv) {
+ int c;
+ int lInternalAudio=true;
+ char* width=NULL;
+ char* height=NULL;
+ int fps=1;
+
+ pow(6.0,3.0); // fixes bug in __math.h
+
+
+
+
+ InputInterface* input=new InputInterface();
+
+ OutputInterface output(&cout);
+
+ YafOutputStream* yafOutput=new YafOutputStream(input);
+
+ YUVPlugin* plugin=new YUVPlugin();
+
+ plugin->setOutputPlugin(yafOutput);
+ InputDecoderYAF decoder(plugin,yafOutput);
+
+
+
+ while(1) {
+ c = getopt (argc, argv, "w:g:y:hf:");
+ if (c == -1) break;
+ switch(c) {
+ case 'a': {
+ lInternalAudio=false;
+ break;
+ }
+ case 'h': {
+ cout << "query for help"<<endl;
+ usage();
+ exit(0);
+ }
+ case 'w': {
+ width=optarg;
+ printf("setting width:%s\n",width);
+ break;
+ }
+ case 'f': {
+ fps=atoi(optarg);
+ if (fps <= 0) {
+ cout << "wrong fps. must be > 0"<<endl;
+ exit(0);
+ }
+ break;
+ }
+ case 'g': {
+ height=optarg;
+ printf("setting height:%s\n",height);
+ break;
+ }
+ case 'y': {
+ cout << "config:imageType:"<<optarg<<endl;
+ plugin->config("imageType",optarg,NULL);
+ break;
+ }
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ usage();
+ exit(-1);
+ }
+ }
+ if (optind < argc ) {
+ Buffer buffer(300);
+ buffer.append("open ");
+ buffer.append(argv[optind]);
+ buffer.append("\n");
+
+ input->addInputLine(&buffer);
+
+ }
+ if ((width == NULL) || (height == NULL)) {
+ int w;
+ int h;
+ cout << "automatic try to read a .format file"<<endl;
+ if (readFormat(&w,&h,argv[optind]) == false) {
+ cout << "no format specified"<<endl;
+ exit(-1);
+ }
+ width=new char[20];
+ height=new char[20];
+ snprintf(width,20,"%d",w);
+ snprintf(height,20,"%d",h);
+ }
+
+ char* picPerSec=new char[20];
+ snprintf(picPerSec,20,"%d",fps);
+
+
+ plugin->config("picPerSec",picPerSec,NULL);
+ plugin->config("height",height,NULL);
+ plugin->config("width",width,NULL);
+
+
+ yafOutput->internalDevice(lInternalAudio);
+ control_yuv(input,&output,&decoder);
+ delete plugin;
+ delete yafOutput;
+ delete input;
+
+}
+