Package io.antmedia.streamsource
Class StreamFetcherManager
java.lang.Object
io.antmedia.streamsource.StreamFetcherManager
Organizes and checks stream fetcher and restarts them if it is required
- Author:
- davut
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AppSettingsprivate DataStoreprotected AtomicBooleanprivate intprivate ILicenceServiceprotected static org.slf4j.Loggerprivate booleanprivate IScopeprivate ServerSettings(package private) booleanprivate intprivate intTime period in milli seconds for checking stream fetchers status, restart issues etc.private Map<String,StreamFetcher> private longprivate io.vertx.core.Vertxprivate int -
Constructor Summary
ConstructorsConstructorDescriptionStreamFetcherManager(io.vertx.core.Vertx vertx, DataStore datastore, IScope scope) -
Method Summary
Modifier and TypeMethodDescriptionstatic ResultvoidcontrolStreamFetchers(boolean restart) createAndStartNextPlaylistItem(Broadcast playlistBroadcast, StreamFetcher.IStreamFetcherListener listener, int currentStreamIndex) intintgetStreamFetcher(String streamId) intbooleanbooleanisStreamRunning(Broadcast broadcast) booleanisToBeStoppedAutomatically(Broadcast broadcast) 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.private voidvoidsetDatastore(DataStore datastore) voidsetRestartStreamAutomatically(boolean restartStreamAutomatically) voidsetStreamCheckerCount(int streamCheckerCount) voidsetStreamFetcherList(Map<String, StreamFetcher> streamFetcherList) voidsetWaitForTestMilliseconds(int waitForTestMilliseconds) voidskipNextPlaylistQueue(Broadcast playlist, int index) Skips the next item or set to first item in the list.startPlaylist(Broadcast playlist) startStreaming(Broadcast broadcast) startStreaming(Broadcast broadcast, boolean forceStart) startStreamScheduler(StreamFetcher streamScheduler) voidstopPlayList(String streamId) stopStreaming(String streamId, boolean stopBlocking) Stop streaming for the streamId.voidtestSetStreamCheckerInterval(int streamCheckerInterval) Set stream checker interval, this value is used in periodically checking the status of the stream fetchersprivate booleanwaitForTest(int milliseconds)
-
Field Details
-
logger
protected static org.slf4j.Logger logger -
streamCheckerCount
private int streamCheckerCount -
streamFetcherList
-
streamCheckerIntervalMs
private int streamCheckerIntervalMsTime 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 withAntMediaApplicationAdapter#isStreaming(Broadcast) -
datastore
-
scope
-
streamFetcherScheduleJobName
private long streamFetcherScheduleJobName -
isJobRunning
-
restartStreamAutomatically
private boolean restartStreamAutomatically -
vertx
private io.vertx.core.Vertx vertx -
lastRestartCount
private int lastRestartCount -
appSettings
-
licenseService
-
serverShuttingDown
boolean serverShuttingDown -
serverSettings
-
waitForTestMilliseconds
private int waitForTestMilliseconds
-
-
Constructor Details
-
StreamFetcherManager
-
-
Method Details
-
setWaitForTestMilliseconds
public void setWaitForTestMilliseconds(int waitForTestMilliseconds) -
getWaitForTestMilliseconds
public int getWaitForTestMilliseconds() -
shuttingDown
public void shuttingDown() -
make
-
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
-
startStreamScheduler
-
startStreaming
-
startStreaming
-
stopStreaming
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
-
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
-
skipNextPlaylistQueue
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
-
controlStreamFetchers
public void controlStreamFetchers(boolean restart) -
getDatastore
-
setDatastore
-
getStreamFetcherList
-
getStreamFetcher
-
setStreamFetcherList
-
isRestartStreamAutomatically
public boolean isRestartStreamAutomatically() -
setRestartStreamAutomatically
public void setRestartStreamAutomatically(boolean restartStreamAutomatically) -
getStreamCheckerCount
public int getStreamCheckerCount() -
setStreamCheckerCount
public void setStreamCheckerCount(int streamCheckerCount) -
stopPlayList
-