#!/bin/sh

set -e

case $1 in
"xmt"	)
	echo "Converting BT to XMT-A"
  find . -name "*.bt" | sort | while read FILE; do
	echo "Processing $FILE"
	MP4Box -xmt -quiet "$(basename "$FILE")"
	done
	;;
"xmp4"	)
	echo "Converting XMT-A to MP4"
  find . -name "*.xmt" | sort | while read FILE; do
	echo "Processing $FILE"
	MP4Box -mp4 -quiet "$(basename "$FILE")"
	done
	;;
"x3d"	)
	echo "Converting X3DV to X3D"
  find . -name "*.x3dv" | sort | while read FILE; do
	echo "Processing $FILE"
	MP4Box -x3d -quiet "$(basename "$FILE")"
	done
	;;
"clean"	) 
	echo "Removing XMT and MP4 files"
	rm -rf *.xmt
	rm -rf *.mp4
	;;
"help"	) 
	echo "GPAC Regression Tests Build Script usage: 00-do-build [opt]"
	echo "	no op / opt = "mp4": builds MP4 file sfrom BT scripts"
	echo "	opt = "xmt": builds XMT-A files from BT scripts"
	echo "	opt = "xmp4": builds MP4 files from XMT-A scripts"
	echo "	opt = "clean": deletes all XMT-A and MP4 files"
	echo "	opt = "help": prints this screen."
	;;
*	) 
	echo "Converting BT to MP4"
  find . -name "*.bt" | sort | while read FILE; do
	echo "Processing $FILE"
	MP4Box -mp4 -quiet "$(basename "$FILE")"
	done
	;;

esac

