Multiparty conference rtmp publishing

Rahul

New Member
Is it possible to publish multiparty conference to rtmp using wcs?
Currently I am simply following the docs here https://flashphoner.com/docs/wcs5/wcs_docs/html/en/wcs-developer-guide-2/ (video conference/web sdk)

The video conference works as expected.
But if I try to use the rtmp publishing code with it(whcih looks like:
Code:
function startStreaming(session){
   session.createStream({
      name: streamName,
     display: localVideo,
     cacheLocalResources: true,
     receiveVideo: false,
     receiveAudion: false,
     rtmpUrl : myRtmpUrl
   }).on(STREAM_STATUS.PUBLISHING,.......)
   //.....
   .publish();
}
Above code (when combined with event handlers so that a button click invokes above rtmp publishing code) asks for camera and microphone permissions again.
It should ideally use the ongoing conference's stream(from the localVideo div which shows the relevant video frame).
So how should I go about it?
 

Max

Administrator
Staff member
Yes it should work.
If you check the conferencing example, line 221 conference.js

Code:
room.publish({
display: document.getElementById("localDisplay"),
constraints: constraints,
record: false,
receiveVideo: false,
receiveAudio: false
})
So you can add rtmpUrl
Code:
room.publish({
display: document.getElementById("localDisplay"),
constraints: constraints,
record: false,
receiveVideo: false,
receiveAudio: false,
rtmpUrl: "rtmp://host:1935/live" 
})
However here in the line 385 of room-module.js you can see that stream name is formed using several params:
Code:
options.name = (options.name) ? (name_ + "-" + username_ + "-" + options.name) : (name_ + "-" + username_);
Therefore, yes. It should work.
But stream name will be constructed as described above.

If you want to use your own stream names, you can build your own conference on the following methods: play(), publish(), sendData()
 

Rahul

New Member
you can build your own conference on the following methods: play(), publish(), sendData()
So does that mean I need to override the room.publish etc.. methods?(because modifying the original flashphoner.js method looks like a bad idea)
 

Max

Administrator
Staff member
You don't need to override methods.
You can just build your custom streaming logic using simple publish() and play()
For example:
1. User1 does publish(stream1)
2. User1 sends stream name to User2
3. User2 play(stream1)
etc.
 

Rahul

New Member
Thanks for the response @Max
I tried to follow Alex's answer in which he showed me how conference.js uses https://github.com/flashphoner/flas.../demo/streaming/conference/conference.js#L221 to publish the stream.
But the challenge that I am facing is that I require a session object that has a createStream function defined on it(as per the publish method in room-module.js which would be used for rtmp publishing with a different stream name in my case).

Currently I am doing it like this in my conference.js:

Code:
connection = Flashphoner.roomApi.connect({
        urlServer: url,
        username: username
    }).on(SESSION_STATUS.FAILED, function (session) {
        sessionGlobal=session;
        setStatus('#status', session.status());
        onLeft();
    }).on(SESSION_STATUS.DISCONNECTED, function (session) {
        sessionGlobal=session;
        setStatus('#status', session.status());
        onLeft();
    }).on(SESSION_STATUS.ESTABLISHED, function (session) {
        sessionGlobal=session;
        setStatus('#status', session.status());
        joinRoom();
    });
In above, I am saving the session in sessionGlobal global variable.
Then I am overriding the room.publish method like this:

Code:
room.publish = function (options) {
console.log("Inside overrided publish: " + JSON.stringify(options));
options.cacheLocalResources = (typeof options.cacheLocalResources === "boolean") ? options.cacheLocalResources : true;
options.custom = {name: room.name()};
var stream = sessionGlobal.createStream(options);
stream.publish();
return stream;
};
And here is how I am publishing the stream(by calling above method)
Code:
room.publish({
display: document.getElementById("localDisplay"),
name: "someCustomNameOfStream",
cacheLocalResources: true,
constraints: {
audio: true,
video: true},
receiveVideo: false,
receiveAudio: false,
rtmpUrl: "rtmp://somertmpurl"}).on(STREAM_STATUS.FAILED, function (stream) {
console.warn("Local stream failed!");
setStatus("#localStatus", stream.status());
onMediaStopped(room);
}).on(STREAM_STATUS.PUBLISHING, function (stream) {
setStatus("#localStatus", stream.status());
onMediaPublished(stream);
}).on(STREAM_STATUS.UNPUBLISHED, function (stream) {
setStatus("#localStatus", stream.status());
onMediaStopped(room);
});
:
But above code gives me error that sessionGlobal.createStream is not a function. This means that Flashphoner.roomApi.connect gives a session object that does not have this method defined.
So how do I publish the stream in my case?
 

Max

Administrator
Staff member
In current implementation:
1. You can't change name of re-published stream.
If you publish a stream with name stream1, it will be re-published to RTMP with name stream1
2. You can't use custom stream names in the Conference room.
If you would like to use custom stream names you have to implement your own room with custom unique stream names.

We will check if we can add a setting and use full RTMP URL for streaming.
If we add such setting, you will be able to set stream name immediately in rtmpUrl.
Example:
Code:
rtmpUrl = 'rtmp://localhost:1935/live/stream1';
And in flashphoner.properties something like this
Code:
rtmp_transponder_full_url=true
I will inform you through this forum thread if we implement such setting.
 

Rahul

New Member
That will be a very useful feature to use custom stream names.
For youtube live publishing(something which is in high demand now) if we are not able to use custom names, then it won't work.
 

Max

Administrator
Staff member
We added this setting in flashphoner.properties
Code:
rtmp_transponder_full_url=false
If it is true, then stream name will be parsed from rtmpUrl
Build 2133
Not verified by QA
 
Last edited:

Max

Administrator
Staff member
So if you have such RTMP URL
Code:
rtmp://localhost:1935/live/stream1
Stream name will be parsed as stream1
 
Top