C# Class wpf_player.ObservableStream

This class extends memory stream to allow waiting state management and position change notify. Using the WaitForMore method, a event will be launched when the needed data has been read. Position Changed event will be launched when more data has been written on the stream: the maximum resolution for this events is 1024 byte; if the position changed for less than 1024 byte the event won't be raised.
Inheritance: System.IO.MemoryStream
Mostrar archivo Open project: zencoders/sambatyon Class Usage Examples

Public Methods

Method Description
ObservableStream ( ) : System

Default constructor

ObservableStream ( byte buffer ) : System

Byte-buffer constructor

ObservableStream ( byte buffer, bool writable ) : System

See MSDN Reference for Memory Stream for Details

ObservableStream ( byte buffer, int index, int count ) : System

See MSDN Reference for Memory Stream for Details

ObservableStream ( byte buffer, int index, int count, bool writable ) : System

See MSDN Reference for Memory Stream for Details

ObservableStream ( byte buffer, int index, int count, bool writable, bool isVisible ) : System

See MSDN Reference for Memory Stream for Details

ObservableStream ( int capacity ) : System

Capacity contructor. Create a buffer with the given capacity

WaitForMore ( int how_many = 15000 ) : void

Sets the waiting state for the stream and sets the position waited.

Write ( byte buffer, int offset, int count ) : void

This method after the call of the base class implementation uses the launchEvent method to raise the right event See MSDN Reference for Memory Stream for Details.

WriteByte ( byte value ) : void

This method after the call of the base class implementation uses the launchEvent method to raise the right event See MSDN Reference for Memory Stream for Details.

Protected Methods

Method Description
OnPositionChanges ( EventArgs args ) : void

This method calls the event handler for the position changed event

OnWaitedPositionReached ( EventArgs args ) : void

This method calls the event handler for the waited position reached event

Private Methods

Method Description
launchEvent ( ) : void

This method is used to launch stream events. This performs check for waiting state and last launched position and raise the right event in the right moment.

Method Details

ObservableStream() public method

Default constructor
public ObservableStream ( ) : System
return System

ObservableStream() public method

Byte-buffer constructor
public ObservableStream ( byte buffer ) : System
buffer byte Byte buffer used by the stream
return System

ObservableStream() public method

See MSDN Reference for Memory Stream for Details
public ObservableStream ( byte buffer, bool writable ) : System
buffer byte
writable bool
return System

ObservableStream() public method

See MSDN Reference for Memory Stream for Details
public ObservableStream ( byte buffer, int index, int count ) : System
buffer byte
index int
count int
return System

ObservableStream() public method

See MSDN Reference for Memory Stream for Details
public ObservableStream ( byte buffer, int index, int count, bool writable ) : System
buffer byte
index int
count int
writable bool
return System

ObservableStream() public method

See MSDN Reference for Memory Stream for Details
public ObservableStream ( byte buffer, int index, int count, bool writable, bool isVisible ) : System
buffer byte
index int
count int
writable bool
isVisible bool
return System

ObservableStream() public method

Capacity contructor. Create a buffer with the given capacity
public ObservableStream ( int capacity ) : System
capacity int Capacity of the stream buffer
return System

OnPositionChanges() protected method

This method calls the event handler for the position changed event
protected OnPositionChanges ( EventArgs args ) : void
args System.EventArgs Arguments that will be passed to the handler
return void

OnWaitedPositionReached() protected method

This method calls the event handler for the waited position reached event
protected OnWaitedPositionReached ( EventArgs args ) : void
args System.EventArgs Arguments that will be passed to the handler
return void

WaitForMore() public method

Sets the waiting state for the stream and sets the position waited.
public WaitForMore ( int how_many = 15000 ) : void
how_many int Number of bytes needed. Default is 15000
return void

Write() public method

This method after the call of the base class implementation uses the launchEvent method to raise the right event See MSDN Reference for Memory Stream for Details.
public Write ( byte buffer, int offset, int count ) : void
buffer byte
offset int
count int
return void

WriteByte() public method

This method after the call of the base class implementation uses the launchEvent method to raise the right event See MSDN Reference for Memory Stream for Details.
public WriteByte ( byte value ) : void
value byte
return void