How mayamatakeshi/sip-mrcp works
Purpose and public entry point
sip-mrcp is a Node.js library for building MRCPv2 clients and servers over SIP, with RTP media transport. The package entry point is index.js, which exposes the SIP/MRCP stack API used by applications such as the paired examples in samples/client.js and samples/server.js.
Stack orchestration
lib/sip_mrcp_stack.js defines SipMrcpStack, the primary integration boundary. It is configured with:
• SIP signaling options and listening address/port
• RTP local address and allocatable media ports
• MRCP control-channel port
• an optional inbound-session callback
Applications instantiate one stack per client/server endpoint and use it to create outgoing sessions or receive incoming ones.
Paths: lib/sip_mrcp_stack.js, index.js
SIP signaling and session negotiation
The stack manages SIP-based session establishment and resource negotiation for MRCP resources such as speech synthesis. Client flow begins with create_session(sip_uri, resource_type, offer_payloads, callback). Server flow enters through new_session_callback, where the application accepts a negotiated media payload or refuses the invitation.
Codec payload definitions—including payload ID, codec name, and clock rate—cross the SIP/SDP negotiation boundary and determine the RTP media format.
Paths: lib/sip_mrcp_stack.js, samples/client.js, samples/server.js
Session abstraction
lib/session.js represents an established or pending client/server interaction. It provides the application-facing control and event boundary:
• accept or refuse inbound sessions
• send MRCP messages with send_mrcp_msg
• receive mrcp_msg events
• receive rtp_data events
This keeps protocol transport details below a session-oriented EventEmitter-style API.
Paths: lib/session.js, samples/client.js, samples/server.js
MRCP control flow
After SIP negotiation creates the session, MRCPv2 control messages are sent and received through the session abstraction. Client applications issue MRCP requests; server applications consume those messages and implement the chosen resource behavior. The library’s MRCP integration is external to this repository and is supplied through the Node dependency ecosystem.
Paths: lib/session.js, lib/sip_mrcp_stack.js
RTP media flow
RTP media is negotiated alongside the MRCP session, using configured local IPs and a supplied pool/list of local RTP ports. Received media is emitted as rtp_data on the session. Payload selection made during session acceptance determines the codec expected on this path.
Paths: lib/sip_mrcp_stack.js, lib/session.js
Runtime and external boundaries
The repository is a Node.js package, executed directly by consumers or sample programs. Its material external protocol/runtime dependencies are SIP signaling, MRCPv2 control transport, RTP media transport, and the external SIP.js and MRCP libraries referenced by the package and README. Utility logic is centralized separately from stack/session ownership.
Paths: package.json, lib/utils.js, samples/client.js
Main entry points: sip_mrcp_stack.js SipMrcpStack · session.js Session · index.js Package entry · client.js Client sample
Components 12
Consumers
- Client sample · Creates outgoing MRCP sessions and sends requests.
samples/client.js - Server sample · Accepts inbound sessions and handles MRCP requests.
samples/server.js
sip-mrcp package
- Package entry
index.js - SipMrcpStack · Owns SIP setup, negotiation, and media/control configuration.
lib/sip_mrcp_stack.js - Session · Application boundary for acceptance, MRCP messages, and RTP events.
lib/session.js - Utilities
lib/utils.js - Package manifest
package.json
Protocol dependencies
- SIP.js · Provides SIP signaling integration.
- MRCP library · Provides MRCPv2 control transport integration.
- SIP peer
- MRCP resource
- RTP media peer · Codec payload selection determines the media format.
Connections 15
- Client sample → Package entry: uses
- Server sample → Package entry: uses
- Package entry → SipMrcpStack: exports
- SipMrcpStack → Session: creates negotiated sessions
- SipMrcpStack → Utilities: uses
- Package manifest → SIP.js: declares
- Package manifest → MRCP library: declares
- SipMrcpStack → SIP.js: uses
- SipMrcpStack → SIP peer: SIP/SDP negotiation
- SipMrcpStack → MRCP library: opens control channel
- Session → MRCP library: sends and receives MRCP
- MRCP library → MRCP resource: MRCPv2 messages
- Session → RTP media peer: emits and sends RTP
- Server sample → Session: accepts or refuses; handles events
- Client sample → Session: sends requests; handles events