Package org.red5.server.stream
Class StreamService
java.lang.Object
org.red5.server.stream.StreamService
- All Implemented Interfaces:
IScopeService,IStreamService
Stream service
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static org.slf4j.Loggerprivate ThreadLocal<Boolean>Use to determine playback type.(package private) static Stringprivate static String[]Fields inherited from interface org.red5.server.api.stream.IStreamService
BEAN_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClose streamvoidcloseStream(IConnection conn, Number streamId) Close stream.Create a stream and return a corresponding id.createStream(Number streamId) Create a stream and return a corresponding id.voiddeleteStream(Number streamId) Close the stream if not been closed.voiddeleteStream(IStreamCapableConnection conn, Number streamId) Delete streamgetBroadcastScope(IScope scope, String name) Return broadcast scope object for given scope and child scope name.getSecurityService(IScope scope) voidinitStream(Number streamId) Called by FMS.voidinitStream(Number streamId, Object idk) Called by FMS.parsePathSegments(String name) parseQueryParameters(String name) voidPause at given position.voidUndocumented Flash Plugin 10 call, assuming to be the alias to pause(boolean, int)voidPlay stream without initial stopvoidPlay stream with namevoidPlay stream with name from start positionvoidPlay stream with name from start position and for given amount if timevoidPublishes stream from given position for given amount of timevoidPlays back a stream based on the supplied name, from the specified position for the given length of time.voidplay2(String oldStreamName, int start, String transition, int length, double offset, String streamName) Dynamic streaming play method.voidDynamic streaming play method.voidDynamic streaming play method.voidPublishvoidPublishes stream with given namevoidPublishes stream with given name and modevoidreceiveAudio(boolean receive) Can recieve audio?voidreceiveVideo(boolean receive) Can recieve video?voidreleaseStream(String streamName) Called by FME.voidseek(int position) Seek to positionstatic voidsendNetStreamStatus(IConnection conn, String statusCode, String description, String name, String status, Number streamId) Send NetStream.Status to the client.voidsendNSFailed(IConnection conn, String errorCode, String description, String name, Number streamId) Send NetStream.Play.Failed to the client.private voidsendNSStatus(IConnection conn, String statusCode, String description, String name, Number streamId) Send NetStream.Status to the client.booleanverifySecurity(IScope scope, IStreamCapableConnection streamConn, String name, Number streamId, Map<String, String> params, String mode, StreamAction action)
-
Field Details
-
urlKeys
-
log
private static org.slf4j.Logger log -
STREAM_NAME
-
simplePlayback
Use to determine playback type.
-
-
Constructor Details
-
StreamService
public StreamService()
-
-
Method Details
-
createStream
Create a stream and return a corresponding id.- Specified by:
createStreamin interfaceIStreamService- Returns:
- ID of created stream
-
createStream
Create a stream and return a corresponding id.- Specified by:
createStreamin interfaceIStreamService- Parameters:
streamId- Stream id- Returns:
- ID of created stream
-
initStream
Called by FMS.- Specified by:
initStreamin interfaceIStreamService- Parameters:
streamId- Stream id
-
initStream
Called by FMS.- Specified by:
initStreamin interfaceIStreamService- Parameters:
streamId- Stream ididk- I dont know what this is yet
-
closeStream
public void closeStream()Close stream -
closeStream
Close stream. This method can close both IClientBroadcastStream (coming from Flash Player to Red5) and ISubscriberStream (from Red5 to Flash Player). Corresponding application handlers (streamSubscriberClose, etc.) are called as if close was initiated by Flash Player. It is recommended to remember stream id in application handlers, ex.:public void streamBroadcastStart(IBroadcastStream stream) { super.streamBroadcastStart(stream); if (stream instanceof IClientBroadcastStream) { int publishedStreamId = ((ClientBroadcastStream) stream).getStreamId(); Red5.getConnectionLocal().setAttribute(PUBLISHED_STREAM_ID_ATTRIBUTE, publishedStreamId); } }public void streamPlaylistItemPlay(IPlaylistSubscriberStream stream, IPlayItem item, boolean isLive) { super.streamPlaylistItemPlay(stream, item, isLive); Red5.getConnectionLocal().setAttribute(WATCHED_STREAM_ID_ATTRIBUTE, stream.getStreamId()); }When stream is closed, corresponding NetStream status will be sent to stream provider / consumers. Implementation is based on Red5's StreamService.close()- Specified by:
closeStreamin interfaceIStreamService- Parameters:
conn- client connectionstreamId- stream ID (number: 1,2,...)
-
releaseStream
Called by FME.- Specified by:
releaseStreamin interfaceIStreamService- Parameters:
streamName- stream name
-
deleteStream
Close the stream if not been closed. Deallocate the related resources.- Specified by:
deleteStreamin interfaceIStreamService- Parameters:
streamId- Stream id
-
deleteStream
Delete stream- Specified by:
deleteStreamin interfaceIStreamService- Parameters:
conn- Stream capable connectionstreamId- Stream id
-
pauseRaw
Undocumented Flash Plugin 10 call, assuming to be the alias to pause(boolean, int)- Specified by:
pauseRawin interfaceIStreamService- Parameters:
pausePlayback- Pause or resume flashposition- Pause position
-
pause
Pause at given position. Required as "pausePlayback" can be "null" if no flag is passed by the client- Specified by:
pausein interfaceIStreamService- Parameters:
pausePlayback- Pause playback or notposition- Pause position
-
play
Plays back a stream based on the supplied name, from the specified position for the given length of time.- Parameters:
name- - The name of a recorded file, or the identifier for live data. Ifstart- - The start time, in seconds. Allowed values are -2, -1, 0, or a positive number. The default value is -2, which looks for a live stream, then a recorded stream, and if it finds neither, opens a live stream. If -1, plays only a live stream. If 0 or a positive number, plays a recorded stream, beginning start seconds in.length- - The duration of the playback, in seconds. Allowed values are -1, 0, or a positive number. The default value is -1, which plays a live or recorded stream until it ends. If 0, plays a single frame that is start seconds from the beginning of a recorded stream. If a positive number, plays a live or recorded stream for length seconds.reset- - Whether to clear a playlist. The default value is 1 or true, which clears any previous play calls and plays name immediately. If 0 or false, adds the stream to a playlist. If 2, maintains the playlist and returns all stream messages at once, rather than at intervals. If 3, clears the playlist and returns all stream messages at once.
-
play
Publishes stream from given position for given amount of time- Specified by:
playin interfaceIStreamService- Parameters:
name- Stream published namestart- Start positionlength- Playback lengthflushPlaylist- Flush playlist?
-
play
Play stream with name from start position and for given amount if time- Specified by:
playin interfaceIStreamService- Parameters:
name- Stream namestart- Start positionlength- Playback length
-
play
Play stream with name from start position- Specified by:
playin interfaceIStreamService- Parameters:
name- Stream namestart- Start position
-
play
Play stream with name- Specified by:
playin interfaceIStreamService- Parameters:
name- Stream name
-
play
Play stream without initial stop- Specified by:
playin interfaceIStreamService- Parameters:
dontStop- Stoppage flag
-
play2
public void play2(String oldStreamName, int start, String transition, int length, double offset, String streamName) Dynamic streaming play method. This is a convenience method.- Parameters:
oldStreamName- oldstart- start postransition- type of transitionlength- length to playoffset- offsetstreamName- stream name
-
play2
Dynamic streaming play method. This is a convenience method.- Parameters:
params- play parameters
-
play2
Dynamic streaming play method. The following properties are supported on the play options:streamName: String. The name of the stream to play or the new stream to switch to. oldStreamName: String. The name of the initial stream that needs to be switched out. This is not needed and ignored when play2 is used for just playing the stream and not switching to a new stream. start: Number. The start time of the new stream to play, just as supported by the existing play API. and it has the same defaults. This is ignored when the method is called for switching (in other words, the transition is either NetStreamPlayTransition.SWITCH or NetStreamPlayTransitions.SWAP) len: Number. The duration of the playback, just as supported by the existing play API and has the same defaults. transition: String. The transition mode for the playback command. It could be one of the following: NetStreamPlayTransitions.RESET NetStreamPlayTransitions.APPEND NetStreamPlayTransitions.SWITCH NetStreamPlayTransitions.SWAPNetStreamPlayTransitions:APPEND : String = "append" - Adds the stream to a playlist and begins playback with the first stream. APPEND_AND_WAIT : String = "appendAndWait" - Builds a playlist without starting to play it from the first stream. RESET : String = "reset" - Clears any previous play calls and plays the specified stream immediately. RESUME : String = "resume" - Requests data from the new connection starting from the point at which the previous connection ended. STOP : String = "stop" - Stops playing the streams in a playlist. SWAP : String = "swap" - Replaces a content stream with a different content stream and maintains the rest of the playlist. SWITCH : String = "switch" - Switches from playing one stream to another stream, typically with streams of the same content.- Parameters:
playOptions- play options- See Also:
-
publish
Publish- Specified by:
publishin interfaceIStreamService- Parameters:
dontStop- Whether need to stop first
-
parseQueryParameters
-
parsePathSegments
-
getSecurityService
-
verifySecurity
public boolean verifySecurity(IScope scope, IStreamCapableConnection streamConn, String name, Number streamId, Map<String, String> params, String mode, StreamAction action) -
publish
Publishes stream with given name and mode We have added "synchronized" because this method can be called exactly with the same names at the same time It creates an extra zombi scope that is not deleted anytime. By synching this method, we prevent this problem.- Specified by:
publishin interfaceIStreamService- Parameters:
name- Stream published namemode- Stream publishing mode
-
publish
Publishes stream with given name- Specified by:
publishin interfaceIStreamService- Parameters:
name- Stream published name
-
seek
public void seek(int position) Seek to position- Specified by:
seekin interfaceIStreamService- Parameters:
position- Seek position
-
receiveVideo
public void receiveVideo(boolean receive) Can recieve video?- Specified by:
receiveVideoin interfaceIStreamService- Parameters:
receive- Boolean flag
-
receiveAudio
public void receiveAudio(boolean receive) Can recieve audio?- Specified by:
receiveAudioin interfaceIStreamService- Parameters:
receive- Boolean flag
-
getBroadcastScope
Return broadcast scope object for given scope and child scope name.- Parameters:
scope- Scope objectname- Child scope name- Returns:
- Broadcast scope
-
sendNSFailed
public void sendNSFailed(IConnection conn, String errorCode, String description, String name, Number streamId) Send NetStream.Play.Failed to the client.- Parameters:
conn-errorCode-description-name-streamId-
-
sendNSStatus
private void sendNSStatus(IConnection conn, String statusCode, String description, String name, Number streamId) Send NetStream.Status to the client.- Parameters:
conn-statusCode- see StatusCodes classdescription-name-streamId-
-
sendNetStreamStatus
public static void sendNetStreamStatus(IConnection conn, String statusCode, String description, String name, String status, Number streamId) Send NetStream.Status to the client.- Parameters:
conn- connectionstatusCode- NetStream status codedescription- descriptionname- namestatus- The status - error, warning, or statusstreamId- stream id
-