From 9ed62d4414897fc8c55e26480ad2ab59bebae4a0 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Thu, 28 Jul 2016 23:21:57 +0300 Subject: [PATCH] travis --- .travis.yml | 31 +++++++++++++++++++++++++++++++ tests/travis.py | 4 ++++ toxygen/toxav.py | 35 +++++++++++++++++------------------ toxygen/toxencryptsave.py | 3 +-- 4 files changed, 53 insertions(+), 20 deletions(-) create mode 100644 .travis.yml create mode 100644 tests/travis.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5bd30bb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +language: python +python: + - "3.4" +before_install: + - sudo apt-get install -y checkinstall build-essential + - sudo apt-get install portaudio19-dev +install: + - pip install PySide --no-index --find-links https://parkin.github.io/python-wheelhouse/; + - python ~/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pyside_postinstall.py -install + - pip install pyaudio +before_script: +# Libsodium + - git clone git://github.com/jedisct1/libsodium.git + - cd libsodium + - git checkout tags/1.0.3 + - ./autogen.sh + - ./configure && make -j$(nproc) + - sudo checkinstall --install --pkgname libsodium --pkgversion 1.0.0 --nodoc -y + - sudo ldconfig + - cd .. +# Toxcore + - git clone https://github.com/irungentoo/toxcore.git + - cd toxcore + - autoreconf -if + - ./configure + - make -j$(nproc) + - sudo make install + - echo '/usr/local/lib/' | sudo tee -a /etc/ld.so.conf.d/locallib.conf + - sudo ldconfig + - cd .. +script: py.test tests/travis.py diff --git a/tests/travis.py b/tests/travis.py new file mode 100644 index 0000000..fe72338 --- /dev/null +++ b/tests/travis.py @@ -0,0 +1,4 @@ +class TestToxygen: + + def test_main(self): + import toxygen.main \ No newline at end of file diff --git a/toxygen/toxav.py b/toxygen/toxav.py index a9f46b3..0ab891c 100644 --- a/toxygen/toxav.py +++ b/toxygen/toxav.py @@ -12,8 +12,6 @@ class ToxAV: peers. """ - libtoxav = LibToxAV() - # ----------------------------------------------------------------------------------------------------------------- # Creation and destruction # ----------------------------------------------------------------------------------------------------------------- @@ -24,9 +22,10 @@ class ToxAV: :param tox_pointer: pointer to Tox instance """ + self.libtoxav = LibToxAV() toxav_err_new = c_int() - ToxAV.libtoxav.toxav_new.restype = POINTER(c_void_p) - self._toxav_pointer = ToxAV.libtoxav.toxav_new(tox_pointer, byref(toxav_err_new)) + self.libtoxav.toxav_new.restype = POINTER(c_void_p) + self._toxav_pointer = self.libtoxav.toxav_new(tox_pointer, byref(toxav_err_new)) toxav_err_new = toxav_err_new.value if toxav_err_new == TOXAV_ERR_NEW['NULL']: raise ArgumentError('One of the arguments to the function was NULL when it was not expected.') @@ -48,7 +47,7 @@ class ToxAV: If any calls were ongoing, these will be forcibly terminated without notifying peers. After calling this function, no other functions may be called and the av pointer becomes invalid. """ - ToxAV.libtoxav.toxav_kill(self._toxav_pointer) + self.libtoxav.toxav_kill(self._toxav_pointer) def get_tox_pointer(self): """ @@ -56,8 +55,8 @@ class ToxAV: :return: pointer to the Tox instance """ - ToxAV.libtoxav.toxav_get_tox.restype = POINTER(c_void_p) - return ToxAV.libtoxav.toxav_get_tox(self._toxav_pointer) + self.libtoxav.toxav_get_tox.restype = POINTER(c_void_p) + return self.libtoxav.toxav_get_tox(self._toxav_pointer) # ----------------------------------------------------------------------------------------------------------------- # A/V event loop @@ -70,14 +69,14 @@ class ToxAV: :return: interval in milliseconds """ - return ToxAV.libtoxav.toxav_iteration_interval(self._toxav_pointer) + return self.libtoxav.toxav_iteration_interval(self._toxav_pointer) def iterate(self): """ Main loop for the session. This function needs to be called in intervals of toxav_iteration_interval() milliseconds. It is best called in the separate thread from tox_iterate. """ - ToxAV.libtoxav.toxav_iterate(self._toxav_pointer) + self.libtoxav.toxav_iterate(self._toxav_pointer) # ----------------------------------------------------------------------------------------------------------------- # Call setup @@ -97,7 +96,7 @@ class ToxAV: :return: True on success. """ toxav_err_call = c_int() - result = ToxAV.libtoxav.toxav_call(self._toxav_pointer, c_uint32(friend_number), c_uint32(audio_bit_rate), + result = self.libtoxav.toxav_call(self._toxav_pointer, c_uint32(friend_number), c_uint32(audio_bit_rate), c_uint32(video_bit_rate), byref(toxav_err_call)) toxav_err_call = toxav_err_call.value if toxav_err_call == TOXAV_ERR_CALL['OK']: @@ -131,7 +130,7 @@ class ToxAV: """ c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_bool, c_bool, c_void_p) self.call_cb = c_callback(callback) - ToxAV.libtoxav.toxav_callback_call(self._toxav_pointer, self.call_cb, user_data) + self.libtoxav.toxav_callback_call(self._toxav_pointer, self.call_cb, user_data) def answer(self, friend_number, audio_bit_rate, video_bit_rate): """ @@ -146,7 +145,7 @@ class ToxAV: :return: True on success. """ toxav_err_answer = c_int() - result = ToxAV.libtoxav.toxav_answer(self._toxav_pointer, c_uint32(friend_number), c_uint32(audio_bit_rate), + result = self.libtoxav.toxav_answer(self._toxav_pointer, c_uint32(friend_number), c_uint32(audio_bit_rate), c_uint32(video_bit_rate), byref(toxav_err_answer)) toxav_err_answer = toxav_err_answer.value if toxav_err_answer == TOXAV_ERR_ANSWER['OK']: @@ -184,7 +183,7 @@ class ToxAV: """ c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_void_p) self.call_state_cb = c_callback(callback) - ToxAV.libtoxav.toxav_callback_call_state(self._toxav_pointer, self.call_state_cb, user_data) + self.libtoxav.toxav_callback_call_state(self._toxav_pointer, self.call_state_cb, user_data) # ----------------------------------------------------------------------------------------------------------------- # Call control @@ -199,7 +198,7 @@ class ToxAV: :return: True on success. """ toxav_err_call_control = c_int() - result = ToxAV.libtoxav.toxav_call_control(self._toxav_pointer, c_uint32(friend_number), c_int(control), + result = self.libtoxav.toxav_call_control(self._toxav_pointer, c_uint32(friend_number), c_int(control), byref(toxav_err_call_control)) toxav_err_call_control = toxav_err_call_control.value if toxav_err_call_control == TOXAV_ERR_CALL_CONTROL['OK']: @@ -241,7 +240,7 @@ class ToxAV: 24000, or 48000. """ toxav_err_send_frame = c_int() - result = ToxAV.libtoxav.toxav_audio_send_frame(self._toxav_pointer, c_uint32(friend_number), + result = self.libtoxav.toxav_audio_send_frame(self._toxav_pointer, c_uint32(friend_number), cast(pcm, c_void_p), c_size_t(sample_count), c_uint8(channels), c_uint32(sampling_rate), byref(toxav_err_send_frame)) @@ -281,7 +280,7 @@ class ToxAV: :param v: V (Chroma) plane data. """ toxav_err_send_frame = c_int() - result = ToxAV.libtoxav.toxav_video_send_frame(self._toxav_pointer, c_uint32(friend_number), c_uint16(width), + result = self.libtoxav.toxav_video_send_frame(self._toxav_pointer, c_uint32(friend_number), c_uint16(width), c_uint16(height), c_char_p(y), c_char_p(u), c_char_p(v), byref(toxav_err_send_frame)) toxav_err_send_frame = toxav_err_send_frame.value @@ -328,7 +327,7 @@ class ToxAV: """ c_callback = CFUNCTYPE(None, c_void_p, c_uint32, POINTER(c_uint8), c_size_t, c_uint8, c_uint32, c_void_p) self.audio_receive_frame_cb = c_callback(callback) - ToxAV.libtoxav.toxav_callback_audio_receive_frame(self._toxav_pointer, self.audio_receive_frame_cb, user_data) + self.libtoxav.toxav_callback_audio_receive_frame(self._toxav_pointer, self.audio_receive_frame_cb, user_data) def callback_video_receive_frame(self, callback, user_data): """ @@ -360,4 +359,4 @@ class ToxAV: c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint16, c_uint16, POINTER(c_uint8), POINTER(c_uint8), POINTER(c_uint8), c_int32, c_int32, c_int32, c_void_p) self.video_receive_frame_cb = c_callback(callback) - ToxAV.libtoxav.toxav_callback_video_receive_frame(self._toxav_pointer, self.video_receive_frame_cb, user_data) + self.libtoxav.toxav_callback_video_receive_frame(self._toxav_pointer, self.video_receive_frame_cb, user_data) diff --git a/toxygen/toxencryptsave.py b/toxygen/toxencryptsave.py index 14d3aee..e420ecf 100644 --- a/toxygen/toxencryptsave.py +++ b/toxygen/toxencryptsave.py @@ -36,10 +36,9 @@ TOX_PASS_ENCRYPTION_EXTRA_LENGTH = 80 class ToxEncryptSave(util.Singleton): - libtoxencryptsave = libtox.LibToxEncryptSave() - def __init__(self): super().__init__() + self.libtoxencryptsave = libtox.LibToxEncryptSave() self._passphrase = None def set_password(self, passphrase):