Package com.wowza.wms.stream
Class MediaStreamMap
- Object
-
- com.wowza.wms.stream.MediaStreamMap
-
public class MediaStreamMap extends Object
MediaStreamMap: collection of IMediaStream object. This collection is usually attached to an IApplicationInstance object.
-
-
Field Summary
Fields Modifier and Type Field Description protected IApplicationInstance
appInstance
boolean
debugDVRShutdown
protected java.util.Map<String,ILiveStreamDvrRecorder>
dvrRecorders
protected java.util.Map<String,ILiveStreamPacketizer>
liveStreamPacketizers
static int
MAXSTREAMINDEX
protected java.util.List<IMediaStreamNotify>
mediaStreamListeners
protected java.util.Map<String,com.wowza.wms.stream.MediaStreamMap.NameGroupHolder>
nameGroupDelayRemoveMap
protected long
nameGroupId
protected int
nameGroupRemoveDelayTime
protected java.util.List<com.wowza.wms.stream.MediaStreamMapGroup>
nameGroups
protected java.util.concurrent.atomic.AtomicLong
nextStreamId
protected java.util.Map<ILiveStreamPacketizer,java.util.Map<Integer,com.wowza.wms.client.LicenseHolder>>
packetizerLicenses
protected java.util.Map<Long,java.util.Map<Integer,com.wowza.wms.client.LicenseHolder>>
streamLicenses
protected edu.emory.mathcs.backport.java.util.concurrent.locks.WMSReadWriteLock
streamLock
protected java.util.Map<String,IMediaStream>
streamNames
protected edu.emory.mathcs.backport.java.util.concurrent.locks.WMSReadWriteLock
streamNamesLock
protected java.util.Map<String,java.util.Set<com.wowza.wms.stream.MediaStreamMapGroup>>
streamNameToGroup
protected java.util.Map<Long,IMediaStream>
streams
-
Constructor Summary
Constructors Constructor Description MediaStreamMap(IApplicationInstance appInstance)
Create empty MediaStreamMap collection
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.wowza.wms.client.LicenseHolder
addLicense(IMediaStream stream, int licenseType)
com.wowza.wms.client.LicenseHolder
addLicense(ILiveStreamPacketizer liveStreamPacketizer, int licenseType)
void
addMediaStreamListener(IMediaStreamNotify mediaStreamListener)
Add a media stream listener.com.wowza.wms.stream.MediaStreamMapGroup
addNameGroup(com.wowza.wms.stream.MediaStreamMapGroup newGroup)
void
broadcasePlayMessage(IMediaStream stream, long timecode, java.nio.ByteBuffer msg, int objectEncoding)
Send a broadcast message to all play stream that are listening to this live published stream.int
broadcastGetObjectEncoding(IMediaStream stream)
Get the minimum object encoding level for the clients playing this stream.void
clearStreamName(String name)
Unregister a published live media stream name.void
clearStreamName(String name, IMediaStream stream)
Unregister a published live media stream name.void
closeLiveStreamPacketizer(String streamName, String packetizerName)
Close live stream packetizer by sending the last data receivedvoid
doWatchdog()
IApplicationInstance
getAppInstance()
Get the parent applicationInstance.String
getAppInstanceName()
Get the name of the parent applicationInstance.String
getAppName()
Get the name of the parent application.int
getCount()
Get the total number of streams stored in the mediaStreamMapILiveStreamDvrRecorder
getDvrRecorder(String streamName, String recorderName, boolean doCreate)
Get a DVR recorder by name and recorder namejava.util.List<ILiveStreamDvrRecorder>
getDvrRecorders()
Returns a list of ILiveStreamDvrRecorder objectsILiveStreamPacketizer
getLiveStreamPacketizer(String streamName, String packetizerName, boolean doCreate)
Get a live stream packetizer by name and packetizer idObject
getLiveStreamPacketizerLock()
Get the lock to the live stream packetizer systemcom.wowza.wms.stream.MediaStreamMapGroup
getNameGroupByGroupName(String groupName)
int
getNameGroupRemoveDelayTime()
java.util.Set<com.wowza.wms.stream.MediaStreamMapGroup>
getNameGroups()
java.util.Set<com.wowza.wms.stream.MediaStreamMapGroup>
getNameGroups(String streamName)
java.util.Set<String>
getNameGroupStreamNames(String streamName)
long
getNextNameGroupId(com.wowza.wms.stream.MediaStreamMapGroup newGroup)
int
getNextStreamIndex()
Reserve a clientless stream id for a new media stream.int
getNextStreamIndex(IClient client)
Reserve a stream for a client connection.int
getNextStreamIndex(INetConnection netConnection)
Reserve a stream for a netConnection connection.java.util.List<String>
getPublishStreamNames()
Returns a List of published stream namesIMediaStream
getStream(IClient client, int index)
Get a media stream reference by stream id.IMediaStream
getStream(IClient client, int index, boolean doCreate)
Get a media stream reference by stream id.IMediaStream
getStream(INetConnection netConnection, int index)
Get a media stream object that is owned by a server to server netConnection object (not yet implemented).IMediaStream
getStream(INetConnection netConnection, int index, boolean doCreate)
Get a media stream reference by stream id.IMediaStream
getStream(String name)
Get a media stream by stream name.IMediaStream
getStreamClientless(int index, String streamTypeStr)
Get a media stream reference by stream id.edu.emory.mathcs.backport.java.util.concurrent.locks.WMSReadWriteLock
getStreamListLock()
Get the underlying read/write lock associated with the list of streamsedu.emory.mathcs.backport.java.util.concurrent.locks.WMSReadWriteLock
getStreamNameLock()
Get the underlying read/write lock associated with the stream names listjava.util.List<IMediaStream>
getStreams()
Returns a list of IMediaStream objectsIVHost
getVHost()
Get the parent vHost.void
notifyMediaStreamCreate(IMediaStream mediaStream)
Notify all media stream listeners that a new media stream object has been created.void
notifyMediaStreamDestroy(IMediaStream mediaStream)
Notify all media stream listeners that a media stream object is being destroyed.void
notifyPlayPublish(IMediaStream stream)
Notify all play streams that are listening to this stream that the stream is going into a state of publish (NetStream.Play.PublishNotify).void
notifyPlayUnpublish(IMediaStream stream)
Notify all play streams that are listening to this stream that the stream is going into a state of unpublished (NetStream.Play.UnpublishNotify).void
notifyPlayUnpublish(String streamName)
Notify all play streams that are listening to this stream name that the stream is going into a state of unpublished (NetStream.Play.UnpublishNotify).void
removeDvrRecorder(String streamName)
ILiveStreamDvrRecorder
removeDvrRecorder(String streamName, String recorderName)
Remove DVR Recordervoid
removeLiveStreamPacketizer(String streamName)
Remove all live stream packetizers for this stream nameILiveStreamPacketizer
removeLiveStreamPacketizer(String streamName, String packetizerName)
Remove live stream packetizervoid
removeMediaStreamListener(IMediaStreamNotify mediaStreamListener)
Remove a media stream listener.com.wowza.wms.stream.MediaStreamMapGroup
removeNameGroup(int groupId)
com.wowza.wms.stream.MediaStreamMapGroup
removeNameGroup(com.wowza.wms.stream.MediaStreamMapGroup nameGroup)
void
removeStream(int index)
Remove a clientless media streamvoid
removeStream(IClient client, int index)
Remove a stream associated with a client connectionvoid
removeStream(INetConnection netConnection, int index)
Remove a stream associated with a netConnection objectvoid
setNameGroupRemoveDelayTime(int nameGroupRemoveDelayTime)
void
setStreamName(IMediaStream stream, String name)
Insert live media stream into the mediaStreamMap by name.long
streamToIndex(IMediaStream stream)
Get the unique stream identifier for a given stream
-
-
-
Field Detail
-
MAXSTREAMINDEX
public static final int MAXSTREAMINDEX
- See Also:
- Constant Field Values
-
debugDVRShutdown
public boolean debugDVRShutdown
-
streams
protected java.util.Map<Long,IMediaStream> streams
-
streamNames
protected java.util.Map<String,IMediaStream> streamNames
-
streamLicenses
protected java.util.Map<Long,java.util.Map<Integer,com.wowza.wms.client.LicenseHolder>> streamLicenses
-
packetizerLicenses
protected java.util.Map<ILiveStreamPacketizer,java.util.Map<Integer,com.wowza.wms.client.LicenseHolder>> packetizerLicenses
-
streamNameToGroup
protected java.util.Map<String,java.util.Set<com.wowza.wms.stream.MediaStreamMapGroup>> streamNameToGroup
-
nameGroups
protected java.util.List<com.wowza.wms.stream.MediaStreamMapGroup> nameGroups
-
nameGroupId
protected long nameGroupId
-
nameGroupRemoveDelayTime
protected int nameGroupRemoveDelayTime
-
nameGroupDelayRemoveMap
protected java.util.Map<String,com.wowza.wms.stream.MediaStreamMap.NameGroupHolder> nameGroupDelayRemoveMap
-
streamLock
protected edu.emory.mathcs.backport.java.util.concurrent.locks.WMSReadWriteLock streamLock
-
streamNamesLock
protected edu.emory.mathcs.backport.java.util.concurrent.locks.WMSReadWriteLock streamNamesLock
-
appInstance
protected IApplicationInstance appInstance
-
mediaStreamListeners
protected java.util.List<IMediaStreamNotify> mediaStreamListeners
-
nextStreamId
protected java.util.concurrent.atomic.AtomicLong nextStreamId
-
liveStreamPacketizers
protected java.util.Map<String,ILiveStreamPacketizer> liveStreamPacketizers
-
dvrRecorders
protected java.util.Map<String,ILiveStreamDvrRecorder> dvrRecorders
-
-
Constructor Detail
-
MediaStreamMap
public MediaStreamMap(IApplicationInstance appInstance)
Create empty MediaStreamMap collection- Parameters:
appInstance
- parent applicationInstance
-
-
Method Detail
-
getStreamListLock
public edu.emory.mathcs.backport.java.util.concurrent.locks.WMSReadWriteLock getStreamListLock()
Get the underlying read/write lock associated with the list of streams- Returns:
- underlying read/write lock associated with the list of streams
-
getStreamNameLock
public edu.emory.mathcs.backport.java.util.concurrent.locks.WMSReadWriteLock getStreamNameLock()
Get the underlying read/write lock associated with the stream names list- Returns:
- underlying read/write lock associated with the stream names list
-
getPublishStreamNames
public java.util.List<String> getPublishStreamNames()
Returns a List of published stream names- Returns:
- List of published stream names
-
getStreams
public java.util.List<IMediaStream> getStreams()
Returns a list of IMediaStream objects- Returns:
- list of IMediaStream objects
-
getStream
public IMediaStream getStream(IClient client, int index)
Get a media stream reference by stream id.- Parameters:
client
- clientindex
- stream id- Returns:
- media stream object or null if does not exist.
-
getStreamClientless
public IMediaStream getStreamClientless(int index, String streamTypeStr)
Get a media stream reference by stream id. If it does not exist, create a new one with the given id. This is a clientless stream that is served by the backend of the server. If creating a new media stream object, its id must first be obtained by callinggetNextStreamIndex()
.- Parameters:
index
- stream idstreamTypeStr
- stream type- Returns:
- media stream object
-
getStream
public IMediaStream getStream(IClient client, int index, boolean doCreate)
Get a media stream reference by stream id. If it does not exist, create a new one with the given id. If creating a new media stream object, its id must first be obtained by callinggetNextStreamIndex(IClient)
.- Parameters:
client
- clientindex
- stream iddoCreate
- true to create if it does not exist- Returns:
- media stream object
-
getStream
public IMediaStream getStream(INetConnection netConnection, int index)
Get a media stream object that is owned by a server to server netConnection object (not yet implemented).- Parameters:
netConnection
- netConnection to remote serverindex
- stream id- Returns:
- media stream object or null if does not exist
-
getStream
public IMediaStream getStream(INetConnection netConnection, int index, boolean doCreate)
Get a media stream reference by stream id. If it does not exist, create a new one with the given id. If creating a new media stream object, its id must first be obtained by callinggetNextStreamIndex(INetConnection)
.- Parameters:
netConnection
- netConnection to remote serverindex
- stream iddoCreate
- true to create if it does not exist- Returns:
- media stream object
-
getStream
public IMediaStream getStream(String name)
Get a media stream by stream name. Only published live streams are stored in the mediaStreamMap by name. This method is used to lookup a published live stream by name.- Parameters:
name
- stream name- Returns:
- media stream object or null if does not exist
-
setStreamName
public void setStreamName(IMediaStream stream, String name)
Insert live media stream into the mediaStreamMap by name.- Parameters:
stream
- mediea stream objectname
- media stream name
-
clearStreamName
public void clearStreamName(String name)
Unregister a published live media stream name.- Parameters:
name
- stream name
-
streamToIndex
public long streamToIndex(IMediaStream stream)
Get the unique stream identifier for a given stream- Parameters:
stream
- stream- Returns:
- unique stream identifier
-
clearStreamName
public void clearStreamName(String name, IMediaStream stream)
Unregister a published live media stream name.- Parameters:
name
- stream namestream
- stream
-
getNextStreamIndex
public int getNextStreamIndex(INetConnection netConnection)
Reserve a stream for a netConnection connection. UsegetStream(INetConnection, int, boolean)
to create stream.- Parameters:
netConnection
-- Returns:
- next stream index
-
getNextStreamIndex
public int getNextStreamIndex(IClient client)
Reserve a stream for a client connection. UsegetStream(IClient, int, boolean)
to create stream.- Parameters:
client
- parent client- Returns:
- stream index
-
getNextStreamIndex
public int getNextStreamIndex()
Reserve a clientless stream id for a new media stream. Use this method to obtain a stream id for a new media stream object that is then created with a call to getClientlessStream().- Returns:
- new reserved stream id
-
getCount
public int getCount()
Get the total number of streams stored in the mediaStreamMap- Returns:
- total number of streams stored in the mediaStreamMap
-
removeStream
public void removeStream(INetConnection netConnection, int index)
Remove a stream associated with a netConnection object- Parameters:
netConnection
- net connectionindex
- stream index
-
removeStream
public void removeStream(IClient client, int index)
Remove a stream associated with a client connection- Parameters:
client
- clientindex
- stream index
-
removeStream
public void removeStream(int index)
Remove a clientless media stream- Parameters:
index
- stream index
-
getAppName
public String getAppName()
Get the name of the parent application.- Returns:
- parent application name.
-
getAppInstanceName
public String getAppInstanceName()
Get the name of the parent applicationInstance.- Returns:
- parent applicationInstance name
-
getVHost
public IVHost getVHost()
Get the parent vHost.- Returns:
- parent vHost
-
getAppInstance
public IApplicationInstance getAppInstance()
Get the parent applicationInstance.- Returns:
- parent applicationInstance
-
notifyPlayUnpublish
public void notifyPlayUnpublish(IMediaStream stream)
Notify all play streams that are listening to this stream that the stream is going into a state of unpublished (NetStream.Play.UnpublishNotify).- Parameters:
stream
- live published stream that is being unpublished
-
notifyPlayUnpublish
public void notifyPlayUnpublish(String streamName)
Notify all play streams that are listening to this stream name that the stream is going into a state of unpublished (NetStream.Play.UnpublishNotify).- Parameters:
streamName
- live published stream that is being unpublished
-
broadcastGetObjectEncoding
public int broadcastGetObjectEncoding(IMediaStream stream)
Get the minimum object encoding level for the clients playing this stream.- Parameters:
stream
- publish stream- Returns:
- object encoding level (AMF0 or AMF3)
-
broadcasePlayMessage
public void broadcasePlayMessage(IMediaStream stream, long timecode, java.nio.ByteBuffer msg, int objectEncoding)
Send a broadcast message to all play stream that are listening to this live published stream.- Parameters:
stream
- media streamtimecode
- timecode (milliseconds)msg
- byte[] of data that will be deserialized as an AMFData object.objectEncoding
- object encoding (AMF0 or AMF3)
-
notifyPlayPublish
public void notifyPlayPublish(IMediaStream stream)
Notify all play streams that are listening to this stream that the stream is going into a state of publish (NetStream.Play.PublishNotify).- Parameters:
stream
- live published stream that is being published
-
addMediaStreamListener
public void addMediaStreamListener(IMediaStreamNotify mediaStreamListener)
Add a media stream listener. A media stream listener will receive the following events: onMediaStreamCreate, onMediaStreamDestroy.- Parameters:
mediaStreamListener
- media stream listener
-
removeMediaStreamListener
public void removeMediaStreamListener(IMediaStreamNotify mediaStreamListener)
Remove a media stream listener.- Parameters:
mediaStreamListener
- media stream listener
-
notifyMediaStreamCreate
public void notifyMediaStreamCreate(IMediaStream mediaStream)
Notify all media stream listeners that a new media stream object has been created.- Parameters:
mediaStream
- new media stream object
-
notifyMediaStreamDestroy
public void notifyMediaStreamDestroy(IMediaStream mediaStream)
Notify all media stream listeners that a media stream object is being destroyed.- Parameters:
mediaStream
- media stream object being destroyed
-
removeLiveStreamPacketizer
public void removeLiveStreamPacketizer(String streamName)
Remove all live stream packetizers for this stream name- Parameters:
streamName
- streamName
-
closeLiveStreamPacketizer
public void closeLiveStreamPacketizer(String streamName, String packetizerName)
Close live stream packetizer by sending the last data received- Parameters:
streamName
- stream name
-
removeLiveStreamPacketizer
public ILiveStreamPacketizer removeLiveStreamPacketizer(String streamName, String packetizerName)
Remove live stream packetizer- Parameters:
streamName
- stream namepacketizerName
- packetizer id- Returns:
- live stream packetizer
-
getLiveStreamPacketizerLock
public Object getLiveStreamPacketizerLock()
Get the lock to the live stream packetizer system- Returns:
- lock to the live stream packetizer system
-
getLiveStreamPacketizer
public ILiveStreamPacketizer getLiveStreamPacketizer(String streamName, String packetizerName, boolean doCreate)
Get a live stream packetizer by name and packetizer id- Parameters:
streamName
- stream namepacketizerName
- packetizer iddoCreate
- create if does not exist- Returns:
- live stream packetizer
-
getNextNameGroupId
public long getNextNameGroupId(com.wowza.wms.stream.MediaStreamMapGroup newGroup)
-
addNameGroup
public com.wowza.wms.stream.MediaStreamMapGroup addNameGroup(com.wowza.wms.stream.MediaStreamMapGroup newGroup)
-
removeNameGroup
public com.wowza.wms.stream.MediaStreamMapGroup removeNameGroup(int groupId)
-
removeNameGroup
public com.wowza.wms.stream.MediaStreamMapGroup removeNameGroup(com.wowza.wms.stream.MediaStreamMapGroup nameGroup)
-
getNameGroups
public java.util.Set<com.wowza.wms.stream.MediaStreamMapGroup> getNameGroups()
-
getNameGroupByGroupName
public com.wowza.wms.stream.MediaStreamMapGroup getNameGroupByGroupName(String groupName)
-
getNameGroups
public java.util.Set<com.wowza.wms.stream.MediaStreamMapGroup> getNameGroups(String streamName)
-
getNameGroupStreamNames
public java.util.Set<String> getNameGroupStreamNames(String streamName)
-
getDvrRecorder
public ILiveStreamDvrRecorder getDvrRecorder(String streamName, String recorderName, boolean doCreate)
Get a DVR recorder by name and recorder name- Parameters:
streamName
- stream namerecorderName
- packetizer iddoCreate
- create if does not exist- Returns:
- dvr recorder
-
removeDvrRecorder
public void removeDvrRecorder(String streamName)
-
removeDvrRecorder
public ILiveStreamDvrRecorder removeDvrRecorder(String streamName, String recorderName)
Remove DVR Recorder- Parameters:
streamName
- stream namerecorderName
- recorder name- Returns:
- DVR Recorder
-
getDvrRecorders
public java.util.List<ILiveStreamDvrRecorder> getDvrRecorders()
Returns a list of ILiveStreamDvrRecorder objects- Returns:
- list of ILiveStreamDvrRecorder objects
-
addLicense
public com.wowza.wms.client.LicenseHolder addLicense(IMediaStream stream, int licenseType)
-
addLicense
public com.wowza.wms.client.LicenseHolder addLicense(ILiveStreamPacketizer liveStreamPacketizer, int licenseType)
-
doWatchdog
public void doWatchdog()
-
getNameGroupRemoveDelayTime
public int getNameGroupRemoveDelayTime()
-
setNameGroupRemoveDelayTime
public void setNameGroupRemoveDelayTime(int nameGroupRemoveDelayTime)
-
-