-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to completely skip RTSP Discovery in autodiscover() #47
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
01f08aa
Added option to completely skip rtsp discovery in autodiscover
honeytung c95bc22
Automatically reformatting code with black and isort
cd8f87f
Bumped version
honeytung d59cfa5
Changed AutoDiscoverModes name
honeytung 7123383
Modified AutodiscoverMode to have another option to completely disabl…
honeytung e9e6528
Automatically reformatting code with black and isort
2f201c6
Updated README.md
honeytung cb0be80
Changed disable to off to be more clear
honeytung 18f917f
Automatically reformatting code with black and isort
681a459
Updated README
honeytung dacd382
Fixed docstring error
honeytung d68f9fa
Changed CLI option name to use hyphens
honeytung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
import yaml | ||
|
||
from .exceptions import GrabError | ||
from .rtsp_discovery import AutodiscoverModes, RTSPDiscovery | ||
from .rtsp_discovery import AutodiscoverMode, RTSPDiscovery | ||
from .unavailable_module import UnavailableModule | ||
|
||
logger = logging.getLogger(__name__) | ||
|
@@ -273,24 +273,24 @@ def create_grabber(config: dict, autogenerate_name: bool = True, warmup_delay: f | |
return grabber | ||
|
||
@staticmethod | ||
def autodiscover( | ||
warmup_delay: float = 1.0, rtsp_discover_modes: AutodiscoverModes = AutodiscoverModes.light | ||
) -> dict: | ||
def autodiscover(warmup_delay: float = 1.0, rtsp_discover_mode: AutodiscoverMode = AutodiscoverMode.off) -> dict: | ||
"""Autodiscovers cameras and returns a dictionary of FrameGrabber objects | ||
|
||
warmup_delay (float, optional): The number of seconds to wait after creating the grabbers. USB | ||
cameras often need a moment to warm up before they can be used; grabbing frames too early | ||
might result in dark or blurry images. | ||
Defaults to 1.0. Only happens if there are any generic_usb cameras in the config list. | ||
|
||
rtsp_discover_modes (AutodiscoverModes, optional): Options to try different default credentials | ||
rtsp_discover_mode (AutodiscoverMode, optional): Options to try different default credentials | ||
stored in DEFAULT_CREDENTIALS for RTSP cameras. | ||
Consists of four options: | ||
disable: Disable guessing camera credentials. | ||
Consists of five options: | ||
off: No discovery. | ||
ip_only: Only discover the IP address of the camera. | ||
light: Only try first two usernames and passwords ("admin:admin" and no username/password). | ||
complete_fast: Try the entire DEFAULT_CREDENTIALS without delays in between. | ||
complete_slow: Try the entire DEFAULT_CREDENTIALS with a delay of 1 seconds in between. | ||
Defaults to AutodiscoverModes.light. | ||
Defaults to ip_only. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should 'Defaults to ip_only' be removed? It default to off, right? |
||
Defaults to off. | ||
""" | ||
autodiscoverable_input_types = ( | ||
InputTypes.REALSENSE, | ||
|
@@ -304,20 +304,22 @@ def autodiscover( | |
for input_type in autodiscoverable_input_types: | ||
logger.info(f"Autodiscovering {input_type} cameras...") | ||
|
||
# If the input type is RTSP and rtsp_discover_modes is provided, use RTSPDiscovery to find the cameras | ||
if input_type == InputTypes.RTSP: | ||
onvif_devices = RTSPDiscovery.discover_onvif_devices(auto_discover_modes=rtsp_discover_modes) | ||
for device in onvif_devices: | ||
for index, rtsp_url in enumerate(device.rtsp_urls): | ||
grabber = FrameGrabber.create_grabber( | ||
{ | ||
"input_type": input_type, | ||
"id": {"rtsp_url": rtsp_url}, | ||
"name": f"RTSP Camera - {device.ip} - {index}", | ||
}, | ||
autogenerate_name=False, | ||
warmup_delay=0, | ||
) | ||
grabber_list.append(grabber) | ||
if rtsp_discover_mode is not None: | ||
onvif_devices = RTSPDiscovery.discover_onvif_devices(auto_discover_mode=rtsp_discover_mode) | ||
for device in onvif_devices: | ||
for index, rtsp_url in enumerate(device.rtsp_urls): | ||
grabber = FrameGrabber.create_grabber( | ||
{ | ||
"input_type": input_type, | ||
"id": {"rtsp_url": rtsp_url}, | ||
"name": f"RTSP Camera - {device.ip} - {index}", | ||
}, | ||
autogenerate_name=False, | ||
warmup_delay=0, | ||
) | ||
grabber_list.append(grabber) | ||
continue | ||
|
||
for _ in range( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should just be
rstp
(lowercase) here. Should match the actual input type that is used when creating the grabber.