aiohikvision 0.1.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 (200) hide show
  1. aiohikvision-0.1.0/.gitignore +11 -0
  2. aiohikvision-0.1.0/CHANGELOG.md +49 -0
  3. aiohikvision-0.1.0/LICENSE +202 -0
  4. aiohikvision-0.1.0/NOTICE +8 -0
  5. aiohikvision-0.1.0/PKG-INFO +180 -0
  6. aiohikvision-0.1.0/README.md +148 -0
  7. aiohikvision-0.1.0/pyproject.toml +147 -0
  8. aiohikvision-0.1.0/scripts/assets/README.md +11 -0
  9. aiohikvision-0.1.0/src/aiohikvision/__init__.py +38 -0
  10. aiohikvision-0.1.0/src/aiohikvision/isapi/__init__.py +9 -0
  11. aiohikvision-0.1.0/src/aiohikvision/isapi/door_station.py +186 -0
  12. aiohikvision-0.1.0/src/aiohikvision/isapi/model/__init__.py +1 -0
  13. aiohikvision-0.1.0/src/aiohikvision/isapi/model/audit.py +102 -0
  14. aiohikvision-0.1.0/src/aiohikvision/isapi/model/discover.py +306 -0
  15. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/__init__.py +132 -0
  16. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/acslog.py +213 -0
  17. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/adjust.py +49 -0
  18. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/detection.py +122 -0
  19. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/health.py +94 -0
  20. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/image.py +247 -0
  21. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/intercom.py +91 -0
  22. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/io.py +90 -0
  23. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/linkage.py +80 -0
  24. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/park.py +156 -0
  25. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/privacy.py +125 -0
  26. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/ptz.py +126 -0
  27. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/recordings.py +674 -0
  28. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/scrambling.py +238 -0
  29. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/signals.py +208 -0
  30. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/speaker.py +87 -0
  31. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/storage.py +44 -0
  32. aiohikvision-0.1.0/src/aiohikvision/isapi/model/features/talk.py +176 -0
  33. aiohikvision-0.1.0/src/aiohikvision/isapi/model/ids.py +24 -0
  34. aiohikvision-0.1.0/src/aiohikvision/isapi/model/inventory.py +175 -0
  35. aiohikvision-0.1.0/src/aiohikvision/isapi/model/vocabulary.py +97 -0
  36. aiohikvision-0.1.0/src/aiohikvision/isapi/wire/__init__.py +1 -0
  37. aiohikvision-0.1.0/src/aiohikvision/isapi/wire/faults.py +202 -0
  38. aiohikvision-0.1.0/src/aiohikvision/isapi/wire/feed.py +687 -0
  39. aiohikvision-0.1.0/src/aiohikvision/isapi/wire/link.py +764 -0
  40. aiohikvision-0.1.0/src/aiohikvision/isapi/wire/scrub.py +141 -0
  41. aiohikvision-0.1.0/src/aiohikvision/isapi/wire/signer.py +179 -0
  42. aiohikvision-0.1.0/src/aiohikvision/isapi/wire/xmlview.py +250 -0
  43. aiohikvision-0.1.0/src/aiohikvision/media/__init__.py +1 -0
  44. aiohikvision-0.1.0/src/aiohikvision/media/g711.py +84 -0
  45. aiohikvision-0.1.0/src/aiohikvision/py.typed +0 -0
  46. aiohikvision-0.1.0/src/aiohikvision/rtp/__init__.py +1 -0
  47. aiohikvision-0.1.0/src/aiohikvision/rtp/talkback.py +222 -0
  48. aiohikvision-0.1.0/src/aiohikvision/sip/__init__.py +1 -0
  49. aiohikvision-0.1.0/src/aiohikvision/sip/calls.py +333 -0
  50. aiohikvision-0.1.0/src/aiohikvision/sip/messages.py +29 -0
  51. aiohikvision-0.1.0/src/aiohikvision/sip/registrar.py +160 -0
  52. aiohikvision-0.1.0/src/aiohikvision/sip/transport.py +53 -0
  53. aiohikvision-0.1.0/tests/__init__.py +1 -0
  54. aiohikvision-0.1.0/tests/conftest.py +62 -0
  55. aiohikvision-0.1.0/tests/fakes/__init__.py +14 -0
  56. aiohikvision-0.1.0/tests/fakes/door.py +229 -0
  57. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_ContentMgmt_Storage.xml +52 -0
  58. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Event_channels_capabilities.xml +18 -0
  59. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Event_notification_httpHosts.xml +78 -0
  60. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Event_triggers.xml +612 -0
  61. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Image_channels_1_supplementLight.xml +10 -0
  62. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Security_adminAccesses.xml +98 -0
  63. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Security_userCheck.xml +10 -0
  64. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Smart_FieldDetection_1.xml +148 -0
  65. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Smart_LineDetection_1.xml +170 -0
  66. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Smart_capabilities.xml +48 -0
  67. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Smart_regionEntrance_1.xml +158 -0
  68. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Smart_regionExiting_1.xml +94 -0
  69. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_Streaming_channels_101.xml +140 -0
  70. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_System_IO_inputs.xml +18 -0
  71. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_System_IO_outputs.xml +24 -0
  72. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_System_Network_EZVIZ.xml +26 -0
  73. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_System_Network_interfaces.xml +112 -0
  74. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_System_Video_inputs_channels_1_motionDetection.xml +86 -0
  75. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_System_capabilities.xml +548 -0
  76. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/ISAPI_System_deviceInfo.xml +52 -0
  77. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g2/_index.json +82 -0
  78. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_ContentMgmt_Storage.xml +54 -0
  79. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Event_channels_capabilities.xml +16 -0
  80. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Event_notification_httpHosts.xml +96 -0
  81. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Event_triggers.xml +638 -0
  82. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Image_channels_1_supplementLight.xml +26 -0
  83. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Security_adminAccesses.xml +110 -0
  84. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Security_userCheck.xml +10 -0
  85. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Smart_FieldDetection_1.xml +196 -0
  86. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Smart_LineDetection_1.xml +234 -0
  87. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Smart_capabilities.xml +52 -0
  88. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Smart_regionEntrance_1.xml +194 -0
  89. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Smart_regionExiting_1.xml +154 -0
  90. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_Streaming_channels_101.xml +154 -0
  91. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_System_IO_inputs.xml +18 -0
  92. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_System_IO_outputs.xml +26 -0
  93. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_System_Network_EZVIZ.xml +28 -0
  94. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_System_Network_interfaces.xml +112 -0
  95. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_System_Video_inputs_channels_1_motionDetection.xml +94 -0
  96. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_System_Video_inputs_channels_1_privacyMask.xml +32 -0
  97. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_System_capabilities.xml +720 -0
  98. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/ISAPI_System_deviceInfo.xml +60 -0
  99. aiohikvision-0.1.0/tests/fakes/fixtures/camera_g3/_index.json +86 -0
  100. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_ContentMgmt_Storage.xml +20 -0
  101. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Event_channels_capabilities.xml +16 -0
  102. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Event_notification_httpHosts.xml +100 -0
  103. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Event_triggers.xml +546 -0
  104. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Image_channels_1_supplementLight.xml +18 -0
  105. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Security_adminAccesses.xml +110 -0
  106. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Security_userCheck.xml +10 -0
  107. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Smart_FieldDetection_1.xml +132 -0
  108. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Smart_LineDetection_1.xml +170 -0
  109. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Smart_capabilities.xml +52 -0
  110. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Smart_regionEntrance_1.xml +90 -0
  111. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Smart_regionExiting_1.xml +90 -0
  112. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_Streaming_channels_101.xml +152 -0
  113. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_System_IO_inputs.xml +7 -0
  114. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_System_IO_outputs.xml +7 -0
  115. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_System_Network_EZVIZ.xml +28 -0
  116. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_System_Network_interfaces.xml +100 -0
  117. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_System_Video_inputs_channels_1_motionDetection.xml +86 -0
  118. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_System_capabilities.xml +660 -0
  119. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/ISAPI_System_deviceInfo.xml +60 -0
  120. aiohikvision-0.1.0/tests/fakes/fixtures/camera_noio/_index.json +82 -0
  121. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/ISAPI_AccessControl_RemoteControl_door_capabilities.xml +5 -0
  122. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/ISAPI_Security_adminAccesses.xml +38 -0
  123. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/ISAPI_Streaming_channels_101.xml +41 -0
  124. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/ISAPI_System_Network_SIP.xml +29 -0
  125. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/ISAPI_System_TwoWayAudio_channels.xml +8 -0
  126. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/ISAPI_System_deviceInfo.xml +31 -0
  127. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/ISAPI_VideoIntercom_callStatus.json +5 -0
  128. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/ISAPI_VideoIntercom_capabilities.xml +39 -0
  129. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/ISAPI_VideoIntercom_operationTime.xml +6 -0
  130. aiohikvision-0.1.0/tests/fakes/fixtures/door_station/_index.json +38 -0
  131. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_ContentMgmt_InputProxy_channels.xml +151 -0
  132. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_ContentMgmt_InputProxy_channels_1_capabilities.xml +20 -0
  133. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_ContentMgmt_InputProxy_channels_1_portMapping.xml +8 -0
  134. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_ContentMgmt_InputProxy_channels_1_video_motionDetection.xml +47 -0
  135. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_ContentMgmt_InputProxy_channels_status.xml +186 -0
  136. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_ContentMgmt_Storage.xml +19 -0
  137. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_ContentMgmt_storage_hdd.xml +7 -0
  138. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Event_capabilities.xml +30 -0
  139. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Event_channels_capabilities.xml +27 -0
  140. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Event_notification_httpHosts.xml +16 -0
  141. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Event_notification_httpHosts_capabilities.xml +7 -0
  142. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Event_triggers.xml +1335 -0
  143. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Event_triggers_VMD_4.xml +17 -0
  144. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Event_triggers_fielddetection_1.xml +13 -0
  145. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Security_adminAccesses.xml +50 -0
  146. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Security_encryption_capabilities.xml +7 -0
  147. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Security_userCheck.xml +8 -0
  148. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Smart_FieldDetection_1.xml +63 -0
  149. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Smart_LineDetection_1.xml +84 -0
  150. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Smart_capabilities.xml +24 -0
  151. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Smart_regionEntrance_1.xml +63 -0
  152. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Streaming_channels.xml +561 -0
  153. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_Streaming_channels_102.xml +37 -0
  154. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Holiday.xml +7 -0
  155. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_IO_inputs.xml +47 -0
  156. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_IO_outputs.xml +178 -0
  157. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Network_Bond.xml +7 -0
  158. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Network_EZVIZ.xml +16 -0
  159. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Network_POE.xml +7 -0
  160. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Network_PPPoE.xml +8 -0
  161. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Network_VirtualHost.xml +7 -0
  162. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Network_interfaces.xml +51 -0
  163. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Video_inputs_channels.xml +7 -0
  164. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Video_inputs_channels_1_motionDetection.xml +47 -0
  165. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_Video_inputs_channels_4_motionDetection.xml +43 -0
  166. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_capabilities.xml +415 -0
  167. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_deviceInfo.xml +20 -0
  168. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/ISAPI_System_workingstatus_format_json.json +1 -0
  169. aiohikvision-0.1.0/tests/fakes/fixtures/nvr/_index.json +154 -0
  170. aiohikvision-0.1.0/tests/fakes/isapi.py +247 -0
  171. aiohikvision-0.1.0/tests/fakes/talk.py +129 -0
  172. aiohikvision-0.1.0/tests/isapi/__init__.py +1 -0
  173. aiohikvision-0.1.0/tests/isapi/conftest.py +29 -0
  174. aiohikvision-0.1.0/tests/isapi/model/__init__.py +1 -0
  175. aiohikvision-0.1.0/tests/isapi/model/test_access_log.py +70 -0
  176. aiohikvision-0.1.0/tests/isapi/model/test_discover_audit.py +252 -0
  177. aiohikvision-0.1.0/tests/isapi/model/test_extras.py +175 -0
  178. aiohikvision-0.1.0/tests/isapi/model/test_features.py +186 -0
  179. aiohikvision-0.1.0/tests/isapi/model/test_intercom.py +192 -0
  180. aiohikvision-0.1.0/tests/isapi/model/test_privacy.py +78 -0
  181. aiohikvision-0.1.0/tests/isapi/model/test_ptz.py +122 -0
  182. aiohikvision-0.1.0/tests/isapi/model/test_scrambling.py +134 -0
  183. aiohikvision-0.1.0/tests/isapi/test_door_station.py +151 -0
  184. aiohikvision-0.1.0/tests/isapi/test_two_way_audio.py +134 -0
  185. aiohikvision-0.1.0/tests/isapi/wire/__init__.py +1 -0
  186. aiohikvision-0.1.0/tests/isapi/wire/test_feed.py +139 -0
  187. aiohikvision-0.1.0/tests/isapi/wire/test_feed_anpr.py +144 -0
  188. aiohikvision-0.1.0/tests/isapi/wire/test_feed_more.py +259 -0
  189. aiohikvision-0.1.0/tests/isapi/wire/test_link.py +290 -0
  190. aiohikvision-0.1.0/tests/isapi/wire/test_link_insecure_auth.py +71 -0
  191. aiohikvision-0.1.0/tests/isapi/wire/test_link_paths.py +202 -0
  192. aiohikvision-0.1.0/tests/isapi/wire/test_scrub_faults_signer.py +120 -0
  193. aiohikvision-0.1.0/tests/isapi/wire/test_security_lock_feed.py +96 -0
  194. aiohikvision-0.1.0/tests/isapi/wire/test_xmlview.py +62 -0
  195. aiohikvision-0.1.0/tests/test_calls.py +369 -0
  196. aiohikvision-0.1.0/tests/test_door_server.py +102 -0
  197. aiohikvision-0.1.0/tests/test_g711.py +51 -0
  198. aiohikvision-0.1.0/tests/test_registrar.py +185 -0
  199. aiohikvision-0.1.0/tests/test_talkback.py +169 -0
  200. aiohikvision-0.1.0/tests/test_transport.py +77 -0
@@ -0,0 +1,11 @@
1
+ # The captures of milestone 0 hold addresses, names and serials of a real installation:
2
+ # they stay out of the repository; anonymized excerpts go to tests/fakes/fixtures
3
+ captures/
4
+ .venv/
5
+ .mypy_cache/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ .coverage
9
+ dist/
10
+ __pycache__/
11
+ *.egg-info/
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ All notable changes to aiohikvision. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
+ [Semantic Versioning](https://semver.org/). Before 1.0, a minor version may change the API.
6
+
7
+ ## [0.1.0] - 2026-11-26
8
+
9
+ The first version: Home Assistant can be the SIP server and the callee of a Hikvision door
10
+ station. The design is hybrid: the call and the microphone go over SIP, and the door's picture and
11
+ sound come over RTSP ([ADR 0001](docs/ADR-0001-hybrid-call.md)). It was measured on a
12
+ DS-KD8003-IME1(B), firmware V3.7.1 and V3.7.3 ([findings](docs/DEVICE_FINDINGS.md)).
13
+
14
+ ### Added
15
+
16
+ - **`DoorTransport`:** UDP SIP that only hears the configured door stations. It drops eXosip2's
17
+ `jaK` keepalives without logging a parse error, and counts them so the door is known to be
18
+ alive.
19
+ - **`DoorRegistrar`:** the SIP server of the door's VoIP line. It grants a shorter registration
20
+ than the hour the door asks, so the door comes back sooner after a restart, and reports when a
21
+ line registers and when it expires.
22
+ - **`CallServer` and `DoorCall`:**
23
+ - A call rings with 180 at once. Answering, rejecting (486, "busy") and hanging up happen on
24
+ command, and every command names its call. Two answers at once (two phones) give the call
25
+ to the first; a visitor who leaves while the answer is under way gets no 200 OK.
26
+ - Stopping hangs up the answered calls and refuses the ringing ones; the calls that ended
27
+ before are left as they were. Only the latest 20 ended calls are kept.
28
+ - The answer is G.711 at `a=ptime:40` with `a=sendonly` and `m=video 0`.
29
+ - A second press during a call gets "busy".
30
+ - The `<locknumXML>` MESSAGE is answered and read.
31
+ - A door that offers no G.711 is refused with a hint.
32
+ - **`Talkback`:** the microphone to the door.
33
+ - The browser's 20 ms G.711 frames go two per packet. The door sends 40 ms packets, and slows
34
+ its own audio to about 0.7 of real time while it receives 20 ms ones.
35
+ - Packets leave on an absolute clock, in bursts, with nothing sent in silence. The marker bit
36
+ starts each burst, and the timestamp counts the silence.
37
+ - The delay is bounded: the oldest frames are dropped first.
38
+ - **`aiohikvision.media.g711`:** the reference µ-law and A-law encoders, identical to audioop on
39
+ every 16-bit sample, plus tones and 20 ms framing.
40
+ - **`DoorStation`:** the ISAPI side of a door station. It reads what the device is (and refuses
41
+ one that is no door station), its doors, its speaker and its RTSP port; it opens a door, takes
42
+ a snapshot, gives the stream's RTSP address, checks that the device answers (`check`), and
43
+ talks through the speaker outside a call (`TwoWayAudio`: one talk at a time, a new one takes
44
+ the speaker over).
45
+ - **`aiohikvision.isapi`:** the ISAPI client and device model of Hikvision Bridge (see NOTICE).
46
+ - **`scripts/door_server.py`:** the library as the door's server, from a terminal. Its `facade`
47
+ mode rings until the door gives up; its `hybrid` mode answers and talks in tone bursts.
48
+
49
+ [0.1.0]: https://github.com/webysther/aio-hikvision/releases/tag/v0.1.0
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -0,0 +1,8 @@
1
+ aiohikvision
2
+ Copyright 2026 Webysther Sperandio
3
+
4
+ The ISAPI subpackage (aiohikvision.isapi: wire and model) and the fake ISAPI device of the
5
+ tests (tests/fakes/isapi.py, with its fixtures) come from Hikvision Bridge
6
+ (https://github.com/yannik2480/hikvision_bridge), by yannik2480, licensed under the
7
+ Apache License, Version 2.0. They were moved out of that Home Assistant integration on
8
+ 2026-11-26, with their imports adapted; later changes are in the git history.
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.5
2
+ Name: aiohikvision
3
+ Version: 0.1.0
4
+ Summary: Asyncio library for Hikvision devices: ISAPI (cameras, recorders, door stations) and the SIP calls of door stations
5
+ Project-URL: Homepage, https://github.com/webysther/aio-hikvision
6
+ Project-URL: Issues, https://github.com/webysther/aio-hikvision/issues
7
+ Author: Webysther Sperandio
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ License-File: NOTICE
11
+ Keywords: asyncio,camera,door station,hikvision,home assistant,intercom,isapi,nvr,rtp,sip
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Framework :: AsyncIO
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Natural Language :: English
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Communications :: Internet Phone
22
+ Classifier: Topic :: Home Automation
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.13
26
+ Requires-Dist: aiohttp>=3.10
27
+ Requires-Dist: aiosipua==0.7.1
28
+ Requires-Dist: cryptography>=42
29
+ Requires-Dist: defusedxml>=0.7.1
30
+ Requires-Dist: yarl>=1.9
31
+ Description-Content-Type: text/markdown
32
+
33
+ # aiohikvision
34
+
35
+ Asyncio library for Hikvision devices: ISAPI (cameras, recorders, door stations)
36
+ and the SIP calls of video door stations. It is fully typed and has no Home
37
+ Assistant dependency; its main user is
38
+ [Hikvision Virtual Indoor Station](https://github.com/webysther/ha-hikvision-virtual-indoor-station),
39
+ which makes Home Assistant the indoor station of a door station.
40
+
41
+ ```sh
42
+ pip install aiohikvision
43
+ ```
44
+
45
+ Python 3.13 or newer.
46
+
47
+ ## A door station, over ISAPI
48
+
49
+ `DoorStation` is what a door station does for its indoor station, on one
50
+ authenticated link: what it is, its doors, its picture, and its speaker.
51
+
52
+ ```python
53
+ import asyncio
54
+ import os
55
+
56
+ import aiohttp
57
+
58
+ from aiohikvision import DoorStation
59
+
60
+
61
+ async def main() -> None:
62
+ async with aiohttp.ClientSession() as session:
63
+ door = DoorStation(
64
+ session,
65
+ os.environ["DOOR_HOST"],
66
+ os.environ["DOOR_USERNAME"],
67
+ os.environ["DOOR_PASSWORD"],
68
+ port=int(os.environ.get("DOOR_PORT", "80")),
69
+ )
70
+ info = await door.read_info()
71
+ print(info.identity.model, info.identity.firmware)
72
+ print("Doors:", info.doors, "Speaker:", info.talk)
73
+ # await door.open_door(1) # opens the lock of door 1
74
+
75
+
76
+ asyncio.run(main())
77
+ ```
78
+
79
+ It also takes a snapshot (`snapshot()`), gives the RTSP address of the stream with
80
+ its sound (`rtsp_url()`), checks that the device answers (`check()`), and plays
81
+ G.711 through the speaker outside a call (`talk()`, a `TwoWayAudio`: one talk at a
82
+ time, a new one takes the speaker over).
83
+
84
+ ## Its calls, over SIP
85
+
86
+ The door station calls over SIP; its picture and sound are read over RTSP. The
87
+ library is the SIP server of the door's VoIP line and the callee of its calls
88
+ ([why](https://github.com/webysther/aio-hikvision/blob/main/docs/ADR-0001-hybrid-call.md)):
89
+
90
+ ```python
91
+ import asyncio
92
+ import os
93
+
94
+ from aiohikvision import CallServer, CallState, DoorCall, DoorRegistrar, DoorTransport
95
+
96
+
97
+ async def main() -> None:
98
+ door_ip = os.environ["DOOR_IP"] # the address its SIP packets come from
99
+ port = int(os.environ.get("SIP_PORT", "5060"))
100
+ transport = DoorTransport(local_addr=("0.0.0.0", port), allowed_hosts={door_ip})
101
+ tasks: set[asyncio.Task[object]] = set()
102
+
103
+ def changed(call: DoorCall) -> None:
104
+ print(call.state.value, call.callee, call.end_reason)
105
+ if call.state is CallState.RINGING:
106
+ # Refuse it: the door shows "busy". calls.answer(call.id) would answer
107
+ task = asyncio.get_running_loop().create_task(calls.reject(call.id))
108
+ tasks.add(task)
109
+ task.add_done_callback(tasks.discard)
110
+
111
+ calls = CallServer(
112
+ transport,
113
+ advertise=os.environ["MY_IP"], # this machine's address, as the door reaches it
114
+ on_change=changed,
115
+ registrar=DoorRegistrar(),
116
+ )
117
+ await calls.start()
118
+ try:
119
+ await asyncio.sleep(float(os.environ.get("SECONDS", "600")))
120
+ finally:
121
+ await calls.stop()
122
+
123
+
124
+ asyncio.run(main())
125
+ ```
126
+
127
+ - **`DoorTransport`:** UDP SIP that only hears the configured door stations, and
128
+ drops their `jaK` keepalives quietly (`on_keepalive` tells they are alive).
129
+ - **`DoorRegistrar`:** accepts the REGISTER of the door's VoIP line, grants a
130
+ shorter registration than it asks, and says when it registers and expires.
131
+ - **`CallServer` / `DoorCall`:** a call rings with 180 at once, then is answered,
132
+ refused or hung up on command; every command names its call. Two answers at once
133
+ give the call to the first. The answer is G.711 at `a=ptime:40`, `a=sendonly`,
134
+ `m=video 0`.
135
+ - **`Talkback`:** the microphone to the door during a call: `call.push(frame)` takes
136
+ 20 ms G.711 frames, and they leave as 40 ms RTP packets on an absolute clock, in
137
+ bursts. The door slows its own audio when it receives 20 ms packets.
138
+ - **`aiohikvision.media.g711`:** reference µ-law and A-law encoders, identical to
139
+ audioop on every sample, tones and 20 ms frames.
140
+
141
+ ### From a terminal
142
+
143
+ `scripts/door_server.py` runs the library as the server of a real door station,
144
+ with port 5060 free and the door's VoIP line pointing at this machine:
145
+
146
+ ```sh
147
+ # Ring until the door gives up: the visitor hears the ringback
148
+ uv run python scripts/door_server.py --advertise <ha-ip> --door <door-ip> facade
149
+ # Answer after 5 s, talk in 1 kHz bursts (2 s on, 2 s off), hang up after 30 s
150
+ uv run python scripts/door_server.py --advertise <ha-ip> --door <door-ip> hybrid --answer-after 5
151
+ ```
152
+
153
+ ## What the door station does
154
+
155
+ Measured on a DS-KD8003-IME1(B) with firmware V3.7.1 and V3.7.3:
156
+ [docs/DEVICE_FINDINGS.md](https://github.com/webysther/aio-hikvision/blob/main/docs/DEVICE_FINDINGS.md).
157
+ In short: point its VoIP line at your server, set its SIP audio to G.711 only
158
+ (its Opus is non-standard), and expect it to cancel after its ring time (60 s)
159
+ and hang up at its talk time (90 s by default).
160
+
161
+ ## Development
162
+
163
+ ```sh
164
+ uv sync
165
+ uv run pytest --cov
166
+ uv run mypy
167
+ uv run ruff check . && uv run ruff format --check .
168
+ ```
169
+
170
+ The tests never reach a device: they run against doubles of the measured ones
171
+ (`tests/fakes`), with anonymized answers. `scripts/sip_probe.py` is the measuring
172
+ tool of the findings; its captures stay out of the repository.
173
+
174
+ ## License
175
+
176
+ Apache License 2.0. The ISAPI subpackage comes from
177
+ [Hikvision Bridge](https://github.com/yannik2480/hikvision_bridge), by yannik2480,
178
+ under the same license: see
179
+ [NOTICE](https://github.com/webysther/aio-hikvision/blob/main/NOTICE). Hikvision is
180
+ a trademark of its owner; this project is not affiliated with it.
@@ -0,0 +1,148 @@
1
+ # aiohikvision
2
+
3
+ Asyncio library for Hikvision devices: ISAPI (cameras, recorders, door stations)
4
+ and the SIP calls of video door stations. It is fully typed and has no Home
5
+ Assistant dependency; its main user is
6
+ [Hikvision Virtual Indoor Station](https://github.com/webysther/ha-hikvision-virtual-indoor-station),
7
+ which makes Home Assistant the indoor station of a door station.
8
+
9
+ ```sh
10
+ pip install aiohikvision
11
+ ```
12
+
13
+ Python 3.13 or newer.
14
+
15
+ ## A door station, over ISAPI
16
+
17
+ `DoorStation` is what a door station does for its indoor station, on one
18
+ authenticated link: what it is, its doors, its picture, and its speaker.
19
+
20
+ ```python
21
+ import asyncio
22
+ import os
23
+
24
+ import aiohttp
25
+
26
+ from aiohikvision import DoorStation
27
+
28
+
29
+ async def main() -> None:
30
+ async with aiohttp.ClientSession() as session:
31
+ door = DoorStation(
32
+ session,
33
+ os.environ["DOOR_HOST"],
34
+ os.environ["DOOR_USERNAME"],
35
+ os.environ["DOOR_PASSWORD"],
36
+ port=int(os.environ.get("DOOR_PORT", "80")),
37
+ )
38
+ info = await door.read_info()
39
+ print(info.identity.model, info.identity.firmware)
40
+ print("Doors:", info.doors, "Speaker:", info.talk)
41
+ # await door.open_door(1) # opens the lock of door 1
42
+
43
+
44
+ asyncio.run(main())
45
+ ```
46
+
47
+ It also takes a snapshot (`snapshot()`), gives the RTSP address of the stream with
48
+ its sound (`rtsp_url()`), checks that the device answers (`check()`), and plays
49
+ G.711 through the speaker outside a call (`talk()`, a `TwoWayAudio`: one talk at a
50
+ time, a new one takes the speaker over).
51
+
52
+ ## Its calls, over SIP
53
+
54
+ The door station calls over SIP; its picture and sound are read over RTSP. The
55
+ library is the SIP server of the door's VoIP line and the callee of its calls
56
+ ([why](https://github.com/webysther/aio-hikvision/blob/main/docs/ADR-0001-hybrid-call.md)):
57
+
58
+ ```python
59
+ import asyncio
60
+ import os
61
+
62
+ from aiohikvision import CallServer, CallState, DoorCall, DoorRegistrar, DoorTransport
63
+
64
+
65
+ async def main() -> None:
66
+ door_ip = os.environ["DOOR_IP"] # the address its SIP packets come from
67
+ port = int(os.environ.get("SIP_PORT", "5060"))
68
+ transport = DoorTransport(local_addr=("0.0.0.0", port), allowed_hosts={door_ip})
69
+ tasks: set[asyncio.Task[object]] = set()
70
+
71
+ def changed(call: DoorCall) -> None:
72
+ print(call.state.value, call.callee, call.end_reason)
73
+ if call.state is CallState.RINGING:
74
+ # Refuse it: the door shows "busy". calls.answer(call.id) would answer
75
+ task = asyncio.get_running_loop().create_task(calls.reject(call.id))
76
+ tasks.add(task)
77
+ task.add_done_callback(tasks.discard)
78
+
79
+ calls = CallServer(
80
+ transport,
81
+ advertise=os.environ["MY_IP"], # this machine's address, as the door reaches it
82
+ on_change=changed,
83
+ registrar=DoorRegistrar(),
84
+ )
85
+ await calls.start()
86
+ try:
87
+ await asyncio.sleep(float(os.environ.get("SECONDS", "600")))
88
+ finally:
89
+ await calls.stop()
90
+
91
+
92
+ asyncio.run(main())
93
+ ```
94
+
95
+ - **`DoorTransport`:** UDP SIP that only hears the configured door stations, and
96
+ drops their `jaK` keepalives quietly (`on_keepalive` tells they are alive).
97
+ - **`DoorRegistrar`:** accepts the REGISTER of the door's VoIP line, grants a
98
+ shorter registration than it asks, and says when it registers and expires.
99
+ - **`CallServer` / `DoorCall`:** a call rings with 180 at once, then is answered,
100
+ refused or hung up on command; every command names its call. Two answers at once
101
+ give the call to the first. The answer is G.711 at `a=ptime:40`, `a=sendonly`,
102
+ `m=video 0`.
103
+ - **`Talkback`:** the microphone to the door during a call: `call.push(frame)` takes
104
+ 20 ms G.711 frames, and they leave as 40 ms RTP packets on an absolute clock, in
105
+ bursts. The door slows its own audio when it receives 20 ms packets.
106
+ - **`aiohikvision.media.g711`:** reference µ-law and A-law encoders, identical to
107
+ audioop on every sample, tones and 20 ms frames.
108
+
109
+ ### From a terminal
110
+
111
+ `scripts/door_server.py` runs the library as the server of a real door station,
112
+ with port 5060 free and the door's VoIP line pointing at this machine:
113
+
114
+ ```sh
115
+ # Ring until the door gives up: the visitor hears the ringback
116
+ uv run python scripts/door_server.py --advertise <ha-ip> --door <door-ip> facade
117
+ # Answer after 5 s, talk in 1 kHz bursts (2 s on, 2 s off), hang up after 30 s
118
+ uv run python scripts/door_server.py --advertise <ha-ip> --door <door-ip> hybrid --answer-after 5
119
+ ```
120
+
121
+ ## What the door station does
122
+
123
+ Measured on a DS-KD8003-IME1(B) with firmware V3.7.1 and V3.7.3:
124
+ [docs/DEVICE_FINDINGS.md](https://github.com/webysther/aio-hikvision/blob/main/docs/DEVICE_FINDINGS.md).
125
+ In short: point its VoIP line at your server, set its SIP audio to G.711 only
126
+ (its Opus is non-standard), and expect it to cancel after its ring time (60 s)
127
+ and hang up at its talk time (90 s by default).
128
+
129
+ ## Development
130
+
131
+ ```sh
132
+ uv sync
133
+ uv run pytest --cov
134
+ uv run mypy
135
+ uv run ruff check . && uv run ruff format --check .
136
+ ```
137
+
138
+ The tests never reach a device: they run against doubles of the measured ones
139
+ (`tests/fakes`), with anonymized answers. `scripts/sip_probe.py` is the measuring
140
+ tool of the findings; its captures stay out of the repository.
141
+
142
+ ## License
143
+
144
+ Apache License 2.0. The ISAPI subpackage comes from
145
+ [Hikvision Bridge](https://github.com/yannik2480/hikvision_bridge), by yannik2480,
146
+ under the same license: see
147
+ [NOTICE](https://github.com/webysther/aio-hikvision/blob/main/NOTICE). Hikvision is
148
+ a trademark of its owner; this project is not affiliated with it.