Minimum streaming example

Can anyone provide a minimum streaming example with something like video and video+audio for both server side AND client side please?

thanks

The repo comes with samples exactly for that, which reference what’s in the sample configuration file for the Streaming plugin. The Streaming plugin demo page is what you can refer to for the client side.

The demo page is not a minimal example, it mixes multicast/singlecast, audio, video, some stereo stuff, some esthetic stuff.

The protocol is not clear nor explained and one have to go with the debugger to understand the different steps.

This project will greatly benefit from a better documentation, something like tutorials, getting started, hello worlds…

here’s what I call a minimal example :

let janus = null;
        let pluginHandle = null;
        const server = "http://127.0.0.1:8088/janus";
        Janus.init({
            debug: "all",
            callback: function() {
                janus = new Janus({
                    server: server,
                    success: function() {
                        janus.attach({
                            plugin: "janus.plugin.streaming",
                            success: function(plugin) {
                                pluginHandle = plugin;
                                Janus.log("Plugin attached! (" + pluginHandle.getPlugin() + ", id=" + pluginHandle.getId() + ")");
                                let body = { request: "list" };
                                pluginHandle.send({ message: body, success: function(result) {
                                    if(result["list"]) {
                                      let list = result["list"];
                                      Janus.log("Got a list of available streams:", list);
                                      let body = { request: "watch", id: 10};
                                      pluginHandle.send({ message: body });
                                    }
                               }});
                            },
                             onmessage: function(msg, jsep) {
                                Janus.debug(" ::: Got a message :::", msg);
                                let result = msg["result"];
                                if(jsep) {
                                  Janus.debug("Handling SDP as well...", jsep);
                                  pluginHandle.createAnswer({jsep: jsep,tracks: [{ type: 'data' }],
                                        success: function(jsep) {Janus.debug("Got SDP!", jsep);
                                                      let body = { request: "start" };
                                                      pluginHandle.send({ message: body, jsep: jsep });},
                                        error: function(error) {
                                                     Janus.error("WebRTC error:", error);
                                                }});
                                }
                            },
                            onremotetrack: function(track, mid, on, metadata) {
                                Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + (metadata ? " (" + metadata.reason + ") ": "") + ":", track);
                                let stream = new MediaStream([track]);
                                let video = document.getElementById('remoteVideo');
                                Janus.log("Created remote video stream:", stream);
                                Janus.attachMediaStream(video, stream);
                                video.play();
                           }
                        });
                    }
                });
            }
        });

We do have documentation, and the existing demos, minimal or not, are supposed to be an example of how you can use the existing APIs. Of course everything can be improved, so we always welcome contributions in that sense.

You may also want to check Janode, our Node.js/JavaScript SDK, which also has Streaming plugin examples that may be simpler to digest, since it’s a much better and modern library than the ugly janus.js we use in the demos.

When I have a full working example I will make a tutorial video to help you guys, I cannot write full tutorials because I don’t have enough time to dive into your api though.