Skip to main content

Python wrapper for libssp

Project description

Introduction

Python wrapper for 'libssp' library which is a c++ library developed by Z CAM

if you want to know more about 'libssp', please visit C++ libssp

For now, 'pylibssp' is only tested on Windows 11 64bit, but all source code should be platform independent. I will try to support linux and mac in the future.

project folder

'pylibssp' project folder structure is as follows:

pylibssp/
├── libssp/
│   ├── __init__.py
│   ├── _libssp.cpp             ← pybind11 c++ extension implementation
│   ├── sspclient.py            ← python wrapper
│   ├── include/                ← libssp c++ headers,used for compiling
│   └── lib/                    ← .lib/.a/.dll files,used for compiling
├── docs/ 
│   ├── api.md                  ← python sspclient class api document
├── test/
│   ├── example.py              ← example code for demonstration
├── pyproject.toml              ← configuration
├── setup.cfg                   ← setup configuration
├── setup.py                    ← setup script     
└── MANIFEST.in                 ← manifest file
└── README.md                   ← this file

Build and test from source code

If you want to build python 'libssp' from source code, please make sure the build environment :

  • Windows 10(11) 64bit (My current build environment)

    • Visual Studio 2017 (or later) with C++ build tools installed\
    • Python 3.11 (or later)
  • Linux (will be confirmed in future)

    • gcc 11 (or later)\
    • python 3.11 (or later)
  • Mac (will be confirmed in future)

    • Xcode 14 (or later)\
    • python 3.11 (or later)

then follow the steps below:

  1. make a project folder in your computer and clone this repo

    mkdir pylibssp
    cd pylibssp
    git clone https://github.com/Jack-vexel-ws/pylibssp.git
    
  2. install dependencies

    pip install -r requirements.txt
    
  3. build and install libssp to current environment

    pip install . --no-build-isolation -v
    

If no any error occurs, you should be able to import 'libssp' in your python code now.

Test

After building 'libssp' successfully, you can test it by running the example code in 'pylibssp/test' folder.

cd pylibssp/test
python example.py

according to prompt to input your camera IP and select stream index, then streaming should start. You will see the video and audio meta data and streaming data from the callback functions. 'Example.py' print these data to console.

Rebuild or clean

# uninstall libssp
python -m pip uninstall libssp -y
python setup.py clean -all

# build and install again
pip install . --no-build-isolation -v

Usage

If you did not want to build from source code, you can install 'libssp' by pip directly.

Open a command prompt in windows and run

pip install libssp

In your python code, import 'libssp' and create your 'SspClient' instance.

'SspClient' Python API is similar to 'libssp' c++ library, please refer to API documents in 'pylibssp/docs' folder for more details.

Here is a code example:

import libssp

client = libssp.SspClient(camera_ip, 0x400000, 9999, libssp.STREAM_DEFAULT)

# Set callback functions
client.on_h264_data = on_h264_data
client.on_audio_data = on_audio_data
client.on_meta = on_meta
client.on_disconnected = on_disconnected
client.on_connected = on_connected
client.on_exception = on_exception
client.on_recv_buffer_full = on_recv_buffer_full

# Set HLG mode if needed
client.is_hlg = False

# Start client
client.start()

... do something

# Stop client
client.stop()

NOTE

If you want to streaming zcam camera, you must set the stream index 0 or 1 and to be sure its streaming status is 'idle'. In Example.py, there is sample code to show how to set the stream index and how to sure the streaming status is 'Idle'.

set the stream index (0 or 1) http command

http://192.168.1.100/ctrl/set?send_stream=Stream0
or
http://192.168.1.100/ctrl/set?send_stream=Stream1

query the streaming status http command

http://192.168.1.100/ctrl/stream_setting?index=stream0&action=query

if you want to setting camera or its streaming parameters, please refer to the ZCAM offical HTTP API Document

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

libssp-0.1.0-cp313-cp313-win_amd64.whl (205.5 kB view details)

Uploaded CPython 3.13Windows x86-64

libssp-0.1.0-cp312-cp312-win_amd64.whl (205.4 kB view details)

Uploaded CPython 3.12Windows x86-64

libssp-0.1.0-cp311-cp311-win_amd64.whl (205.7 kB view details)

Uploaded CPython 3.11Windows x86-64

libssp-0.1.0-cp310-cp310-win_amd64.whl (205.0 kB view details)

Uploaded CPython 3.10Windows x86-64

libssp-0.1.0-cp39-cp39-win_amd64.whl (205.2 kB view details)

Uploaded CPython 3.9Windows x86-64

File details

Details for the file libssp-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: libssp-0.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 205.5 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for libssp-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f7224467874c489fcba2592a45c7e63d362f9b13c938e1732462f4da787f4aa0
MD5 d3093816d9cb98c894721ec1774f92fd
BLAKE2b-256 a3f607c9ae619c1ef01f3a10e94c2388c0754983e2aa5ed97b97d3a5a33a83e3

See more details on using hashes here.

File details

Details for the file libssp-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: libssp-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 205.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for libssp-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3707290877878391c5a3b1ebfaacabc76a09c89b7df72091692d3369af0f97d0
MD5 2aa75b8cc353c09ed5979f891b619cb3
BLAKE2b-256 24e233bc271c61d49a417b394983a485c43c75663867d9ce6f592ddfd14cb62f

See more details on using hashes here.

File details

Details for the file libssp-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: libssp-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 205.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for libssp-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 050eb53f3b200df5544440a93753e0000f58b01e015c4991f993f98093ead3d3
MD5 7161c7e25a2b66f198cb9cb6a512fd03
BLAKE2b-256 bf18d1cbd2fc10c46df1554f7d58b1862922431e0bd17cfcf4c335184d7a8dfd

See more details on using hashes here.

File details

Details for the file libssp-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: libssp-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 205.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for libssp-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b07d85871ebbf013ec9fbdfb96e0ec4e7e35a52bf2307bccb183f514c885eed9
MD5 066aee53ea2d4f79085e70fb1e421d51
BLAKE2b-256 9a62457ea6c2ee3e9b1849e51a188dd58758ec4ea93da1033c03c73f0438d118

See more details on using hashes here.

File details

Details for the file libssp-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: libssp-0.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 205.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for libssp-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7c27ddf7143211947008af5e98c62cca49ce3fcfca309400715e7641b85f9c0b
MD5 14830cb9df3c5375bdba449cd77ccf88
BLAKE2b-256 3d1ad6723c1978bd6bb9ac7c5e29ca8a26bf89181c4c801b48aee121cdd15502

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page