RTCMultiConnection icon indicating copy to clipboard operation
RTCMultiConnection copied to clipboard

One way video

Open aemal opened this issue 8 years ago • 6 comments

Hello!

I want to make two simple pages (client.html and expert.html), client should see the video of the expert page but expert should not be able to see the client's video. With the demos provided, the video of both sides are displayed. After a little play around I found that if I do the following:

in expert.html:

connExpert.session = {
 audio: false, 
 video: true,
 oneway: true
};

and on client.html:

connUser.session = {
 audio: false,
 video: false,
 oneway: true
 };

From the above I get the video of expert displayed on the expert's screen but on the user's screen I get a black video element. Can you kindly guide me on how to make something like this?

aemal avatar Aug 07 '16 09:08 aemal

var roomid = 'xyz';

var connection = new RTCMultiConnection();
connection.session = {
    video: true,
    oneway: true
};

connection.mediaConstraints.audio = false; // we don't need auadio (optional, though)

$('#btn-start-braodcast').click(function() {
    connection.sdpConstraints.mandatory = {
        OfferToReceiveAudio: false,
        OfferToReceiveVideo: false
    };
    connection.open(roomid);
});

$('#btn-join-braodcast').click(function() {
    connection.sdpConstraints.mandatory = {
        OfferToReceiveAudio: false,
        OfferToReceiveVideo: true // TURE here i.e. I want to receive video tracks
    };
    connection.join(roomid);
});

muaz-khan avatar Aug 07 '16 12:08 muaz-khan

Hello! How to realize scenario where expert and all users have audio conference and only expert broadcasted video?

lukesavoy avatar Aug 08 '16 13:08 lukesavoy

Thank you so much Mr. Khan!

@lukesavoy I think right now it is like so, whoever join the room will get voice and video (of the expert), most probably the voice of others.

aemal avatar Aug 08 '16 14:08 aemal

@lukesavoy You can setup two RTCMultiConnection instances; one can be used to relay/broadcast video; and other one can be used for audio-twoWay-broadcasting.

var roomid = 'xyz';

var instance1 = new RTCMultiConnection();
var instance2 = new RTCMultiConnection();

instance1.session = {
     video: true,
     oneway: true
};
instance2.session = {
     audio: true,
     broadcast: true // make it one-to-many (two-way)
};

instance1.mediaConstraints.audio = false; // we don't need audio for instance 1
instance2.mediaConstraints.video = false; // we don't need video for instance 2

$('#btn-start-braodcast').click(function() {
    instance1.sdpConstraints.mandatory = {
        OfferToReceiveAudio: false,
        OfferToReceiveVideo: false
    };
    instance2.sdpConstraints.mandatory = {
        OfferToReceiveAudio: true, // broadcaster need to listen audios (bcz it is 2-way)
        OfferToReceiveVideo: false
    };

    instance1.open(roomid + '1');
});

$('#btn-join-braodcast').click(function() {
    instance1.sdpConstraints.mandatory = {
        OfferToReceiveAudio: false,
        OfferToReceiveVideo: true // viewers nee to receive oneway videos
    };
    instance2.sdpConstraints.mandatory = {
        OfferToReceiveAudio: true, // viewers need to listen audios too (bcz it is 2-way)
        OfferToReceiveVideo: false
    };

    instance1.join(roomid + '2');
});

muaz-khan avatar Aug 10 '16 14:08 muaz-khan

what if A) an expert wants to send audio only (not video) to many clients. B) and clients can only listen. and they cant speak back.

imranaalam avatar Nov 13 '20 10:11 imranaalam

@imranaalam there is an example here which just does that.

ansarnisargill avatar Nov 13 '20 11:11 ansarnisargill