From 8d09c73d60c20346b0b54e7aad87f0939ba4b9f3 Mon Sep 17 00:00:00 2001 From: Tim Camise Date: Mon, 8 Jul 2024 10:49:25 -0700 Subject: [PATCH] Don't default to hardcoded parameters for livestream set mode (#565) --- .../sdk_wireless_camera_control/docs/changelog.rst | 1 + .../open_gopro/api/ble_commands.py | 14 ++++++++------ .../open_gopro/demos/gui/livestream.py | 11 ++--------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/demos/python/sdk_wireless_camera_control/docs/changelog.rst b/demos/python/sdk_wireless_camera_control/docs/changelog.rst index 5c33ddd5..f703b586 100644 --- a/demos/python/sdk_wireless_camera_control/docs/changelog.rst +++ b/demos/python/sdk_wireless_camera_control/docs/changelog.rst @@ -13,6 +13,7 @@ Unreleased ---------- * Add Setting 125 +* Don't default to hardcoded parameters for set livestream mode 0.16.1 (April-23-2024) ---------------------- diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/api/ble_commands.py b/demos/python/sdk_wireless_camera_control/open_gopro/api/ble_commands.py index 84dc1f09..b9cbc9cc 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/api/ble_commands.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/api/ble_commands.py @@ -660,22 +660,22 @@ async def set_livestream_mode( self, *, url: str, - window_size: proto.EnumWindowSize.ValueType, minimum_bitrate: int, maximum_bitrate: int, starting_bitrate: int, - lens: proto.EnumLens.ValueType, + window_size: proto.EnumWindowSize.ValueType | None = None, + lens: proto.EnumLens.ValueType | None = None, certs: list[Path] | None = None, ) -> GoProResp[None]: """Initiate livestream to any site that accepts an RTMP URL and simultaneously encode to camera. Args: url (str): url used to stream. Set to empty string to invalidate/cancel stream - window_size (open_gopro.api.proto.EnumWindowSize): Streaming video resolution minimum_bitrate (int): Desired minimum streaming bitrate (>= 800) maximum_bitrate (int): Desired maximum streaming bitrate (<= 8000) starting_bitrate (int): Initial streaming bitrate (honored if 800 <= value <= 8000) - lens (open_gopro.api.proto.EnumLens): Streaming Field of View + window_size (open_gopro.api.proto.EnumWindowSize | None): Streaming video resolution. Defaults to None (use camera default). + lens (open_gopro.api.proto.EnumLens): Streaming Field of View. Defaults to None (use camera default). certs (list[Path] | None): list of certificates to use. Defaults to None. Returns: @@ -684,11 +684,9 @@ async def set_livestream_mode( d = { "url": url, "encode": True, - "window_size": window_size, "minimum_bitrate": minimum_bitrate, "maximum_bitrate": maximum_bitrate, "starting_bitrate": starting_bitrate, - "lens": lens, } if certs: cert_buf = bytearray() @@ -698,6 +696,10 @@ async def set_livestream_mode( cert_buf.pop() d["cert"] = bytes(cert_buf) + if lens: + d["lens"] = lens + if window_size: + d["window_size"] = window_size return d # type: ignore @ble_proto_command( diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/livestream.py b/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/livestream.py index a67a6b44..bacbeeb8 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/livestream.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/livestream.py @@ -73,15 +73,8 @@ def parse_arguments() -> argparse.Namespace: parser.add_argument("--min_bit", type=int, help="Minimum bitrate.", default=1000) parser.add_argument("--max_bit", type=int, help="Maximum bitrate.", default=1000) parser.add_argument("--start_bit", type=int, help="Starting bitrate.", default=1000) - parser.add_argument( - "--resolution", - help="Resolution.", - choices=list(proto.EnumWindowSize.values()), - default=proto.EnumWindowSize.WINDOW_SIZE_720, - ) - parser.add_argument( - "--fov", help="Field of View.", choices=list(proto.EnumLens.values()), default=proto.EnumLens.LENS_LINEAR - ) + parser.add_argument("--resolution", help="Resolution.", choices=list(proto.EnumWindowSize.values()), default=None) + parser.add_argument("--fov", help="Field of View.", choices=list(proto.EnumLens.values()), default=None) return add_cli_args_and_parse(parser, wifi=False)