Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ var eventHandlers = {

var options = {
'eventHandlers' : eventHandlers,
'mediaConstraints' : { 'audio': true, 'video': true }
'mediaConstraints' : { 'audio': true, 'video': true },
'callId' : 'a84b4c76e66710'
};

var session = ua.call('sip:bob@example.com', options);
Expand Down
6 changes: 6 additions & 0 deletions lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ exports.settings = {

// SIP instance id (GRUU).
instance_id : null,
// Default Call-ID for REGISTER.
call_id : null,

// Preloaded SIP Route header field.
use_preloaded_route : false,
Expand Down Expand Up @@ -204,6 +206,10 @@ const checks = {
return instance_id;
}
},
call_id(call_id)
{
return String(call_id);
},

no_answer_timeout(no_answer_timeout)
{
Expand Down
1 change: 1 addition & 0 deletions lib/Message.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface SendMessageOptions extends ExtraHeaders {
eventHandlers?: Partial<MessageEventMap>;
fromUserName?: string;
fromDisplayName?: string;
callId?: string;
}

export class Message extends EventEmitter {
Expand Down
4 changes: 4 additions & 0 deletions lib/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ module.exports = class Message extends EventEmitter
const contentType = options.contentType || 'text/plain';

const requestParams = {};
if (options.callId !== undefined && options.callId !== null)
{
requestParams.call_id = String(options.callId);
}

if (options.fromUserName)
{
Expand Down
8 changes: 7 additions & 1 deletion lib/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ module.exports = class Options extends EventEmitter
const extraHeaders = Utils.cloneArray(options.extraHeaders);
const eventHandlers = Utils.cloneObject(options.eventHandlers);
const contentType = options.contentType || 'application/sdp';
const requestParams = {};

if (options.callId !== undefined && options.callId !== null)
{
requestParams.call_id = String(options.callId);
}

// Set event handlers.
for (const event in eventHandlers)
Expand All @@ -77,7 +83,7 @@ module.exports = class Options extends EventEmitter
extraHeaders.push(`Content-Type: ${contentType}`);

this._request = new SIPMessage.OutgoingRequest(
JsSIP_C.OPTIONS, target, this._ua, null, extraHeaders);
JsSIP_C.OPTIONS, target, this._ua, requestParams, extraHeaders);

if (body)
{
Expand Down
4 changes: 4 additions & 0 deletions lib/RTCSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ module.exports = class RTCSession extends EventEmitter
const anonymous = options.anonymous || false;

const requestParams = { from_tag: this._from_tag };
if (options.callId !== undefined && options.callId !== null)
{
requestParams.call_id = String(options.callId);
}

this._contact = this._ua.contact.toString({
anonymous,
Expand Down
3 changes: 2 additions & 1 deletion lib/Registrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module.exports = class Registrator
this._expires = ua.configuration.register_expires;

// Call-ID and CSeq values RFC3261 10.2.
this._call_id = Utils.createRandomToken(22);
this._call_id = this._ua.configuration.call_id ||
Utils.createRandomToken(22);
this._cseq = 0;

this._to_uri = ua.configuration.uri;
Expand Down
2 changes: 2 additions & 0 deletions lib/UA.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface CallOptions extends AnswerOptions {
anonymous?: boolean;
fromUserName?: string;
fromDisplayName?: string;
callId?: string;
}

export interface UAConfiguration {
Expand All @@ -41,6 +42,7 @@ export interface UAConfiguration {
register?: boolean;
register_expires?: number;
register_from_tag_trail?: string | (() => string);
call_id?: string;
registrar_server?: string;
use_preloaded_route?: boolean;
user_agent?: string;
Expand Down