Class MediaStreamMap


  • public class MediaStreamMap
    extends Object

    MediaStreamMap: collection of IMediaStream object. This collection is usually attached to an IApplicationInstance object.

    • Field Detail

      • 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
      • nextStreamId

        protected java.util.concurrent.atomic.AtomicLong nextStreamId
    • 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 - client
        index - 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 calling getNextStreamIndex() .
        Parameters:
        index - stream id
        streamTypeStr - 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 calling getNextStreamIndex(IClient).
        Parameters:
        client - client
        index - stream id
        doCreate - 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 server
        index - 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 calling getNextStreamIndex(INetConnection) .
        Parameters:
        netConnection - netConnection to remote server
        index - stream id
        doCreate - 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 object
        name - 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 name
        stream - stream
      • getNextStreamIndex

        public int getNextStreamIndex​(IClient client)
        Reserve a stream for a client connection. Use getStream(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 connection
        index - stream index
      • removeStream

        public void removeStream​(IClient client,
                                 int index)
        Remove a stream associated with a client connection
        Parameters:
        client - client
        index - 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 stream
        timecode - 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 name
        packetizerName - 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 name
        packetizerName - packetizer id
        doCreate - 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 name
        recorderName - packetizer id
        doCreate - 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 name
        recorderName - 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)