I am working a little bit off of the one2many call tutorial, the one2many call advanced tutorial, and the hello-world recording but I cannot seem to get my recording to work. It creates the file, but it is always 382 bytes with no playable content. There are no errors being thrown and communication between the browser and app server are working without failure as well.
This is what the code that handles the initial recording request looks like:
//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 is all but the same as hello-world-recording. BroadcastMediaPipeline however looks like this:
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());
}
If more information is needed to help resolve this I will provide it.
For the recorder file to be generated correctly you need to stop the recording or to release the recorder endpoint. I don't see this happening in your code.
To fix it, when you have finished your recording (e.g. with a finish buttom or something like that), you need to execute one of the following
recorderEndpoint.stop(); //this stops the recording
recorderEndpoint.release(); //this stops recording when releasing the recorder
mediaPipeline.release(); //this relases all the pipeline, including recorder
Ensure you setting media profile with RecorderEndpoint like :
recorderCaller
= new RecorderEndpoint.Builder(pipeline, RECORD_PATH)
.stopOnEndOfStream()
.withMediaProfile(isAudioOnly ? MediaProfileSpecType.MP4_AUDIO_ONLY : MediaProfileSpecType.MP4)
.build();
hubportCaller.connect(recorderCaller);
recorderCaller.record();
来源:https://stackoverflow.com/questions/33160648/kurento-recording-not-recording-any-data