From 55de28c93dd649b52f0937b02bdf8fd1dd75de3c Mon Sep 17 00:00:00 2001
From: Sergio Vergata <sergio.vergata@h-da.de>
Date: Wed, 30 Jun 2021 10:58:08 +0000
Subject: [PATCH] Adding StreamView_URL to display in the chat

---
 README.md                           | 1 +
 examples/docker-compose.yml.example | 2 ++
 startStream.sh                      | 9 ++++++++-
 stream.py                           | 6 +++++-
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 9c9a5c4..458e76b 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@ You need to set some environment variables to run the container.
 * BBB_SHOW_CHAT - shows the chat on the left side of the window (Default: false)
 * BBB_RESOLUTION - the streamed/downloaded resolution (Default: 1920x1080)
 * BBB_CHAT_MESSAGE - prefix for the message that would be posted to BBB chat, while joining a conference (Default: "This meeting is streamed to")
+* BBB_STREAMVIEW_URL - post the viewing URL for the STREAM in the BBB chat (Default: "Secret URL")
 * TZ - Timezone (Default: Europe/Vienna)
 
 #### Chat settings
diff --git a/examples/docker-compose.yml.example b/examples/docker-compose.yml.example
index c23165f..47743f6 100644
--- a/examples/docker-compose.yml.example
+++ b/examples/docker-compose.yml.example
@@ -31,6 +31,8 @@ services:
       - BBB_STREAM_URL=rtmp://media_server_url/stream/stream_key
       # Message to post in BBB Chat when joining a conference
       - BBB_CHAT_MESSAGE=This meeting is streamed to
+      # post the viewing URL for the STREAM in the BBB chat (Default: "Secret URL")
+      - BBB_STREAMVIEW_URL=https://yourStream.url
       # Resolution to be streamed/downloaded in format WxH (default 1920x1080)
       - BBB_RESOLUTION=1920x1080
       # stream video bitrate
diff --git a/startStream.sh b/startStream.sh
index 9f70127..084c0c2 100644
--- a/startStream.sh
+++ b/startStream.sh
@@ -86,10 +86,17 @@ then
    DEV_SHM_USAGE='--browser-disable-dev-shm-usage'
 fi
 
+STREAMVIEW_URL="";
+if [ "${BBB_STREAMVIEW_URL}" != "" ]
+then
+   STREAMVIEW_URL="--streamviewUrl ${BBB_STREAMVIEW_URL}";
+fi 
+
+
 if [ "${BBB_ENABLE_CHAT}" = "true" ]
 then
    xvfb-run -n 133 --server-args="-screen 0 1280x720x24" python3 chat.py -s ${BBB_URL} -p ${BBB_SECRET} -i "${BBB_MEETING_ID}" -r ${BBB_REDIS_HOST} -u "${BBB_CHAT_NAME}" -c ${BBB_REDIS_CHANNEL} $START_MEETING $ATTENDEE_PASSWORD $MODERATOR_PASSWORD $DEV_SHM_USAGE -T "$MEETING_TITLE" &
    sleep 10
 fi 
 
-xvfb-run -n 122 --server-args="-screen 0 ${RESOLUTION}x24" python3 stream.py -s ${BBB_URL} -p ${BBB_SECRET} -i "${BBB_MEETING_ID}" -u "${BBB_USER_NAME}" -r "${RESOLUTION}" ${SHOW_CHAT} $START_MEETING $ATTENDEE_PASSWORD $MODERATOR_PASSWORD $DEV_SHM_USAGE -T "$MEETING_TITLE" $STREAM_MEETING $CHAT_STREAM_URL $CHAT_STREAM_MESSAGE $INTRO $BEGIN_INTRO $END_INTRO $DOWNLOAD_MEETING;
+xvfb-run -n 122 --server-args="-screen 0 ${RESOLUTION}x24" python3 stream.py -s ${BBB_URL} -p ${BBB_SECRET} -i "${BBB_MEETING_ID}" -u "${BBB_USER_NAME}" -r "${RESOLUTION}" ${SHOW_CHAT} $START_MEETING $ATTENDEE_PASSWORD $MODERATOR_PASSWORD $DEV_SHM_USAGE -T "$MEETING_TITLE" $STREAM_MEETING $CHAT_STREAM_URL $CHAT_STREAM_MESSAGE $INTRO $BEGIN_INTRO $END_INTRO $DOWNLOAD_MEETING $STREAMVIEW_URL;
diff --git a/stream.py b/stream.py
index 190f0e7..ec2580d 100644
--- a/stream.py
+++ b/stream.py
@@ -42,6 +42,7 @@ parser.add_argument("-u","--user", help="Name to join the meeting",default="Live
 parser.add_argument("-t","--target", help="RTMP Streaming URL")
 parser.add_argument("--chatUrl", help="Streaming URL to display in the chat", default=False)
 parser.add_argument("--chatMsg", nargs='+', help="Message to display in the chat before Streaming URL", default=False)
+parser.add_argument("--streamviewUrl", help="Streaming View URL do display in the chat", default=False)
 parser.add_argument("-c","--chat", help="Show the chat",action="store_true")
 parser.add_argument("-r","--resolution", help="Resolution as WxH", default='1920x1080')
 parser.add_argument('--ffmpeg-stream-threads', help='Threads to use for ffmpeg streaming', type=int,
@@ -148,13 +149,16 @@ def bbb_browser():
         # ensure chat is enabled (might be locked by moderator)
         if element.is_enabled() and chat_send.is_enabled():
            tmp_chatMsg = os.environ.get('BBB_CHAT_MESSAGE', "This meeting is streamed to")
+           tmp_streamviewUrl = os.environ.get('BBB_STREAMVIEW_URL', "Secret URL")
            if not tmp_chatMsg in [ 'false', 'False', 'FALSE' ]:
                tmp_chatUrl = args.target.partition('//')[2].partition('/')[0]
                if args.chatUrl:
                    tmp_chatUrl = args.chatUrl
+               if args.streamviewUrl:
+                   tmp_streamviewUrl = args.streamviewUrl
                if args.chatMsg:
                    tmp_chatMsg = ' '.join(args.chatMsg).strip('"')
-               element.send_keys("{0}: {1}".format(tmp_chatMsg, tmp_chatUrl))
+               element.send_keys("{0}: {1} {2}".format(tmp_chatMsg, tmp_chatUrl, tmp_streamviewUrl))
                chat_send.click()
 
         if args.chat:
-- 
GitLab