Interface RecorderEndpoint
-
- All Superinterfaces:
Endpoint
,KurentoObject
,MediaElement
,MediaObject
,UriEndpoint
public interface RecorderEndpoint extends UriEndpoint
Provides functionality to store media contents.RecorderEndpoint can store media into local files or send it to a remote network storage. When another
MediaElement
is connected to a RecorderEndpoint, the media coming from the former will be muxed into the selected recording format and stored in the designated location.These parameters must be provided to create a RecorderEndpoint, and they cannot be changed afterwards:
-
Destination URI, where media will be stored. These formats
are supported:
-
File: A file path that will be written into the local file system.
Example:
file:///path/to/file
-
HTTP: A POST request will be used against a remote server. The server
must support using the chunked encoding mode (HTTP header
Transfer-Encoding: chunked
). Examples:http(s)://host/path/to/file
-
http(s)://username:password@host:port/path/to/file
-
Relative URIs (with no schema) are supported. They are completed by
prepending a default URI defined by property defaultPath. This
property is defined in the configuration file
/etc/kurento/modules/kurento/UriEndpoint.conf.ini, and the
default value is
file:///var/lib/kurento/
-
NOTE: Special characters must be
URL-encoded
in
username
andpassword
fields.
-
File: A file path that will be written into the local file system.
Example:
-
Media Profile (
MediaProfileSpecType
), which determines the video and audio encoding. See below for more details. - EndOfStream (optional), a parameter that dictates if the recording should be automatically stopped once the EOS event is detected.
Note that RecorderEndpoint requires write permissions to the destination ; otherwise, the media server won't be able to store any information, and an
ErrorEvent
will be fired. Make sure your application subscribes to this event, otherwise troubleshooting issues will be difficult.-
To write local files (if you use
file://
), the system user that is owner of the media server process needs to have write permissions for the requested path. By default, this user is named 'kurento
'. - To record through HTTP, the remote server must be accessible through the network, and also have the correct write permissions for the destination path.
Recording will start as soon as the user invokes the
record()
method. The recorder will then store, in the location indicated, the media that the source is sending to the endpoint. If no media is being received, or no endpoint has been connected, then the destination will be empty. The recorder starts storing information into the file as soon as it gets it.Recording must be stopped when no more data should be stored. This is done with the
stopAndWait()
method, which blocks and returns only after all the information was stored correctly.The source endpoint can be hot-swapped while the recording is taking place. The recorded file will then contain different feeds. When switching video sources, if the new video has different size, the recorder will retain the size of the previous source. If the source is disconnected, the last frame recorded will be shown for the duration of the disconnection, or until the recording is stopped.
NOTE: It is recommended to start recording only after media arrives. For this, you may use the
MediaFlowInStateChanged
andMediaFlowOutStateChanged
events of your endpoints, and synchronize the recording with the moment media comes into the Recorder.WARNING: All connected media types must be flowing to the RecorderEndpoint. If you used the default
connect()
method, it will assume both AUDIO and VIDEO. Failing to provide both kinds of media will result in the RecorderEndpoint creating an empty file and buffering indefinitely; the recorder waits until all kinds of media start arriving, in order to synchronize them appropriately.
For audio-only or video-only recordings, make sure to use the correct, media-specific variant of theconnect()
method.For example:
-
When a web browser's video arrives to Kurento via WebRTC, your
WebRtcEndpoint will emit a
MediaFlowOutStateChanged
event. -
When video starts flowing from the WebRtcEndpoint to the RecorderEndpoint,
the RecorderEndpoint will emit a
MediaFlowInStateChanged
event. You should start recording at this point. -
You should only start recording when RecorderEndpoint has notified a
MediaFlowInStateChanged
for ALL streams. So, if you record AUDIO+VIDEO, your application must receive aMediaFlowInStateChanged
event for audio, and anotherMediaFlowInStateChanged
event for video.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
RecorderEndpoint.Builder
-
Method Summary
-
Methods inherited from interface org.kurento.client.KurentoObject
addEventListener, invoke, isCommited, release, release, release, removeEventListener, waitCommited, whenCommited, whenCommited
-
Methods inherited from interface org.kurento.client.MediaElement
addElementConnectedListener, addElementConnectedListener, addElementDisconnectedListener, addElementDisconnectedListener, addMediaFlowInStateChangedListener, addMediaFlowInStateChangedListener, addMediaFlowOutStateChangedListener, addMediaFlowOutStateChangedListener, addMediaTranscodingStateChangedListener, addMediaTranscodingStateChangedListener, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, disconnect, disconnect, disconnect, disconnect, disconnect, disconnect, disconnect, disconnect, disconnect, disconnect, disconnect, disconnect, getEncoderBitrate, getEncoderBitrate, getEncoderBitrate, getGstreamerDot, getGstreamerDot, getGstreamerDot, getGstreamerDot, getGstreamerDot, getGstreamerDot, getMaxEncoderBitrate, getMaxEncoderBitrate, getMaxEncoderBitrate, getMinEncoderBitrate, getMinEncoderBitrate, getMinEncoderBitrate, getSinkConnections, getSinkConnections, getSinkConnections, getSinkConnections, getSinkConnections, getSinkConnections, getSinkConnections, getSinkConnections, getSinkConnections, getSourceConnections, getSourceConnections, getSourceConnections, getSourceConnections, getSourceConnections, getSourceConnections, getSourceConnections, getSourceConnections, getSourceConnections, getStats, getStats, getStats, getStats, getStats, getStats, isMediaFlowingIn, isMediaFlowingIn, isMediaFlowingIn, isMediaFlowingIn, isMediaFlowingIn, isMediaFlowingIn, isMediaFlowingOut, isMediaFlowingOut, isMediaFlowingOut, isMediaFlowingOut, isMediaFlowingOut, isMediaFlowingOut, isMediaTranscoding, isMediaTranscoding, isMediaTranscoding, isMediaTranscoding, isMediaTranscoding, isMediaTranscoding, removeElementConnectedListener, removeElementConnectedListener, removeElementDisconnectedListener, removeElementDisconnectedListener, removeMediaFlowInStateChangedListener, removeMediaFlowInStateChangedListener, removeMediaFlowOutStateChangedListener, removeMediaFlowOutStateChangedListener, removeMediaTranscodingStateChangedListener, removeMediaTranscodingStateChangedListener, setAudioFormat, setAudioFormat, setAudioFormat, setEncoderBitrate, setEncoderBitrate, setEncoderBitrate, setMaxEncoderBitrate, setMaxEncoderBitrate, setMaxEncoderBitrate, setMinEncoderBitrate, setMinEncoderBitrate, setMinEncoderBitrate, setVideoFormat, setVideoFormat, setVideoFormat
-
Methods inherited from interface org.kurento.client.MediaObject
addErrorListener, addErrorListener, addTag, addTag, addTag, getChildren, getChildren, getChildren, getCreationTime, getCreationTime, getCreationTime, getId, getId, getId, getMediaPipeline, getMediaPipeline, getMediaPipeline, getName, getName, getName, getParent, getParent, getParent, getSendTagsInEvents, getSendTagsInEvents, getSendTagsInEvents, getTag, getTag, getTag, getTags, getTags, getTags, removeErrorListener, removeErrorListener, removeTag, removeTag, removeTag, setName, setName, setName, setSendTagsInEvents, setSendTagsInEvents, setSendTagsInEvents
-
Methods inherited from interface org.kurento.client.UriEndpoint
addUriEndpointStateChangedListener, addUriEndpointStateChangedListener, getState, getState, getState, getUri, getUri, getUri, pause, pause, pause, removeUriEndpointStateChangedListener, removeUriEndpointStateChangedListener, stop, stop, stop
-
-
-
-
Method Detail
-
record
void record()
Starts storing media received through the sink pad.
-
record
void record(Continuation<Void> cont)
Asynchronous version of record:Continuation.onSuccess(F)
is called when the action is done. If an error occurs,Continuation.onError(java.lang.Throwable)
is called.- See Also:
record()
-
record
void record(Transaction tx)
Starts storing media received through the sink pad.
-
stopAndWait
void stopAndWait()
Stops recording and does not return until all the content has been written to the selected uri. This can cause timeouts on some clients if there is too much content to write, or the transport is slow
-
stopAndWait
void stopAndWait(Continuation<Void> cont)
Asynchronous version of stopAndWait:Continuation.onSuccess(F)
is called when the action is done. If an error occurs,Continuation.onError(java.lang.Throwable)
is called.- See Also:
stopAndWait()
-
stopAndWait
void stopAndWait(Transaction tx)
Stops recording and does not return until all the content has been written to the selected uri. This can cause timeouts on some clients if there is too much content to write, or the transport is slow
-
addRecordingListener
ListenerSubscription addRecordingListener(EventListener<RecordingEvent> listener)
Add aEventListener
for eventRecordingEvent
. Synchronous call.- Parameters:
listener
- Listener to be called on RecordingEvent- Returns:
- ListenerSubscription for the given Listener
-
addRecordingListener
void addRecordingListener(EventListener<RecordingEvent> listener, Continuation<ListenerSubscription> cont)
Add aEventListener
for eventRecordingEvent
. Asynchronous call. Calls Continuation<ListenerSubscription> when it has been added.- Parameters:
listener
- Listener to be called on RecordingEventcont
- Continuation to be called when the listener is registered
-
removeRecordingListener
void removeRecordingListener(ListenerSubscription listenerSubscription)
Remove aListenerSubscription
for eventRecordingEvent
. Synchronous call.- Parameters:
listenerSubscription
- Listener subscription to be removed
-
removeRecordingListener
void removeRecordingListener(ListenerSubscription listenerSubscription, Continuation<Void> cont)
Remove aListenerSubscription
for eventRecordingEvent
. Asynchronous call. Calls Continuation<Void> when it has been removed.- Parameters:
listenerSubscription
- Listener subscription to be removedcont
- Continuation to be called when the listener is removed
-
addPausedListener
ListenerSubscription addPausedListener(EventListener<PausedEvent> listener)
Add aEventListener
for eventPausedEvent
. Synchronous call.- Parameters:
listener
- Listener to be called on PausedEvent- Returns:
- ListenerSubscription for the given Listener
-
addPausedListener
void addPausedListener(EventListener<PausedEvent> listener, Continuation<ListenerSubscription> cont)
Add aEventListener
for eventPausedEvent
. Asynchronous call. Calls Continuation<ListenerSubscription> when it has been added.- Parameters:
listener
- Listener to be called on PausedEventcont
- Continuation to be called when the listener is registered
-
removePausedListener
void removePausedListener(ListenerSubscription listenerSubscription)
Remove aListenerSubscription
for eventPausedEvent
. Synchronous call.- Parameters:
listenerSubscription
- Listener subscription to be removed
-
removePausedListener
void removePausedListener(ListenerSubscription listenerSubscription, Continuation<Void> cont)
Remove aListenerSubscription
for eventPausedEvent
. Asynchronous call. Calls Continuation<Void> when it has been removed.- Parameters:
listenerSubscription
- Listener subscription to be removedcont
- Continuation to be called when the listener is removed
-
addStoppedListener
ListenerSubscription addStoppedListener(EventListener<StoppedEvent> listener)
Add aEventListener
for eventStoppedEvent
. Synchronous call.- Parameters:
listener
- Listener to be called on StoppedEvent- Returns:
- ListenerSubscription for the given Listener
-
addStoppedListener
void addStoppedListener(EventListener<StoppedEvent> listener, Continuation<ListenerSubscription> cont)
Add aEventListener
for eventStoppedEvent
. Asynchronous call. Calls Continuation<ListenerSubscription> when it has been added.- Parameters:
listener
- Listener to be called on StoppedEventcont
- Continuation to be called when the listener is registered
-
removeStoppedListener
void removeStoppedListener(ListenerSubscription listenerSubscription)
Remove aListenerSubscription
for eventStoppedEvent
. Synchronous call.- Parameters:
listenerSubscription
- Listener subscription to be removed
-
removeStoppedListener
void removeStoppedListener(ListenerSubscription listenerSubscription, Continuation<Void> cont)
Remove aListenerSubscription
for eventStoppedEvent
. Asynchronous call. Calls Continuation<Void> when it has been removed.- Parameters:
listenerSubscription
- Listener subscription to be removedcont
- Continuation to be called when the listener is removed
-
-