2015-10-16 56 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();