ExWebRTC.Recorder (ex_webrtc_recorder v0.2.1)
View SourceSaves received RTP packets to a file for later processing/analysis.
Dumps raw RTP packets fed to it in a custom format. Use ExWebRTC.Recorder.Converter
to process them.
Can optionally upload the saved files to S3-compatible storage.
See ExWebRTC.Recorder.S3
and options/0
for more info.
Summary
Types
Tuple returned on successful call to end_tracks/2
.
Messages sent by the ExWebRTC.Recorder
process to its controlling process.
Options that can be passed to start_link/1
.
Functions
Adds new tracks to the recording.
Changes the controlling process of this recorder
process.
Finishes the recording for the given tracks and optionally uploads the result files.
Records a received packet on the given track.
Starts a new ExWebRTC.Recorder
process.
Starts a new ExWebRTC.Recorder
process.
Types
@type end_tracks_ok_result() :: {:ok, ExWebRTC.Recorder.Manifest.t(), ExWebRTC.Recorder.S3.upload_task_ref() | nil}
Tuple returned on successful call to end_tracks/2
.
Contains the part of the recording manifest that's relevant to the freshly ended tracks.
See ExWebRTC.Recorder.Manifest.t/0
for more info.
If uploads are configured:
- Contains the reference to the upload task that was spawned.
- Recorder will send the
:upload_complete
/:upload_failed
message with this reference to its controlling process when the task finishes.
Note that the manifest returned by end_tracks/2
always contains local paths to files.
The updated manifest with s3://
scheme URLs is sent in the aforementioned message.
@type message() :: {:ex_webrtc_recorder, pid(), {:upload_complete, ExWebRTC.Recorder.S3.upload_task_ref(), ExWebRTC.Recorder.Manifest.t()} | {:upload_failed, ExWebRTC.Recorder.S3.upload_task_ref(), ExWebRTC.Recorder.Manifest.t()}}
Messages sent by the ExWebRTC.Recorder
process to its controlling process.
:upload_complete
,:upload_failed
- Sent after the completion of the upload task, identified by its reference. Contains the updated manifest withs3://
scheme URLs to uploaded files.
@type option() :: {:base_dir, String.t()} | {:on_start, (-> [ExWebRTC.MediaStreamTrack.t()])} | {:controlling_process, Process.dest()} | {:s3_upload_config, ExWebRTC.Recorder.S3.upload_config()}
Options that can be passed to start_link/1
.
:base_dir
- Base directory where Recorder will save its artifacts../recordings
by default.:on_start
- Callback that will be executed just after the Recorder is (re)started. It should return the initial list of tracks to be added.:controlling_process
- PID of a process where all messages will be sent.self()
by default.:s3_upload_config
- If passed, finished recordings will be uploaded to S3-compatible storage. SeeExWebRTC.Recorder.S3.upload_config/0
for more info.
@type options() :: [option()]
@type recorder() :: GenServer.server()
Functions
@spec add_tracks(recorder(), [ExWebRTC.MediaStreamTrack.t()]) :: {:ok, ExWebRTC.Recorder.Manifest.t()}
Adds new tracks to the recording.
Returns the part of the recording manifest that's relevant to the freshly added tracks.
See ExWebRTC.Recorder.Manifest.t/0
for more info.
@spec controlling_process(recorder(), Process.dest()) :: :ok
Changes the controlling process of this recorder
process.
Controlling process is a process that receives all of the messages (described
by message/0
) from this Recorder.
@spec end_tracks(recorder(), [ExWebRTC.MediaStreamTrack.id()]) :: end_tracks_ok_result() | {:error, :tracks_not_found}
Finishes the recording for the given tracks and optionally uploads the result files.
See end_tracks_ok_result/0
for the success typing.
@spec record( recorder(), ExWebRTC.MediaStreamTrack.id(), ExWebRTC.MediaStreamTrack.rid() | nil, ExRTP.Packet.t() ) :: :ok
Records a received packet on the given track.
@spec start(options(), GenServer.options()) :: GenServer.on_start()
Starts a new ExWebRTC.Recorder
process.
ExWebRTC.Recorder
is a GenServer
under the hood, thus this function allows for
passing the generic GenServer.options/0
as an argument.
@spec start_link(options(), GenServer.options()) :: GenServer.on_start()
Starts a new ExWebRTC.Recorder
process.
Works identically to start/2
, but links to the calling process.