summaryrefslogtreecommitdiffstats
path: root/mpeglib/example/yaf/yafxplayer
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch)
tree9047cf9e6b5c43878d5bf82660adae77ceee097a /mpeglib/example/yaf/yafxplayer
downloadtdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz
tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'mpeglib/example/yaf/yafxplayer')
-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
16 files changed, 1565 insertions, 0 deletions
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