@ariaflowagents/livekit-plugin-transport-sip 0.9.0
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.
- package/README.md +22 -0
- package/dist/audio_input.d.ts +24 -0
- package/dist/audio_input.d.ts.map +1 -0
- package/dist/audio_input.js +58 -0
- package/dist/audio_input.js.map +1 -0
- package/dist/audio_output.d.ts +34 -0
- package/dist/audio_output.d.ts.map +1 -0
- package/dist/audio_output.js +133 -0
- package/dist/audio_output.js.map +1 -0
- package/dist/codec/g711.d.ts +17 -0
- package/dist/codec/g711.d.ts.map +1 -0
- package/dist/codec/g711.js +123 -0
- package/dist/codec/g711.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/jssip_signaling.d.ts +76 -0
- package/dist/jssip_signaling.d.ts.map +1 -0
- package/dist/jssip_signaling.js +255 -0
- package/dist/jssip_signaling.js.map +1 -0
- package/dist/rtp/jitter_buffer.d.ts +19 -0
- package/dist/rtp/jitter_buffer.d.ts.map +1 -0
- package/dist/rtp/jitter_buffer.js +51 -0
- package/dist/rtp/jitter_buffer.js.map +1 -0
- package/dist/rtp/rtp_packet.d.ts +23 -0
- package/dist/rtp/rtp_packet.d.ts.map +1 -0
- package/dist/rtp/rtp_packet.js +63 -0
- package/dist/rtp/rtp_packet.js.map +1 -0
- package/dist/rtp/rtp_session.d.ts +54 -0
- package/dist/rtp/rtp_session.d.ts.map +1 -0
- package/dist/rtp/rtp_session.js +162 -0
- package/dist/rtp/rtp_session.js.map +1 -0
- package/dist/sdp_g711.d.ts +18 -0
- package/dist/sdp_g711.d.ts.map +1 -0
- package/dist/sdp_g711.js +74 -0
- package/dist/sdp_g711.js.map +1 -0
- package/dist/server.d.ts +76 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +197 -0
- package/dist/server.js.map +1 -0
- package/dist/sip_signaling.d.ts +73 -0
- package/dist/sip_signaling.d.ts.map +1 -0
- package/dist/sip_signaling.js +553 -0
- package/dist/sip_signaling.js.map +1 -0
- package/dist/text_output.d.ts +16 -0
- package/dist/text_output.d.ts.map +1 -0
- package/dist/text_output.js +35 -0
- package/dist/text_output.js.map +1 -0
- package/dist/transport_adapter.d.ts +22 -0
- package/dist/transport_adapter.d.ts.map +1 -0
- package/dist/transport_adapter.js +44 -0
- package/dist/transport_adapter.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport_adapter.d.ts","sourceRoot":"","sources":["../src/transport_adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAEjE,qBAAa,mBAAoB,SAAQ,gBAAgB;IAUrD,OAAO,CAAC,UAAU;IATpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAExC,OAAO,CAAC,OAAO,CAAiB;gBAGtB,UAAU,EAAE,UAAU,EAC9B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B;IAgCH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ7B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TransportAdapter, } from '@ariaflow/livekit-plugin';
|
|
2
|
+
import { SIPAudioInput } from './audio_input.js';
|
|
3
|
+
import { SIPAudioOutput } from './audio_output.js';
|
|
4
|
+
import { SIPTextOutput } from './text_output.js';
|
|
5
|
+
export class SIPTransportAdapter extends TransportAdapter {
|
|
6
|
+
rtpSession;
|
|
7
|
+
id;
|
|
8
|
+
audioInput;
|
|
9
|
+
audioOutput;
|
|
10
|
+
textOutput;
|
|
11
|
+
config;
|
|
12
|
+
_isOpen = true;
|
|
13
|
+
constructor(rtpSession, codec, options) {
|
|
14
|
+
super();
|
|
15
|
+
this.rtpSession = rtpSession;
|
|
16
|
+
this.id = options.id;
|
|
17
|
+
const packetDurationMs = options.packetDurationMs ?? 20;
|
|
18
|
+
// SIPAudioInput upsamples decoded G.711 (8kHz) to 16kHz for STT.
|
|
19
|
+
// Report the actual output rate so AriaFlowVoiceSession forwards
|
|
20
|
+
// the correct sample rate to the STT engine.
|
|
21
|
+
const outputSampleRate = 16000;
|
|
22
|
+
this.config = {
|
|
23
|
+
sampleRate: outputSampleRate,
|
|
24
|
+
numChannels: codec.channels,
|
|
25
|
+
encoding: codec.name === 'PCMU' ? 'mulaw' : 'alaw',
|
|
26
|
+
samplesPerChannel: (outputSampleRate * packetDurationMs) / 1000,
|
|
27
|
+
};
|
|
28
|
+
this.audioInput = new SIPAudioInput(rtpSession, codec.sampleRate, codec.channels);
|
|
29
|
+
this.audioOutput = new SIPAudioOutput(rtpSession, codec.sampleRate, packetDurationMs);
|
|
30
|
+
this.textOutput = new SIPTextOutput();
|
|
31
|
+
}
|
|
32
|
+
get isOpen() {
|
|
33
|
+
return this._isOpen;
|
|
34
|
+
}
|
|
35
|
+
async close() {
|
|
36
|
+
if (!this._isOpen)
|
|
37
|
+
return;
|
|
38
|
+
this._isOpen = false;
|
|
39
|
+
await this.audioInput.close();
|
|
40
|
+
await this.audioOutput.close();
|
|
41
|
+
this.rtpSession.close();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=transport_adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport_adapter.js","sourceRoot":"","sources":["../src/transport_adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAIjD,MAAM,OAAO,mBAAoB,SAAQ,gBAAgB;IAU7C;IATD,EAAE,CAAS;IACX,UAAU,CAAgB;IAC1B,WAAW,CAAiB;IAC5B,UAAU,CAAgB;IAC1B,MAAM,CAAyB;IAEhC,OAAO,GAAY,IAAI,CAAC;IAEhC,YACU,UAAsB,EAC9B,KAAY,EACZ,OAGC;QAED,KAAK,EAAE,CAAC;QAPA,eAAU,GAAV,UAAU,CAAY;QAS9B,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QACrB,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC;QAExD,iEAAiE;QACjE,iEAAiE;QACjE,6CAA6C;QAC7C,MAAM,gBAAgB,GAAG,KAAK,CAAC;QAE/B,IAAI,CAAC,MAAM,GAAG;YACZ,UAAU,EAAE,gBAAgB;YAC5B,WAAW,EAAE,KAAK,CAAC,QAAQ;YAC3B,QAAQ,EAAE,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;YAClD,iBAAiB,EAAE,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,IAAI;SAChE,CAAC;QAEF,IAAI,CAAC,UAAU,GAAG,IAAI,aAAa,CACjC,UAAU,EACV,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,QAAQ,CACf,CAAC;QACF,IAAI,CAAC,WAAW,GAAG,IAAI,cAAc,CACnC,UAAU,EACV,KAAK,CAAC,UAAU,EAChB,gBAAgB,CACjB,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,IAAI,aAAa,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QAC1B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QAErB,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SIP transport type.
|
|
3
|
+
*/
|
|
4
|
+
export type SIPTransport = 'udp' | 'websocket';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for SIP server.
|
|
7
|
+
*/
|
|
8
|
+
export interface SIPServerOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Transport type:
|
|
11
|
+
* - 'udp': production RTP telephony in this package
|
|
12
|
+
* - 'websocket': deprecated here, use @ariaflow/livekit-plugin-transport-sip-jssip
|
|
13
|
+
* Default: 'udp'
|
|
14
|
+
*/
|
|
15
|
+
transport?: SIPTransport;
|
|
16
|
+
/** Port for SIP signaling (UDP transport). Default: 5060. */
|
|
17
|
+
sipPort?: number;
|
|
18
|
+
/** Protocol for UDP transport ('udp' or 'tcp'). Default: 'udp'. */
|
|
19
|
+
sipProtocol?: 'udp' | 'tcp';
|
|
20
|
+
/** Starting port for RTP media. Each call uses two consecutive ports. Default: 10000. */
|
|
21
|
+
rtpPortStart?: number;
|
|
22
|
+
/** Local IP address to advertise in SDP. */
|
|
23
|
+
localAddress: string;
|
|
24
|
+
/** Preferred codec. Default: 'PCMU' (G.711 μ-law). */
|
|
25
|
+
codec?: 'PCMU' | 'PCMA';
|
|
26
|
+
/**
|
|
27
|
+
* Send RTP on a fixed wall clock with silence fill when idle (see RtpSession).
|
|
28
|
+
* Default false.
|
|
29
|
+
*/
|
|
30
|
+
continuousPacing?: boolean;
|
|
31
|
+
/** WebSocket server host (for WebSocket transport). Default: localAddress. */
|
|
32
|
+
wsServerHost?: string;
|
|
33
|
+
/** WebSocket server port (for WebSocket transport). Default: 8080. */
|
|
34
|
+
wsServerPort?: number;
|
|
35
|
+
/** Use secure WebSocket (WSS) instead of WS (for WebSocket transport). Default: true. */
|
|
36
|
+
secureWebSocket?: boolean;
|
|
37
|
+
/** SIP username for registration (for WebSocket transport). */
|
|
38
|
+
sipUsername?: string;
|
|
39
|
+
/** SIP password for registration (for WebSocket transport). */
|
|
40
|
+
sipPassword?: string;
|
|
41
|
+
/** SIP domain for registration (for WebSocket transport). Default: localAddress. */
|
|
42
|
+
sipDomain?: string;
|
|
43
|
+
/** Whether to register with SIP server (for WebSocket transport). Default: true. */
|
|
44
|
+
shouldRegister?: boolean;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,WAAW,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC;IAEzB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mEAAmE;IACnE,WAAW,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAE5B,yFAAyF;IACzF,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAC;IAErB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAI3B,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,yFAAyF;IACzF,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,oFAAoF;IACpF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ariaflowagents/livekit-plugin-transport-sip",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "SIP/RTP transport adapter for LiveKit Agents. Run voice agents over traditional telephony with G.711 codec support.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"test": "bun test test",
|
|
20
|
+
"test:typecheck": "tsc -p test/tsconfig.json --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"node.js-sip": "^1.0.9"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@ariaflowagents/livekit-plugin": "workspace:*",
|
|
27
|
+
"@livekit/agents": ">=1.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^22.10.0",
|
|
31
|
+
"typescript": "^5.5.0"
|
|
32
|
+
},
|
|
33
|
+
"license": "Apache-2.0"
|
|
34
|
+
}
|