aboutsummaryrefslogtreecommitdiff
path: root/bin/arctica-testclient-gst
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-06-27 09:42:57 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-06-27 09:42:57 +0200
commitd7a4e3b79f7b000968f175cfd173017ce3f35676 (patch)
tree2b3378ddc757de16f4306e72591727cba877da4b /bin/arctica-testclient-gst
parent7ace0717361f455f244738f4c34ac4677beecfd0 (diff)
downloadperl-Arctica-Services-Audio-Streamer-ClientGST-d7a4e3b79f7b000968f175cfd173017ce3f35676.tar.gz
perl-Arctica-Services-Audio-Streamer-ClientGST-d7a4e3b79f7b000968f175cfd173017ce3f35676.tar.bz2
perl-Arctica-Services-Audio-Streamer-ClientGST-d7a4e3b79f7b000968f175cfd173017ce3f35676.zip
arctica-testclient-gst: Rename from arctica-testclient-ClientGST.
Diffstat (limited to 'bin/arctica-testclient-gst')
-rwxr-xr-xbin/arctica-testclient-gst175
1 files changed, 175 insertions, 0 deletions
diff --git a/bin/arctica-testclient-gst b/bin/arctica-testclient-gst
new file mode 100755
index 0000000..d860266
--- /dev/null
+++ b/bin/arctica-testclient-gst
@@ -0,0 +1,175 @@
+#!/usr/bin/perl -T
+################################################################################
+# _____ _
+# |_ _| |_ ___
+# | | | ' \/ -_)
+# |_| |_||_\___|
+# _ _ ____ _ _
+# / \ _ __ ___| |_(_) ___ __ _ | _ \ _ __ ___ (_) ___ ___| |_
+# / _ \ | '__/ __| __| |/ __/ _` | | |_) | '__/ _ \| |/ _ \/ __| __|
+# / ___ \| | | (__| |_| | (_| (_| | | __/| | | (_) | | __/ (__| |_
+# /_/ \_\_| \___|\__|_|\___\__,_| |_| |_| \___// |\___|\___|\__|
+# |__/
+# The Arctica Modular Remote Computing Framework
+#
+################################################################################
+#
+# Copyright (C) 2015-2016 The Arctica Project
+# http://arctica-project.org/
+#
+# This code is dual licensed: strictly GPL-2 or AGPL-3+
+#
+# GPL-2
+# -----
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+#
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# AGPL-3+
+# -------
+# This programm is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This programm is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Copyright (C) 2015-2017 Guangzhou Nianguan Electronics Technology Co.Ltd.
+# <opensource@gznianguan.com>
+# Copyright (C) 2015-2017 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
+#
+################################################################################
+use strict;
+use Data::Dumper;
+use Arctica::Core::eventInit qw(genARandom BugOUT);
+use Arctica::Core::JABus::Socket;
+use Arctica::Services::Audio::Streamer::ClientGST;
+
+
+my $ACO = Arctica::Core::eventInit->new({
+ app_name=>'audio-client-test',
+ app_class =>'amoduletester',
+ app_version=>'0.0.1.1'});
+
+my $ClientGST = Arctica::Services::Audio::Streamer::ClientGST->new($ACO);
+
+################################################################################
+# Just some stuff to fetch Socket ID from either ARGV or STDIN
+# Watch the log output from server to see what ID the server is.
+my $argsoc;
+
+if (@ARGV) {
+ foreach my $arg (@ARGV) {
+ BugOUT(8,"ARG:\t$arg\t:ARG\n");
+
+ if ($arg =~ /^\-ctrl_soc=([a-zA-Z0-9]{16,128})/) {
+ $argsoc = $1;
+ } elsif ($arg =~ /^\-dgst_soc_port\=([io]\d*)\:(\d*)$/) {# FIXME by the time we're doing something with unix sockets this will be looooooong gone...
+ $ClientGST->set_device_gst_port($1,$2);
+ } elsif ($arg =~ /^\-dgst_soc_type\=([a-z]{3,5})/) {
+ $ClientGST->set_device_socket_type($1);
+ }
+
+ }
+} else {
+ BugOUT(0,"NO ARGS?");
+}
+
+
+if ($argsoc =~ /^([a-zA-Z0-9]{16,128})$/) {
+ $argsoc = $1;
+} else {
+ print "SOCKET_ID:\t";
+ $argsoc = <STDIN>;$argsoc =~ s/[\ \n]//g;
+ if ($argsoc =~ /^([a-zA-Z0-9]{16,128})$/) {
+ $argsoc = $1;
+ } else {
+ die;
+ }
+}
+print "CONNECTING TO SOCKET ID: $argsoc\n";
+#
+################################################################################
+
+
+my $JABusClient = Arctica::Core::JABus::Socket->new($ACO,{
+ type => "unix",
+ destination => "local",
+ is_client => 1,
+ connect_to => $argsoc,
+ handle_in_dispatch => {
+# heartbeat => \&heartbeat, #FIXME heartbeat will be intergrated in RTT and persistency code in JABus...
+ gstctl => \&gstctl_handler,
+ },
+ hooks => {
+ on_ready => \&my_on_ready,
+ },
+
+});
+
+
+$ACO->{'Glib'}{'MainLoop'}->run;
+
+
+sub gstctl_handler {
+ my $JDATA = $_[0];
+ my $laSock = $_[1];
+
+ if ($JDATA->{'action'} eq "start") {
+ BugOUT(8,"JACTION IS START");
+ if ($JDATA->{'type'} eq "output") {
+ $ClientGST->start_output($JDATA->{'idnum'},sub {
+ BugOUT(1,"SINK READY!");
+ $JABusClient->client_send("gstctl",{
+ action => "ready",
+ type => "output",
+ idnum => $JDATA->{'idnum'},
+ });
+ });
+
+ } elsif ($JDATA->{'type'} eq "input") {
+ $ClientGST->start_input($JDATA->{'idnum'},$JDATA->{'bitrate'});
+ }
+
+ } elsif ($JDATA->{'action'} eq "stop") {
+ BugOUT(8,"JACTION IS STOP");
+ if ($JDATA->{'type'} eq "output") {
+ $ClientGST->stop_output($JDATA->{'idnum'});
+ } elsif ($JDATA->{'type'} eq "input") {
+ $ClientGST->stop_input($JDATA->{'idnum'});
+ }
+
+ } elsif ($JDATA->{'action'} eq "ch_input_bitrate") {
+ if ($JDATA->{'bitrate'} =~ /^(\d{1,})/) {
+ BugOUT(1,"CHBITRATE: $1");
+ $ClientGST->set_bitrate($1);
+ }
+ }
+}
+
+#sub notify_gst_sink_ready
+
+sub my_on_ready {
+ print "YAY READY ($_[0])\n";
+ $JABusClient->client_send('init',time);
+}
+