Interface RecorderEndpoint
- All Superinterfaces:
Endpoint, KurentoObject, MediaElement, MediaObject, UriEndpoint
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
usernameandpasswordfields.
-
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 and
MediaFlowOutStateChanged
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 the connect() method.
For example:
-
When a web browser's video arrives to Kurento via WebRTC, your
WebRtcEndpoint will emit a
MediaFlowOutStateChangedevent. -
When video starts flowing from the WebRtcEndpoint to the RecorderEndpoint,
the RecorderEndpoint will emit a
MediaFlowInStateChangedevent. You should start recording at this point. -
You should only start recording when RecorderEndpoint has notified a
MediaFlowInStateChangedfor ALL streams. So, if you record AUDIO+VIDEO, your application must receive aMediaFlowInStateChangedevent for audio, and anotherMediaFlowInStateChangedevent for video.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionaddPausedListener(EventListener<PausedEvent> listener) Add aEventListenerfor eventPausedEvent.voidaddPausedListener(EventListener<PausedEvent> listener, Continuation<ListenerSubscription> cont) Add aEventListenerfor eventPausedEvent.addRecordingListener(EventListener<RecordingEvent> listener) Add aEventListenerfor eventRecordingEvent.voidaddRecordingListener(EventListener<RecordingEvent> listener, Continuation<ListenerSubscription> cont) Add aEventListenerfor eventRecordingEvent.addStoppedListener(EventListener<StoppedEvent> listener) Add aEventListenerfor eventStoppedEvent.voidaddStoppedListener(EventListener<StoppedEvent> listener, Continuation<ListenerSubscription> cont) Add aEventListenerfor eventStoppedEvent.voidrecord()Starts storing media received through the sink pad.voidrecord(Continuation<Void> cont) Asynchronous version of record:Continuation.onSuccess(F)is called when the action is done.voidrecord(Transaction tx) Starts storing media received through the sink pad.voidremovePausedListener(ListenerSubscription listenerSubscription) Remove aListenerSubscriptionfor eventPausedEvent.voidremovePausedListener(ListenerSubscription listenerSubscription, Continuation<Void> cont) Remove aListenerSubscriptionfor eventPausedEvent.voidremoveRecordingListener(ListenerSubscription listenerSubscription) Remove aListenerSubscriptionfor eventRecordingEvent.voidremoveRecordingListener(ListenerSubscription listenerSubscription, Continuation<Void> cont) Remove aListenerSubscriptionfor eventRecordingEvent.voidremoveStoppedListener(ListenerSubscription listenerSubscription) Remove aListenerSubscriptionfor eventStoppedEvent.voidremoveStoppedListener(ListenerSubscription listenerSubscription, Continuation<Void> cont) Remove aListenerSubscriptionfor eventStoppedEvent.voidStops recording and does not return until all the content has been written to the selected uri.voidstopAndWait(Continuation<Void> cont) Asynchronous version of stopAndWait:Continuation.onSuccess(F)is called when the action is done.voidStops recording and does not return until all the content has been written to the selected uri.Methods inherited from interface KurentoObject
addEventListener, invoke, isCommited, release, release, release, removeEventListener, waitCommited, whenCommited, whenCommitedMethods inherited from interface 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, dumpGstreamerDot, dumpGstreamerDot, dumpGstreamerDot, dumpGstreamerDot, dumpGstreamerDot, dumpGstreamerDot, 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, setVideoFormatMethods inherited from interface 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, setSendTagsInEventsMethods inherited from interface UriEndpoint
addUriEndpointStateChangedListener, addUriEndpointStateChangedListener, getState, getState, getState, getUri, getUri, getUri, pause, pause, pause, removeUriEndpointStateChangedListener, removeUriEndpointStateChangedListener, stop, stop, stop
-
Method Details
-
record
void record()Starts storing media received through the sink pad. -
record
Asynchronous version of record:Continuation.onSuccess(F)is called when the action is done. If an error occurs,Continuation.onError(Throwable)is called.- See Also:
-
record
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
Asynchronous version of stopAndWait:Continuation.onSuccess(F)is called when the action is done. If an error occurs,Continuation.onError(Throwable)is called.- See Also:
-
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 -
addRecordingListener
Add aEventListenerfor 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 aEventListenerfor 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
Remove aListenerSubscriptionfor eventRecordingEvent. Synchronous call.- Parameters:
listenerSubscription- Listener subscription to be removed
-
removeRecordingListener
Remove aListenerSubscriptionfor 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
Add aEventListenerfor 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 aEventListenerfor 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
Remove aListenerSubscriptionfor eventPausedEvent. Synchronous call.- Parameters:
listenerSubscription- Listener subscription to be removed
-
removePausedListener
Remove aListenerSubscriptionfor 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
Add aEventListenerfor 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 aEventListenerfor 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
Remove aListenerSubscriptionfor eventStoppedEvent. Synchronous call.- Parameters:
listenerSubscription- Listener subscription to be removed
-
removeStoppedListener
Remove aListenerSubscriptionfor 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
-