Class StreamFetcherManager

java.lang.Object
io.antmedia.streamsource.StreamFetcherManager

public class StreamFetcherManager extends Object
Organizes and checks stream fetcher and restarts them if it is required
Author:
davut
  • Field Details

    • logger

      protected static org.slf4j.Logger logger
    • streamCheckerCount

      private int streamCheckerCount
    • streamFetcherList

      private Map<String,StreamFetcher> streamFetcherList
    • streamCheckerIntervalMs

      private int streamCheckerIntervalMs
      Time period in milli seconds for checking stream fetchers status, restart issues etc. It's the same value with MuxAdaptor.STAT_UPDATE_PERIOD_MS because it updates the database record and let us understand if stream is alive with AntMediaApplicationAdapter#isStreaming(Broadcast)
    • datastore

      private DataStore datastore
    • scope

      private IScope scope
    • streamFetcherScheduleJobName

      private long streamFetcherScheduleJobName
    • isJobRunning

      protected AtomicBoolean isJobRunning
    • restartStreamAutomatically

      private boolean restartStreamAutomatically
    • vertx

      private io.vertx.core.Vertx vertx
    • lastRestartCount

      private int lastRestartCount
    • appSettings

      private AppSettings appSettings
    • licenseService

      private ILicenceService licenseService
    • serverShuttingDown

      boolean serverShuttingDown
    • serverSettings

      private ServerSettings serverSettings
    • waitForTestMilliseconds

      private int waitForTestMilliseconds
  • Constructor Details

    • StreamFetcherManager

      public StreamFetcherManager(io.vertx.core.Vertx vertx, DataStore datastore, IScope scope)
  • Method Details

    • setWaitForTestMilliseconds

      public void setWaitForTestMilliseconds(int waitForTestMilliseconds)
    • getWaitForTestMilliseconds

      public int getWaitForTestMilliseconds()
    • shuttingDown

      public void shuttingDown()
    • make

      public StreamFetcher make(Broadcast stream, IScope scope, io.vertx.core.Vertx vertx)
    • getStreamCheckerInterval

      public int getStreamCheckerInterval()
    • testSetStreamCheckerInterval

      public void testSetStreamCheckerInterval(int streamCheckerInterval)
      Set stream checker interval, this value is used in periodically checking the status of the stream fetchers
      Parameters:
      streamCheckerInterval - , time period of the stream fetcher check interval in milliseconds
    • isStreamRunning

      public boolean isStreamRunning(Broadcast broadcast)
    • startStreamScheduler

      public Result startStreamScheduler(StreamFetcher streamScheduler)
    • startStreaming

      public Result startStreaming(@Nonnull Broadcast broadcast)
    • startStreaming

      public Result startStreaming(@Nonnull Broadcast broadcast, boolean forceStart)
    • stopStreaming

      public Result stopStreaming(String streamId, boolean stopBlocking)
      Stop streaming for the streamId. If stopBlocking is true, it will wait until the stream is stopped and return the result. Otherwise, it will call stopStream and return immediately with success true. Pay attention that stopStreaming and playItemInList are synchronized because they can be called at the same time for the same streamId and it can cause a problem if they are not synchronized. We are testing this behavior with a test case that reproduces the problem on StreamFetcherUnitTest#testPlayListSynch
      Parameters:
      streamId -
      stopBlocking -
      Returns:
    • stopCheckerJob

      public void stopCheckerJob()
    • checkStreamUrlWithHTTP

      public static Result checkStreamUrlWithHTTP(String url)
    • createAndStartNextPlaylistItem

      public Result createAndStartNextPlaylistItem(Broadcast playlistBroadcast, StreamFetcher.IStreamFetcherListener listener, int currentStreamIndex)
    • waitForTest

      private boolean waitForTest(int milliseconds)
    • playItemInList

      public Result playItemInList(String streamId, StreamFetcher.IStreamFetcherListener listener, int index)
      Plays the next item in the playlist if index is -1, otherwise it plays the item in the index. It checks the stream url with http before playing and if it's not valid, it tries to play the next item. If there is no item to play, it will set playlist status to finished. Pay attention that stopStreaming and playItemInList are synchronized because they can be called at the same time for the same streamId and it can cause a problem if they are not synchronized. We are testing this behavior with a test case that reproduces the problem on StreamFetcherUnitTest#testPlayListSynch
      Parameters:
      streamId -
      listener -
      index - if it's -1, it plays the next item, if it's zero or bigger, it skips that item to play
    • startPlaylist

      public Result startPlaylist(Broadcast playlist)
    • skipNextPlaylistQueue

      public Broadcast skipNextPlaylistQueue(Broadcast playlist, int index)
      Skips the next item or set to first item in the list. If the looping is disabled, it will not set to first item and return nul
      Parameters:
      playlist -
      index - : if it's -1, plays the next item, otherwise it plays the item that is in the index
      Returns:
      Broadcast object for the next item. If it's not looping, it will return null
    • scheduleStreamFetcherJob

      private void scheduleStreamFetcherJob()
    • isToBeStoppedAutomatically

      public boolean isToBeStoppedAutomatically(Broadcast broadcast)
    • controlStreamFetchers

      public void controlStreamFetchers(boolean restart)
    • getDatastore

      public DataStore getDatastore()
    • setDatastore

      public void setDatastore(DataStore datastore)
    • getStreamFetcherList

      public Map<String,StreamFetcher> getStreamFetcherList()
    • getStreamFetcher

      public StreamFetcher getStreamFetcher(String streamId)
    • setStreamFetcherList

      public void setStreamFetcherList(Map<String,StreamFetcher> streamFetcherList)
    • isRestartStreamAutomatically

      public boolean isRestartStreamAutomatically()
    • setRestartStreamAutomatically

      public void setRestartStreamAutomatically(boolean restartStreamAutomatically)
    • getStreamCheckerCount

      public int getStreamCheckerCount()
    • setStreamCheckerCount

      public void setStreamCheckerCount(int streamCheckerCount)
    • stopPlayList

      public Result stopPlayList(String streamId)