vdm10-python 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,33 @@
1
+ """The simulated indoor station, assembled from one mixin per concern."""
2
+
3
+ from metzler.station.bridge import ProviderBridgeMixin
4
+ from metzler.station.core import StationCore
5
+ from metzler.station.ha_answer import HaAnswerMixin
6
+ from metzler.station.inbound import InboundCallMixin
7
+ from metzler.station.local_answer import LocalAnswerMixin
8
+ from metzler.station.outbound import OutboundCallMixin
9
+ from metzler.station.registration import RegistrationMixin
10
+ from metzler.station.teardown import TeardownMixin
11
+
12
+
13
+ class IndoorStation(
14
+ RegistrationMixin,
15
+ ProviderBridgeMixin,
16
+ HaAnswerMixin,
17
+ LocalAnswerMixin,
18
+ OutboundCallMixin,
19
+ InboundCallMixin,
20
+ TeardownMixin,
21
+ StationCore,
22
+ ):
23
+ """A Hikvision/Metzler indoor extension (VTH) on the intercom LAN.
24
+
25
+ StationCore socket, RTSP server, receive loop, request routing, run/shutdown
26
+ RegistrationMixin REGISTER + <regXML> at the registrar, MESSAGE heartbeat
27
+ ProviderBridgeMixin incoming intercom/door INVITE -> SIP provider leg
28
+ HaAnswerMixin ha_mode: parked calls answered/ended programmatically (vdm10-ha)
29
+ LocalAnswerMixin local headset mode (answer on this machine)
30
+ OutboundCallMixin --call: dial another station (direct or via registrar)
31
+ InboundCallMixin inbound SIP app call -> --inbound-target on the intercom
32
+ TeardownMixin CANCEL/BYE from either leg
33
+ """
@@ -0,0 +1,87 @@
1
+ """Call teardown: CANCEL/BYE from either leg."""
2
+
3
+ import logging
4
+
5
+ from metzler.sip.message import UA, Packet, branch, uri_of
6
+
7
+ log = logging.getLogger("indoor")
8
+
9
+
10
+ class TeardownMixin:
11
+ """Call teardown: CANCEL/BYE from either leg."""
12
+
13
+ def _end_provider_leg(self, call):
14
+ """one side went away -> drop the other leg too"""
15
+ if call.inbound: # app leg ended -> end our intercom call
16
+ return self.bye_outbound(call.out_cid)
17
+ if call.fritz_leg: # door-call race still open? CANCEL it
18
+ self.fritz.cancel_leg(call)
19
+ call.fritz_leg = None
20
+ trunk = call.trunk or self.provider # the live/winning SIP leg
21
+ if trunk and call.prov_call_id in trunk.calls:
22
+ # BYE/CANCEL follows the trunk leg's own state, not call.state
23
+ # (in ha_mode the door leg is established while the trunk still rings)
24
+ if call.prov_established:
25
+ trunk.bye(call)
26
+ else:
27
+ trunk.cancel(call)
28
+ trunk.calls.pop(call.prov_call_id, None)
29
+
30
+ def on_cancel(self, pkt, addr):
31
+ self.send(self.in_dialog_response(pkt, "200 OK"), addr)
32
+ cid = pkt.get("Call-ID")
33
+ call = self.calls.get(cid)
34
+ if call:
35
+ self.reply(call, self.in_dialog_response(call.invite, "487 Request Terminated", extra_to_tag=call.to_tag))
36
+ self._end_provider_leg(call)
37
+ call.end_reason = "cancel"
38
+ self._close_call(call, cid)
39
+
40
+ def on_bye(self, pkt, addr):
41
+ self.send(self.in_dialog_response(pkt, "200 OK"), addr)
42
+ cid = pkt.get("Call-ID")
43
+ if cid in self.calls: # intercom/door caller hung up
44
+ call = self.calls[cid]
45
+ self._end_provider_leg(call)
46
+ call.end_reason = "bye"
47
+ self._close_call(call, cid)
48
+ return
49
+ for trunk in (self.provider, self.fritz):
50
+ if trunk and cid in trunk.calls: # a SIP leg's peer hung up
51
+ call = trunk.calls.pop(cid)
52
+ if call.fritz_leg: # don't leave the fritzfon ringing
53
+ self.fritz.cancel_leg(call)
54
+ call.fritz_leg = None
55
+ self.bye_intercom(call) # end the intercom leg too
56
+ self._close_call(call, call.id)
57
+ return
58
+ if cid in self.out_calls:
59
+ out = self.out_calls.pop(cid)
60
+ if out.get("local"):
61
+ out["local"].stop()
62
+ if out.get("bridged"): # intercom hung up -> BYE the app
63
+ call = out["bridged"]
64
+ self.bye_intercom(call)
65
+ call.end_reason = "bye"
66
+ self._close_call(call, call.id)
67
+ log.info("outbound call to %s ended by peer", out["num"])
68
+
69
+ def bye_intercom(self, call):
70
+ """BYE whoever INVITEd us on that dialog (intercom/door caller, or the
71
+ SIP app on an inbound-bridged call)"""
72
+ p = Packet()
73
+ uri = uri_of(call.invite.get("Contact") or call.invite.status_line.split()[1])
74
+ p.status_line = f"BYE {uri} SIP/2.0"
75
+ p.set("Via", f"SIP/2.0/UDP {self.o.local_ip}:{self.bind_port};rport;branch={branch()}")
76
+ p.set("Max-Forwards", "70")
77
+ p.set("Contact", self.contact())
78
+ p.set("To", call.invite.get("From"))
79
+ frm = call.invite.get("To") or ""
80
+ p.set("From", f"{frm};tag={call.to_tag}" if "tag=" not in frm else frm)
81
+ p.set("Call-ID", call.id)
82
+ p.set("CSeq", "1 BYE")
83
+ p.set("User-Agent", UA)
84
+ try:
85
+ self.send(p, call.addr)
86
+ except OSError:
87
+ pass
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.4
2
+ Name: vdm10-python
3
+ Version: 0.1.0
4
+ Summary: Python library and indoor-station simulator for Metzler/Hikvision VDM10 SIP intercoms
5
+ Keywords: sip,voip,intercom,doorbell,hikvision,metzler,vdm10,rtsp,home-automation
6
+ Author: lodzen
7
+ Author-email: lodzen <dalodzik@googlemail.com>
8
+ License-Expression: GPL-3.0-only
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Topic :: Communications :: Telephony
16
+ Classifier: Topic :: Home Automation
17
+ Classifier: Typing :: Typed
18
+ Requires-Dist: cryptography>=44
19
+ Requires-Python: >=3.13
20
+ Project-URL: Repository, https://github.com/lodzen/metzler-vdm10
21
+ Project-URL: Documentation, https://github.com/lodzen/metzler-vdm10/tree/main/docs
22
+ Project-URL: Issues, https://github.com/lodzen/metzler-vdm10/issues
23
+ Description-Content-Type: text/markdown
24
+
25
+ # vdm10-python
26
+
27
+ **Python library and indoor-station simulator for Metzler/Hikvision VDM10 SIP intercoms.**
28
+
29
+ Reverse-engineered implementation of the VDM10 private SIP dialect: registers as
30
+ a room station on the intercom's SIP registrar, receives door calls, bridges
31
+ them to a SIP provider (Linphone, Fritz!Box, Asterisk/any PBX) and back —
32
+ first answer wins, loser legs are cancelled.
33
+
34
+ ## Features
35
+
36
+ - **Room-station registration** on the indoor unit's registrar (UDP 5065)
37
+ - **Door calls** — INVITE from the outdoor station, RTP media relay, DTMF unlock
38
+ - **Provider bridging** — SIP trunk to Linphone/Fritz!Box/PBX; inbound app calls
39
+ ring the indoor stations, door calls fork to every registered endpoint
40
+ - **Local headset mode** — answer and talk directly on the machine running it
41
+ - **Media** — RTP relay, RTSP pull/talkback (PCMU), optional SRTP via `cryptography`
42
+ - **No mandatory dependencies** beyond `cryptography` — runs standalone with the
43
+ Python stdlib at module level (`python3 src/metzler/__main__.py`)
44
+
45
+ ## Install
46
+
47
+ ```bash
48
+ pip install vdm10-python # or: uv add vdm10-python
49
+ ```
50
+
51
+ Requires Python ≥ 3.13.
52
+
53
+ ## Run
54
+
55
+ ```bash
56
+ indoor-station # entry point, loads ./.env profile
57
+ python -m metzler # equivalent
58
+ ```
59
+
60
+ `.env` is the single profile: provider credentials, optional Fritz!Box trunk,
61
+ and local-audio toggles. See `docs/` for the full CLI surface. Offline
62
+ end-to-end check without hardware: `tools/simulate_call.py`.
63
+
64
+ ## Firmware support
65
+
66
+ - **VDM10 1.0** — fully supported
67
+ - **VDM10 2.x** — registration/call flow documented, support in progress
68
+
69
+ ## Documentation
70
+
71
+ | Path | Contents |
72
+ |---|---|
73
+ | `docs/protocol.md` | The Hikvision private-SIP dialect (registration, calls, media, teardown) |
74
+ | `docs/architecture.md` | Module map of `src/metzler/` |
75
+ | `docs/firmware/` | V1.0.x firmware specifics |
76
+ | `docs/firmware-v2/` | V2.x firmware specifics |
77
+ | `docs/version-comparison/` | V1 ↔ V2 protocol diff |
78
+
79
+ The reverse-engineering artifacts these docs are derived from live in
80
+ [`metzler-vdm-doc`](https://github.com/lodzen/metzler-vdm-doc). A Home Assistant
81
+ custom integration built on this library is
82
+ [`metzler-vdm10-ha`](https://github.com/lodzen/metzler-vdm10-ha).
83
+
84
+ ## License
85
+
86
+ GPL-3.0-only — see [LICENSE](LICENSE).
@@ -0,0 +1,38 @@
1
+ metzler/__init__.py,sha256=o3IYbmYcXJWalDq-04S0AY0ArrBq-NmPc7OlBrde1Vg,2911
2
+ metzler/__main__.py,sha256=EIVwmYb51dCzqlsDclR8NAEQWlAXxkbqVLCH1A1rzF0,485
3
+ metzler/cli.py,sha256=W6MLit-aossjPu1bMPz9pINqV4o_hvArc5Ca3trADrI,11779
4
+ metzler/config.py,sha256=4f2YnzAX9pP14ydX8eDwwaByE_lXp2vPVkmRpgYncb0,1289
5
+ metzler/discovery.py,sha256=jf_cWTWPlV_jkV8Lvy4pn1FbX_1B10dzlN_iD4gpx6s,19696
6
+ metzler/media/__init__.py,sha256=4fgVAoI9-x5__G6CC-UClk043PaQZEOFNcqLEEMkU1Q,94
7
+ metzler/media/g711.py,sha256=IM_r1E65y4J-sFOjZWJmOhegP-GKjD64MMTiNNwu-tg,1320
8
+ metzler/media/intercom.py,sha256=KVm_NO7ibUakSmQ-QIYxKdpnn3JQtY3VpCeTHOe8wSI,12658
9
+ metzler/media/local.py,sha256=tFUwID47lavGgicNO0q6LSj1f1N2871CNWs01PNQIxo,8376
10
+ metzler/media/rtp.py,sha256=GYQ7vW1rcn9dZ5CSb2D7bw1wMi9US40Fo892g8UraI0,3343
11
+ metzler/media/rtsp.py,sha256=g7TvTXI61mB2xg__R2Kz0lEsY3FPWTZWqv39t7Qxdsg,2709
12
+ metzler/media/rtsp_puller.py,sha256=qTJTOXwlIDhamEB09JDefKfTLltIVnehaT4g2Qozumg,4625
13
+ metzler/media/rtsp_server.py,sha256=DSzs6tCK3lYOtW9hAbeMGz5u1EEFJ-4IKihyYfUVZXc,9346
14
+ metzler/media/srtp.py,sha256=l7tJWSSe2SMJ71_fMItaETRCmbzLbnqEP8tCLR6u9Eg,4544
15
+ metzler/provider.py,sha256=APtvIeRObt6tDV7yYOzRTcHCF5an57PaGPn_G4DAtLs,21687
16
+ metzler/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ metzler/sip/__init__.py,sha256=bBXTb-XxAc2WCR51S8p0__uyHCEvinvJLFZFpMIBWmo,98
18
+ metzler/sip/digest.py,sha256=cYbX17LbJCJlfSD_s7hDALWhHnx9vMMKGpnEPI846zI,1663
19
+ metzler/sip/message.py,sha256=KNP5Rv-lXYHSw4sxC95UXeEWJxxL4qJmLBQrzZtIwe4,2159
20
+ metzler/sip/sdp.py,sha256=czGSnXfcp89mFQCrHnW1953l1o5R0_NLkBDPD6qbjOA,3766
21
+ metzler/station/__init__.py,sha256=6Bn1RGLqEU8naVCkv5yam9izouTMnbsESEmo7kxL8B8,198
22
+ metzler/station/bridge.py,sha256=zV93z8l_DCoLwQCjc92K_x05BGsDVqKyYsvM3b1iGh4,13145
23
+ metzler/station/call.py,sha256=W9GX2eY4oVuyQCLFI4X3dDTO0cAjDM-MzdC01-BzdCc,2580
24
+ metzler/station/core.py,sha256=yXUXGimkfc00ROrFoLXomFu3YEnbSNWrYqluwJgEsAs,25305
25
+ metzler/station/door_unlock.py,sha256=oQz98BYg9KZdGjCGRoO8TBVm-_t1hZr8_Ovy91nvUow,1719
26
+ metzler/station/ha_answer.py,sha256=dVcalVar_q7BwTDLXNXuJBGJ1y4DASQK886Gus1zZjU,4547
27
+ metzler/station/ha_media.py,sha256=pCTvC8Tl4y27E_SAmDqu_odijtWe4WbgYqTE69PE5WE,3687
28
+ metzler/station/inbound.py,sha256=j69d2oqRnV4Uwn6D290a8ly6GSmF31dmRLT9F2wmQ_o,4375
29
+ metzler/station/local_answer.py,sha256=OdmgkSNe5A0Ge5kZ81IPcqbYgb9iq_getAGxoXJyLAM,4521
30
+ metzler/station/outbound.py,sha256=aCn2X1t2ql2xXhw7aqKa-982mU5-xnLx9C4_Vq9VfJI,5711
31
+ metzler/station/registration.py,sha256=SXxfVypMKVuixGwcKYyk37q9G93ZFD5wcOd3WKkdIlw,6839
32
+ metzler/station/station.py,sha256=7QKHVGefSC-DLieUT2_uDWI0WqdIjDcmqHmQ7fa2fgE,1406
33
+ metzler/station/teardown.py,sha256=F0TD1l9zq8ds7FIN17pG4D8OKX4eUqxgNtwanPkoFPY,3603
34
+ vdm10_python-0.1.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
35
+ vdm10_python-0.1.0.dist-info/WHEEL,sha256=G_-rrEibZr7OEM7zdH1dSO6s-VdjfnS5PA4CLAdI9Vw,80
36
+ vdm10_python-0.1.0.dist-info/entry_points.txt,sha256=OEwvWzx6A_ei1KHpdCqe6kVr4WtEBUjaPs0ay12dJ2Y,76
37
+ vdm10_python-0.1.0.dist-info/METADATA,sha256=09eKNmlV8StnqmjRpVjTa4Ij10PlRh0-dF-djc-6Lbs,3309
38
+ vdm10_python-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.13.9
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ indoor-station = metzler.cli:main
3
+ metzler = metzler:main
4
+