summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2011-03-29 16:43:31 (GMT)
committer Jaromil <jaromil@dyne.org>2011-03-29 16:43:31 (GMT)
commit701c9b906c8647b23889117645fdf8842a365f97 (patch)
tree0066430d50af0f35b5c6bba2abc20de56bc433d6
parent5f78efae5c71cddfea38b1fc4479b000a0382824 (diff)
testing and fixes with upnp
still need to check improvements using fw 0.4.5.3
-rw-r--r--scripts/S88hdsync27
-rwxr-xr-xscripts/assemble-app-bin.sh1
-rw-r--r--scripts/hdsync.conf16
-rwxr-xr-xscripts/listen-sync.sh68
-rwxr-xr-xscripts/offer-sync.sh80
-rw-r--r--scripts/utils-sync.sh47
6 files changed, 114 insertions, 125 deletions
diff --git a/scripts/S88hdsync b/scripts/S88hdsync
index af9bc4d..ee35ad2 100644
--- a/scripts/S88hdsync
+++ b/scripts/S88hdsync
@@ -38,27 +38,32 @@ if ! [ -r $USBROOT/hdsync.conf ]; then
else
# source settings
. $USBROOT/hdsync.conf
- echo "config file found in $USBROOT/hdsync.conf" > $SYNC_LOG
- echo "sync role configured to: $SYNC_ROLE" >> $SYNC_LOG
+ echo "config file found in ${USBROOT}hdsync.conf" >> /tmp/hdsync.log
fi
export USBROOT
export APPROOT
-export SYNC_LOG
-export OFFER_SLEEP
-export ETH_IFACE
+export HDSYNC_NETWORK
export HDSYNC_CHANNEL
export TOTAL_CHANNELS
# load up utils
-. /apps/hdsync/bin/utils-sync.sh
+. $APPROOT/bin/utils-sync.sh
-if ! [ -z "x$VIDEO_OUT" ]; then
- switch_output $VIDEO_OUT
-fi
+# retrieve network details
+get_ip
+
+# retrieve application details
+get_bins $APPROOT
+
+# wait that the usb is mounted
+sleep 10
+
+# will get ready for play button
+prepare_play
if [ "$HDSYNC_CHANNEL" = "1" ]; then
- $APPROOT/bin/offer-sync.sh >> $SYNC_LOG
+ $APPROOT/bin/offer-sync.sh >> /tmp/hdsync.log
else
- $APPROOT/bin/listen-sync.sh >> $SYNC_LOG
+ $APPROOT/bin/listen-sync.sh >> /tmp/hdsync.log
fi
diff --git a/scripts/assemble-app-bin.sh b/scripts/assemble-app-bin.sh
index 15b8284..2fb12d3 100755
--- a/scripts/assemble-app-bin.sh
+++ b/scripts/assemble-app-bin.sh
@@ -56,6 +56,7 @@ if [ -z $1 ]; then
cp -a $appdir/* $loopdir/ &&
sudo rm -rf $loopdir/lost+found &&
sudo chown root:root -R $loopdir &&
+ sleep 1 &&
sudo umount $loopdir &&
sudo rm -rf $loopdir $appdir &&
sudo /sbin/fsck.ext3 $imagefile
diff --git a/scripts/hdsync.conf b/scripts/hdsync.conf
index 09a5471..835c2e1 100644
--- a/scripts/hdsync.conf
+++ b/scripts/hdsync.conf
@@ -1,14 +1,10 @@
# ----------------------------------------------------
# configuration file for hdsync
-# NIC to use
-ETH_IFACE=eth0
-
-# where to log operations
-SYNC_LOG=/tmp/hdsync.log
-
-# fine tuning sleep
-OFFER_SLEEP=0.1
+# Network configuration to use: DYNAMIC or STATIC
+# DYNAMIC = use the DHCP daemon on LAN to assign IPs
+# STATIC = most of the time you'll need this
+HDSYNC_NETWORK=DYNAMIC
# number of this video channel
HDSYNC_CHANNEL=1
@@ -18,7 +14,3 @@ HDSYNC_CHANNEL=1
# total video channels expected
TOTAL_CHANNELS=2
-# video output can be: none (will autodetect)
-# hdmi (set HDMI / res. auto)
-# composite (set comp. / format PAL)
-# VIDEO_OUT=hdmi
diff --git a/scripts/listen-sync.sh b/scripts/listen-sync.sh
index 0e00faa..7147d85 100755
--- a/scripts/listen-sync.sh
+++ b/scripts/listen-sync.sh
@@ -19,59 +19,45 @@ PATH=/usr/bin:/bin:/usr/sbin:/sbin
. /apps/hdsync/bin/utils-sync.sh
-get_ip $ETH_IFACE
-
-get_netcat $APPROOT
# launch background listener for acks
+rm -f /tmp/offer.replies
+touch /tmp/offer.replies
(while [ true ]; do
answer=`echo | $NC -c -u -l -p 3333`;
echo $answer >> /tmp/offer.replies
done) &
-# will get ready for play button
-prepare_play
+echo "listening for offers on $IP"
-# loop continuously
-while [ true ]; do
- sleep 3
- lsof | grep videos > /dev/null
- if [ $? == 1 ]; then
+offer="`echo | $NC -c -u -l -p 3332`"
- rm -f /tmp/offer.replies
- touch /tmp/offer.replies
+echo "offered sync by $offer"
- echo "listening for offers"
- offer="`echo | $NC -c -u -l -p 3332`"
+ # repeat udp replies to offer until ack
+echo "replying with our ip until ack"
+ack=""
+while [ "$ack" = "" ]; do
+ sleep 1
+ echo "$IP" | $NC -c -u $offer 3331
+ echo -n "."
+ ack=`cat /tmp/offer.replies`
+done
- echo "offered sync by $offer"
+echo "ack received, we are channel $ack"
+sync
+
+echo "ready: awaiting syncstarter signal"
+
+
+# exit after connection (-e true)
+$NC -c -u -l -p 3336 -e true
+
+# "press play on tape"
+$UP play
+
+echo "sync playback started"
- # repeat udp replies to offer until ack
- echo "replying with our ip until ack"
- ack=""
- while [ "$ack" = "" ]; do
- sleep 1
- echo "$IP" | $NC -c -u $offer 3331
- echo -n "."
- ack=`cat /tmp/offer.replies`
- done
-
- echo "ack received, we are channel $ack"
-
- sync
-
- echo "ready: awaiting syncstarter signal"
-
-
- # exit after connection (-e true)
- $NC -c -u -l -p 3336 -e true
-
- # "press play on tape"
- upnp.sh play
-
- echo "sync playback started"
- fi
-done
diff --git a/scripts/offer-sync.sh b/scripts/offer-sync.sh
index 7d351ed..a0e545d 100755
--- a/scripts/offer-sync.sh
+++ b/scripts/offer-sync.sh
@@ -17,73 +17,59 @@
PATH=/usr/bin:/bin:/usr/sbin:/sbin
-. /apps/hdsync/bin/utils-sync.sh
-
-get_ip $ETH_IFACE
-
-get_netcat $APPROOT
+. $APPROOT/bin/utils-sync.sh
# launch background listener
+rm -f /tmp/offer.replies
+touch /tmp/offer.replies
(while [ true ]; do
answer=`echo | $NC -c -u -l -p 3331`;
echo $answer >> /tmp/listener.replies
done) &
-# will get ready for play button
-prepare_play
-
-# loop continuously
-while [ true ]; do
- sleep 5
- lsof | grep videos > /dev/null
- if [ $? == 1 ]; then # no video is running
-
- rm -f /tmp/listener.replies
- touch /tmp/listener.replies
-
- echo "broadcasting offer signals from $IP"
- bcast=`echo $IP | awk 'BEGIN { FS="." } {print $1 }'`.255.255.255
- echo "to netmask $bcast"
-
- # send broadcast signals until somebody listens
- listeners=0
- expected=`expr $TOTAL_CHANNELS - 1`
- while [ "$listeners" != "$expected" ]; do
- echo -n "$b: `date +%X` "
- $BC $bcast 3332 $IP
- sleep 2
- listeners=`cat /tmp/listener.replies | sort | uniq | wc -w`
- done
+echo "broadcasting offer signals from $IP"
+ # we do broadcast only on class C
+ # must always make sure also listener expects on class C
+bcast=`echo $IP | awk 'BEGIN { FS="." } {print $1 "." $2 "." $3 }'`.255
+echo "to netmask $bcast"
+
+# send broadcast signals until somebody listens
+listeners=0
+expected=`expr $TOTAL_CHANNELS - 1`
+while [ "$listeners" != "$expected" ]; do
+ echo -n "$b: `date +%X` "
+ $BC $bcast 3332 $IP
+ sleep 2
+ listeners=`cat /tmp/listener.replies | sort | uniq | wc -w`
+done
- echo "harvesting replies"
- cat /tmp/listener.replies | sort | uniq > /tmp/listeners
+echo "harvesting replies"
+cat /tmp/listener.replies | sort | uniq > /tmp/listeners
- echo "sending acks"
- c=1
- for l in `cat /tmp/listeners`; do
- echo "$c: $l"
- echo "$c" | $NC -c -u $l 3333
- done
+echo "sending acks"
+c=1
+for l in `cat /tmp/listeners`; do
+ echo "$c: $l"
+ echo "$c" | $NC -c -u $l 3333
+done
- echo "waiting for other players to get ready..."
- sleep 15
+echo "waiting for other players to get ready..."
+sleep 15
- sync
+sync
- # sync start!
- $BC $bcast 3336 s
+# sync start!
+$BC $bcast 3336 s
# configurable wait step
# sleep $OFFER_SLEEP
# "press play on tape"
- upnp.sh play
+$UP play
- echo "sync playback started"
+echo "sync playback started"
- fi
-done
diff --git a/scripts/utils-sync.sh b/scripts/utils-sync.sh
index 02de54f..69c1269 100644
--- a/scripts/utils-sync.sh
+++ b/scripts/utils-sync.sh
@@ -22,35 +22,54 @@ get_conf() {
}
get_ip() {
- echo "getting a network address"
- IFACE=$1
- IP="192.168.0.$HDSYNC_CHANNEL"
- config_tool -c LAN_TYPE=s
- config_tool -c IP2=$IP
- config_tool -c NETMASK2=255.0.0.0
- ifconfig $IFACE $IP netmask 255.0.0.0
- echo "network interface $IFACE configured with address $IP ..."
+ if [ "$HDSYNC_NETWORK" = "DYNAMIC" ]; then
+ echo "listening for DHCP assigned IP on the network"
+ config_tool -c LAN_TYPE='d'
+ IP=`get_conf IP2`
+ else
+ echo "setting a static network address"
+ IP="192.168.0.$HDSYNC_CHANNEL"
+ config_tool -c LAN_TYPE='s'
+ config_tool -c IP2=$IP
+ config_tool -c NETMASK2=255.255.255.0
+ ifconfig eth0 $IP netmask 255.255.255.0
+ echo "network interface configured with address $IP ..."
+ fi
export IP
}
-get_netcat() {
+get_bins() {
+ # wrapper to test in development on local paths
if [ -z $1 ]; then
NC="../src/netcat"
BC="../src/broadcaster"
+ UP="../scripts/upnp.sh"
else
NC="$APPROOT/bin/netcat"
BC="$APPROOT/bin/broadcaster"
+ UP="$APPROOT/bin/upnp.sh"
fi
echo "netcat binaries found:"
echo "$BC"
echo "$NC"
- export BC NC
+ echo "$UP"
+ export BC NC UP
}
prepare_play() {
- file=`ls $USBROOT/sync`
- upnp.sh load "$USBROOT/sync/$file"
- upnp.sh play
- upnp.sh pause
+ # turn off screensaver
+ config_tool -c DMA_ENABLE_SCREENSAVER='0'
+ config_tool -c DMA_SCREENSAVER='0'
+
+ # go to the video from the initial menu position
+ echo "r" > /tmp/ir_injection; sleep 1
+ echo "r" > /tmp/ir_injection; sleep 1
+ echo "r" > /tmp/ir_injection; sleep 2
+ echo "p" > /tmp/ir_injection; sleep 10
+# file=`ls $USBROOT/sync`
+# $UP load "$USBROOT/sync/$file"
+ echo "T" > /tmp/ir_injection; sleep 5
+ $UP play
+ $UP pause
}