flutterjanus/flutter_janus_client

join google meet only as audience not publishing anything

Closed this issue · 9 comments

I am able to get Google Meet working fine. But I am building a different App like InstaLive, users can enter a room see comments, and view videos and audio but it is not publishing anything.

It is straightforward
The live broadcaster publish his media to videoroom
Then you do rtp forward of that publisher to a streaming plugin and for messages you attach a text room plugin, please refrain from opening an issue instead ask these questions in discussions

I tried joining as a subscriber

await videoPlugin!.joinSubscriber(roomId);

I get error : Unhandled Exception: JanusError{ error_code: 429, error: Missing mandatory element (feed), pluginName: videoroom, event: null,}

No you can't have subscriber feeds or information of feeds without joining as publisher if you are talking about video room what i suggested you is entirely different and scalable architecture you can't solely rely on video room to solve your problems

I was passing through the Janus documentation:
VideoRoom Subscribers In a VideoRoom, subscribers are NOT participants but simply handles that will be used exclusively to receive media from one or more publishers in the room.

I am implementing like a InstaLive where users cans see a video but not publish anything. Therefor i am looking for a way a user can subscribe without publishing. Other method i thought was:

fetching publishers using adminApi when a user joins a room to subscribe to the publishers

Yes i get that but you can create publisher without publishing anything just for observing events and other videoroom specific stuff which then you can use to attach subscriber handles

setting
mediaConstraints: {
'video': false,
'audio': false
}
i do not receive any video from subscriber. I think there is an error, but when i set one of the 2 to true works fine.

No you don't have to use initMediaStream it is used when you want to publish a media, in your case you should just attach the plugin joinPublisher and listen to events to subscribe to other publisher in the room

`

joinRoom(StreamRoom room) async {
if (session == null) {
await initialize();
}

dbJoinRoom(room.roomId);//notifying my own server

videoPlugin = await attachPlugin();
await eventMessagesHandler(room.roomId);

await videoPlugin?.joinPublisher(room.roomId,
    displayName: userController.user!.username, pin: '');

}

`
This works perfectly i can join a room without publishing anything.

So after joining the stream and viewing video, incase i want to publish my video i am calling this:

`

showMyVideo() async {
localVideoRenderer = StreamRenderer('local').obs;

await localVideoRenderer.value.init();

localVideoRenderer.value.mediaStream =
    await videoPlugin?.initializeMediaDevices(simulcastSendEncodings: [
.....//removed to reduce space
], mediaConstraints: { 
  'video': {'width': 1280, 'height': 720},
  'audio': true
});
localVideoRenderer.value.videoRenderer.srcObject =
    localVideoRenderer.value.mediaStream;
localVideoRenderer.value.publisherName = "You";
localVideoRenderer.value.publisherId = userController.user!.uuid.toString();

videoState.value.streamsToBeRendered
    .putIfAbsent('local', () => localVideoRenderer.value);

await videoPlugin?.configure();

`

Doing this brings name but no video or audio. Once i mistakenly pressed the publish button twice so audio started but pressing only once no video.

Kindly suggest better way to publish.

You can take paid consultation or sponsor this project and i will write basic example for functionality that you need, anyway it's hard for me to help you by looking at code snippet maybe you can share a basic example as a repo and maybe when i get time i will look at it and suggest changes