Class IsoSink
Implements IMediaSink and IUriRotatable for writing ISO base media file format (MP4) files using IsoFormatParser as the underlying writer. Supports file URI rotation for chunked recording.
public class IsoSink : IMediaSink, IDisposable, IUriRotatable
- Inheritance
-
IsoSink
- Implements
- Inherited Members
Constructors
IsoSink()
Initializes a new instance of the IsoSink class.
public IsoSink()
IsoSink(ParsingParameters)
Initializes a new instance of the IsoSink class with the specified parsing parameters.
public IsoSink(ParsingParameters parsingParameters)
Parameters
parsingParametersParsingParametersThe parsing parameters to use, or
nullto use defaults.
Properties
Capabilities
Gets the list of sink capabilities
public List<SinkCapability> Capabilities { get; }
Property Value
IsNetworkSink
Whether it's a network or local sink. Necessary to apply longer timeouts in media session processing logic.
public bool IsNetworkSink { get; }
Property Value
NextUri
Function which returns next URI to be opened. Either Uri or NextUri or Stream shall be specified. Necessary for sinks with dynamically generated URI or file chunking. Exact URI syntax depends on the implementation.
public Func<string> NextUri { get; set; }
Property Value
Parameters
Gets or sets sink parameters
public SinkParameters Parameters { get; set; }
Property Value
ParsingParameters
Gets or sets the parsing parameters used by the underlying ISO format writer.
public ParsingParameters ParsingParameters { get; set; }
Property Value
RotationPeriod
Rotation period in seconds after which the NextUri function will be called and sink will be re-created with the newly provided uri. Value 0 means no rotation
public int RotationPeriod { get; set; }
Property Value
State
Gets the current sink state.
public MediaState State { get; }
Property Value
Stream
Gets or sets the output stream to write media data to.
Either Uri or NextUri or Stream shall be specified.
public Stream Stream { get; set; }
Property Value
UniqueId
Gets or sets the unique identifier for this sink instance.
public Guid UniqueId { get; set; }
Property Value
Uri
URI to be opened. Either Uri or NextUri or Stream shall be specified. Exact URI syntax depends on the implementation.
public string Uri { get; set; }
Property Value
UserData
Gets or sets user data. Can be used to attach user specific data to a sink.
public object UserData { get; set; }
Property Value
Methods
AddStream(int, MediaType)
Adds a media stream descriptor for writing to the output file.
public void AddStream(int streamIndex, MediaType mediaType)
Parameters
Dispose()
Releases all resources used by the IsoSink class.
public void Dispose()
Open()
Opens the sink using the configured URI, NextUri function, or output stream.
public void Open()
PushMedia(int, VersatileBuffer)
Writes a media sample to the output file. Handles file rotation when the rotation period has elapsed.
public void PushMedia(int streamIndex, VersatileBuffer packet)
Parameters
streamIndexintThe input stream index.
packetVersatileBufferThe media sample to write.
Start(bool)
Starts media sample writing. Streams must be added via AddStream(int, MediaType) before calling this method.
public void Start(bool delayedStart = false)
Parameters
delayedStartboolfalseif media samples are expected immediately;trueif the first media sample is expected after a significant time interval (e.g. tens of seconds).
Stop()
Stops media sample writing, flushes the writer, and releases file resources.
public void Stop()
Events
Error
Occurs when an error is encountered during writing.
public event EventHandler<ErrorEventArgs> Error
Event Type
StateChanged
Occurs when the sink state changes.
public event EventHandler<MediaState> StateChanged
Event Type
UriRotated
Occurs when the output URI has been rotated to a new file.
public event EventHandler<UriRotatedEventArgs> UriRotated