Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: timvideos/gst-switch
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 42cdae47d12e
Choose a base ref
...
head repository: timvideos/gst-switch
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 47600c7db2ea
Choose a head ref
  • 5 commits
  • 21 files changed
  • 2 contributors

Commits on Jan 23, 2015

  1. Remove unused TCP-Server

    MaZderMind committed Jan 23, 2015
    Copy the full SHA
    b5dd6ee View commit details
  2. Allow specifying an DBus-Address on the Command-Line

    Default to tCP on 127.0.0.1:5000
    MaZderMind committed Jan 23, 2015
    Copy the full SHA
    31140d1 View commit details
  3. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    d9507d3 View commit details
  4. Set an DBus-Connection-String on the Server instead of just a Port

    This way one could ie. decide to use encrypted TCP for the Control-Connection
    MaZderMind committed Jan 23, 2015
    Copy the full SHA
    de77871 View commit details

Commits on Jan 25, 2015

  1. Merge pull request #183 from MaZderMind/dbus-tcp

    Dbus tcp
    mithro committed Jan 25, 2015
    Copy the full SHA
    47600c7 View commit details
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ Application Options:
-r, --record=FILENAME Enable recorder and record into the specified FILENAME
-p, --video-input-port=NUM Specify the video input listen port.
-a, --audio-input-port=NUM Specify the audio input listen port.
--control-port=NUM Specify the control port.
-c, --controller-address=ADDRESS Specify DBus-Address for remote control, defaults to tcp:host=0.0.0.0,port=5000.
```

### Video Input
4 changes: 2 additions & 2 deletions python-api/gstswitch/connection.py
Original file line number Diff line number Diff line change
@@ -15,15 +15,15 @@ class Connection(object):
"""Class which makes all remote object class.
Deals with lower level connection and remote method invoking
:default bus-address: unix:abstract=gstswitch
:default bus-address: tcp:host=127.0.0.1,port=5000
:param: None
"""
CONNECTION_FLAGS = Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT

def __init__(
self,
address="unix:abstract=gstswitch",
address="tcp:host=127.0.0.1,port=5000",
bus_name='info.duzy.gst.switch.SwitchController',
object_path="/info/duzy/gst/switch/SwitchController",
default_interface=("info.duzy.gst.switch."
2 changes: 1 addition & 1 deletion python-api/gstswitch/controller.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ class Controller(object):

def __init__(
self,
address="unix:abstract=gstswitch",
address="tcp:host=127.0.0.1,port=5000",
bus_name='info.duzy.gst.switch.SwitchController',
object_path="/info/duzy/gst/switch/SwitchController",
default_interface="info.duzy.gst.switch.SwitchControllerInterface"
54 changes: 28 additions & 26 deletions python-api/gstswitch/server.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,8 @@ class Server(object):
By default looks in the current $PATH.
:param video_port: The video port number - default = 3000
:param audio_port: The audio port number - default = 4000
:param control_port: The control port number - default = 5000
:param controller_address: The DBus-Address for remote control -
default = tcp:host=0.0.0.0,port=5000
:param record_file: The record file format
:returns: nothing
"""
@@ -39,22 +40,22 @@ def __init__(
path=None,
video_port=3000,
audio_port=4000,
control_port=5000,
controller_address='tcp:host=0.0.0.0,port=5000',
record_file=False):

super(Server, self).__init__()

self._path = None
self._video_port = None
self._audio_port = None
self._control_port = None
self._controller_address = None
self._record_file = None
self.gst_option_string = ''

self.path = path
self.video_port = video_port
self.audio_port = audio_port
self.control_port = control_port
self.controller_address = controller_address
self.record_file = record_file

self.proc = None
@@ -125,31 +126,32 @@ def audio_port(self, audio_port):
" not '{0}'".format(type(audio_port)))

@property
def control_port(self):
def controller_address(self):
"""Get the control port"""
return self._control_port

@control_port.setter
def control_port(self, control_port):
"""Set Control Port
:raises ValueError: Control Port cannot be left blank
:raises ValueError: Control Port must be in range 1 to 65535
:raises TypeError: Control Port must be a string or a number
return self._controller_address

@controller_address.setter
def controller_address(self, controller_address):
"""Set Control Address
:raises ValueError: Control Address cannot be left blank
:raises ValueError: Control Address must contain at least one Colon
:raises TypeError: Control Address must be a string
"""
if not control_port:
raise ValueError("Control Port '{0}' cannot be blank"
.format(control_port))
if not controller_address:
raise ValueError("Control Address '{0}' cannot be blank"
.format(controller_address))
else:
if not isinstance(controller_address, basestring):
raise TypeError("Control Address must be a string,"
" not '{0}'".format(type(controller_address)))

try:
i = int(control_port)
if i < 1 or i > 65535:
raise ValueError(
'Control Port must be in range 1 to 65535')
else:
self._control_port = control_port
except TypeError:
raise TypeError("Control Port must be a string or a number,"
" not '{0}'".format(type(control_port)))
controller_address.index(':')
self._controller_address = controller_address
except ValueError:
raise ValueError("Control Address must contain at least "
" one Colon. It is '{0}'" \
.format(controller_address))

@property
def record_file(self):
@@ -215,7 +217,7 @@ def _run_process(self):
cmd += [self.gst_option_string]
cmd.append("--video-input-port={0}".format(self.video_port))
cmd.append("--audio-input-port={0}".format(self.audio_port))
cmd.append("--control-port={0}".format(self.control_port))
cmd.append("--controller-address={0}".format(self.controller_address))
if self.record_file is False:
pass
elif self.record_file is True:
2 changes: 1 addition & 1 deletion python-api/scripts/dbusConnect.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ def main():
loop.run()

if __name__=="__main__":
os.environ["DBUS_SESSION_BUS_ADDRESS"] = "unix:abstract=gstswitch"
os.environ["DBUS_SESSION_BUS_ADDRESS"] = "tcp:host=127.0.0.1,port=5000"
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
main()

4 changes: 2 additions & 2 deletions python-api/scripts/dbusConnect.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
dbus-send \
--address="unix:abstract=gstswitch" \
--address="tcp:host=127.0.0.1,port=5000" \
--print-reply=literal \
--dest="info.duzy.gst_switch.SwitchClientInterface" \
/info/duzy/gst_switch/SwitchController \
info.duzy.gst_switch.SwitchControllerInterface.get_compose_port

gdbus introspect --address unix:abstract=gstswitch \
gdbus introspect --address tcp:host=127.0.0.1,port=5000 \
--dest info.duzy.gst.switch.SwitchUIInterface \
--object-path /info/duzy/gst/switch/SwitchUI
2 changes: 1 addition & 1 deletion python-api/scripts/dbusConnect2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from gi.repository import Gio, GLib
from time import sleep

address = "unix:abstract=gstswitch"
address = "tcp:host=127.0.0.1,port=5000"
name = None
object_path = "/info/duzy/gst/switch/SwitchController"

2 changes: 1 addition & 1 deletion python-api/scripts/dbusConnection3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from gi.repository import Gio, GLib
from time import sleep

address = "unix:abstract=gstswitch"
address = "tcp:host=127.0.0.1,port=5000"
name = None
object_path = "/info/duzy/gst/switch/SwitchController"

2 changes: 1 addition & 1 deletion python-api/tests/unittests/test_connection_unit.py
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ def test_address_colon(self):

def test_address_normal(self):
""""Test if address is valid"""
address = ['unix:abstract=gstswitch', 'unix:temp=/tmp/abcd/xyz']
address = ['tcp:host=127.0.0.1,port=5000', 'unix:temp=/tmp/abcd/xyz']
for addr in address:
conn = Connection(address=addr)
assert conn.address == addr
2 changes: 1 addition & 1 deletion python-api/tests/unittests/test_controller_unit.py
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ def test_address_colon(self):

def test_address_normal(self):
"""Test if address is valid"""
address = ['unix:abstract=gstswitch', 'unix:temp=/tmp/abcd/xyz']
address = ['tcp:host=127.0.0.1,port=5000', 'unix:temp=/tmp/abcd/xyz']
for addr in address:
conn = Controller(address=addr)
assert conn.address == addr
49 changes: 25 additions & 24 deletions python-api/tests/unittests/test_server_unit.py
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ def mock_method(arg):
serv._start_process = mock_method
assert serv._run_process() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000".split()
--controller-address=tcp:host=0.0.0.0,port=5000".split()

def test_path_provided_no_slash(self):
"""Test if a path is provided"""
@@ -41,7 +41,7 @@ def mock_method(arg):
serv._start_process = mock_method
assert serv._run_process() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000".split()
--controller-address=tcp:host=0.0.0.0,port=5000".split()

def test_path_empty(self, monkeypatch):
"""Test if null path is given"""
@@ -60,7 +60,7 @@ def mockreturn(path):
serv._start_process = mock_method
assert serv._run_process() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000".split()
--controller-address=tcp:host=0.0.0.0,port=5000".split()


class TestVideoPort(object):
@@ -119,32 +119,32 @@ def test_invalid_audio_port_range(self):
Server(path=PATH, audio_port=audio_port)


class TestControlPort(object):
class TestControllerAddress(object):

"""Test the control_port parameter"""
# Control Port Tests
"""Test the controller_address parameter"""
# Control Address Tests

def test_invalid_control_port_null(self):
def test_invalid_controller_address_null(self):
"""Test when the control port is null"""
control_ports = [None, '', [], {}]
for control_port in control_ports:
controller_addresses = [None, '', [], {}]
for controller_address in controller_addresses:
with pytest.raises(ValueError):
Server(path=PATH, control_port=control_port)
Server(path=PATH, controller_address=controller_address)

def test_invalid_control_port_type(self):
def test_invalid_controller_address_type(self):
"""Test when the control port is not a valid
integral value"""
control_ports = [[1, 2, 3], {1: 2, 2: 3}]
for control_port in control_ports:
controller_addresses = [[1, 2, 3], {1: 2, 2: 3}]
for controller_address in controller_addresses:
with pytest.raises(TypeError):
Server(path=PATH, control_port=control_port)
Server(path=PATH, controller_address=controller_address)

def test_invalid_control_port_range(self):
"""Test when the control port is not in range"""
control_ports = [-99, -1, 1e6]
for control_port in control_ports:
def test_invalid_controller_address_range(self):
"""Test when the control port does not contain a colon"""
controller_addresses = ['42', 'port=42', '127.0.0.1']
for controller_address in controller_addresses:
with pytest.raises(ValueError):
Server(path=PATH, control_port=control_port)
Server(path=PATH, controller_address=controller_address)


class TestRecordFile(object):
@@ -162,7 +162,7 @@ def mock_method(arg):
serv._start_process = mock_method
assert serv._run_process() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000".split()
--controller-address=tcp:host=0.0.0.0,port=5000".split()

def test_record_file_true(self):
"""Test if record file is True"""
@@ -174,7 +174,7 @@ def mock_method(arg):
serv._start_process = mock_method
assert serv._run_process() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000 -r".split()
--controller-address=tcp:host=0.0.0.0,port=5000 -r".split()

def test_record_file_valid(self):
"""Test if record file is valid"""
@@ -186,7 +186,7 @@ def mock_method(arg):
serv._start_process = mock_method
assert serv._run_process() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000 --record=record.data".split()
--controller-address=tcp:host=0.0.0.0,port=5000 --record=record.data".split()

def test_record_file_valid_date(self):
"""Test if record file is valid"""
@@ -198,7 +198,7 @@ def mock_method(arg):
serv._start_process = mock_method
assert serv._run_process() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000 \
--controller-address=tcp:host=0.0.0.0,port=5000 \
--record=record_%Y.data".split()

def test_record_file_valid_space(self):
@@ -211,7 +211,8 @@ def mock_method(arg):
serv._start_process = mock_method
assert serv._run_process() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000".split() + ["--record=record 1.data"]
--controller-address=tcp:host=0.0.0.0,port=5000".split() + \
["--record=record 1.data"]

def test_record_file_invalid(self):
"""Test when the record_file is invalid"""
2 changes: 1 addition & 1 deletion tests/test_switch_server.c
Original file line number Diff line number Diff line change
@@ -1032,7 +1032,7 @@ testclient_run (gpointer data)
client->mainloop = g_main_loop_new (NULL, TRUE);

connect_ok =
gst_switch_client_connect (GST_SWITCH_CLIENT (client), CLIENT_ROLE_UI);
gst_switch_client_connect (GST_SWITCH_CLIENT (client), CLIENT_ROLE_UI, "tcp:host=127.0.0.1,port=5000");
g_assert (connect_ok);

client->compose_port0 =
2 changes: 1 addition & 1 deletion tools/gst-switch-srv.sh
Original file line number Diff line number Diff line change
@@ -9,5 +9,5 @@
--gst-debug="multiqueue:0" \
--video-input-port="3000" \
--audio-input-port="4000" \
--control-port="5000" \
--controller-address="tcp:host=0.0.0.0,port=5000" \
--record="record.dat"
6 changes: 5 additions & 1 deletion tools/gstswitchcapture.c
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@
#define GST_SWITCH_CAPTURE_WORKER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), GST_TYPE_SWITCH_CAPTURE_WORKER, GstSwitchCaptureWorkerClass))
#define GST_IS_SWITCH_CAPTURE_WORKER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GST_TYPE_SWITCH_CAPTURE_WORKER))
#define GST_IS_SWITCH_CAPTURE_WORKER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), GST_TYPE_SWITCH_CAPTURE_WORKER))
#define GST_SWITCH_CAPTURE_DEFAULT_ADDRESS "tcp:host=127.0.0.1,port=5000"

/**
* @class GstSwitchCaptureWorker
@@ -80,6 +81,7 @@ G_DEFINE_TYPE (GstSwitchCaptureWorker, gst_switch_capture_worker,
gboolean verbose = FALSE;
const char *device = "/dev/ttyUSB0";
const char *protocol = "visca";
const char *srv_address = GST_SWITCH_CAPTURE_DEFAULT_ADDRESS;
const char **srcsegments = NULL;
int srcsegmentc = 0;

@@ -89,6 +91,8 @@ static GOptionEntry options[] = {
"PTZ camera control device", "DEVICE"},
{"protocol", 'p', 0, G_OPTION_ARG_STRING, &protocol,
"PTZ camera control protocol", "NAME"},
{"address", 'a', 0, G_OPTION_ARG_STRING, &srv_address,
"Server Control-Adress, defaults to " GST_SWITCH_CAPTURE_DEFAULT_ADDRESS, NULL},
{NULL}
};

@@ -228,7 +232,7 @@ static void
gst_switch_capture_run (GstSwitchCapture * capture)
{
if (!gst_switch_client_connect (GST_SWITCH_CLIENT (capture),
CLIENT_ROLE_CAPTURE)) {
CLIENT_ROLE_CAPTURE, srv_address)) {
ERROR ("failed to connect to controller");
return;
}
Loading