Reputation: 11
I would like to record every participant video stream either seperate file for each participant or it would be great if get in single video using composite.
I have added my code in UserSession.java as below:
public UserSession(final String name, String roomName, finalWebSocketSession session, MediaPipeline pipeline) {
this.pipeline = pipeline;
this.name = name;
this.session = session;
this.roomName = roomName;
this.outgoingMedia = new WebRtcEndpoint.Builder(pipeline).build();
this.outgoingMedia.connect(this.outgoingMedia);
this.outgoingMedia.addIceCandidateFoundListener(newEventListener<IceCandidateFoundEvent>() {
@Override
public void onEvent(IceCandidateFoundEvent event) {
JsonObject response = new JsonObject();
response.addProperty("id", "iceCandidate");
response.addProperty("name", name);
response.add("candidate",JsonUtils.toJsonObject(event.getCandidate()));
try {
synchronized (session) {
session.sendMessage(new TextMessage(response.toString()));
}
} catch (IOException e) {
log.debug(e.getMessage());
}
}
});
this.composite = new Composite.Builder(pipeline).build();
this.hubPort = new HubPort.Builder(this.composite).build();
this.outgoingMedia.connect(hubPort);
this.recorder = new RecorderEndpoint.Builder(composite.getMediaPipeline(), "file:///home/vikram/Videos/9/"+this.roomName+"/"+this.name+".webm").build();
try{
recorder.record();
}catch(Exception e){
e.printStackTrace();
}
}
Webm file get created for every participants, but with size '0 Byte'.
Upvotes: 1
Views: 682
Reputation: 11
Here is the solution for my own question:
write listener in userSesion.java where you are mangaing outgoingWebRtcEndPoint
`this.outgoingMedia.addMediaStateChangedListener(new EventListener() {
@Override
public void onEvent(MediaStateChangedEvent event) {
if (event.getNewState() == MediaState.CONNECTED){
webRtcEndPoints.add(outgoingMedia);
RecorderEndpoint recorderEndpoint = new RecorderEndpoint.Builder(pipeline,"file://"+room.getRecordingFilePath()+ roomName + "/"+ counter + ".webm").build();
webRtcEndPoints.connect(recorderEndpoint);
recorderEndpoint.setMaxOutputBitrate(2000);
recorderEndpoint.record();
}
});`
Upvotes: -1