i used this code its working on system but not in motorola device
navigator.getUserMedia(constraints,
function(stream) {
consentCB(false);
myStream = stream;
// Create PeerConnection
var pc_config = iceServers;
var pc_constraints = {
"optional": [{"DtlsSrtpKeyAgreement": true}]
};
//pc connection details
//pc = new RTCPeerConnection(iceServers, pc_constraints);
pc = new RTCPeerConnection({
"iceServers": iceServers,
pc_constraints,
});
window.pc = pc;
pc.onicecandidate = function(event) {
// Trickle candidate (or the end of the gathering process)
var candidate = null;
if(event.candidate === null) {
candidate = { completed: true };
} else {
candidate = {
candidate: event.candidate.candidate,
sdpMid: event.candidate.sdpMid,
sdpMLineIndex: event.candidate.sdpMLineIndex
};
}
console.log("Trickling candidate:", candidate);
console.log(iceServers);
var msg = {
monet: "trickle",
id: randomString(16),
payload: {
candidate: candidate
}
};
sendMsg(msg);
};
pc.addStream(stream);
var previewCB = (typeof that.callbacks["preview"] == "function") ? that.callbacks["preview"] : MonetDemo.noop;
previewCB(stream);
// Create offer
pc.createOffer(
function(offer) {
if(sdpSent === true) {
console.log("Offer already sent, not sending it again");
return;
}
sdpSent = true;
pc.setLocalDescription(offer);
var jsep = {
type: offer.type,
sdp: offer.sdp
};
// Send the open request
var msg = {
monet: "open",
id: randomString(16),
payload: {
jsep: jsep
}
};
sendMsg(msg, function response(result) {
console.log("Got answer to offer");
if(result["monet"] === "error") {
that.hangup();
console.log(result["payload"]["reason"]);
callback(result["payload"]["reason"]);
return;
}
var remoteJsep = result["payload"]["jsep"];
console.log(remoteJsep);
pc.setRemoteDescription(
new RTCSessionDescription(remoteJsep),
function() {
console.log("Remote description accepted!");
callback();
}, function(error) {
that.hangup();
console.log(error);
callback(error);
});
});
}, function(error) {
that.hangup();
console.log(error);
callback(error);
});
},
function(error) {
consentCB(false);
console.log(error);
callback(error);
alert("Please allow camera to processed or check your camera setting");
window.location.reload();
});