Skip to content

Commit

Permalink
Add ReactNativeUnifiedPlan
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Jun 13, 2024
1 parent 3335081 commit 9924973
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/handlers/ReactNativeUnifiedPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export class ReactNativeUnifiedPlan extends HandlerInterface {
encodings,
codecOptions,
codec,
onRtpSender,
}: HandlerSendOptions): Promise<HandlerSendResult> {
this.assertNotClosed();
this.assertSendDirection();
Expand Down Expand Up @@ -368,6 +369,11 @@ export class ReactNativeUnifiedPlan extends HandlerInterface {
streams: [this._sendStream],
sendEncodings: encodings,
});

if (onRtpSender) {
onRtpSender(transceiver.sender);
}

let offer = await this._pc.createOffer();
let localSdpObject = sdpTransform.parse(offer.sdp);
let offerMediaObject;
Expand Down Expand Up @@ -884,6 +890,23 @@ export class ReactNativeUnifiedPlan extends HandlerInterface {

await this._pc.setRemoteDescription(offer);

for (const options of optionsList) {
const { trackId, onRtpReceiver } = options;

if (onRtpReceiver) {
const localId = mapLocalId.get(trackId);
const transceiver = this._pc
.getTransceivers()
.find((t: RTCRtpTransceiver) => t.mid === localId);

if (!transceiver) {
throw new Error('transceiver not found');
}

onRtpReceiver(transceiver.receiver);
}
}

let answer = await this._pc.createAnswer();
const localSdpObject = sdpTransform.parse(answer.sdp);

Expand Down

0 comments on commit 9924973

Please sign in to comment.