diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/api/http_commands.py b/demos/python/sdk_wireless_camera_control/open_gopro/api/http_commands.py index 26843b1d..37eb0ed8 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/api/http_commands.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/api/http_commands.py @@ -203,17 +203,20 @@ async def load_preset_group(self, *, group: proto.EnumPresetGroup.ValueType) -> """ return {"id": group} # type: ignore - @http_get_json_command(endpoint="gopro/camera/stream", components=["mode"], identifier="Preview Stream") - async def set_preview_stream(self, *, mode: Params.Toggle) -> GoProResp[None]: + @http_get_json_command( + endpoint="gopro/camera/stream", arguments=["port"], components=["mode"], identifier="Preview Stream" + ) + async def set_preview_stream(self, *, mode: Params.Toggle, port: int | None = None) -> GoProResp[None]: """Start or stop the preview stream Args: mode (open_gopro.api.params.Toggle): enable to start or disable to stop + port (int): Port to use for Preview Stream. Defaults to 8554 if None. Only relevant when starting the stream. Returns: GoProResp: command status """ - return {"mode": "start" if mode is Params.Toggle.ENABLE else "stop"} # type: ignore + return {"mode": "start" if mode is Params.Toggle.ENABLE else "stop", "port": port} # type: ignore @http_get_json_command(endpoint="gopro/camera/analytics/set_client_info") async def set_third_party_client_info(self) -> GoProResp[None]: diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/preview_stream.py b/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/preview_stream.py index fa5aff5e..1334eb05 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/preview_stream.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/preview_stream.py @@ -22,10 +22,10 @@ async def main(args: argparse.Namespace) -> None: async with WirelessGoPro(args.identifier) as gopro: await gopro.http_command.set_preview_stream(mode=Params.Toggle.DISABLE) await gopro.ble_command.set_shutter(shutter=Params.Toggle.DISABLE) - assert (await gopro.http_command.set_preview_stream(mode=Params.Toggle.ENABLE)).ok + assert (await gopro.http_command.set_preview_stream(mode=Params.Toggle.ENABLE, port=args.port)).ok console.print("Displaying the preview stream...") - display_video_blocking(r"udp://127.0.0.1:8554", printer=console.print) + display_video_blocking(f"udp://127.0.0.1:{args.port}", printer=console.print) await gopro.http_command.set_preview_stream(mode=Params.Toggle.DISABLE) @@ -34,6 +34,9 @@ def parse_arguments() -> argparse.Namespace: parser = argparse.ArgumentParser( description="Connect to the GoPro via BLE and Wifi, start a preview stream, then display it with CV2." ) + parser.add_argument( + "--port", type=int, help="Port to use for livestream. Defaults to 8554 if not set", default=8554 + ) return add_cli_args_and_parse(parser, wifi=False)