Skip to content

Commit

Permalink
update uuid_audio_fork to have new delimiter |
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu committed Mar 28, 2024
1 parent 2a6f471 commit c31edc3
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions lib/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,11 @@ class Endpoint extends Emitter {
* @param {function} [callback] - callback invoked when api request completes
* @return {Promise|Endpoint} returns a Promise if no callback supplied; otherwise
* a reference to the Endpoint object
* Freeswitch command
* <uuid> [start | stop | send_text | pause | resume | graceful-shutdown | stop_play ]
* [wss-url | path] [mono | mixed | stereo] [8000 | 16000 | 24000 | 32000 | 64000]
* [bugname] [metadata] [bidrectionalAduo_enabled] [bidrectionalAduo_stream_enabled]
* [bidrectionalAduo_stream_samplerate]
*/
forkAudioStart(opts, callback) {
assert.ok(typeof opts.wsUrl === 'string', 'opts.wsUrl is required');
Expand All @@ -895,18 +900,27 @@ class Endpoint extends Emitter {
'opts.mixType must be \'mono\', \'mixed\', \'stereo\'');

const __x = (callback) => {
// uudid start ws-url mono 8000
const args = [this.uuid, 'start', opts.wsUrl, mix, sampling];
if (opts.bugname) args.push(opts.bugname);
// bugname
args.push(opts.bugname || '');
// metadata
if (opts.metadata) {
const text = typeof opts.metadata === 'string' ?
`'${opts.metadata}'` :
`'${JSON.stringify(opts.metadata)}'`;
args.push(text);
} else {
args.push('');
}
if (opts.bidirectionalAudioSampleRate) {
args.push(`bi_audio_sample_rate=${opts.bidirectionalAudioSampleRate}`);
}
this.api('uuid_audio_fork', args, (err, evt) => {
// bidrectionalAduo_enabled
//jslint does not support opts.bidirectionalAudio?.enabled
args.push(opts.bidirectionalAudio ? opts.bidirectionalAudio.enabled || 'true' : 'true');
//bidrectionalAduo_stream_enabled
args.push(opts.bidirectionalAudio ? opts.bidirectionalAudio.streaming || 'false' : 'false');
//bidrectionalAduo_stream_samplerate
args.push(opts.bidirectionalAudio ? opts.bidirectionalAudio.sampleRate || '' : '');
this.api('uuid_audio_fork', `^^|${args.join('|')}`, (err, evt) => {
if (err) return callback(err);
const body = evt.getBody() ;
if (0 === body.indexOf('+OK')) {
Expand Down

0 comments on commit c31edc3

Please sign in to comment.