Skip to content

Latest commit

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Stream router library

Simple library intended to group all stream routing algorithms used throughout the CDN.

Installation

Add the following line into you requirements.txt:

git+https://github.com/angelcam/python-stream-router-lib.git@v7.3.0#egg=streamrouter

and run pip3 install -r requirements.txt.

Usage

Here is a simple usage example:

fromstreamrouterimportStreamRouter, CamerafromstreamrouterimportRouterConfig
...
# stream router configurationconfig=RouterConfig()
config.consul_host='consul'config.consul_port=8500config.rtspcon_secret='secret'config.mjpeg_proxy_secret='secret'# create a new stream routerrouter=StreamRouter(config)
# it might be a good idea to log exceptions ;)# you can use the event to wait until the router gets initializeddefupdated():
ex=router.exception()
ifexisnotNone:
print(ex)
router.add_update_callback(updated)
# get rtspcon service for a given cameramaster=router.assign_rtspcon_service('eu', Camera(5))
# get rtspcon service for a given Arrow cameramaster=router.assign_rtspcon_service('eu', Camera(
'10',
setup=Camera.ARROW,
arrow_uuid='1234567890abcdef'
))
# get Arrow ASNS service for a given Arrow clientasns=router.assign_arrow_asns_service('eu', '1234567890abcdef')
...
# get HLS edge URL for a given cameraroute=router.construct_edge_route('eu', Camera(
'preview-10',
setup=Camera.ARROW,
arrow_uuid='1234567890abcdef'),
)
url=route.hls_url# get rtsp_con URL for a given cameraroute=router.construct_rtspcon_route('eu', Camera(
'10',
setup=Camera.ARROW,
arrow_uuid='1234567890abcdef')
)
route.hls_urlroute.mp4_urlroute.mjpeg_urlroute.snapshot_url

See the StreamRouter, Camera and XXXRoute docs for all available methods and fields. The assign_xxx_service() methods return instances of the XXXService class. The construct_XXX_route() methods return instances of the XXXRoute classes.

Important note: the stream router does not re-map continent codes as the RTSP router does. Routing decision will be always made within a given region (if possible).

Development

  • Before each commit, make sure that all tests are passing and that there are no syntax errors. Use the the following commands: py.test and flake8.
  • In order to release a new version, change the package version in setup.py and tag the version in the git repository.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages