esp-rainmaker-cli 1.14.1__tar.gz → 1.16.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/PKG-INFO +29 -1
  2. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/esp_rainmaker_cli.egg-info/PKG-INFO +29 -1
  3. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/esp_rainmaker_cli.egg-info/SOURCES.txt +5 -0
  4. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rainmaker/rainmaker.py +46 -0
  5. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rainmaker/version.py +1 -1
  6. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/node.py +38 -1
  7. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/provision.py +2 -1
  8. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/stream.py +126 -1
  9. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/kvs_streaming.py +29 -42
  10. esp_rainmaker_cli-1.16.0/rmaker_lib/local_streaming.py +754 -0
  11. esp_rainmaker_cli-1.16.0/rmaker_lib/proto_webrtc_signal.py +53 -0
  12. esp_rainmaker_cli-1.16.0/rmaker_lib/video_recording.py +131 -0
  13. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/transport/ble_cli.py +3 -3
  14. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/transport/transport_ble.py +6 -2
  15. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/transport/transport_http.py +18 -1
  16. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/esp_prov.py +2 -2
  17. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/esp_rainmaker_ctrl.py +7 -2
  18. esp_rainmaker_cli-1.16.0/rmaker_tools/rmaker_local_ctrl/esp_rmaker_prov_local_ctrl_pb2.py +52 -0
  19. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/integration.py +9 -0
  20. esp_rainmaker_cli-1.16.0/rmaker_tools/rmaker_local_ctrl/prov_local_ctrl_ext.py +156 -0
  21. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/raw_config.py +18 -4
  22. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/raw_params.py +77 -12
  23. esp_rainmaker_cli-1.16.0/rmaker_tools/rmaker_local_ctrl/rmaker_webrtc_signal_pb2.py +58 -0
  24. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/esp_rainmaker_prov.py +2 -2
  25. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/prov/prov_util.py +5 -3
  26. esp_rainmaker_cli-1.14.1/rmaker_tools/rmaker_local_ctrl/esp_rmaker_prov_local_ctrl_pb2.py +0 -48
  27. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/LICENSE +0 -0
  28. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/README.md +0 -0
  29. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/esp_rainmaker_cli.egg-info/dependency_links.txt +0 -0
  30. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/esp_rainmaker_cli.egg-info/entry_points.txt +0 -0
  31. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/esp_rainmaker_cli.egg-info/requires.txt +0 -0
  32. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/esp_rainmaker_cli.egg-info/top_level.txt +0 -0
  33. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rainmaker/__init__.py +0 -0
  34. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/__init__.py +0 -0
  35. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/automation.py +0 -0
  36. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/browserlogin.py +0 -0
  37. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/cache.py +0 -0
  38. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/cmd_response.py +0 -0
  39. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/group.py +0 -0
  40. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/html/welcome.html +0 -0
  41. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/test.py +0 -0
  42. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_cmd/user.py +0 -0
  43. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/__init__.py +0 -0
  44. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/aws_credentials.py +0 -0
  45. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/cmd_response.py +0 -0
  46. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/configmanager.py +0 -0
  47. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/constants.py +0 -0
  48. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/device.py +0 -0
  49. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/envval.py +0 -0
  50. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/exceptions.py +0 -0
  51. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/local_control.py +0 -0
  52. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/logger.py +0 -0
  53. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/node.py +0 -0
  54. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/node_cache.py +0 -0
  55. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/profile_manager.py +0 -0
  56. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/profile_utils.py +0 -0
  57. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/schedule_utils.py +0 -0
  58. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/serverconfig.py +0 -0
  59. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/service.py +0 -0
  60. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/session.py +0 -0
  61. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/session_store.py +0 -0
  62. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/simple_local_control.py +0 -0
  63. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_lib/user.py +0 -0
  64. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/__init__.py +0 -0
  65. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/__init__.py +0 -0
  66. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/discovery/__init__.py +0 -0
  67. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/discovery/mdns_discovery.py +0 -0
  68. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/prov/__init__.py +0 -0
  69. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/prov/wifi_ctrl.py +0 -0
  70. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/prov/wifi_prov.py +0 -0
  71. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/prov/wifi_scan.py +0 -0
  72. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/security/__init__.py +0 -0
  73. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/security/security.py +0 -0
  74. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/security/security0.py +0 -0
  75. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/security/security1.py +0 -0
  76. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/security/security2.py +0 -0
  77. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/security/srp6a.py +0 -0
  78. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/transport/__init__.py +0 -0
  79. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/transport/transport.py +0 -0
  80. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/transport/transport_console.py +0 -0
  81. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/utils/__init__.py +0 -0
  82. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/common/utils/convenience.py +0 -0
  83. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_claim/__init__.py +0 -0
  84. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_claim/claim.py +0 -0
  85. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_claim/claim_config.py +0 -0
  86. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/__init__.py +0 -0
  87. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/constants_pb2.py +0 -0
  88. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/esp_local_ctrl.py +0 -0
  89. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/esp_local_ctrl_pb2.py +0 -0
  90. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/proto/__init__.py +0 -0
  91. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/proto/proto_lc.py +0 -0
  92. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/prov/__init__.py +0 -0
  93. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/prov/custom_prov.py +0 -0
  94. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/prov/wifi_ctrl.py +0 -0
  95. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/sec0_pb2.py +0 -0
  96. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/sec1_pb2.py +0 -0
  97. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/sec2_pb2.py +0 -0
  98. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/security/__init__.py +0 -0
  99. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/session_pb2.py +0 -0
  100. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/transport/__init__.py +0 -0
  101. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_local_ctrl/utils/__init__.py +0 -0
  102. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/__init__.py +0 -0
  103. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/challenge_response.py +0 -0
  104. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/config/__init__.py +0 -0
  105. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/config/custom_cloud_config_pb2.py +0 -0
  106. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/config/esp_rmaker_chal_resp_pb2.py +0 -0
  107. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/config/esp_rmaker_claim_pb2.py +0 -0
  108. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/config/esp_rmaker_user_mapping_pb2.py +0 -0
  109. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/on_network_chal_resp.py +0 -0
  110. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/proto/__init__.py +0 -0
  111. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/protocomm/__init__.py +0 -0
  112. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/protocomm/python/__init__.py +0 -0
  113. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/protocomm/python/constants_pb2.py +0 -0
  114. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/protocomm/python/sec0_pb2.py +0 -0
  115. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/protocomm/python/sec1_pb2.py +0 -0
  116. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/protocomm/python/sec2_pb2.py +0 -0
  117. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/protocomm/python/session_pb2.py +0 -0
  118. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/prov/__init__.py +0 -0
  119. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/prov/user_mapping.py +0 -0
  120. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/security/__init__.py +0 -0
  121. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/transport/__init__.py +0 -0
  122. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/utils/__init__.py +0 -0
  123. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/wifi_provisioning/__init__.py +0 -0
  124. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/wifi_provisioning/python/__init__.py +0 -0
  125. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/wifi_provisioning/python/wifi_config_pb2.py +0 -0
  126. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/wifi_provisioning/python/wifi_constants_pb2.py +0 -0
  127. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/wifi_provisioning/python/wifi_ctrl_pb2.py +0 -0
  128. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/rmaker_tools/rmaker_prov/wifi_provisioning/python/wifi_scan_pb2.py +0 -0
  129. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/server_cert/__init__.py +0 -0
  130. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/server_cert/server_cert.pem +0 -0
  131. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/setup.cfg +0 -0
  132. {esp_rainmaker_cli-1.14.1 → esp_rainmaker_cli-1.16.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: esp-rainmaker-cli
3
- Version: 1.14.1
3
+ Version: 1.16.0
4
4
  Summary: A python utility to perform host based claiming
5
5
  Home-page: https://github.com/espressif/esp-rainmaker-cli
6
6
  Author: Espressif Systems
@@ -122,6 +122,34 @@ Changelog
122
122
 
123
123
  All major changes to ESP RainMaker CLI will be documented in this file.
124
124
 
125
+ ## [1.16.0] - 02-Dec-2026
126
+ ### Added
127
+ - Local WebRTC signaling for the `stream` command. The CLI signals directly with the device over the LAN through ESP Local Control, with no cloud dependency:
128
+ - `--local`: use local signaling. The node must expose the `webrtc_signal` endpoint.
129
+ - `--auto`: try local signaling first and fall back to KVS cloud signaling. The fallback also covers a WebRTC connection that fails or times out, and a stream with no video.
130
+ - `--pop`: the Proof of Possession. It is fetched from the cloud when omitted.
131
+ - Protobuf-based signaling protocol (`rmaker_webrtc_signal.proto`) exchanged over a Security 1 or Security 2 local control session.
132
+ - `--host`: device IP or hostname, for a device that mDNS cannot resolve (default: `<node_id>.local`).
133
+ - `--port`: local control port (default: the cached port, else 8080). The RainMaker split camera uses 62080.
134
+ - Security 2 (SRP6a) and RainMaker Neo cameras. The CLI reads the version endpoint (`rmaker_local_ctrl/version` for Neo, `esp_local_ctrl/version` for classic). It then picks the session endpoint and the security version.
135
+ - `--sec_ver`: security version override (0, 1 or 2). Default: the device's `sec_ver`, else the node's `local_control_type`, else 1.
136
+ - `--sec2_username`: SRP6a username. Default: the node's `local_control_username`, else `wifiprov`. `--pop` is the password.
137
+ - `--ep_prefix`: `rmaker_local_ctrl` (Neo) or `esp_local_ctrl` (classic), to skip endpoint detection.
138
+ - The local control options need `--local` or `--auto`. The command stops with an error otherwise.
139
+
140
+ ### Fixed
141
+ - HTTP local control transport (`Transport_HTTP`): the CLI reads the response body on error responses too, and closes the connection on any failure. A stale body could break the next request on a reused connection. This affects provisioning and `getparams`/`setparams` over HTTP, not only `stream`.
142
+ - `stream --output`: the saved video length matches the capture time. WebRTC delivers a variable frame rate, and the writer used a fixed 30 fps. This also fixes the cloud (KVS) save path. `--duration` and the stats `Elapsed` counter start at the first frame.
143
+ - `stream`: the video window opens on macOS. The display check required an X11 `DISPLAY` on macOS too.
144
+
145
+ ## [1.15.0] - 19-Nov-2026
146
+ ### Added
147
+ - BLE provisioning local control options `--filter` and `--frag-size` require firmware built with `esp_rainmaker` 2.2.0 or later.
148
+ - Local control aligned with esp-rainmaker 2.2.0 provisioning endpoints:
149
+ - `getparams --filter '{"params":{"Light":["Power"],"Schedule":true}}'` sends `CmdGetData.ParamsFilter` over BLE provisioning (`--local-raw --transport ble`). The CLI prints a note to stderr when the device returns extra parameters.
150
+ - `setparams --local-raw --transport ble --frag-size` sends `CmdSetData` fragments on `set_params` when `rmaker_extra.cap` contains `set_frag`. The device sets the maximum JSON size and reports it in `RespSetData.MaxLen`.
151
+ - `--ble_adapter` option for the `provision` command to select the HCI adapter used for BLE transport (default: `hci0`). Useful with `vhci_bridge` for emulated devices, e.g. `--ble_adapter hci1`. Linux/BlueZ only.
152
+
125
153
  ## [1.14.1] - 05-Jun-2026
126
154
  ### Bugfixes
127
155
  - Security 2 fixes across provisioning and local control:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: esp-rainmaker-cli
3
- Version: 1.14.1
3
+ Version: 1.16.0
4
4
  Summary: A python utility to perform host based claiming
5
5
  Home-page: https://github.com/espressif/esp-rainmaker-cli
6
6
  Author: Espressif Systems
@@ -122,6 +122,34 @@ Changelog
122
122
 
123
123
  All major changes to ESP RainMaker CLI will be documented in this file.
124
124
 
125
+ ## [1.16.0] - 02-Dec-2026
126
+ ### Added
127
+ - Local WebRTC signaling for the `stream` command. The CLI signals directly with the device over the LAN through ESP Local Control, with no cloud dependency:
128
+ - `--local`: use local signaling. The node must expose the `webrtc_signal` endpoint.
129
+ - `--auto`: try local signaling first and fall back to KVS cloud signaling. The fallback also covers a WebRTC connection that fails or times out, and a stream with no video.
130
+ - `--pop`: the Proof of Possession. It is fetched from the cloud when omitted.
131
+ - Protobuf-based signaling protocol (`rmaker_webrtc_signal.proto`) exchanged over a Security 1 or Security 2 local control session.
132
+ - `--host`: device IP or hostname, for a device that mDNS cannot resolve (default: `<node_id>.local`).
133
+ - `--port`: local control port (default: the cached port, else 8080). The RainMaker split camera uses 62080.
134
+ - Security 2 (SRP6a) and RainMaker Neo cameras. The CLI reads the version endpoint (`rmaker_local_ctrl/version` for Neo, `esp_local_ctrl/version` for classic). It then picks the session endpoint and the security version.
135
+ - `--sec_ver`: security version override (0, 1 or 2). Default: the device's `sec_ver`, else the node's `local_control_type`, else 1.
136
+ - `--sec2_username`: SRP6a username. Default: the node's `local_control_username`, else `wifiprov`. `--pop` is the password.
137
+ - `--ep_prefix`: `rmaker_local_ctrl` (Neo) or `esp_local_ctrl` (classic), to skip endpoint detection.
138
+ - The local control options need `--local` or `--auto`. The command stops with an error otherwise.
139
+
140
+ ### Fixed
141
+ - HTTP local control transport (`Transport_HTTP`): the CLI reads the response body on error responses too, and closes the connection on any failure. A stale body could break the next request on a reused connection. This affects provisioning and `getparams`/`setparams` over HTTP, not only `stream`.
142
+ - `stream --output`: the saved video length matches the capture time. WebRTC delivers a variable frame rate, and the writer used a fixed 30 fps. This also fixes the cloud (KVS) save path. `--duration` and the stats `Elapsed` counter start at the first frame.
143
+ - `stream`: the video window opens on macOS. The display check required an X11 `DISPLAY` on macOS too.
144
+
145
+ ## [1.15.0] - 19-Nov-2026
146
+ ### Added
147
+ - BLE provisioning local control options `--filter` and `--frag-size` require firmware built with `esp_rainmaker` 2.2.0 or later.
148
+ - Local control aligned with esp-rainmaker 2.2.0 provisioning endpoints:
149
+ - `getparams --filter '{"params":{"Light":["Power"],"Schedule":true}}'` sends `CmdGetData.ParamsFilter` over BLE provisioning (`--local-raw --transport ble`). The CLI prints a note to stderr when the device returns extra parameters.
150
+ - `setparams --local-raw --transport ble --frag-size` sends `CmdSetData` fragments on `set_params` when `rmaker_extra.cap` contains `set_frag`. The device sets the maximum JSON size and reports it in `RespSetData.MaxLen`.
151
+ - `--ble_adapter` option for the `provision` command to select the HCI adapter used for BLE transport (default: `hci0`). Useful with `vhci_bridge` for emulated devices, e.g. `--ble_adapter hci1`. Linux/BlueZ only.
152
+
125
153
  ## [1.14.1] - 05-Jun-2026
126
154
  ### Bugfixes
127
155
  - Security 2 fixes across provisioning and local control:
@@ -32,11 +32,13 @@ rmaker_lib/envval.py
32
32
  rmaker_lib/exceptions.py
33
33
  rmaker_lib/kvs_streaming.py
34
34
  rmaker_lib/local_control.py
35
+ rmaker_lib/local_streaming.py
35
36
  rmaker_lib/logger.py
36
37
  rmaker_lib/node.py
37
38
  rmaker_lib/node_cache.py
38
39
  rmaker_lib/profile_manager.py
39
40
  rmaker_lib/profile_utils.py
41
+ rmaker_lib/proto_webrtc_signal.py
40
42
  rmaker_lib/schedule_utils.py
41
43
  rmaker_lib/serverconfig.py
42
44
  rmaker_lib/service.py
@@ -44,6 +46,7 @@ rmaker_lib/session.py
44
46
  rmaker_lib/session_store.py
45
47
  rmaker_lib/simple_local_control.py
46
48
  rmaker_lib/user.py
49
+ rmaker_lib/video_recording.py
47
50
  rmaker_tools/__init__.py
48
51
  rmaker_tools/common/__init__.py
49
52
  rmaker_tools/common/discovery/__init__.py
@@ -77,8 +80,10 @@ rmaker_tools/rmaker_local_ctrl/esp_prov.py
77
80
  rmaker_tools/rmaker_local_ctrl/esp_rainmaker_ctrl.py
78
81
  rmaker_tools/rmaker_local_ctrl/esp_rmaker_prov_local_ctrl_pb2.py
79
82
  rmaker_tools/rmaker_local_ctrl/integration.py
83
+ rmaker_tools/rmaker_local_ctrl/prov_local_ctrl_ext.py
80
84
  rmaker_tools/rmaker_local_ctrl/raw_config.py
81
85
  rmaker_tools/rmaker_local_ctrl/raw_params.py
86
+ rmaker_tools/rmaker_local_ctrl/rmaker_webrtc_signal_pb2.py
82
87
  rmaker_tools/rmaker_local_ctrl/sec0_pb2.py
83
88
  rmaker_tools/rmaker_local_ctrl/sec1_pb2.py
84
89
  rmaker_tools/rmaker_local_ctrl/sec2_pb2.py
@@ -370,6 +370,13 @@ def main():
370
370
  type=str,
371
371
  help='Device name for BLE transport (e.g., PROV_aaf824). Required when using --transport ble')
372
372
 
373
+ setparams_parser.add_argument('--frag-size',
374
+ type=int,
375
+ default=None,
376
+ dest='frag_size',
377
+ help='Send the JSON through BLE set_params as protobuf fragments (1 to 200 bytes per chunk). '
378
+ 'Requires rmaker_extra.cap to include set_frag. '
379
+ 'Without this option the JSON is sent in one body to set_params.')
373
380
  setparams_parser.add_argument('--auto',
374
381
  action='store_true',
375
382
  help='Try local control first, fall back to cloud if local fails')
@@ -410,6 +417,9 @@ def main():
410
417
  type=str,
411
418
  default=None,
412
419
  help='SRP6a username for Security 2 local control. Defaults to the username cached from cloud params, else \'wifiprov\'. --pop is used as the password.')
420
+ getparams_parser.add_argument('--filter',
421
+ help='Parameter filter for --local-raw --transport ble. '
422
+ 'JSON: {"params":{"Light":["Power"],"Schedule":true}}')
413
423
  getparams_parser.add_argument('--local-raw',
414
424
  action='store_true',
415
425
  help='Use local control via raw endpoints (get_params/set_params) instead of esp_local_ctrl')
@@ -564,6 +574,12 @@ def main():
564
574
  help='Metadata as JSON string to attach during node mapping\n'
565
575
  '(e.g., \'{"serial_no": "abc123", "region": "us"}\')')
566
576
 
577
+ provision_parser.add_argument('--ble_adapter',
578
+ type=str,
579
+ default='hci0',
580
+ help='HCI adapter to use for BLE transport (default: hci0).\n'
581
+ 'Useful with vhci_bridge for emulated devices, e.g. --ble_adapter hci1')
582
+
567
583
  add_profile_argument(provision_parser)
568
584
  provision_parser.set_defaults(func=provision)
569
585
 
@@ -1273,6 +1289,36 @@ def main():
1273
1289
  stream_parser.add_argument('--stats-only',
1274
1290
  action='store_true',
1275
1291
  help='Show statistics only, no video display')
1292
+ stream_parser.add_argument('--local',
1293
+ action='store_true',
1294
+ help='Use local signaling over LAN (instead of KVS cloud)')
1295
+ stream_parser.add_argument('--auto',
1296
+ action='store_true',
1297
+ help='Try local signaling first, fall back to cloud')
1298
+ stream_parser.add_argument('--pop',
1299
+ help='Proof of Possession for local control (auto-fetched if omitted)')
1300
+ stream_parser.add_argument('--port',
1301
+ type=int,
1302
+ help='Local control port (default: the cached port, else 8080)')
1303
+ stream_parser.add_argument('--host',
1304
+ help='Device IP or hostname for local signaling (default: <node_id>.local)')
1305
+ stream_parser.add_argument('--sec_ver',
1306
+ dest='sec_ver',
1307
+ type=int,
1308
+ choices=[0, 1, 2],
1309
+ help='Local control security version (default: from the device version endpoint, '
1310
+ 'else the node\'s local_control_type, else 1)')
1311
+ stream_parser.add_argument('--sec2_username',
1312
+ dest='sec2_username',
1313
+ metavar='<username>',
1314
+ help='SRP6a username for Security 2 (default: the node\'s local_control_username, '
1315
+ 'else \'wifiprov\'). --pop is the password.')
1316
+ stream_parser.add_argument('--ep_prefix',
1317
+ dest='ep_prefix',
1318
+ choices=['rmaker_local_ctrl', 'esp_local_ctrl'],
1319
+ help='Local control session/version endpoint prefix: rmaker_local_ctrl '
1320
+ '(RainMaker Neo) or esp_local_ctrl (RainMaker classic). '
1321
+ 'Default: detected from the version endpoint')
1276
1322
  add_profile_argument(stream_parser)
1277
1323
  stream_parser.set_defaults(func=stream_video)
1278
1324
 
@@ -5,4 +5,4 @@
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
7
  # This file contains the version information for the ESP RainMaker CLI
8
- VERSION = "1.14.1"
8
+ VERSION = "1.16.0"
@@ -139,6 +139,8 @@ def _build_local_options_with_cache(vars_dict, node_cache=None, session_store=No
139
139
  'sec2_username': sec2_username,
140
140
  'local_raw': vars_dict.get('local_raw', False),
141
141
  'device_name': vars_dict.get('device_name', None),
142
+ 'params_filter': vars_dict.get('filter'),
143
+ 'frag_size': vars_dict.get('frag_size'),
142
144
  'node_cache': node_cache,
143
145
  'session_store': session_store,
144
146
  'explicit_sec_ver': explicit_sec_ver,
@@ -1478,6 +1480,14 @@ def set_params(vars=None):
1478
1480
  :rtype: None
1479
1481
  """
1480
1482
 
1483
+ if vars and vars.get('frag_size') is not None:
1484
+ if int(vars['frag_size']) < 1:
1485
+ print('Error: --frag-size must be at least 1.')
1486
+ return
1487
+ if not vars.get('local_raw') or vars.get('transport') != 'ble' or vars.get('auto'):
1488
+ print('Error: --frag-size requires --local-raw --transport ble and cannot be used with --auto.')
1489
+ return
1490
+
1481
1491
  data = None
1482
1492
  if vars['data']:
1483
1493
  data = json.loads(vars['data'])
@@ -1495,6 +1505,12 @@ def set_params(vars=None):
1495
1505
  auto_vars = dict(vars)
1496
1506
  auto_vars['nodeid'] = node_id
1497
1507
  result = _try_local_operation(auto_vars, 'set_params', data)
1508
+ if isinstance(result, dict) and result.get('fatal'):
1509
+ print(result.get('message') or 'Local control failed.')
1510
+ return
1511
+ if isinstance(result, dict) and result.get('status') not in (None, 'success'):
1512
+ all_succeeded = False
1513
+ break
1498
1514
  if result is None or result is False:
1499
1515
  all_succeeded = False
1500
1516
  break
@@ -1586,7 +1602,8 @@ def set_params(vars=None):
1586
1602
  'sec_ver': vars.get('sec_ver') if vars.get('sec_ver') is not None else 0,
1587
1603
  'sec2_username': vars.get('sec2_username', 'wifiprov') or 'wifiprov',
1588
1604
  'local_raw': vars.get('local_raw', False),
1589
- 'device_name': vars.get('device_name', None)
1605
+ 'device_name': vars.get('device_name', None),
1606
+ 'frag_size': vars.get('frag_size'),
1590
1607
  }
1591
1608
 
1592
1609
  log.info("Using simplified local control (security level 0)")
@@ -1695,6 +1712,21 @@ def get_params(vars=None):
1695
1712
  :return: None on Success
1696
1713
  :rtype: None
1697
1714
  """
1715
+ if vars and vars.get('filter') is not None:
1716
+ from rmaker_tools.rmaker_local_ctrl.prov_local_ctrl_ext import prepare_params_filter
1717
+ if not vars.get('local_raw') or vars.get('transport') != 'ble' or vars.get('auto'):
1718
+ print('Error: --filter requires --local-raw --transport ble and cannot be used with --auto.')
1719
+ return
1720
+ if vars.get('init') or vars.get('proxy_report'):
1721
+ print('Error: --filter cannot be used with --init or --proxy-report.')
1722
+ return
1723
+ try:
1724
+ vars = dict(vars)
1725
+ vars['filter'] = prepare_params_filter(vars['filter'])
1726
+ except ValueError as exc:
1727
+ print(f'Error: {exc}')
1728
+ return
1729
+
1698
1730
  try:
1699
1731
  params = None
1700
1732
  proxy_report = vars.get('proxy_report', False) if vars else False
@@ -1774,6 +1806,7 @@ def get_params(vars=None):
1774
1806
  'sec2_username': vars.get('sec2_username', 'wifiprov') or 'wifiprov',
1775
1807
  'local_raw': vars.get('local_raw', False),
1776
1808
  'device_name': vars.get('device_name', None),
1809
+ 'params_filter': vars.get('filter'),
1777
1810
  'timestamp': timestamp if not (proxy_report and vars.get('local_raw', False) and not timestamp_explicitly_provided) else timestamp,
1778
1811
  'proxy_report': proxy_report
1779
1812
  }
@@ -1801,6 +1834,7 @@ def get_params(vars=None):
1801
1834
  'sec2_username': vars.get('sec2_username', 'wifiprov') or 'wifiprov',
1802
1835
  'local_raw': vars.get('local_raw', False),
1803
1836
  'device_name': vars.get('device_name', None),
1837
+ 'params_filter': vars.get('filter'),
1804
1838
  'timestamp': timestamp if not (proxy_report and vars.get('local_raw', False) and not timestamp_explicitly_provided) else timestamp,
1805
1839
  'proxy_report': proxy_report
1806
1840
  }
@@ -1837,6 +1871,9 @@ def get_params(vars=None):
1837
1871
  if params is None:
1838
1872
  log.error('Node status not updated.')
1839
1873
  return
1874
+ if isinstance(params, dict) and params.get('fatal') is True and params.get('status') == 'error':
1875
+ print(f"Error: {params['message']}")
1876
+ return
1840
1877
 
1841
1878
  # If proxy_report is enabled and we got a signed response, POST it to proxy API
1842
1879
  if proxy_report:
@@ -244,7 +244,8 @@ def provision(vars=None):
244
244
  no_wifi=no_wifi,
245
245
  disable_chal_resp=disable_chal_resp,
246
246
  tags=mapping_tags,
247
- metadata=mapping_metadata
247
+ metadata=mapping_metadata,
248
+ ble_adapter=vars.get('ble_adapter', 'hci0')
248
249
  )
249
250
  except RuntimeError as claim_err:
250
251
  # Handle claim requirement error specifically
@@ -132,9 +132,106 @@ def _stream_via_kvs(vars, node_id, save_path, duration, stats_only, region_overr
132
132
  print(f"Warning: Video file was not saved. No frames were received or recording failed.")
133
133
 
134
134
 
135
+ def _cached_local_control_info(vars, node_id):
136
+ """Return the cached local control info (pop, sec_ver, username) for node_id, if any."""
137
+ try:
138
+ from rmaker_cmd.node import _get_cache_objects
139
+ node_cache, _ = _get_cache_objects(vars or {})
140
+ if node_cache:
141
+ return node_cache.get_local_control_info(node_id) or {}
142
+ except Exception as e:
143
+ log.debug(f"Local control info cache lookup failed: {e}")
144
+ return {}
145
+
146
+
147
+ def _stream_via_local(vars, node_id, save_path, duration, stats_only, pop=None, port=None, host=None,
148
+ sec_ver=None, username=None, ep_prefix=None):
149
+ """Stream video using local signaling over local control."""
150
+ from rmaker_lib.local_streaming import start_local_streaming
151
+
152
+ # Security hints from the node's cloud params (local_control_type and
153
+ # local_control_username). The device version endpoint takes precedence
154
+ # over hint_sec_ver. Explicit sec_ver and username take precedence over both.
155
+ lc_info = _cached_local_control_info(vars, node_id)
156
+ hint_sec_ver = lc_info.get('sec_ver')
157
+ hint_username = lc_info.get('username')
158
+
159
+ # Resolve PoP using cache hierarchy: capability cache → local_control_info cache → cloud API
160
+ if not pop:
161
+ try:
162
+ from rmaker_cmd.node import _get_cache_objects, _build_local_options_with_cache
163
+ node_cache, session_store = _get_cache_objects(vars or {})
164
+ local_opts = _build_local_options_with_cache(
165
+ {**(vars or {}), 'nodeid': node_id},
166
+ node_cache=node_cache, session_store=session_store
167
+ )
168
+ if local_opts:
169
+ pop = local_opts.get('pop', '')
170
+ if port is None:
171
+ port = local_opts.get('port')
172
+ if pop:
173
+ log.info(f"Resolved PoP for {node_id} (cache or cloud)")
174
+ # The lookup above may have filled the cache from cloud params.
175
+ lc_info = _cached_local_control_info(vars, node_id)
176
+ hint_sec_ver = lc_info.get('sec_ver', hint_sec_ver)
177
+ hint_username = lc_info.get('username', hint_username)
178
+ except Exception as e:
179
+ log.debug(f"Cache-based PoP resolution failed: {e}")
180
+
181
+ # Fallback: fetch PoP directly from cloud if still missing
182
+ if not pop:
183
+ try:
184
+ from rmaker_lib.local_streaming import _fetch_local_control_info_from_cloud
185
+ s = get_session_with_profile(vars or {})
186
+ cloud_info = _fetch_local_control_info_from_cloud(node_id, s) or {}
187
+ pop = cloud_info.get('pop')
188
+ hint_sec_ver = cloud_info.get('sec_ver', hint_sec_ver)
189
+ hint_username = cloud_info.get('username', hint_username)
190
+ except Exception as e:
191
+ log.warning(f"Could not auto-fetch PoP: {e}")
192
+
193
+ print(f"\nStarting video stream from node {node_id} (local signaling)...")
194
+ if save_path:
195
+ print(f"Saving video to: {save_path}")
196
+ if stats_only:
197
+ print("Statistics mode enabled")
198
+ print()
199
+
200
+ show_video_param = False if stats_only else None
201
+
202
+ asyncio.run(start_local_streaming(
203
+ node_id=node_id,
204
+ pop=pop,
205
+ show_video=show_video_param,
206
+ save_path=save_path,
207
+ duration=duration,
208
+ stats_only=stats_only,
209
+ port=port or 8080,
210
+ host=host,
211
+ sec_ver=sec_ver,
212
+ username=username or hint_username,
213
+ ep_prefix=ep_prefix,
214
+ hint_sec_ver=hint_sec_ver,
215
+ ))
216
+
217
+ # Post-stream summary for saved video
218
+ if save_path:
219
+ import os
220
+ if os.path.isfile(save_path) and os.path.getsize(save_path) > 0:
221
+ size_mb = os.path.getsize(save_path) / (1024 * 1024)
222
+ print(f"Video saved: {save_path} ({size_mb:.1f} MB)")
223
+ else:
224
+ print(f"Warning: Video file was not saved. No frames were received or recording failed.")
225
+
226
+
135
227
  def stream_video(vars=None):
136
228
  """
137
- Stream video from a camera device using WebRTC via KVS cloud signaling.
229
+ Stream video from a camera device using WebRTC.
230
+
231
+ Supports two signaling modes:
232
+ - Cloud (default): Uses KVS signaling via AWS
233
+ - Local (--local): Uses local control HTTP for signaling on LAN
234
+ - Auto (--auto): Tries local first, falls back to cloud
138
235
 
139
236
  :param vars: Parameters dict from argparse
140
237
  :type vars: dict | None
@@ -149,6 +246,19 @@ def stream_video(vars=None):
149
246
  region_override = vars.get('region')
150
247
  duration = vars.get('duration')
151
248
  stats_only = vars.get('stats_only', False)
249
+ use_local = vars.get('local', False)
250
+ use_auto = vars.get('auto', False)
251
+ pop = vars.get('pop')
252
+
253
+ # Local control options only apply to local signaling
254
+ if not (use_local or use_auto):
255
+ local_only = [opt for opt, key in (('--pop', 'pop'), ('--port', 'port'), ('--host', 'host'),
256
+ ('--sec_ver', 'sec_ver'), ('--sec2_username', 'sec2_username'),
257
+ ('--ep_prefix', 'ep_prefix'))
258
+ if vars.get(key) is not None]
259
+ if local_only:
260
+ print(f"Error: {', '.join(local_only)} requires --local or --auto.")
261
+ return
152
262
 
153
263
  # Validate duration
154
264
  if duration is not None:
@@ -174,7 +284,22 @@ def stream_video(vars=None):
174
284
  return
175
285
 
176
286
  try:
287
+ if use_local or use_auto:
288
+ try:
289
+ _stream_via_local(vars, node_id, save_path, duration, stats_only, pop=pop,
290
+ port=vars.get('port'), host=vars.get('host'),
291
+ sec_ver=vars.get('sec_ver'),
292
+ username=vars.get('sec2_username'),
293
+ ep_prefix=vars.get('ep_prefix'))
294
+ return
295
+ except Exception as e:
296
+ if use_auto:
297
+ print(f"Local streaming failed ({e}), falling back to cloud signaling...")
298
+ else:
299
+ raise
300
+
177
301
  _stream_via_kvs(vars, node_id, save_path, duration, stats_only, region_override)
302
+
178
303
  except KeyboardInterrupt:
179
304
  print("\nStream interrupted by user")
180
305
  except ImportError as e:
@@ -90,6 +90,7 @@ except ImportError:
90
90
 
91
91
  from rmaker_lib.logger import log
92
92
  from rmaker_lib.aws_credentials import AWSCredentials
93
+ from rmaker_lib.video_recording import BucketedVideoRecorder
93
94
 
94
95
 
95
96
  class VideoStatistics:
@@ -97,7 +98,8 @@ class VideoStatistics:
97
98
 
98
99
  def __init__(self):
99
100
  self.frames_received = 0
100
- self.start_time = time.time()
101
+ self.start_time = None # set on first frame so Elapsed matches the video
102
+ self._init_time = time.time() # fallback before the first frame arrives
101
103
  self.resolution = None
102
104
  self.codec = None
103
105
  # Per-interval tracking for instantaneous FPS
@@ -112,6 +114,8 @@ class VideoStatistics:
112
114
 
113
115
  def update_frame(self, resolution=None, codec=None):
114
116
  """Update statistics with a new decoded frame."""
117
+ if self.start_time is None:
118
+ self.start_time = time.time() # Elapsed counts from the first frame
115
119
  self.frames_received += 1
116
120
  self._interval_frames += 1
117
121
  if resolution:
@@ -151,7 +155,7 @@ class VideoStatistics:
151
155
 
152
156
  resolution_str = f"{self.resolution[0]}x{self.resolution[1]}" if self.resolution else "Unknown"
153
157
  codec_str = self.codec or "Unknown"
154
- elapsed_total = now - self.start_time
158
+ elapsed_total = now - (self.start_time or self._init_time)
155
159
 
156
160
  return (
157
161
  f"[STATS] Frames: {self.frames_received} | "
@@ -171,26 +175,15 @@ def is_video_display_available():
171
175
  :return: True if display is available, False otherwise
172
176
  :rtype: bool
173
177
  """
174
- # Check DISPLAY environment variable (Linux/macOS)
175
- if sys.platform != 'win32':
176
- display = os.environ.get('DISPLAY')
177
- if not display:
178
- return False
179
-
180
- # Check if OpenCV can create a window
181
- # On macOS, cv2 operations can hang, so be conservative
182
- if CV2_AVAILABLE:
183
- try:
184
- # Try to create a test window
185
- # Note: On macOS, this might hang if X11/display server isn't properly configured
186
- test_img = np.zeros((100, 100, 3), dtype=np.uint8)
187
- cv2.namedWindow('test', cv2.WINDOW_NORMAL)
188
- cv2.destroyWindow('test')
189
- return True
190
- except Exception:
191
- return False
178
+ # Only Linux needs an X11 DISPLAY for a GUI window. macOS (Cocoa) and
179
+ # Windows use native windowing, where DISPLAY is never set, so checking
180
+ # it there would wrongly disable the video window.
181
+ if sys.platform.startswith('linux') and not os.environ.get('DISPLAY'):
182
+ return False
192
183
 
193
- return False
184
+ # Same default as the cloud streaming path: show video when OpenCV is
185
+ # available. (Probing with cv2.namedWindow can hang on macOS, so avoid it.)
186
+ return CV2_AVAILABLE
194
187
 
195
188
 
196
189
  class KVSViewerTrack(VideoStreamTrack):
@@ -224,13 +217,11 @@ class KVSViewerTrack(VideoStreamTrack):
224
217
  # Update statistics
225
218
  self.stats.update_frame(resolution=(width, height), codec="H264")
226
219
 
227
- # Save frame if needed
228
- if self.save_path and self.writer is None:
229
- fourcc = cv2.VideoWriter_fourcc(*'mp4v')
230
- self.writer = cv2.VideoWriter(self.save_path, fourcc, 30.0, (width, height))
231
-
232
- if self.writer:
233
- self.writer.write(img)
220
+ # NOTE: Frame saving is centralized in
221
+ # KVSStreamingClient._consume_video_frames (the canonical consumer that
222
+ # reads the remote track directly). This wrapper is not pulled during
223
+ # recvonly streaming; saving here would race the run loop and bypass the
224
+ # bucketed recorder, so it is intentionally omitted.
234
225
 
235
226
  # Display or return frame
236
227
  if self.show_video:
@@ -312,6 +303,7 @@ class KVSStreamingClient:
312
303
  self.kvs_client = None
313
304
  self.running = False
314
305
  self._frame_task = None
306
+ self._recorder = None # BucketedVideoRecorder, created on first saved frame
315
307
  self._stream_start_time = None
316
308
  self._duration = None
317
309
 
@@ -497,18 +489,13 @@ class KVSStreamingClient:
497
489
  resolution = (frame.width, frame.height)
498
490
  self.stats.update_frame(resolution=resolution, codec="H264")
499
491
 
500
- # Save frame if recording
492
+ # Save frame if recording (bucketed resampler -> correct wall-clock duration)
501
493
  if self.save_path and CV2_AVAILABLE:
502
494
  try:
503
495
  img = frame.to_ndarray(format="bgr24")
504
- height, width = img.shape[:2]
505
- if self.video_track_handler and self.video_track_handler.writer is None:
506
- fourcc = cv2.VideoWriter_fourcc(*'mp4v')
507
- self.video_track_handler.writer = cv2.VideoWriter(
508
- self.save_path, fourcc, 30.0, (width, height))
509
- log.info(f"Video writer initialized: {self.save_path} ({width}x{height})")
510
- if self.video_track_handler and self.video_track_handler.writer:
511
- self.video_track_handler.writer.write(img)
496
+ if self._recorder is None:
497
+ self._recorder = BucketedVideoRecorder(self.save_path)
498
+ self._recorder.add_frame(img, time.time())
512
499
  except Exception as e:
513
500
  log.warning(f"Error saving frame: {e}")
514
501
 
@@ -1934,11 +1921,11 @@ class KVSStreamingClient:
1934
1921
  log.info("Stopping KVS stream...")
1935
1922
  self.running = False
1936
1923
 
1937
- # Release video writer before closing peer connection
1938
- if self.video_track_handler and hasattr(self.video_track_handler, 'writer') and self.video_track_handler.writer:
1939
- self.video_track_handler.writer.release()
1940
- self.video_track_handler.writer = None
1941
- log.info("Video writer released")
1924
+ # Flush and release the bucketed recorder before closing the connection
1925
+ if self._recorder is not None:
1926
+ self._recorder.close()
1927
+ self._recorder = None
1928
+ log.info("Video recorder closed")
1942
1929
 
1943
1930
  if self.peer_connection:
1944
1931
  await self.peer_connection.close()