Lots happening with the @KompilerDJ (@sullrich on GitHub) fork of the original androidhdmi-for-channels repository, which I am now building Docker versions of the project against. With the Docker version of the project, there's no need to install Go or ADB directly on the host, so it's a couple of steps easier to get up-and-running with this extension.
The M3U data has been made generic, and is hosted by the container -- so no need to add custom channels tuning and guide data in Channels DVR, you can just use the URL http://[hostname or ip]:[port]/m3u/[appname]. And, as previously mentioned the scripts have been made generic, so it's no longer necessary to have script variations for each virtual tuner.
So far, only @KompilerDJ and I have contributed scripts for a particular streaming device and app combinations, but I'm confident more of you will add to the script code base so that not everyone has to start from scratch.
It's now also possible to use the channel name from the M3U for tuning in a couple of different ways, either as an input to a search box if the app doesn't support URL style tunning, or as UUID or other unique identifier -- which supports having a single, generic tuning statement in bmitune.sh.
So, for example here are my current scripts for firetv/directv:
#!/bin/bash
#prebmitune.sh for firetv/directv
STREAMERIP="$1"
ADB_CMD="adb -s $1 shell"
WAKE="input keyevent KEYCODE_WAKEUP"
HOME="input keyevent KEYCODE_HOME"
APP_LAUNCH="tv.youi.clientapp.AppActivity"
APP_NAME="com.att.tv"
APP_PID=$($ADB_CMD pidof $APP_NAME)
adb connect $STREAMERIP
if [ ! -z $APP_PID ]; then
$ADB_CMD $WAKE
$ADB_CMD am start -n $APP_NAME/$APP_LAUNCH
echo "Waking $STREAMERIP"
touch /tmp/wake
else
$ADB_CMD $WAKE
$ADB_CMD am start -n $APP_NAME/$APP_LAUNCH
echo "Starting $APP_NAME on $STREAMERIP"
fi
#!/bin/bash
#bmitune.sh for firetv/directv
ADB_CMD="adb -s $2 shell"
CHANNEL=\""$1\""
CHANNEL_NAME=$(awk -F, '/channel-id='"$CHANNEL"'/ {print $2}' m3u/directv.m3u)
CHANNEL_NAME=$(echo $CHANNEL_NAME | sed 's/^/"/;s/$/"/')
SEARCH="input keyevent 20; sleep 3; input keyevent 22 22 22 22; input keyevent 20; sleep 3; input keyevent 66; sleep 2"
SELECT="input keyevent 85; sleep 3; input keyevent 20 20 66"
#Variable delay based on whether app was running or needed to be launched
if [ -f /tmp/wake ]; then
sleep 8
rm /tmp/wake
else
sleep 24
fi
#Tuning is based on channel name values from directv.m3u.
$ADB_CMD $SEARCH
$ADB_CMD input text $CHANNEL_NAME
$ADB_CMD $SELECT
#!/bin/bash
#stopbmitune.sh for firetv/directv
STREAMERIP="$1"
ADB_CMD="adb -s $1 shell"
STOP="input keyevent KEYCODE_HOME"
SLEEP="input keyevent KEYCODE_SLEEP"
#Stop Video
$ADB_CMD $STOP; sleep 2
echo "Streaming stopped for $STREAMERIP"
$ADB_CMD $SLEEP
echo "Sleep initiated for $STREAMERIP"
Pretty simple right?
And here's the latest annotated docker compose for this container:
version: '3.9'
services:
androidhdmi-for-channels:
image: bnhf/androidhdmi-for-channels:alpha
container_name: ah4channels-alpha
hostname: ah4channels
dns_search: localdomain # Specify the name of your LAN's domain, usually local or localdomain
ports:
- 5037:5037 # Port used by adb-server
- 7654:7654 # Port used by Channels androidhdmi-for-channels proxy
environment:
- IPADDRESS=${IPADDRESS} # Hostname or IP address to be used in M3U file
- NUMBER_TUNERS=${NUMBER_TUNERS} # Number of tuners you'd like defined 1, 2, 3 or 4 supported
- TUNER1_IP=${TUNER1_IP} # Streaming device #1 with adb port in the form hostname:port or ip:port
- TUNER2_IP=${TUNER2_IP} # Streaming device #2 with adb port in the form hostname:port or ip:port
- TUNER3_IP=${TUNER3_IP} # Streaming device #3 with adb port in the form hostname:port or ip:port
- TUNER4_IP=${TUNER4_IP} # Streaming device #4 with adb port in the form hostname:port or ip:port
- TUNER1_URL=${TUNER1_URL} # Full URL for tuner #1 in the form http://hostname/stream or http://ip/stream
- TUNER2_URL=${TUNER2_URL} # Full URL for tuner #2 in the form http://hostname/stream or http://ip/stream
- TUNER3_URL=${TUNER3_URL} # Full URL for tuner #3 in the form http://hostname/stream or http://ip/stream
- TUNER4_URL=${TUNER4_URL} # Full URL for tuner #4 in the form http://hostname/stream or http://ip/stream
- STREAMER_APP=${STREAMER_APP} # Streaming device name and streaming app you're using in the form streamer/app (use lowercase with slash between as shown)
volumes:
- /data2/androidhdmi-for-channels:/opt/scripts # pre/stop/bmitune.sh scripts will be stored in this bound host directory under streamer/app
- /data/adb:/root/.android # Persistent data directory for adb keys
restart: unless-stopped
And the environment variables I'm using:
IPADDRESS=htpc6
NUMBER_TUNERS=1
TUNER1_IP=amazon-1170239ab:5555
TUNER1_URL=http://encoder_14121/0.ts
STREAMER_APP=firetv/directv
For those looking to jump start their androidhdmi-for-channels project, in the immortal words of the Mandalorian: "This is the way"