Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #35 from fwestenberg/RTMP-password-option
Browse files Browse the repository at this point in the history
RTMP password option
  • Loading branch information
fwestenberg authored Jul 21, 2021
2 parents fabe24a + d30c386 commit 1b5c938
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion reolink/camera_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DEFAULT_CHANNEL = 0
DEFAULT_TIMEOUT = 30
DEFAULT_STREAM_FORMAT = "h264"
DEFAULT_STREAM_USE_PASS = True

_LOGGER = logging.getLogger(__name__)

Expand All @@ -35,6 +36,7 @@ def __init__(
stream=DEFAULT_STREAM,
timeout=DEFAULT_TIMEOUT,
stream_format=DEFAULT_STREAM_FORMAT,
stream_use_pass=DEFAULT_STREAM_USE_PASS,
):
"""Initialize the API class."""
self._url = f"http://{host}:{port}/cgi-bin/api.cgi"
Expand All @@ -46,6 +48,7 @@ def __init__(
self._stream = stream
self._protocol = protocol
self._stream_format = stream_format
self._stream_use_pass = stream_use_pass
self._timeout = aiohttp.ClientTimeout(total=timeout)

self._token = None
Expand Down Expand Up @@ -434,7 +437,10 @@ async def get_stream_source(self):
return

if self.protocol == DEFAULT_PROTOCOL:
stream_source = f"rtmp://{self._host}:{self._rtmp_port}/bcs/channel{self._channel}_{self._stream}.bcs?channel={self._channel}&stream=0&token={self._token}"
if self.stream_use_pass == DEFAULT_STREAM_USE_PASS:
stream_source = f"rtmp://{self._host}:{self._rtmp_port}/bcs/channel{self._channel}_{self._stream}.bcs?channel={self._channel}&stream=0&user={self._username}&password={self._password}"
else:
stream_source = f"rtmp://{self._host}:{self._rtmp_port}/bcs/channel{self._channel}_{self._stream}.bcs?channel={self._channel}&stream=0&token={self._token}"
else:
password = parse.quote(self._password)
channel = "{:02d}".format(self._channel + 1)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setup(
name = 'reolink',
packages = ['reolink'],
version = '0.0.19',
version = '0.0.20',
license='MIT',
description = 'Reolink camera package',
author = 'fwestenberg',
Expand Down

0 comments on commit 1b5c938

Please sign in to comment.