From 1ee332f6c65ccb605bbcd7b28883ec594f08073c Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Thu, 13 Jun 2024 22:00:30 -0700 Subject: [PATCH 1/5] fix: move media player to C++ code instead --- viewer.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/viewer.py b/viewer.py index b5599049a..b598c9858 100755 --- a/viewer.py +++ b/viewer.py @@ -372,14 +372,11 @@ def view_video(uri, duration): view_image('null') - try: - while media_player.is_playing(): - watchdog() - sleep(1) - except sh.ErrorReturnCode_1: - logging.info('Resource URI is not correct, remote host is not responding or request was rejected.') + if browser is None or not browser.process.alive: + load_browser() - media_player.stop() + browser_bus.loadVideo(uri) + logging.info('Current url is {0}'.format(uri)) def load_settings(): @@ -416,7 +413,7 @@ def asset_loop(scheduler): else: logging.error('Unknown MimeType %s', mime) - if 'image' in mime or 'web' in mime: + if 'image' in mime or 'web' in mime or 'video' in mime: duration = int(asset['duration']) logging.info('Sleeping for %s', duration) sleep(duration) From 76aa0ab01518a0d503319eabb31a9e2adb15cbb3 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Tue, 25 Jun 2024 11:27:50 -0700 Subject: [PATCH 2/5] fix: add a 500-ms delay to prevent cross-playback of videos --- viewer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/viewer.py b/viewer.py index b598c9858..a1f39db27 100755 --- a/viewer.py +++ b/viewer.py @@ -413,8 +413,10 @@ def asset_loop(scheduler): else: logging.error('Unknown MimeType %s', mime) - if 'image' in mime or 'web' in mime or 'video' in mime: + if any(mimetype for mimetype in ['image', 'web', 'video']): duration = int(asset['duration']) + if 'video' in mime: + duration += 0.5 # Add a 500-ms delay to avoid cross-playback. logging.info('Sleeping for %s', duration) sleep(duration) From 1d68b69a561acadb8e4db1e0db068bbef25854f5 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Thu, 27 Jun 2024 11:04:23 -0700 Subject: [PATCH 3/5] fix: tweak code so that viewer will wait for the player to be ready --- viewer.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/viewer.py b/viewer.py index 5730da02a..aa784f863 100755 --- a/viewer.py +++ b/viewer.py @@ -376,7 +376,14 @@ def view_video(uri, duration): if browser is None or not browser.process.alive: load_browser() - browser_bus.loadVideo(uri) + browser_bus.loadVideo(uri, int(duration)) + + while True: + is_ready = browser_bus.isReady() + if is_ready: + break + sleep(1) + logging.info('Current url is {0}'.format(uri)) @@ -414,10 +421,8 @@ def asset_loop(scheduler): else: logging.error('Unknown MimeType %s', mime) - if any(mimetype for mimetype in ['image', 'web', 'video']): + if any(mimetype in mime for mimetype in ['image', 'web']): duration = int(asset['duration']) - if 'video' in mime: - duration += 0.5 # Add a 500-ms delay to avoid cross-playback. logging.info('Sleeping for %s', duration) sleep(duration) From 0e61a720dfa0fb16a73da5cf0455cb4f7fc0edc0 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Tue, 23 Jul 2024 20:00:19 -0700 Subject: [PATCH 4/5] fix: install GStreamer dependencies required for video playback --- docker/Dockerfile.viewer.tmpl | 15 +++++++++++++++ viewer.py | 8 +------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docker/Dockerfile.viewer.tmpl b/docker/Dockerfile.viewer.tmpl index e322fd530..44dac4871 100644 --- a/docker/Dockerfile.viewer.tmpl +++ b/docker/Dockerfile.viewer.tmpl @@ -32,6 +32,21 @@ RUN --mount=type=cache,target=/var/cache/apt \ libgles2-mesa-dev \ libglib2.0-dev \ libgst-dev \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgstreamer-plugins-bad1.0-dev \ + gstreamer1.0-plugins-base \ + gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad \ + gstreamer1.0-plugins-ugly \ + gstreamer1.0-libav \ + gstreamer1.0-tools \ + gstreamer1.0-x \ + gstreamer1.0-alsa \ + gstreamer1.0-gl \ + gstreamer1.0-gtk3 \ + gstreamer1.0-qt5 \ + gstreamer1.0-pulseaudio \ libicu-dev \ libinput-dev \ libiodbc2-dev \ diff --git a/viewer.py b/viewer.py index 292902145..7528da353 100755 --- a/viewer.py +++ b/viewer.py @@ -26,7 +26,6 @@ from lib import assets_helper from lib import db from lib.errors import SigalrmException -from lib.media_player import VLCMediaPlayer from lib.utils import ( url_fails, is_balena_app, @@ -63,8 +62,6 @@ browser_bus = None r = connect_to_redis() -media_player = VLCMediaPlayer() - HOME = None db_conn = None @@ -84,7 +81,7 @@ def sigusr1(signum, frame): playing web or image asset is skipped. """ logging.info('USR1 received, skipping.') - media_player.stop() + # @TODO: Stop the Qt media player here via a DBus call. def skip_asset(back=False): @@ -357,9 +354,6 @@ def view_image(uri): def view_video(uri, duration): logging.debug('Displaying video %s for %s ', uri, duration) - media_player.set_asset(uri, duration) - media_player.play() - view_image('null') if browser is None or not browser.process.alive: From 2e2ff5ae0f0baadc0232c394a084a91713314e8f Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Thu, 12 Dec 2024 12:01:44 -0800 Subject: [PATCH 5/5] fix: install the necessary deps inside the viewer service --- tools/image_builder/__main__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/image_builder/__main__.py b/tools/image_builder/__main__.py index 1d52d7ddf..592a412a7 100644 --- a/tools/image_builder/__main__.py +++ b/tools/image_builder/__main__.py @@ -160,6 +160,21 @@ def build_image( 'libgles2-mesa', 'libgles2-mesa-dev', 'libglib2.0-dev', + 'libgstreamer1.0-dev', + 'libgstreamer-plugins-base1.0-dev', + 'libgstreamer-plugins-bad1.0-dev', + 'gstreamer1.0-plugins-base', + 'gstreamer1.0-plugins-good', + 'gstreamer1.0-plugins-bad', + 'gstreamer1.0-plugins-ugly', + 'gstreamer1.0-libav', + 'gstreamer1.0-tools', + 'gstreamer1.0-x', + 'gstreamer1.0-alsa', + 'gstreamer1.0-gl', + 'gstreamer1.0-gtk3', + 'gstreamer1.0-qt5', + 'gstreamer1.0-pulseaudio', 'libicu-dev', 'libinput-dev', 'libiodbc2-dev',