#!/bin/bash

# 
# SRT - Secure, Reliable, Transport
# Copyright (c) 2017 Haivision Systems Inc.
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# 
# This library 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
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; If not, see <http://www.gnu.org/licenses/>
# 

FFPLAY=`type -p ffplay || echo none`
if [[ $FFPLAY == "none" ]]; then
	echo >&2 "ERROR: ffplay not available to call. Please install ffplay first."
	exit 1
fi

DIRNAME=`dirname $0`
if [[ ! -x $DIRNAME/stransmit ]]; then
	echo >&2 "ERROR: you need 'stransmit' tool from SRT package in the same directory as this script."
	exit 1
fi

SRCLOC=$1
if [[ -z $SRCLOC ]]; then
	echo >&2 "Usage: `basename $0` <source URL>"
	exit 1
fi

$DIRNAME/stransmit "$1" file://con/ | ffplay -

