Hi Everyone, please assist.
I am able to publish a live video stream but when i subscribe to it, nothing is rendered on the page.
Currently running this locally.
When i start the Janus server, the log shows:
Initializing ICE stuff (Full mode, ICE-TCP candidates disabled, half-trickle, IPv6 support disabled)
STUN server to use: stun.l.google.com:19302
>> 74.125.27.36:19302 (IPv4)
Testing STUN server: message is of 20 bytes
>> Our public address is 172.139.156.5
TURN server to use: localhost:3478 (udp)
TURN REST API backend: (disabled)
When i publish a new live stream, the janus server log shows:
HTTP transport timer started
HTTP webserver started (port 8088, /janus path listener)...
Admin/monitor HTTP webserver started (port 7088, /admin path listener)...
JANUS REST (HTTP/HTTPS) transport plugin initialized!
Creating new session: 3112666674173711; 0x6000017d80a0
Creating new handle in session 3112666674173711: 7033155524207313; 0x6000017d80a0 0x11a004770
[7033155524207313] Creating ICE agent (ICE Full mode, controlled)
[7033155524207313] The DTLS handshake has been completed
[janus.plugin.videoroom-0x600003ae8030] WebRTC media is now available
When i subscribe to that live stream, the janus server log shows:
The warning i keep getting is “Failed to add some remote candidates (added 1, expected 2)”
creating new session: 7140347901636727; 0x6000017d4960
Creating new handle in session 7140347901636727: 1130652029014476; 0x6000017d4960 0x11a0048b0
[WARN] Deprecated subscriber 'join' API: please start looking into the new one for the future
[1130652029014476] Creating ICE agent (ICE Full mode, controlling)
👉[WARN] [1130652029014476] Failed to add some remote candidates (added 1, expected 2)👈
[1130652029014476] The DTLS handshake has been completed
I checked admin API for SDP details:
For Publisher:
"plugin_specific": {
👉"type": "publisher",
},
"streams": [
{
"type": "audio",
"mindex": 0,
"mid": "0",
"codec": "opus",
"audio-level-dBov": 0,
"talking": false,
👉"subscribers": 1
},
"flags": {
👉"got-offer": true,
👉"got-answer": true,
👉"negotiated": true,
}
For Subscriber:
"plugin": "janus.plugin.videoroom",
"plugin_specific": {
👉 "type": "subscriber",
"room": 1234,
"private_id": 0,
"answered": true,
"pending_offer": false,
"pending_restart": false,
"paused": false,
"streams": [
{
"type": "audio",
👉"active": true,
"mindex": 0,
"mid": "0",
"ready": true,
👉"send": true,
👉"feed_id": 302664780087,
"feed_display": "Publisher",
"feed_mid": "0",
"codec": "opus"
},
{
"type": "video",
👉active": true,
"mindex": 1,
"mid": "1",
"ready": true,
"send": true,
👉"feed_id": 302664780087,
"feed_display": "Publisher",
"feed_mid": "1",
"codec": "vp8"
}
Inside the subscribe.js file, i realised that “onremotestream” is not invoked since there’s no log with “Currently receiving the video stream”
subscribe.js
function startViewer() {
// Initialize the library (all console debuggers enabled)
Janus.init({
debug: "all",
callback: function() {
// Make sure the browser supports WebRTC
if(!Janus.isWebrtcSupported()) {
alert("No WebRTC support... ");
return;
}
// Create session
janus = new Janus({
server: "ws://localhost:8188",
success: function() {
// Attach to VideoRoom plugin as a subscriber
janus.attach({
plugin: "janus.plugin.videoroom",
success: function(pluginHandle) {
videoroom = pluginHandle;
var selectedPublisherId = 5516362373519243;//Hard coded for now, but this will be dynamic
console.log("Plugin attached! (" + videoroom.getPlugin() + ", id=" + videoroom.getId() + ")");
// Join the room
var register = { "request": "join", "room": 1234, "ptype": "subscriber", "feed": selectedPublisherId}; // Update room ID
videoroom.send({"message": register});
},
onremotestream: function(stream) {
// THIS PART DOES NOT RUN
👉console.log("Currently receiving the video stream");
var video = document.getElementById('remoteVideo');
Janus.attachMediaStream(video, stream);
},
I have been trying to get this running for a few days and reading documentation, but cannot solve this. I can provide more details if needed. Any help will be appreciated. Thanks.