org.red5.server.stream

## Class PlayEngine

- java.lang.Object
- - org.red5.server.stream.PlayEngine

All Implemented Interfaces:
  IConsumer, IFilter, IMessageComponent, IPipeConnectionListener, IProvider, IPushableConsumer

    public final class PlayEngine
    extends Object
    implements IFilter, IPushableConsumer, IPipeConnectionListener

A play engine for playing an IPlayItem.

Author:
  The Red5 Project (red5@osflash.org), Steven Gong, Paul Gregoire (mondain@gmail.com), Dan Rossi, Tiago Daniel Jacobs (tiago@imdt.com.br), Vladimir Hmelyoff (vlhm@splitmedialabs.com)

### Nested Class Summary

Nested Classes
`static class` `PlayEngine.Builder` Builder pattern

### Field Summary

### Fields inherited from interface org.red5.server.messaging.IPushableConsumer

`KEY`

### Method Summary

Methods
`protected boolean` `checkSendMessageEnabled(RTMPMessage message)` Check if sending the given message was enabled by the client.
`void` `close()` Close stream
`int` `getLastMessageTimestamp()` Returns the timestamp of the last message sent.
`long` `getPlaybackStart()`
`boolean` `isPaused()`
`boolean` `isPullMode()`
`void` `onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)`
`void` `onPipeConnectionEvent(PipeConnectionEvent event)` Pipe connection event handler
`void` `pause(int position)` Pause at position
`void` `play(IPlayItem item)` Play stream
`void` `play(IPlayItem item, boolean withReset)` Play stream
`void` `pushMessage(IPipe pipe, IMessage message)` Pushes message through pipe
`boolean` `receiveAudio()` Returns true if the engine currently receives audio.
`boolean` `receiveAudio(boolean receive)` Returns true if the engine currently receives audio and sets the new value.
`boolean` `receiveVideo()` Returns true if the engine currently receives video.
`boolean` `receiveVideo(boolean receive)` Returns true if the engine currently receives video and sets the new value.
`void` `resume(int position)` Resume playback
`void` `seek(int position)` Seek to a given position
`void` `sendBlankAudio(boolean sendBlankAudio)`
`void` `setBufferCheckInterval(int bufferCheckInterval)`
`void` `setMaxPendingVideoFrames(int maxPendingVideoFrames)`
`void` `setMaxSequentialPendingVideoFrames(int maxSequentialPendingVideoFrames)`
`void` `setUnderrunTrigger(int underrunTrigger)`
`void` `start()` Start stream
`void` `stop()` Stop playback

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### setBufferCheckInterval

    public void setBufferCheckInterval(int bufferCheckInterval)

#### setUnderrunTrigger

    public void setUnderrunTrigger(int underrunTrigger)

#### start

    public void start()

Start stream

#### play

    public void play(IPlayItem item)
              throws StreamNotFoundException,
                     IllegalStateException,
                     IOException

Play stream

Parameters:
  `item` - Playlist item
Throws:
  `StreamNotFoundException` - Stream not found
  `IllegalStateException` - Stream is in stopped state
  `IOException` - Stream had io exception

#### play

    public void play(IPlayItem item,
            boolean withReset)
              throws StreamNotFoundException,
                     IllegalStateException,
                     IOException

Play stream

Parameters:
  `item` - Playlist item
  `withReset` - Send reset status before playing.
Throws:
  `StreamNotFoundException` - Stream not found
  `IllegalStateException` - Stream is in stopped state
  `IOException` - Stream had IO exception

#### pause

    public void pause(int position)
               throws IllegalStateException

Pause at position

Parameters:
  `position` - Position in file
Throws:
  `IllegalStateException` - If stream is stopped

#### resume

    public void resume(int position)
                throws IllegalStateException

Resume playback

Parameters:
  `position` - Resumes playback
Throws:
  `IllegalStateException` - If stream is stopped

#### seek

    public void seek(int position)
              throws IllegalStateException,
                     OperationNotSupportedException

Seek to a given position

Parameters:
  `position` - Position
Throws:
  `IllegalStateException` - If stream is in stopped state
  `OperationNotSupportedException` - If this object doesn't support the operation.

#### stop

    public void stop()
              throws IllegalStateException

Stop playback

Throws:
  `IllegalStateException` - If stream is in stopped state

#### close

    public void close()

Close stream

#### onOOBControlMessage

    public void onOOBControlMessage(IMessageComponent source,
                           IPipe pipe,
                           OOBControlMessage oobCtrlMsg)

Specified by:
  `onOOBControlMessage` in interface `IMessageComponent`
Parameters:
  `source` - Message component source
  `pipe` - Connection pipe
  `oobCtrlMsg` - Out-of-band control message

#### onPipeConnectionEvent

    public void onPipeConnectionEvent(PipeConnectionEvent event)

Pipe connection event handler

Specified by:
  `onPipeConnectionEvent` in interface `IPipeConnectionListener`
Parameters:
  `event` - Pipe connection event

#### pushMessage

    public void pushMessage(IPipe pipe,
                   IMessage message)
                     throws IOException

Pushes message through pipe

Specified by:
  `pushMessage` in interface `IPushableConsumer`
Parameters:
  `pipe` - Pipe
  `message` - Message
Throws:
  `IOException` - if message could not be written

#### isPullMode

    public boolean isPullMode()

#### isPaused

    public boolean isPaused()

#### getLastMessageTimestamp

    public int getLastMessageTimestamp()

Returns the timestamp of the last message sent.

Returns:
  last message timestamp

#### getPlaybackStart

    public long getPlaybackStart()

#### sendBlankAudio

    public void sendBlankAudio(boolean sendBlankAudio)

#### receiveAudio

    public boolean receiveAudio()

Returns true if the engine currently receives audio.

Returns:
  receive audio

#### receiveAudio

    public boolean receiveAudio(boolean receive)

Returns true if the engine currently receives audio and sets the new value.

Parameters:
  `receive` - new value
Returns:
  old value

#### receiveVideo

    public boolean receiveVideo()

Returns true if the engine currently receives video.

Returns:
  receive video

#### receiveVideo

    public boolean receiveVideo(boolean receive)

Returns true if the engine currently receives video and sets the new value.

Parameters:
  `receive` - new value
Returns:
  old value

#### checkSendMessageEnabled

    protected boolean checkSendMessageEnabled(RTMPMessage message)

Check if sending the given message was enabled by the client.

Parameters:
  `message` - the message to check
Returns:
  `true` if the message should be sent, `false` otherwise (and the message is discarded)

#### setMaxPendingVideoFrames

    public void setMaxPendingVideoFrames(int maxPendingVideoFrames)

Parameters:
  `maxPendingVideoFrames` - the maxPendingVideoFrames to set

#### setMaxSequentialPendingVideoFrames

    public void setMaxSequentialPendingVideoFrames(int maxSequentialPendingVideoFrames)

Parameters:
  `maxSequentialPendingVideoFrames` - the maxSequentialPendingVideoFrames to set