-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix audio only sources #350
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import logging | ||
import sys | ||
|
||
from gi.repository import Gst, Gdk | ||
|
||
from lib.args import Args | ||
from lib.config import Config | ||
from lib.clock import Clock | ||
|
||
from vocto.port import Port | ||
from vocto.debug import gst_generate_dot | ||
from vocto.pretty import pretty | ||
|
||
class AudioOnlyDisplay(object): | ||
"""Displays a Voctomix-AudioOnly-Stream into a GtkWidget""" | ||
|
||
def __init__(self, audio_display, port, name, play_audio=False): | ||
self.log = logging.getLogger('AudioOnlyDisplay:%s' % name) | ||
self.name = name | ||
self.level_callback = None if audio_display is None else audio_display.callback | ||
|
||
# Setup Server-Connection, Demuxing and Decoding | ||
pipe = """ | ||
tcpclientsrc | ||
name=tcpsrc-{name} | ||
host={host} | ||
port={port} | ||
blocksize=1048576 | ||
! matroskademux | ||
name=demux-{name} | ||
""".format(name=name, | ||
host=Config.getHost(), | ||
port=port) | ||
|
||
# add an Audio-Path through a level-Element | ||
pipe += """ | ||
demux-{name}. | ||
! queue | ||
name=queue-audio-{name} | ||
! level | ||
name=lvl | ||
interval=50000000 | ||
! audioconvert | ||
""" | ||
|
||
# If Playback is requested, push fo pulseaudio | ||
if play_audio: | ||
pipe += """ ! pulsesink | ||
name=audiosink-{name} | ||
""" | ||
else: | ||
pipe += """ ! fakesink | ||
""" | ||
pipe = pipe.format(name=name, | ||
acaps=Config.getAudioCaps(), | ||
port=port, | ||
) | ||
|
||
self.log.info("Creating Display-Pipeline:\n%s", pretty(pipe)) | ||
try: | ||
# launch gstreamer pipeline | ||
self.pipeline = Gst.parse_launch(pipe) | ||
self.log.info("pipeline launched successfuly") | ||
except: | ||
self.log.error("Can not launch pipeline") | ||
sys.exit(-1) | ||
|
||
if Args.dot: | ||
self.log.debug("Generating DOT image of audioonlydisplay pipeline") | ||
gst_generate_dot(self.pipeline, "gui.audioonlydisplay.{}".format(name)) | ||
|
||
self.pipeline.use_clock(Clock) | ||
|
||
bus = self.pipeline.get_bus() | ||
bus.add_signal_watch() | ||
|
||
bus.connect('message::error', self.on_error) | ||
bus.connect("message::element", self.on_level) | ||
|
||
self.log.info("Launching Display-Pipeline") | ||
self.pipeline.set_state(Gst.State.PLAYING) | ||
|
||
def on_error(self, bus, message): | ||
(error, debug) = message.parse_error() | ||
self.log.error( | ||
"GStreamer pipeline element '%s' signaled an error #%u: %s" % (message.src.name, error.code, error.message)) | ||
|
||
def mute(self, mute): | ||
self.pipeline.get_by_name("audiosink-{name}".format(name=self.name)).set_property( | ||
"volume", 1 if mute else 0) | ||
|
||
def on_level(self, bus, msg): | ||
if self.level_callback and msg.src.name == 'lvl': | ||
rms = msg.get_structure().get_value('rms') | ||
peak = msg.get_structure().get_value('peak') | ||
decay = msg.get_structure().get_value('decay') | ||
self.level_callback(rms, peak, decay) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, this is inverted (but also inverted in
videodisplay.py
, so let's keep this here as well).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh, this is just a quick workaround - a better long-term solution would probably be for videodisplay to handle optional audio or optional video itself.