i modified kurento's one2many tutorial (https://github.com/Kurento/kurento-tutorial-java/blob/master/kurento-one2many-call/src/main/java/org/kurento/tutorial/one2manycall/CallHandler.java) examples to record the webcam stream to a mp4 or webm file like in below.
Here i commented out the RecorderEndpoint writing the mp4.
My question is, how can i write both files (webm and mp4) from just one WebRtcEndpoint? I thought about using DispatcherOneToMany (http://www.kurento.org/docs/4.2.0/kmf-media-api/com/kurento/kmf/media/DispatcherOneToMany.html) but setSource needs a HubPort which i didn't get to work with my WebRtcEndpoint masterWebRtc. So how can i dispatch the masterWebRtc to two RecorderEndpoint's?
Thanks for any help.
private synchronized void master(WebSocketSession session,
JsonObject jsonMessage) throws IOException {
if (masterUserSession == null) {
masterUserSession = new UserSession(session);
pipeline = kurento.createMediaPipeline();
masterUserSession.setWebRtcEndpoint(new WebRtcEndpoint.Builder(
pipeline).build());
WebRtcEndpoint masterWebRtc = masterUserSession.getWebRtcEndpoint();
String sdpOffer = jsonMessage.getAsJsonPrimitive("sdpOffer")
.getAsString();
String sdpAnswer = masterWebRtc.processOffer(sdpOffer);
JsonObject response = new JsonObject();
response.addProperty("id", "masterResponse");
response.addProperty("response", "accepted");
response.addProperty("sdpAnswer", sdpAnswer);
masterUserSession.sendMessage(response);
//RecorderEndpoint recorderEndpoint = new RecorderEndpoint.Builder(pipeline,"file:///tmp/recording.mp4").withMediaProfile(MediaProfileSpecType.MP4).build();
RecorderEndpoint recorderEndpoint = new RecorderEndpoint.Builder(pipeline,"file:///tmp/recording.webm").withMediaProfile(MediaProfileSpecType.WEBM).build();
masterWebRtc.connect(recorderEndpoint);
recorderEndpoint.record();
} else {
JsonObject response = new JsonObject();
response.addProperty("id", "masterResponse");
response.addProperty("response", "rejected");
response.addProperty("message",
"Another user is currently acting as sender. Try again later ...");
session.sendMessage(new TextMessage(response.toString()));
}
}
In Kurento, all media elements are "one-to-many" meaning that you can connect a source media element to as many sink media elements as you want. Following you code: