#
# Copyright (C) by Stefano Falsetto
# e-mail contact ....: mailto:stefko5@inwind.it
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#
# Config plugin for mpg321
#

cat_variables_mpg321 () {

  cat <<EOF 
# Complete path for mp3 decoder
mpg321_DECODER="$mpg321_DECODER"

# Parameters to only show a time line
EXTRACT_TIME="$EXTRACT_TIME"

# Parameters to output to stdout with buffered mode
BUFFERED_DECODE="$BUFFERED_DECODE"

# Parameters to output to stdout without buffer
DECODE_TO_STDOUT="$DECODE_TO_STDOUT"

# Parameters to simply decode
NORMALDECODE="$NORMALDECODE"

# Array of output supported formats files
OUTPUT_FORMATS_mpg321=( $OUTPUT_FORMATS_mpg321 )

# Parameters to output to file in wav format
TO_wav="$TO_wav"

# Parameters to output to file in cdr format
TO_cdr="$TO_cdr"

# Parameters to output to file in au format
TO_au="$TO_au"

# default output file format
TOFMT="$TOFMT"

# Default conversion file extension
MPGCMD="$MPGCMD"

# Bound and criteria to check file type using magic file
# Layer 3
MPEGS1_1=$MPEGS1_1
MPEGS2_1=$MPEGS2_1
MPEGCRITERIA="$MPEGCRITERIA"
# Layer 2
MPEGS1_2=$MPEGS1_2
MPEGS2_2=$MPEGS2_2
MPEGCRITERIA_2="$MPEGCRITERIA_2"

EOF

}


. $PLUGINDIR/config/general/mp3funcs.inc

###################
# MAIN
###################

if [ $(expr "$SUPPORTED_FORMATS" : ".*mp3.*") -ne ${#SUPPORTED_FORMATS} ]; then
  begin_check mpg321
  find_prg mpg321
  mpg321_DECODER=$FOUND_PRG
  if [ -z "$mpg321_DECODER" ]; then
    missing mpg321 "http://sourceforge.net/projects/mpg321"
    end_check
  else
    QueryVersion $($mpg321_DECODER --version 2>&1|head -n 1|cut -d' ' -f3) mpg321 "0.2.3."
    shared_mp3_desc
    EXTENSIONS="mp3"
    SUPPORTED_FORMATS="$SUPPORTED_FORMATS $EXTENSIONS"
    AUDIO_PLUGINS="$AUDIO_PLUGINS mpg321"
    EXTRACT_TIME=" -t -v -k 99999999 "
    BUFFERED_DECODE=" -v -s "     # -b 10000 non funzia in ver 0.2.[23]
    DECODE_TO_STDOUT=" --cdr - " 
    NORMALDECODE=" -v -q "
    OUTPUT_FORMATS_mpg321="wav cdr au"
    TO_wav="--wav"
    TO_cdr="--cdr"
    TO_au="--au"
    TOFMT=$TO_wav
    MPGCMD="wav"
    shared_summary_strings "$mpg321_DECODER"
    end_check 
  fi
fi

