我修改了 kurento 的 one2many 教程(https://github.com/Kurento/kurento-tutorial-java/blob/master/kurento-one2many-call/src/main/java/org/kurento/tutorial/one2manycall/CallHandler.java)将网络摄像头流录制到 mp4 或 webm 文件的示例,如下所示。
在这里,我注释掉了编写 mp4 的 RecorderEndpoint。
我的问题是,如何仅从一个 WebRtcEndpoint 编写两个文件(webm 和 mp4)?我考虑过使用 DispatcherOneToMany (http://www.kurento.org/docs/4.2.0/kmf-media-api/com/kurento/kmf/media/DispatcherOneToMany.html ) 但 setSource 需要一个 HubPort 我没有开始使用我的 WebRtcEndpoint masterWebRtc。那么如何将 masterWebRtc 分派到两个 RecorderEndpoint 呢?
谢谢你的帮助。
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()));
}
}