Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 64125ee

Browse files
committed
Allow video codec preference when publishing with RTCRtpEncodingParameters.
As per Lei's request, codec preference is a mandatory feature for simulcast. This parameter is a workaround for setting video codecs. We'll move to RTCRtpSendParameters in the future.
1 parent 3bb7ed7 commit 64125ee

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/sdk/base/publication.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,14 @@ export class PublishOptions {
181181
* @member {?Array<Owt.Base.AudioEncodingParameters> | ?Array<RTCRtpEncodingParameters>} audio
182182
* @instance
183183
* @memberof Owt.Base.PublishOptions
184-
* @desc Parameters for audio RtpSender.
184+
* @desc Parameters for audio RtpSender. Publishing with RTCRtpEncodingParameters is an experimental feature. It is subject to change.
185185
*/
186186
this.audio = audio;
187187
/**
188188
* @member {?Array<Owt.Base.VideoEncodingParameters> | ?Array<RTCRtpEncodingParameters>} video
189189
* @instance
190190
* @memberof Owt.Base.PublishOptions
191-
* @desc Parameters for video RtpSender.
191+
* @desc Parameters for video RtpSender. Publishing with RTCRtpEncodingParameters is an experimental feature. It is subject to change.
192192
*/
193193
this.video = video;
194194
}

src/sdk/conference/channel.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
3434
super();
3535
this._config = config;
3636
this._options = null;
37+
this._videoCodecs = undefined;
3738
this._signaling = signaling;
3839
this._pc = null;
3940
this._internalId = null; // It's publication ID or subscription ID.
@@ -75,7 +76,7 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
7576
}
7677
}
7778

78-
publish(stream, options) {
79+
publish(stream, options, videoCodecs) {
7980
if (options === undefined) {
8081
options = {audio: !!stream.mediaStream.getAudioTracks().length, video: !!stream
8182
.mediaStream.getVideoTracks().length};
@@ -218,6 +219,7 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
218219
};
219220
if (this._isRtpEncodingParameters(options.video)) {
220221
transceiverInit.sendEncodings = options.video;
222+
this._videoCodecs = videoCodecs;
221223
}
222224
this._pc.addTransceiver(stream.mediaStream.getVideoTracks()[0],
223225
transceiverInit);
@@ -675,6 +677,11 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
675677
}
676678

677679
_setRtpReceiverOptions(sdp, options) {
680+
// _videoCodecs is a workaround for setting video codecs. It will be moved to RTCRtpSendParameters.
681+
if (this._isRtpEncodingParameters(options.video) && this._videoCodecs) {
682+
sdp = SdpUtils.reorderCodecs(sdp, 'video', this._videoCodecs);
683+
return sdp;
684+
}
678685
if (this._isRtpEncodingParameters(options.audio) ||
679686
this._isRtpEncodingParameters(options.video)) {
680687
return sdp;

src/sdk/conference/client.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,10 @@ export const ConferenceClient = function(config, signalingImpl) {
394394
* @desc Publish a LocalStream to conference server. Other participants will be able to subscribe this stream when it is successfully published.
395395
* @param {Owt.Base.LocalStream} stream The stream to be published.
396396
* @param {Owt.Base.PublishOptions} options Options for publication.
397+
* @param {string[]} videoCodecs Video codec names for publishing. Valid values are 'VP8', 'VP9' and 'H264'. This parameter only valid when options.video is RTCRtpEncodingParameters. Publishing with RTCRtpEncodingParameters is an experimental feature. This parameter is subject to change.
397398
* @returns {Promise<Publication, Error>} Returned promise will be resolved with a newly created Publication once specific stream is successfully published, or rejected with a newly created Error if stream is invalid or options cannot be satisfied. Successfully published means PeerConnection is established and server is able to process media data.
398399
*/
399-
this.publish = function(stream, options) {
400+
this.publish = function(stream, options, videoCodecs) {
400401
if (!(stream instanceof StreamModule.LocalStream)) {
401402
return Promise.reject(new ConferenceError('Invalid stream.'));
402403
}
@@ -405,7 +406,7 @@ export const ConferenceClient = function(config, signalingImpl) {
405406
'Cannot publish a published stream.'));
406407
}
407408
const channel = createPeerConnectionChannel();
408-
return channel.publish(stream, options);
409+
return channel.publish(stream, options, videoCodecs);
409410
};
410411

411412
/**

0 commit comments

Comments
 (0)