Sagar Pilkhwal
Sagar Pilkhwal

Reputation: 3993

Kurento: multiple mediapipeline mux

I am thinking of creating a kms filter which will take input as 2 mediapipeline (A) (B) and output one mediapipeline (C) with Video from 1st mediapipeline (A) and Audio from 2nd media pipeline (B).

I am confused, shall I do this on java level or shall I do this in KMS filter level, Is it even possible to achive this in Java/KMS Filter layer ?

enter image description here

Upvotes: 2

Views: 1333

Answers (2)

igracia
igracia

Reputation: 3541

By media pipeline, I take it you refer to media source, right? It is not possible to mix media from different pipelines.

You can check with the Composite mixer element. It has never been tested, but it should work. It would be very simple to get the audio from B and the video from A mixed. Let's assume you are getting that media through a WebRtcEndpoint

Composite composite = new Composite.Builder(pipeline).build();
HubPort hubPortA = new HubPort.Builder(composite).build();
webRtcA.connect(hubPortA, MediaType.VIDEO);
HubPort hubPortB = new HubPort.Builder(composite).build();
webRtcB.connect(hubPortB, MediaType.AUDIO);

WebRtcEndpoint creation and negotiation are not shown for clarity.


EDIT 1

Thought you might want to mix more that just those two, but as @santoscadenas pointed out, if you only want to mix two streams of different type, you can use directly the WebRtcEndpoint. This will also save resources and will scale better, as the Composite is quite a hungry thing. Taken from the other answer, and adapting it to your naming conventions, it would be

webRtcA.connect(webRtcOut, MediaType.VIDEO);
webRtcB.connect(webRtOut, MediaType.AUDIO);

Upvotes: 1

santoscadenas
santoscadenas

Reputation: 1492

The simplest way to do this is to create all in one pipeline because different media pipelines cannot share media easily. All can be implemented from the client side (java or js).

You can receive media from two Endpoints (for example WebRtcEndpoints), webRtcEp1 and webRtcEp2 and emit using webRtcEpOut. Then just connect them like this:

webRtcEp1.connect (webRtcEpOut, MediaType.AUDIO);
webRtcEp2.connect (webRtcEpOut, MediaType.VIDEO);

At this point, WebRctOut is emiting audio from webRtcEp1 and video from webRtcEp2.

Upvotes: 1

Related Questions