| 1 |
#!/bin/bash |
|---|
| 2 |
# |
|---|
| 3 |
# Copyright (c) 2009, Whispersoft s.r.l. |
|---|
| 4 |
# All rights reserved. |
|---|
| 5 |
# |
|---|
| 6 |
# Redistribution and use in source and binary forms, with or without |
|---|
| 7 |
# modification, are permitted provided that the following conditions are |
|---|
| 8 |
# met: |
|---|
| 9 |
# |
|---|
| 10 |
# * Redistributions of source code must retain the above copyright |
|---|
| 11 |
# notice, this list of conditions and the following disclaimer. |
|---|
| 12 |
# * Redistributions in binary form must reproduce the above |
|---|
| 13 |
# copyright notice, this list of conditions and the following disclaimer |
|---|
| 14 |
# in the documentation and/or other materials provided with the |
|---|
| 15 |
# distribution. |
|---|
| 16 |
# * Neither the name of Whispersoft s.r.l. nor the names of its |
|---|
| 17 |
# contributors may be used to endorse or promote products derived from |
|---|
| 18 |
# this software without specific prior written permission. |
|---|
| 19 |
# |
|---|
| 20 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|---|
| 21 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|---|
| 22 |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|---|
| 23 |
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|---|
| 24 |
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|---|
| 25 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|---|
| 26 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|---|
| 27 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|---|
| 28 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|---|
| 29 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|---|
| 30 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 31 |
# |
|---|
| 32 |
|
|---|
| 33 |
if [ $(ls -l $1/test/test_data/media/*.flv | wc -l) -ne 4 ]; then |
|---|
| 34 |
echo "Probably you don't have all the test flv files - skipping" |
|---|
| 35 |
exit 0 |
|---|
| 36 |
fi |
|---|
| 37 |
|
|---|
| 38 |
rm -rf /tmp/state_instance_1 |
|---|
| 39 |
mkdir -p /tmp/state_instance_1 |
|---|
| 40 |
|
|---|
| 41 |
rm -rf /tmp/state_instance_2 |
|---|
| 42 |
mkdir -p /tmp/state_instance_2 |
|---|
| 43 |
|
|---|
| 44 |
OLD_PIDS=$(ps ax -www | grep "whispercast --http_port=8481 --rtmp_port=8482" \ |
|---|
| 45 |
| grep -v grep | awk '{print $1}') |
|---|
| 46 |
[[ -n $OLD_PIDS ]] && kill $OLD_PIDS; sleep 2; kill -9 $OLD_PIDS |
|---|
| 47 |
|
|---|
| 48 |
$2/whispercast \ |
|---|
| 49 |
--http_port=8481 \ |
|---|
| 50 |
--rtmp_port=8482 \ |
|---|
| 51 |
--base_media_dir=$1/test/test_data/media/ \ |
|---|
| 52 |
--media_state_dir=/tmp/state_instance_1/ \ |
|---|
| 53 |
--media_config_dir=$1/test/test_data/config/instance_1/ \ |
|---|
| 54 |
--rtmp_connection_media_chunk_size_ms=0 \ |
|---|
| 55 |
--element_libraries_dir=$2/../whisperstreamlib/elements/ & |
|---|
| 56 |
|
|---|
| 57 |
PID_0=$! |
|---|
| 58 |
|
|---|
| 59 |
sleep 10 |
|---|
| 60 |
|
|---|
| 61 |
if [ "$3" == "--longtest" ]; then |
|---|
| 62 |
$2/rtmp_client --server_host=127.0.0.1 --server_port=8482 \ |
|---|
| 63 |
--stream_name=ns --log_received_events > \ |
|---|
| 64 |
/tmp/rtmp_stream_s.out & |
|---|
| 65 |
PID_1=$! |
|---|
| 66 |
fi |
|---|
| 67 |
|
|---|
| 68 |
$2/rtmp_client --server_host=127.0.0.1 --server_port=8482 \ |
|---|
| 69 |
--stream_name=f/whispercast_test1.flv --log_received_events > \ |
|---|
| 70 |
/tmp/rtmp_stream_f_1.out & |
|---|
| 71 |
PID_2=$! |
|---|
| 72 |
|
|---|
| 73 |
$2/rtmp_client --server_host=127.0.0.1 --server_port=8482 \ |
|---|
| 74 |
--stream_name=f/whispercast_test1.flv?seek_pos=14000 \ |
|---|
| 75 |
--log_received_events > \ |
|---|
| 76 |
/tmp/rtmp_stream_f_1_seek_14000.out & |
|---|
| 77 |
PID_3=$! |
|---|
| 78 |
|
|---|
| 79 |
$2/rtmp_client --server_host=127.0.0.1 --server_port=8482 \ |
|---|
| 80 |
--stream_name=f/whispercast_test4.flv --log_received_events > \ |
|---|
| 81 |
/tmp/rtmp_stream_f_4.out & |
|---|
| 82 |
PID_4=$! |
|---|
| 83 |
|
|---|
| 84 |
if [ "$3" == "--longtest" ]; then |
|---|
| 85 |
echo "Waiting "$PID_1 |
|---|
| 86 |
wait $PID_1 |
|---|
| 87 |
fi |
|---|
| 88 |
|
|---|
| 89 |
echo "Waiting "$PID_2 |
|---|
| 90 |
wait $PID_2 |
|---|
| 91 |
echo "Waiting "$PID_3 |
|---|
| 92 |
wait $PID_3 |
|---|
| 93 |
echo "Waiting "$PID_4 |
|---|
| 94 |
wait $PID_4 |
|---|
| 95 |
|
|---|
| 96 |
kill -9 $PID_0 |
|---|
| 97 |
|
|---|
| 98 |
if [ "$3" == "--longtest" ]; then |
|---|
| 99 |
echo "Diffing rtmp_stream_s.out... " |
|---|
| 100 |
diff /tmp/rtmp_stream_s.out $1/test/test_data/rtmp_stream_s.out || exit 1 |
|---|
| 101 |
echo "OK" |
|---|
| 102 |
fi |
|---|
| 103 |
|
|---|
| 104 |
echo "Diffing rtmp_stream_f_1.out... " |
|---|
| 105 |
diff /tmp/rtmp_stream_f_1.out $1/test/test_data/rtmp_stream_f_1.out || exit 1 |
|---|
| 106 |
echo "OK" |
|---|
| 107 |
|
|---|
| 108 |
echo "Diffing rtmp_stream_f_1_seek_14000.out..." |
|---|
| 109 |
diff /tmp/rtmp_stream_f_1_seek_14000.out \ |
|---|
| 110 |
$1/test/test_data/rtmp_stream_f_1_seek_14000.out || exit 1 |
|---|
| 111 |
echo "OK" |
|---|
| 112 |
|
|---|
| 113 |
echo "Diffing rtmp_stream_f_4.out..." |
|---|
| 114 |
diff /tmp/rtmp_stream_f_4.out $1/test/test_data/rtmp_stream_f_4.out || exit 1 |
|---|
| 115 |
echo "OK" |
|---|
| 116 |
|
|---|
| 117 |
echo "PASS" |
|---|