how set media constraints

336 views
Skip to first unread message

Wilbert Jackson

unread,
Mar 4, 2015, 1:14:38 PM3/4/15
to meetech...@googlegroups.com
In Janus.js (ver 0.0.8) using Chrome I am trying to set media constraints using the snippet code below. The problem I am having is that media.video returns undefined and never provides a match for lowres, hires, nor screen cases.

Thanks

wilbert jackson

var videoSupport = isVideoSendEnabled(media);
if(videoSupport === true && media != undefined && media != null) {
if(media.video === 'lowres') {
// Add a video constraint (320x240)
if(!navigator.mozGetUserMedia) {
videoSupport = {"mandatory": {"maxHeight": "240", "maxWidth": "320"}, "optional": []};
Janus.log("Adding media constraint (low-res video)");
Janus.log(videoSupport);
} else {
Janus.log("Firefox doesn't support media constraints at the moment, ignoring low-res video");
}
} else if(media.video === 'hires') {
// Add a video constraint (1280x720)
if(!navigator.mozGetUserMedia) {
videoSupport = {"mandatory": {"minHeight": "720", "minWidth": "1280"}, "optional": []};
Janus.log("Adding media constraint (hi-res video)");
Janus.log(videoSupport);
} else {
Janus.log("Firefox doesn't support media constraints at the moment, ignoring hi-res video");
}
} else if(media.video === 'screen') {
// Not a webcam, but screen capture
if(window.location.protocol !== 'https:') {
// Screen sharing mandates HTTPS
Janus.log("Screen sharing only works on HTTPS, try the https:// version of this page");
pluginHandle.consentDialog(false);
callbacks.error("Screen sharing only works on HTTPS, try the https:// version of this page");
return;
}

Gatecrasher777

unread,
Mar 4, 2015, 8:55:58 PM3/4/15
to meetech...@googlegroups.com
You need to update janus.js (and probably adapter.js) That code has changed quite a lot recently. It now has more options that just lowres or hires.

If you want to put in your own global constraints, you could just define the videoSupport object at the end of that block. i.e.

if(navigator.mozGetUserMedia) {
videoSupport = {
   'require': ['height', 'width'],
   'height': {'max': 640, 'min': 480},
   'width':  {'max': 640, 'min': 480}
};
} else {
videoSupport = {
   'mandatory': {},
   'optional': [{"minHeight": "480"},{"maxHeight": "640"},{"minWidth": "480"},{"maxWidth": "640"},{"minFrameRate": "10"}]
};
}

Wilbert Jackson

unread,
Mar 5, 2015, 10:19:02 AM3/5/15
to meetech...@googlegroups.com
Thanks much

wilbert jackson

Wilbert Jackson

unread,
Mar 6, 2015, 11:44:45 AM3/6/15
to meetech...@googlegroups.com
I updated Janus.js. but the media object has fields:

audioRecv: true
videoRecv: true
audioSend: true
videoSend: true
data: true

and no media.video as expected in the snippet below. media.video returns undefined.

Thanks

wilbert jackson

if(videoSupport === true && media != undefined && media != null) {
if(media.video && media.video != 'screen') {
var width = 0;
var height = 0, maxHeight = 0;

On Wednesday, March 4, 2015 at 8:55:58 PM UTC-5, Gatecrasher777 wrote:

Lorenzo Miniero

unread,
Mar 6, 2015, 12:26:55 PM3/6/15
to meetech...@googlegroups.com
The documentation explains all that,

L.

Wilbert Jackson

unread,
Mar 6, 2015, 2:13:30 PM3/6/15
to meetech...@googlegroups.com
Thanks
Reply all
Reply to author
Forward
0 new messages