如何在Kurento组呼叫中实现录音?

问题描述 投票:0回答:1

我想将每个参与者视频流记录为每个参与者的单独文件,或者如果使用复合视频获得单个视频则会很棒。

我在UserSession.java中添加了我的代码,如下所示:

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文件,但大小为“0 Byte”。

kurento
1个回答
0
投票

这是我自己的问题的解决方案:

在userSesion.java中编写监听器,您将在其中传递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();
                        }
            });`
© www.soinside.com 2019 - 2024. All rights reserved.