# class StreamInterface

### abstract

Module | phonon
Namespace | Phonon
Class | StreamInterface
Inherits |

\class StreamInterface streaminterface.h Phonon/StreamInterface Backend interface to handle media streams (AbstractMediaStream).

Author Matthias Kretz <kretz@kde.org>

### methods

- StreamInterface ( )

  returns ctor

- connectToSource (mediaSource)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  mediaSource | Phonon.MediaSource |

  Call this function from the constructor of your StreamInterface implementation (or as soon as you get the MediaSource object). This will connect your object to the AbstractMediaStream object. Only after the connection is done will the following functions have an effect.

- endOfData ( )

  returns Nothing
  pure virtual

  Called when no more media data is available and writeData will not be called anymore.

- enoughData ( )

  returns Nothing

  Call this function to tell the AbstractMediaStream that you have enough data in your buffer and that it should pause calling writeData if possible.

- needData ( )

  returns Nothing

  Call this function to tell the AbstractMediaStream that you need more data. The data will arrive through writeData. Don't rely on writeData getting called from needData, though some AbstractMediaStream implementations might do so.

  Depending on the buffering you need you either treat needData as a replacement for a read call like QIODevice.read, or you start calling needData whenever your buffer reaches a certain lower threshold.

- reset ( )

  returns Nothing

  Resets the AbstractMediaStream. E.g. this can be useful for non-seekable streams to start over again.

- seekStream (seekTo)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  seekTo | qint64 |

  If the stream is seekable, calling this function will make the next call to writeData pass data that starts at the byte offset seekTo.

- setStreamSeekable (s)

  returns Nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  s | bool |

  Tells whether the stream is seekable.

- setStreamSize (newSize)

  returns Nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  newSize | qint64 |

  Called at the start of the stream to tell how many bytes will be sent through writeData (if no seeks happen, of course). If this value is negative the stream size cannot be determined (might be a "theoretically infinite" stream - like webradio).

- writeData (data)

  returns Nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  data | QByteArray |

  Called by the application to send a chunk of (encoded) media data.

  It is recommended to keep the QByteArray object until the data is consumed so that no memcopy is needed.