com.smaxe.uv.client
Class NetStream

java.lang.Object
  extended by AbstractNetStream
      extended by com.smaxe.uv.client.NetStream
All Implemented Interfaces:
INetStream

public final class NetStream
extends AbstractNetStream
implements INetStream

NetStream - implementation of the INetStream interface.

Version:
1.5.12
Author:
Andrei Sochirca
See Also:
JUV RTMP Client

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.smaxe.uv.client.INetStream
INetStream.IListener, INetStream.Info, INetStream.ListenerAdapter
 
Field Summary
 
Fields inherited from interface com.smaxe.uv.client.INetStream
APPEND, CLEAR_FAILED, CLEAR_SUCCESS, DATA_START, FAILED, INVALID_ARGUMENT, LIVE, PAUSE_NOTIFY, PLAY_COMPLETE, PLAY_FAILED, PLAY_FILE_STRUCTURE_INVALID, PLAY_INSUFFICIENT_BW, PLAY_NO_SUPPORTED_TRACK_FOUND, PLAY_PUBLISH_NOTIFY, PLAY_RESET, PLAY_START, PLAY_STOP, PLAY_STREAM_NOT_FOUND, PLAY_SWITCH, PLAY_UNPUBLISH_NOTIFY, PUBLISH_BADNAME, PUBLISH_START, RECORD, RECORD_FAILED, RECORD_NOACCESS, RECORD_START, RECORD_STOP, SEEK_FAILED, SEEK_NOTIFY, UNPAUSE_NOTIFY, UNPUBLISH_SUCCESS
 
Constructor Summary
NetStream(INetConnection connection)
          Constructor.
 
Method Summary
 void _RtmpSampleAccess(boolean audio, boolean video)
          '|RtmpSampleAccess' invoked by FMS server.
 void attachAudio(IMicrophone microphone)
          Specifies an audio stream sent over the INetStream object, from a microphone object passed as the source.
 void attachCamera(ICamera camera, int snapshotMilliseconds)
          Starts capturing video from the specified source, or stops capturing if camera is set to null.
 double bufferLength()
          Returns number of seconds of data currently in the buffer.
 int bufferSize()
          Returns number of data bytes currently in the buffer.
 long bytesLoaded()
          Returns number of bytes of data that have been loaded.
 long bytesTotal()
          Returns total size (in bytes) of the file being loaded.
 int clearBuffer()
          Clears buffer.
 void close()
          Stops playing all data on the stream, sets the time property to 0, and makes the stream available for another use.
 double currentFPS()
          Returns the number of frames per second being displayed.
 ICamera getCamera()
          Returns ICamera associated with the stream.
 INetStream.Info getInfo()
          Returns overall stream info.
 IMicrophone getMicrophone()
          Returns IMicrophone associated with the stream.
 IVideo getVideo()
          Returns IVideo associated with the stream.
 double liveDelay()
          Returns the number of seconds of data in the subscribing stream's buffer in live (unbuffered) mode.
 void pause()
          Pauses playback of a video stream.
 void play(IVideo video, java.lang.Object... args)
          Begins playback of external audio or a video (FLV) file.
 void publish(java.lang.String name, java.lang.String type)
          Sends streaming audio, video, and text messages from a client to a server.
 void receiveAudio(boolean flag)
          Specifies whether incoming audio plays on the stream.
 void receiveVideo(boolean flag)
          Specifies whether incoming video plays on the stream.
 void resume()
          Resumes playback of a video stream that is paused.
 void seek(double offset)
          Seeks the keyframe closest to the specified location (an offset, in seconds, from the beginning of the stream).
 void send(java.lang.String handlerName, java.lang.Object... args)
          Sends a message on the specified stream to all subscribing clients.
 double time()
          Returns position of the playhead (in seconds).
 void togglePause()
          Pauses or resumes playback of a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.smaxe.uv.client.INetStream
addEventListener, bufferTime, bufferTime, client, client, objectEncoding, removeEventListener
 

Constructor Detail

NetStream

public NetStream(INetConnection connection)
Constructor.

Parameters:
connection - connection
Method Detail

getInfo

public INetStream.Info getInfo()
Description copied from interface: INetStream
Returns overall stream info.

Specified by:
getInfo in interface INetStream
Returns:
overall stream info

getCamera

public ICamera getCamera()
Description copied from interface: INetStream
Returns ICamera associated with the stream.

Note:
- Camera is set by INetStream.attachCamera(ICamera, int) method.

Specified by:
getCamera in interface INetStream
Returns:
camera

getMicrophone

public IMicrophone getMicrophone()
Description copied from interface: INetStream
Returns IMicrophone associated with the stream.

Note:
- Microphone is set by INetStream.attachAudio(IMicrophone) method.

Specified by:
getMicrophone in interface INetStream
Returns:
microphone

getVideo

public IVideo getVideo()
Description copied from interface: INetStream
Returns IVideo associated with the stream.

Note:
- Video is set by INetStream.play(IVideo, Object[]) method.

Specified by:
getVideo in interface INetStream
Returns:
video

bufferLength

public double bufferLength()
Description copied from interface: INetStream
Returns number of seconds of data currently in the buffer.

Specified by:
bufferLength in interface INetStream
Returns:
number of seconds of data currently in the buffer

bufferSize

public int bufferSize()
Description copied from interface: INetStream
Returns number of data bytes currently in the buffer.

Specified by:
bufferSize in interface INetStream
Returns:
number of data bytes currently in the buffer

bytesLoaded

public long bytesLoaded()
Description copied from interface: INetStream
Returns number of bytes of data that have been loaded.

Specified by:
bytesLoaded in interface INetStream
Returns:
number of bytes of data that have been loaded

bytesTotal

public long bytesTotal()
Description copied from interface: INetStream
Returns total size (in bytes) of the file being loaded.

Specified by:
bytesTotal in interface INetStream
Returns:
total size in bytes of the file being loaded

clearBuffer

public int clearBuffer()
Description copied from interface: INetStream
Clears buffer.

Specified by:
clearBuffer in interface INetStream
Returns:
cleared stream duration

attachAudio

public void attachAudio(IMicrophone microphone)
Description copied from interface: INetStream
Specifies an audio stream sent over the INetStream object, from a microphone object passed as the source.

Specified by:
attachAudio in interface INetStream
Parameters:
microphone - source of the audio transmission

attachCamera

public void attachCamera(ICamera camera,
                         int snapshotMilliseconds)
Description copied from interface: INetStream
Starts capturing video from the specified source, or stops capturing if camera is set to null. This method is available only to the publisher of the specified stream.

Specified by:
attachCamera in interface INetStream
Parameters:
camera - source of the video transmission
snapshotMilliseconds - Specifies whether the video stream is continuous, a single frame, or a series of single frames used to create time-lapse photography

publish

public void publish(java.lang.String name,
                    java.lang.String type)
Description copied from interface: INetStream
Sends streaming audio, video, and text messages from a client to a server.

Specified by:
publish in interface INetStream
Parameters:
name - string that identifies the stream
type - string that specifies how to publish the stream. Valid values are "record", "append", and "live". The default value is "live".

send

public void send(java.lang.String handlerName,
                 java.lang.Object... args)
Description copied from interface: INetStream
Sends a message on the specified stream to all subscribing clients. This method is available only to the publisher of the specified stream.

Specified by:
send in interface INetStream
args - optional arguments that can be of any type

currentFPS

public double currentFPS()
Description copied from interface: INetStream
Returns the number of frames per second being displayed.

Specified by:
currentFPS in interface INetStream
Returns:
number of frames per second being displayed

liveDelay

public double liveDelay()
Description copied from interface: INetStream
Returns the number of seconds of data in the subscribing stream's buffer in live (unbuffered) mode.

Specified by:
liveDelay in interface INetStream
Returns:
number of seconds of data in the subscribing stream's buffer in live (unbuffered) mode

time

public double time()
Description copied from interface: INetStream
Returns position of the playhead (in seconds).

Specified by:
time in interface INetStream
Returns:
position of the playhead, in seconds

play

public void play(IVideo video,
                 java.lang.Object... args)
Description copied from interface: INetStream
Begins playback of external audio or a video (FLV) file.
 Note: 
 file parameter can be either string or object array:
 {name : Object [,start : Number[, len : Number[, reset : Object]]]}
 where
    start - An optional numeric parameter that specifies the
 start time, in seconds. This parameter can also be used to indicate whether
 the stream is live or recorded.
    The default value for start is -2, which means that it first tries to play
 the live stream specified in name. If a live stream of that name is not found,
 it plays the recorded stream specified in name. If neither a live nor a
 recorded stream is found, it opens a live stream named name, even
 though no one is publishing on it. When someone does begin publishing on
 that stream, it begins playing it.
    If you pass -1 for start, it plays only the live stream specified in name.
 If no live stream is found, it waits for it indefinitely if len is set to -1;
 if len is set to a different value, it waits for len seconds before it begins
 playing the next item in the playlist.
    If you pass 0 or a positive number for start, it plays only a recorded
 stream named name, beginning start seconds from the beginning of the stream.
 If no recorded stream is found, it begins playing the next item in the playlist
 immediately.
    If you pass a negative number other than -1 or -2 for start, it
 interprets the value as if it were -2.
 
    len - An optional numeric parameter that specifies the duration of the playback,
 in seconds.
    The default value for len is -1, which means that it plays a live stream
 until it is no longer available or plays a recorded stream until it ends.
    If you pass 0 for len, it plays the single frame that is start seconds
 from the beginning of a recorded stream (assuming start is equal to or greater than 0).
    If you pass a positive number for len, it plays a live stream for len seconds
 after it becomes available, or plays a recorded stream for len seconds.
 (If a stream ends before len seconds, playback ends when the stream ends.)
    If you pass a negative number other than -1 for len, it interprets the value
 as if it were -1.
 
    reset - An optional Boolean value or number that specifies whether to
 flush any previous playlist. If reset is false (0), name is added (queued)
 in the current playlist; that is, name plays only after previous streams
 finish playing. You can use this technique to create a dynamic playlist.
 If reset is true (1), any previous play calls are cleared and name is played
 immediately. By default, the value is true.

Specified by:
play in interface INetStream
Parameters:
video - video object which received audio/video data
args - the location of the FLV file to play, as a URLRequest object or a string

pause

public void pause()
Description copied from interface: INetStream
Pauses playback of a video stream.

Specified by:
pause in interface INetStream

receiveAudio

public void receiveAudio(boolean flag)
Description copied from interface: INetStream
Specifies whether incoming audio plays on the stream. This method is available only to clients subscribed to the specified stream, not to the stream's publisher.

Specified by:
receiveAudio in interface INetStream
Parameters:
flag - specifies whether incoming audio plays on the specified stream (true) or not (false)

receiveVideo

public void receiveVideo(boolean flag)
Description copied from interface: INetStream
Specifies whether incoming video plays on the stream. This method is available only to clients subscribed to the specified stream, not to the stream's publisher.

Specified by:
receiveVideo in interface INetStream
Parameters:
flag - specifies whether incoming video plays on the specified stream (true) or not (false)

resume

public void resume()
Description copied from interface: INetStream
Resumes playback of a video stream that is paused. If the video is already playing, calling this method does nothing.

Specified by:
resume in interface INetStream

seek

public void seek(double offset)
Description copied from interface: INetStream
Seeks the keyframe closest to the specified location (an offset, in seconds, from the beginning of the stream). The stream resumes playing when that location is reached.

Specified by:
seek in interface INetStream
Parameters:
offset - offset position

togglePause

public void togglePause()
Description copied from interface: INetStream
Pauses or resumes playback of a stream. The first time you call this method, it pauses play; the next time, it resumes play. You could use this method to let users pause or resume playback by pressing a single button.

Specified by:
togglePause in interface INetStream

close

public void close()
Description copied from interface: INetStream
Stops playing all data on the stream, sets the time property to 0, and makes the stream available for another use.

Specified by:
close in interface INetStream

_RtmpSampleAccess

public void _RtmpSampleAccess(boolean audio,
                              boolean video)
'|RtmpSampleAccess' invoked by FMS server.

Parameters:
audio -
video -