Skip to content

Commit 83fa78a

Browse files
author
John Riordan
committed
SessionDelegate - add onSessionDescriptionHandler
1 parent 1c49204 commit 83fa78a

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/api/inviter.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,9 @@ export class Inviter extends Session {
10001000
this,
10011001
this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions || {}
10021002
);
1003+
if (this.delegate?.onSessionDescriptionHandler) {
1004+
this.delegate.onSessionDescriptionHandler(sdh, true);
1005+
}
10031006
this.earlyMediaSessionDescriptionHandlers.set(session.id, sdh);
10041007
return sdh
10051008
.setDescription(response.body, sdhOptions, sdhModifiers)

src/api/session-delegate.ts

+28
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Info } from "./info";
44
import { Message } from "./message";
55
import { Notification } from "./notification";
66
import { Referral } from "./referral";
7+
import { SessionDescriptionHandler } from "./session-description-handler";
78

89
/**
910
* Delegate for {@link Session}.
@@ -49,4 +50,31 @@ export interface SessionDelegate {
4950
* @param referral - The referral.
5051
*/
5152
onRefer?(referral: Referral): void;
53+
54+
/**
55+
* Called upon creating a SessionDescriptionHandler.
56+
*
57+
* @remarks
58+
* It's recommended that the SessionDescriptionHandler be accessed via the `Session.sessionDescriptionHandler` property.
59+
* However there are use cases where one needs access immediately after it is constructed and before it is utilized.
60+
* Thus this callback.
61+
*
62+
* In most scenarios a single SessionDescriptionHandler will be created per Session
63+
* in which case this callback will be called at most once and `provisional` will be `false`.
64+
*
65+
* However if reliable provisional responses are being supported and an INVITE is sent without SDP,
66+
* one or more session description handlers will be created if remote offers are received in reliable provisional responses.
67+
* When remote offers are received in reliable provisional responses, the `provisional` parameter will be `true`.
68+
* When the `provisional` paramter is `true`, this callback may (or may not) be called again.
69+
* If the session is ultimately established using a SessionDescriptionHandler which was not created provisionally,
70+
* this callback will be called again and the `provisional` parameter will be `false`.
71+
* If the session is ultimately established using a SessionDescriptionHandler which was created provisionally,
72+
* this callback will not be called again.
73+
* Note that if the session is ultimately established using a SessionDescriptionHandler which was created provisionally,
74+
* the provisional SessionDescriptionHandler being utilized will be available via the `Session.sessionDescriptionHandler` property.
75+
*
76+
* @param sessionDescriptionHandler - The handler.
77+
* @param provisional - True if created provisionally.
78+
*/
79+
onSessionDescriptionHandler?(sessionDescriptionHandler: SessionDescriptionHandler, provisional: boolean): void;
5280
}

src/api/session.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,9 @@ export abstract class Session {
12451245
this,
12461246
this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions
12471247
);
1248+
if (this.delegate?.onSessionDescriptionHandler) {
1249+
this.delegate.onSessionDescriptionHandler(this._sessionDescriptionHandler, false);
1250+
}
12481251
return this._sessionDescriptionHandler;
12491252
}
12501253

0 commit comments

Comments
 (0)