Class TsFileSource
Provides a transport stream file source that reads media data from a file.
public class TsFileSource : IInteractiveMediaSource, IMediaSource, IReferenceable, IDisposable
- Inheritance
-
TsFileSource
- Implements
- Inherited Members
Constructors
TsFileSource(int)
Initializes a new instance of the TsFileSource class.
public TsFileSource(int programPid = -1)
Parameters
programPidintThe program PID to filter, or
-1for no filter.
Fields
filePositions
Maps DTS values to file byte positions for seeking.
public SortedList<long, long> filePositions
Field Value
Properties
AllowEos
Gets or sets whether source will stop on end of stream.
public bool AllowEos { get; set; }
Property Value
Available
Gets a value indicating whether the source actually supports the exposed IInteractiveMediaSource for the currently opened URI.
Always returns true for this class.
public bool Available { get; }
Property Value
CanPause
Gets a value indicating whether the source is capable of pausing.
public bool CanPause { get; }
Property Value
CanSeek
Gets a value indicating whether the source is capable of seeking.
public bool CanSeek { get; }
Property Value
Capabilities
Gets the list of source capabilities
public List<SourceCapability> Capabilities { get; }
Property Value
Duration
Gets the source duration if applicable; otherwise, 0.
public TimeSpan Duration { get; }
Property Value
IsChangeable
Gets a value indicating whether the source is changeable, i.e. duration will change over time.
public bool IsChangeable { get; }
Property Value
IsDisposed
Gets a value indicating whether the object is already disposed and cannot be used anymore.
public bool IsDisposed { get; }
Property Value
IsMonitor
Gets or sets a value indicating whether the source is monitoring file changes.
public bool IsMonitor { get; set; }
Property Value
IsNetworkSource
Gets a value indicating whether this is a network source.
Always returns false for file sources.
public bool IsNetworkSource { get; }
Property Value
Loop
Gets or sets whether playback should be an endless loop. If value is true then seek and pause are not available.
public bool Loop { get; set; }
Property Value
Parameters
Gets or sets source parameters
public SourceParameters Parameters { get; set; }
Property Value
PlaybackRate
Gets or sets playback rate (if applicable). If value is 1 then normal playback pace is maintained. If value is more than 1 then it means fast forward playback with possible I-frames only stream if supported by source. If value is in (0..1) range then it means slow motion playback. If value is less or equal to -1 then it means rewind playback with possible I-frames only stream if supported by source. If value is double.MaxValue then source pushes samples as quickly as possible, without considering sample timestamps and playback time.
public double PlaybackRate { get; set; }
Property Value
Position
Gets or sets source playback position if seek is supported
public TimeSpan Position { get; set; }
Property Value
RefCount
Gets the current reference count of the object.
public int RefCount { get; }
Property Value
State
Gets the current source state.
public MediaState State { get; }
Property Value
StreamCount
Gets the total stream count of the source.
public int StreamCount { get; }
Property Value
UniqueId
Gets or sets the unique source identifier.
public Guid UniqueId { get; set; }
Property Value
Uri
Gets or sets the URI to be opened to pull data from.
public string Uri { get; set; }
Property Value
Methods
AddRef()
Adds a reference to the object.
public void AddRef()
Dispose()
Releases all resources used by the TsFileSource class.
public void Dispose()
GetMediaType(int)
Gets the media type of the specified stream.
public MediaType GetMediaType(int streamIndex)
Parameters
streamIndexintThe stream index to get the media type for.
Returns
- MediaType
The media type of the requested stream, or
nullif the index is out of range.
GetMediaTypeAndIndices(int)
Gets the media type of the specified stream and all indices.
public NewStreamEventArgs GetMediaTypeAndIndices(int streamIndex)
Parameters
streamIndexintThe stream index to get the media type for.
Returns
- NewStreamEventArgs
The media type and all indices of the requested stream, or
nullif the index is out of range.
Open()
Opens the source using the specified URI.
public void Open()
Pause()
Pauses pushing of media data.
public void Pause()
QueueRequiredAction(ActionRequiredEventArgs)
Queues a required action for further processing.
public void QueueRequiredAction(ActionRequiredEventArgs e)
Parameters
eActionRequiredEventArgsThe required action to queue.
Release()
Releases a reference to the object.
If the reference count becomes 0 then the Dispose() method is called.
The calling object must not use the current object after this call.
public void Release()
SetDesiredOutputType(int, MediaType)
Sets the desired output media type of the specified stream. The desired media type could be an incomplete media type specifying only necessary parameters. The source implements decoding internally to provide the requested output type. It is not guaranteed that the actual output type will match the desired type exactly. The GetMediaType(int) method should be used to obtain the actual output media type.
public Task SetDesiredOutputType(int streamIndex, MediaType mediaType)
Parameters
streamIndexintThe stream index to set the desired output media type for.
mediaTypeMediaTypeThe desired media type.
Returns
Start()
Starts media pushing from the file.
public void Start()
Stop()
Stops media pushing and closes the source.
public void Stop()
Events
Error
Occurs when an error has occurred during source operation.
public event EventHandler<ErrorEventArgs> Error
Event Type
NewSample
Occurs when a new media sample is ready.
public event EventHandler<NewSampleEventArgs> NewSample
Event Type
NewStream
Occurs when a new stream has been created.
public event EventHandler<NewStreamEventArgs> NewStream
Event Type
SourceChanged
Occurs when the source has changed, i.e. duration and frame tables have to be updated.
public event EventHandler SourceChanged
Event Type
StateChanged
Occurs when the source state has changed.
public event EventHandler<MediaState> StateChanged