


This file describes how to add new commands to the frontend.
You have to change only two files if you add your own command:


1.  mpg123Command.defs          add command name/number/help text
2.  inputDecoderMPG123.cpp      add decoder specific parts for new command


The following text gives an example for the new command "JUMP"


Example: Add new Command "JUMP" to frontend
******************************************* 

First step
+++++++++++


If you want to add a new command, for example "jump",
then you must first give this command a unique number,
because, later in the decoder, the comparision which
command is called, is not done with strings, but with
numbers.

in this example you add:

#define _MPG123_JUMP       _CT_START+6

to the file: MPG123.defs

Then you must set the string-name for this command.

You add to the array (in MPG123.defs) :

  { 1,"jump" ,"j",_MPG123_JUMP,"jump <frameNr> jumps to Frame"}

1. (true/false) means that this command is shown when user enters "help"
   (why? You may want to define internal commands 
    which the user doesn' know about)
2. The long name for the command
3. The "shortcut" for professionals
4. The associated number for the command
5. help text if user enters "help jump"

IMPORTANT: !!!
               Don't forget to adjust the definition MPG123COMMANDS_SIZE
               at the end of the file !!! 

(This defines how much commands are in the array)

That's it for the definition of the new command. 


Second step
+++++++++++

The File DecoderMPG123.cpp defines the action for the commands.

In the Method processCommand you get the command number (_MPG123_JUMP for
example) and the arguments.(for "jump" its the frame number)


char* DecoderMPG123::processCommand(int command,char* args){

You add to the method:

if (command == _MPG123_JUMP) {
   int nPos=0;
   sscanf(args,"%d",&nPos);  // this converts the string-args to an int
  
   ....... special code for mpg123 ......

 }

The return string describes the succes of the command or
an error code.



That's all :-)


   

What's the difference beween inputDecoder and outputDecoder?
**********************************************************

InputDecoder decodes the input by the user and then performs
the necessary commands on the decoder.
eg. input is "jump 0" then input decoder execute :
    rd->rewind()
    re_read_init-frame()

The outputDecoder is used by a more advanced frontend than
the commandLine frontend.
The inputCommand "jump 0" returns as output (example)

Command:xy Ret:(out of bounds) Msg:jump 0

This must be interpeted by the outputDecoder.
But for the simple commandline frontend there is
no output processing.




