2015-10-16 60 views
2

我工作有点关闭one2many电话教程,one2many电话高级教程,和你好,世界录音,但我似乎无法让我的录音工作。它创建文件,但它总是382字节,没有可播放的内容。没有错误被抛出,浏览器和应用服务器之间的通信也没有失败。Kurento录音不记录任何数据

这是什么,处理初始记录请求的代码如下所示:

 //1. Media logic 
     BroadcastPipeline broadcastPipeline = new BroadcastPipeline(kurento, "test-broadcast"); 

     //2. User session 
     broadcasterUserSession = new UserSession(session); 
     broadcasterUserSession.setWebRtcEndpoint(broadcastPipeline.getWebRtcEndpoint()); 

     //3. SDP negotiation 
     String broadcastSdpOffer = jsonMessage.get("sdpOffer").getAsString(); 
     String broadcastSdpAnswer = broadcastPipeline.generateSdpAnswerForBroadcaster(broadcastSdpOffer); 

     //4. Gather ICE candidates 
     broadcastPipeline.getWebRtcEndpoint().addOnIceCandidateListener(
       new EventListener<OnIceCandidateEvent>() { 

        @Override 
        public void onEvent(OnIceCandidateEvent event) { 
         JsonObject response = new JsonObject(); 
         response.addProperty("id", "iceCandidate"); 
         response.add("candidate", JsonUtils.toJsonObject(event.getCandidate())); 
         try { 
          synchronized (session) { 
           session.sendMessage(new TextMessage(response.toString())); 
          } 
         } catch (IOException e) { 
          log.debug(e.getMessage()); 
         } 
        } 
       }); 

     JsonObject startBroadcast = new JsonObject(); 

     startBroadcast.addProperty("id", "broadcasterResponse"); 
     startBroadcast.addProperty("response", "accepted"); 
     startBroadcast.addProperty("sdpAnswer", broadcastSdpAnswer); 

     synchronized (broadcasterUserSession){ 
      session.sendMessage(new TextMessage(startBroadcast.toString())); 
     } 

     broadcastPipeline.getWebRtcEndpoint().gatherCandidates(); 

     broadcastPipeline.startRecording(); 

UserSession几乎是一样的你好世界记录。 BroadcastMediaPipeline看起来像这样:

public static final String RECORDING_PATH = "file:///tmp/"; 
public static final String RECORDING_EXT = ".webm"; 

private final MediaPipeline mediaPipeline; 
private final WebRtcEndpoint webRtcEndpoint; 
private final RecorderEndpoint recorderEndpoint; 

public BroadcastPipeline(KurentoClient kurento, String broadcastTitle){ 
    log.info("Creating Broadcast pipeline"); 

    //Create the media pipeline 
    mediaPipeline = kurento.createMediaPipeline(); 

    //Create the broadcaster pipeline 
    webRtcEndpoint = new WebRtcEndpoint.Builder(mediaPipeline).build(); 

    //Create the recording endpoint for the broadcast 
    recorderEndpoint = new RecorderEndpoint.Builder(mediaPipeline, RECORDING_PATH + broadcastTitle + RECORDING_EXT).build(); 

    webRtcEndpoint.connect(recorderEndpoint); 
} 

public void startRecording(){ 
    try{ 
     recorderEndpoint.record(); 
     log.info("Started recording broadcast"); 
    } 
    catch(Exception e){ 
     log.error("Something bad happended: + " + e.getMessage()); 
    } 
} 
public MediaPipeline getMediaPipeline(){ 
    return mediaPipeline; 
} 

public String generateSdpAnswerForBroadcaster(String sdpOffer){ 
    return webRtcEndpoint.processOffer(sdpOffer); 
} 

public WebRtcEndpoint getWebRtcEndpoint(){ 
    return webRtcEndpoint; 
} 

public WebRtcEndpoint buildViewerEndpoint(){ 
    return (new WebRtcEndpoint.Builder(mediaPipeline).build()); 
} 

如果需要更多信息来帮助解决这个问题,我会提供它。

+0

知道您的KMS版本和您正在使用的客户端会很有趣。 – igracia

+0

你好,你解决了吗? –

回答

2

要正确生成录音机文件,您需要停止录音或释放录音机端点。我在代码中看不到这种情况。

要解决它,当你完成你的记录(例如,使用结束BUTTOM或类似的东西),你需要执行以下

recorderEndpoint.stop(); //this stops the recording 
recorderEndpoint.release(); //this stops recording when releasing the recorder 
mediaPipeline.release(); //this relases all the pipeline, including recorder 
+0

这也是我的想法,但现在我遇到了任何项目记录的问题。 one2one-call-advanced不再能正常工作了。不知道发生了什么事 – user1634494

2

一个确保你喜欢设置介质特征与RecorderEndpoint:

recorderCaller 
       = new RecorderEndpoint.Builder(pipeline, RECORD_PATH) 
         .stopOnEndOfStream() 
         .withMediaProfile(isAudioOnly ? MediaProfileSpecType.MP4_AUDIO_ONLY : MediaProfileSpecType.MP4) 
         .build(); 
      hubportCaller.connect(recorderCaller); 
      recorderCaller.record();