## org.red5.server.stream
Class ClientBroadcastStream

    java.lang.Object
      org.red5.server.stream.AbstractStream
          org.red5.server.stream.AbstractClientStream
              org.red5.server.stream.ClientBroadcastStream

All Implemented Interfaces:
  IEventDispatcher, IClientBroadcastStreamStatistics, IStatisticsBase, IStreamStatistics, IBroadcastStream, IClientBroadcastStream, IClientStream, IStream, IConsumer, IFilter, IMessageComponent, IPipeConnectionListener, IProvider, IPushableConsumer, ClientBroadcastStreamMBean

    public class ClientBroadcastStream

extends AbstractClientStream
implements IClientBroadcastStream, IFilter, IPushableConsumer, IPipeConnectionListener, IEventDispatcher, IClientBroadcastStreamStatistics, ClientBroadcastStreamMBean

Represents live stream broadcasted from client. As Flash Media Server, Red5 supports recording mode for live streams, that is, broadcasted stream has broadcast mode. It can be either "live" or "record" and latter causes server-side application to record broadcasted stream. Note that recorded streams are recorded as FLV files. The same is correct for audio, because NellyMoser codec that Flash Player uses prohibits on-the-fly transcoding to audio formats like MP3 without paying of licensing fee or buying SDK. This type of stream uses two different pipes for live streaming and recording.

Nested Class Summary

Nested classes/interfaces inherited from class org.red5.server.stream.AbstractStream
`AbstractStream.State`

Field Summary
`protected long` `bytesReceived` Total number of bytes received.
`protected boolean` `checkVideoCodec` Is there need to check video codec?
`protected int` `chunkSize` Data is sent by chunks, each of them has size
`protected boolean` `closed` Is this stream still active?
`protected IMessageOutput` `connMsgOut` Output endpoint that providers use
`protected long` `firstPacketTime` Stores timestamp of first packet.
`protected long` `latestTimeStamp`
`protected Set<IStreamListener>` `listeners` Listeners to get notified about received packets.
`protected IPipe` `livePipe` Pipe for live streaming
`protected String` `publishedName` Stream published name
`protected boolean` `sendStartNotification` Is there need to send start notification?

Fields inherited from class org.red5.server.stream.AbstractStream
`creationTime, metaData, state`

Fields inherited from interface org.red5.server.api.stream.IClientStream
`MODE_APPEND, MODE_LIVE, MODE_PUBLISH, MODE_READ, MODE_RECORD`

Fields inherited from interface org.red5.server.messaging.IPushableConsumer
`KEY`

Constructor Summary
`ClientBroadcastStream()`

Method Summary
`void` `addStreamListener(IStreamListener listener)` Add a listener to be notified about received packets.
`void` `close()` Closes stream, unsubscribes provides, sends stoppage notifications and broadcast close notification.
`void` `dispatchEvent(IEvent event)` Dispatches event
`int` `getActiveSubscribers()` Return current number of subscribers.
`long` `getBytesReceived()` Return total number of bytes received from client for this stream.
`int` `getCurrentTimestamp()` Return the currently active timestamp inside the stream.
`int` `getMaxSubscribers()` Return maximum number of concurrent subscribers.
`IProvider` `getProvider()` Getter for provider
`String` `getPublishedName()` Getter for published name
`String` `getSaveFilename()` Get the filename the stream is being saved as.
`IClientBroadcastStreamStatistics` `getStatistics()` Return statistics about the stream.
`Collection<IStreamListener>` `getStreamListeners()` Return registered stream listeners.
`int` `getTotalSubscribers()` Return total number of subscribers.
`boolean` `isRecording()`
`void` `onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)` Out-of-band control message handler
`void` `onPipeConnectionEvent(PipeConnectionEvent event)` Pipe connection event handler
`void` `pushMessage(IPipe pipe, IMessage message)` Currently not implemented
`void` `removeStreamListener(IStreamListener listener)` Remove a listener from being notified about received packets.
`void` `saveAs(String name, boolean isAppend)` Save broadcasted stream.
`void` `setPublishedName(String name)` Setter for stream published name
`void` `start()` Starts stream.
`void` `startPublishing()` Notify client that stream is ready for publishing.
`void` `stop()` Stop this stream.
`void` `stopRecording()` Stops any currently active recordings.

Methods inherited from class org.red5.server.stream.AbstractClientStream
`getClientBufferDuration, getConnection, getStreamId, setClientBufferDuration, setConnection, setStreamId`

Methods inherited from class org.red5.server.stream.AbstractStream
`getCodecInfo, getCreationTime, getMetaData, getName, getScope, getStreamAwareHandler, setCodecInfo, setName, setScope`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.red5.server.api.stream.IClientStream
`getClientBufferDuration, getConnection, getStreamId, setClientBufferDuration`

Methods inherited from interface org.red5.server.api.stream.IBroadcastStream
`getMetaData`

Methods inherited from interface org.red5.server.api.stream.IStream
`getCodecInfo, getCreationTime, getName, getScope`

Methods inherited from interface org.red5.server.api.statistics.IStatisticsBase
`getCreationTime`

Field Detail

### bytesReceived

    protected long bytesReceived

  Total number of bytes received.

### checkVideoCodec

    protected boolean checkVideoCodec

  Is there need to check video codec?

### chunkSize

    protected int chunkSize

  Data is sent by chunks, each of them has size

### closed

    protected boolean closed

  Is this stream still active?

### connMsgOut

    protected IMessageOutput connMsgOut

  Output endpoint that providers use

### firstPacketTime

    protected long firstPacketTime

  Stores timestamp of first packet.

### livePipe

    protected IPipe livePipe

  Pipe for live streaming

### publishedName

    protected String publishedName

  Stream published name

### sendStartNotification

    protected boolean sendStartNotification

  Is there need to send start notification?

### listeners

    protected Set<IStreamListener> listeners

  Listeners to get notified about received packets.

### latestTimeStamp

    protected long latestTimeStamp

Constructor Detail

### ClientBroadcastStream

    public ClientBroadcastStream()

Method Detail

### close

    public void close()

  Closes stream, unsubscribes provides, sends stoppage notifications and broadcast close notification.

  Specified by:
    `close` in interface `IStream`
  Specified by:
    `close` in interface `ClientBroadcastStreamMBean`

### dispatchEvent

    public void dispatchEvent(IEvent event)

  Dispatches event

  Specified by:
    `dispatchEvent` in interface `IEventDispatcher`
  Parameters:
    `event` - Event to dispatch

### getActiveSubscribers

    public int getActiveSubscribers()

  Return current number of subscribers.

  Specified by:
    `getActiveSubscribers` in interface `IClientBroadcastStreamStatistics`
  Returns:
    number of subscribers

### getBytesReceived

    public long getBytesReceived()

  Return total number of bytes received from client for this stream.

  Specified by:
    `getBytesReceived` in interface `IClientBroadcastStreamStatistics`
  Returns:
    number of bytes

### getCurrentTimestamp

    public int getCurrentTimestamp()

  Return the currently active timestamp inside the stream.

  Specified by:
    `getCurrentTimestamp` in interface `IStreamStatistics`
  Returns:
    the timestamp in milliseconds

### getMaxSubscribers

    public int getMaxSubscribers()

  Return maximum number of concurrent subscribers.

  Specified by:
    `getMaxSubscribers` in interface `IClientBroadcastStreamStatistics`
  Returns:
    number of subscribers

### getProvider

    public IProvider getProvider()

  Getter for provider

  Specified by:
    `getProvider` in interface `IBroadcastStream`
  Specified by:
    `getProvider` in interface `ClientBroadcastStreamMBean`
  Returns:
    Provider

### getPublishedName

    public String getPublishedName()

  Getter for published name

  Specified by:
    `getPublishedName` in interface `IClientBroadcastStreamStatistics`
  Specified by:
    `getPublishedName` in interface `IBroadcastStream`
  Specified by:
    `getPublishedName` in interface `ClientBroadcastStreamMBean`
  Returns:
    Stream published name

### getSaveFilename

    public String getSaveFilename()

  Get the filename the stream is being saved as.

  Specified by:
    `getSaveFilename` in interface `IClientBroadcastStreamStatistics`
  Specified by:
    `getSaveFilename` in interface `IBroadcastStream`
  Specified by:
    `getSaveFilename` in interface `ClientBroadcastStreamMBean`
  Returns:
    The filename relative to the scope or `null` if the stream is not being saved.

### getStatistics

    public IClientBroadcastStreamStatistics getStatistics()

  Return statistics about the stream.

  Specified by:
    `getStatistics` in interface `IClientBroadcastStream`
  Returns:
    statistics

### getTotalSubscribers

    public int getTotalSubscribers()

  Return total number of subscribers.

  Specified by:
    `getTotalSubscribers` in interface `IClientBroadcastStreamStatistics`
  Returns:
    number of subscribers

### onOOBControlMessage

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

  Out-of-band control message handler

  Specified by:
    `onOOBControlMessage` in interface `IMessageComponent`
  Parameters:
    `source` - OOB message source
    `pipe` - Pipe that used to send OOB message
    `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)

  Currently not implemented

  Specified by:
    `pushMessage` in interface `IPushableConsumer`
  Parameters:
    `pipe` - Pipe
    `message` - Message

### saveAs

    public void saveAs(String name,
                       boolean isAppend)
                throws IOException,
                       ResourceNotFoundException,
                       ResourceExistException

  Save broadcasted stream.

  Specified by:
    `saveAs` in interface `IBroadcastStream`
  Specified by:
    `saveAs` in interface `ClientBroadcastStreamMBean`
  Parameters:
    `name` - Stream name
    `isAppend` - Append mode
  Throws:
    `IOException` - File could not be created/written to.
    `ResourceNotFoundException` - Resource doesn't exist when trying to append.
    `ResourceExistException` - Resource exist when trying to create.

### setPublishedName

    public void setPublishedName(String name)

  Setter for stream published name

  Specified by:
    `setPublishedName` in interface `IBroadcastStream`
  Specified by:
    `setPublishedName` in interface `ClientBroadcastStreamMBean`
  Parameters:
    `name` - Name that used for publishing. Set at client side when begin to broadcast with NetStream#publish.

### start

    public void start()

  Starts stream. Creates pipes, connects

  Specified by:
    `start` in interface `IStream`
  Specified by:
    `start` in interface `ClientBroadcastStreamMBean`

### startPublishing

    public void startPublishing()

  Notify client that stream is ready for publishing.

  Specified by:
    `startPublishing` in interface `IClientBroadcastStream`
  Specified by:
    `startPublishing` in interface `ClientBroadcastStreamMBean`

### stop

    public void stop()

  Stop this stream.

  Specified by:
    `stop` in interface `IStream`
  Specified by:
    `stop` in interface `ClientBroadcastStreamMBean`

### stopRecording

    public void stopRecording()

  Stops any currently active recordings.

### isRecording

    public boolean isRecording()

### addStreamListener

    public void addStreamListener(IStreamListener listener)

  Add a listener to be notified about received packets.

  Specified by:
    `addStreamListener` in interface `IBroadcastStream`
  Parameters:
    `listener` - the listener to add

### getStreamListeners

    public Collection<IStreamListener> getStreamListeners()

  Return registered stream listeners.

  Specified by:
    `getStreamListeners` in interface `IBroadcastStream`
  Returns:
    the registered listeners

### removeStreamListener

    public void removeStreamListener(IStreamListener listener)

  Remove a listener from being notified about received packets.

  Specified by:
    `removeStreamListener` in interface `IBroadcastStream`
  Parameters:
    `listener` - the listener to remove

Copyright © 2006-2010 The Red5 Project