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: 22339e30e2c2
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: 40d9c62a124b
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Jan 16, 2015

  1. Verified

    This commit was signed with the committer’s verified signature.
    eramongodb Ezra Chung
    Copy the full SHA
    1558366 View commit details
  2. Merge pull request #153 from hyades/rename_api

    More verbose names for composite modes and switch.
    mithro committed Jan 16, 2015
    Copy the full SHA
    40d9c62 View commit details
Showing with 41 additions and 13 deletions.
  1. +19 −3 python-api/gstswitch/controller.py
  2. +18 −6 python-api/tests/integrationtests/test_controller.py
  3. +4 −4 python-api/tests/unittests/test_controller_unit.py
22 changes: 19 additions & 3 deletions python-api/gstswitch/controller.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,13 @@ class Controller(object):
:param: None
"""
COMPOSITE_NONE = 0
COMPOSITE_PIP = 1
COMPOSITE_DUAL_PREVIEW = 2
COMPOSITE_DUAL_EQUAL = 3
VIDEO_CHANNEL_A = ord('A')
VIDEO_CHANNEL_B = ord('B')
AUDIO_CHANNEL = ord('a')

def __init__(
self,
@@ -206,14 +213,20 @@ def get_preview_ports(self):
'Should return a GVariant tuple')

def set_composite_mode(self, mode):
"""Set the current composite mode. Modes between 0 and 3 are allowed.
"""Set the current composite mode.
Modes allowed are:
- COMPOSITE_NONE
- COMPOSITE_PIP
- COMPOSITE_DUAL_PREVIEW
- COMPOSITE_DUAL_EQUAL
:param mode: new composite mode
:returns: True when requested
"""
self.establish_connection()
# only modes from 0 to 3 are supported
if mode >= 0 and mode <= 3:
res = None
if mode in range(0, 4):
try:
conn = self.connection.set_composite_mode(mode)
print conn
@@ -293,7 +306,10 @@ def adjust_pip(self, xpos, ypos, width, height):
def switch(self, channel, port):
"""Switch the channel to the target port
:param channel: The channel to be switched, 'A', 'B', 'a'
:param channel: The channel to be switched:
VIDEO_CHANNEL_A
VIDEO_CHANNEL_B
AUDIO_CHANNEL
:param port: The target port number
:returns: True when requested
"""
24 changes: 18 additions & 6 deletions python-api/tests/integrationtests/test_controller.py
Original file line number Diff line number Diff line change
@@ -306,7 +306,8 @@ def set_composite_mode(self, mode, generate_frames=False):
sources.terminate_video()
serv.terminate(1)
if not generate_frames:
if mode == 3:
controller = Controller()
if mode == Controller.COMPOSITE_DUAL_EQUAL:
assert res is False
else:
assert res is True
@@ -343,10 +344,21 @@ def verify_output(self, mode, video):
return True
return False

def test_set_composite_mode(self):
def test_set_composite_mode_none(self):
"""Test set_composite_mode"""
for i in range(4):
self.set_composite_mode(i)
self.set_composite_mode(Controller.COMPOSITE_NONE)

def test_set_composite_mode_pip(self):
"""Test set_composite_mode"""
self.set_composite_mode(Controller.COMPOSITE_PIP)

def test_set_composite_mode_preview(self):
"""Test set_composite_mode"""
self.set_composite_mode(Controller.COMPOSITE_DUAL_PREVIEW)

def test_set_composite_mode_equal(self):
"""Test set_composite_mode"""
self.set_composite_mode(Controller.COMPOSITE_DUAL_EQUAL)


class TestNewRecord(object):
@@ -421,7 +433,7 @@ def adjust_pip(self,
sources.new_test_video(pattern=4)
sources.new_test_video(pattern=5)
controller = Controller()
controller.set_composite_mode(1)
controller.set_composite_mode(Controller.COMPOSITE_PIP)
time.sleep(3)
res = controller.adjust_pip(xpos, ypos, width, heigth)
time.sleep(3)
@@ -513,7 +525,7 @@ def switch(self, channel, port, index):
def test_switch(self):
"""Test switch"""
dic = [
[65, 3004]
[Controller.VIDEO_CHANNEL_A, 3004]
]
start = 5
for i in range(start, 6):
8 changes: 4 additions & 4 deletions python-api/tests/unittests/test_controller_unit.py
Original file line number Diff line number Diff line change
@@ -284,14 +284,14 @@ def test_unpack(self):
controller.establish_connection = Mock(return_value=None)
controller.connection = MockConnection(True)
with pytest.raises(ConnectionReturnError):
controller.set_composite_mode(1)
controller.set_composite_mode(Controller.COMPOSITE_NONE)

def test_normal_unpack(self):
"""Test if valid"""
controller = Controller(address='unix:abstract=abcdef')
controller.establish_connection = Mock(return_value=None)
controller.connection = MockConnection(False)
assert controller.set_composite_mode(1) is True
assert controller.set_composite_mode(Controller.COMPOSITE_NONE) is True


class TestSetEncodeMode(object):
@@ -364,14 +364,14 @@ def test_unpack(self):
controller.establish_connection = Mock(return_value=None)
controller.connection = MockConnection(True)
with pytest.raises(ConnectionReturnError):
controller.switch(1, 2)
controller.switch(Controller.VIDEO_CHANNEL_A, 2)

def test_normal_unpack(self):
"""Test if valid"""
controller = Controller(address='unix:abstract=abcdef')
controller.establish_connection = Mock(return_value=None)
controller.connection = MockConnection(False)
assert controller.switch(1, 2) is True
assert controller.switch(Controller.VIDEO_CHANNEL_A, 2) is True


class TestClickVideo(object):