Package io.antmedia
Class AntMediaApplicationAdapter
java.lang.Object
org.red5.server.adapter.AbstractScopeAdapter
org.red5.server.adapter.StatefulScopeWrappingAdapter
org.red5.server.adapter.MultiThreadedApplicationAdapter
io.antmedia.AntMediaApplicationAdapter
- All Implemented Interfaces:
IAntMediaStreamHandler,IShutdownListener,IEventHandler,IAttributeStore,ISchedulingService,IScopeAware,IScopeHandler,IScopeService,IBroadcastStreamService,IOnDemandStreamService,IStreamSecurityService,ISubscriberStreamService,IStreamAwareScopeHandler,ApplicationMXBean,AttributeStoreMXBean
public class AntMediaApplicationAdapter
extends MultiThreadedApplicationAdapter
implements IAntMediaStreamHandler, IShutdownListener
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AppSettingsstatic final Stringstatic final intstatic final intstatic final intprivate IClusterNotifier(package private) IClusterStreamFetcherprivate DataStoreprivate DataStoreFactorystatic final Stringprotected static final intstatic final Stringstatic final Stringstatic final Stringstatic final StringThis is used to notify that the first active subtrack is created in the main track In video conferencing, it means the first stream is started in the roomstatic final StringThis is used to notify that there is no active subtracks left in the main track.static final StringThis is used to notify that the play is startedstatic final StringThis is used to notify that the play is stoppedstatic final Stringstatic final Stringstatic final Stringstatic final StringThis is used to notify that the subtrack is created in the main track In video conferencing, it means a stream is started in the roomstatic final StringThis is used to notify that the subtrack left the main track In video conferencing, it means a stream left the roomstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static org.slf4j.Loggerprotected Map<String,MuxAdaptor> private intprivate Map<String,OnvifCamera> static final Stringprotected intprivate Randomprivate Map<String,RTMPClusterStreamFetcher> private ServerSettingsprotected booleanprivate Set<IAppSettingsUpdateListener>private booleanprivate IStatsCollectorprotected StorageClientstatic final Stringstatic final intTimeout value that stream is considered as finished or stuckprivate StreamAcceptFilterprotected StreamFetcherManagerprotected Queue<IStreamListener>private List<IStreamPlaybackSecurity>private List<IStreamPublishSecurity>static final Stringprotected ISubtrackPollerprivate io.vertx.core.Vertxstatic final Stringprivate static final Stringprotected WebRTCAudioReceiveStatsprotected WebRTCAudioSendStatsprotected WebRTCVideoReceiveStatsprotected WebRTCVideoSendStatsFields inherited from class org.red5.server.adapter.MultiThreadedApplicationAdapter
log, schedulingServiceFields inherited from class org.red5.server.adapter.StatefulScopeWrappingAdapter
plugins, scopeFields inherited from interface io.antmedia.muxer.IAntMediaStreamHandler
BROADCAST_STATUS_BROADCASTING, BROADCAST_STATUS_CREATED, BROADCAST_STATUS_ERROR, BROADCAST_STATUS_FAILED, BROADCAST_STATUS_FINISHED, BROADCAST_STATUS_PREPARING, BROADCAST_STATUS_TERMINATED_UNEXPECTEDLY, DEFAULT_USER_ROLE, PUBLISH_TYPE_PULL, PUBLISH_TYPE_RTMP, PUBLISH_TYPE_SRT, PUBLISH_TYPE_WEBRTC, VERTX_BEAN_NAME, WEBAPPS_PATHFields inherited from interface org.red5.server.api.service.IBroadcastStreamService
BROADCAST_STREAM_SERVICE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFrameListener(String streamId, IFrameListener listener) Add listener to get raw audio or video frames from the internal of Ant Media Server.booleanaddPacketListener(String streamId, IPacketListener listener) Add listener to get audio and video packets from the internal of Ant Media Server.voidAdd listener that is notified when the settings are updatedvoidaddStreamListener(IStreamListener listener) Add a stream listener to get notified when a new stream is started or finished.booleanCalled once on scope (that is, application or application room) start.voidHandler method.booleancallClusterRestMethod(String url, String clusterCommunicationToken, byte[] data) voidcancelPlaylistSchedule(String streamId) voidThis method is used to close the broadcast streamvoidcloseDB(boolean deleteDB) voidvoidcreateCustomBroadcast(String streamId) Create another broadcast.createCustomBroadcast(String streamId, int height, int bitrate) Create another broadcast.private voidcreateIdleCheckTimer(Broadcast broadcast, boolean isMainTrack) voidcreateInitializationFile(String appName, Result result, File initializedFile) createInitializationProcess(String appName) voidcreateShutdownFile(String appName) private ResultcreateSymbolicLink(File streamsFolder, File vodFolder) static BroadcastcreateZombiBroadcast(String streamId, String streamName, String streamStatus, String publishType, String mainTrackStreamId, String metaData, String role) private booleandeleteSymbolicLink(File vodDirectory, File streamsFolder) Deletes the symbolic link under the streams directoryprivate intdeleteUserVoDByStreamId(String streamId) booleandoesWebRTCStreamExist(String streamId) voidencoderBlocked(String streamId, boolean blocked) voidendpointFailedUpdate(String streamId, String url) booleanfetchRtmpFromOriginIfExist(String streamId) voidforwardStartStreaming(Broadcast broadcast) private intGet the AppSettings of the applicationGet data channel router for data channel deliveryGet the DataStore of the applicationgetFreshBroadcastUpdateForStatus(String publishType, String status) It creates a broadcast update object for a broadcast that is about to startorg.apache.http.impl.client.CloseableHttpClientgetListenerHookURL(Broadcast broadcast) getMuxAdaptor(String streamId) Get the MuxAdaptor of the stream.intintNumber of encoders blocked.intgetOnvifCamera(String id) static StringgetRelativePath(String filePath) io.vertx.core.VertxgetVertx()intimportToDB(File subDirectory, File baseDirectory) importVoDFolder(String vodFolderPath) Import vod files recursively in the directory.voidincrementEncoderNotOpenedError(String streamId) booleanisBroadcastOnThisServer(Broadcast broadcast) booleanbooleanbooleanprivate booleanisEncoderSettingsValid(List<EncoderSettings> encoderSettingsList) static booleanisEndpointReachable(String endpoint) booleanisIncomingSettingsDifferent(AppSettings newSettings) static booleanisInstanceAlive(String originAdress, String hostAddress, int httpPort, String appName) booleanbooleanstatic final booleanisStreaming(String status) Important information: Status field of Broadcast class checks the update time to report the status is broadcasting or not.static booleanisSubscriberBlocked(DataStore dataStore, String streamId, String subscriberId, String type) static booleanisSubscriberIdMatching(String subscriberId, String subscriberIdParameter) private booleanisTokenSecuritySettingsValid(AppSettings newSettings) booleanisValidStreamParameters(int width, int height, int fps, int bitrate, String streamId) Checks a Stream parameters is valid.voidjoinedTheRoom(String roomId, String streamId) voidleftTheRoom(String mainTrackId, String subtrackId) private voidlogPublishStartedEvent(String streamId, String publishType, String subscriberId) voidmuxAdaptorAdded(MuxAdaptor muxAdaptor) Adds a MuxAdaptor when a muxAdaptor is createdvoidmuxAdaptorRemoved(MuxAdaptor muxAdaptor) Removes a MuxAdaptor when a muxAdaptor is closingResourcesvoidmuxingFinished(Broadcast broadcast, String streamId, File file, long startTime, long duration, int resolution, String previewFilePath, String vodId) Called by some muxer like MP4Muxer id actually is the name of the file however in some cases file name and the id may be different in some cases like there is already a file with that nameprivate voidnotifyBroadcastIdleTimeExpired(Broadcast broadcast) voidnotifyFirstActiveSubtrackInMainTrack(Broadcast mainTrack, String subtrackId) voidnotifyHook(@NotNull String url, String id, String mainTrackId, String action, String streamName, String category, String vodName, String vodId, String metadata, String subscriberId, Map<String, String> parameters) Notify hook with parameters belowvoidnotifyLiveStreamEnded(Broadcast broadcast, String subscriberId) voidnotifyNoActiveSubtracksLeftInMainTrack(Broadcast mainTrack) voidnotifyPublishStarted(String streamId, String role, String mainTrackId) This method is called to notify the local node and cluster nodes when a stream is startedvoidnotifyPublishStopped(String streamId, String role, String mainTrackId) voidnotifySettingsUpdateListeners(AppSettings appSettings) voidnotifyWebhookForStreamStatus(Broadcast broadcast, int width, int height, long totalByteReceived, int inputQueueSize, int encodingQueueSize, int dropFrameCountInEncoding, int dropPacketCountInIngestion, double speed) Notify the webhook about the stream statusbooleanpublishStarted(String streamId, String role, String mainTrackId) This is a callback-method and called when a stream is fully started and it means it is called post publish operations has finished It can be called from the cluster side or from the local side to synch subtracksbooleanpublishStopped(String streamId, String role, String mainTrackId) This method is called when a stream is fully stopped and it means it is called post publish operations has finished It can be called from the cluster side or from the local side to synch subtracksvoidpublishTimeoutError(String streamId, String subscriberId) private voidvoidregisterSubscriberToNode(String streamId, String subscriberId, String subscriberName) voidremoveFrameListener(String streamId, IFrameListener listener) Remove frame listener from the Stream Handler to stop getting notifiedbooleanremovePacketListener(String streamId, IPacketListener listener) Remove listener from the Stream Handler to stop getting notifiedvoidremoveStreamListener(IStreamListener listener) Remove a stream listener from the Stream Handler to stop getting notifiedThis method is called after ungraceful shutdownvoidresetDASHStats(String streamId) voidresetHLSStats(String streamId) voidretrySendPostWithDelay(String url, Map<String, Object> variables, int retryAttempts, String contentType) private voidrunConfiguredScript(String configuredScript, String... args) private voidrunStreamEndedScript(Broadcast broadcast) static BroadcastsaveBroadcast(Broadcast broadcast, AntMediaApplicationAdapter appAdapter) static BroadcastsaveMainBroadcast(String streamId, String mainTrackId, DataStore dataStore) static BroadcastsaveUndefinedBroadcast(String streamId, String streamName, AntMediaApplicationAdapter appAdapter, String streamStatus, long absoluteStartTimeMs, String publishType, String mainTrackStreamId, String metaData, String role) voidschedulePlayList(long now, Broadcast broadcast) booleansendClusterPost(String url, String clusterCommunicationToken, byte[] data) booleansendDataChannelMessage(String streamId, String message) voidvoidsendWebHook(String id, String mainTrackId, String action, String streamName, String category, String vodName, String vodId, String metadata, String subscriberId, Map<String, String> parameters) voidvoidsetAppSettings(AppSettings appSettings) static booleansetAppSettingsFieldValue(AppSettings appSettings, AppSettings newSettings, Field field) voidsetClusterNotifier(IClusterNotifier clusterNotifier) voidsetDataStore(DataStore dataStore) voidsetDataStoreFactory(DataStoreFactory dataStoreFactory) voidsetQualityParameters(String streamId, PublishStatsEvent stats, long currentTimeMillis) Sets quality parameters for the given stream ID.voidsetServerSettings(ServerSettings serverSettings) voidsetShutdownProperly(boolean shutdownProperly) voidsetStatsCollector(IStatsCollector statsCollector) voidsetStorageClient(StorageClient storageClient) voidsetStorageclientSettings(AppSettings settings) voidsetStreamAcceptFilter(StreamAcceptFilter streamAcceptFilter) voidsetStreamFetcherManager(StreamFetcherManager streamFetcherManager) voidsetStreamPlaySecurityList(List<IStreamPlaybackSecurity> streamPlaySecurityList) voidsetStreamPublishSecurityList(List<IStreamPublishSecurity> streamPublishSecurityList) voidsetSubtrackPoller(ISubtrackPoller subtrackPoller) voidsetVertx(io.vertx.core.Vertx vertx) This setter for test casesstartHttpSignaling(PublishParameters publishParameters, String sdp, String sessionId) voidstartPublish(String streamId, long absoluteStartTimeMs, String publishType, String subscriberId, Map<String, String> parameters) Notify the handler that stream is started to publishstartStreaming(Broadcast broadcast) voidstopApplication(boolean deleteDB) voidstopCustomBroadcast(String streamId) Stop the custom broadcast that is being created.booleanstopPlayingBySubscriberId(String subscriberId, String streamId) voidstopPublish(String streamId, String subscriberId) Notify the handler that is stream is stoppedvoidNotify the handler that is stream is stoppedbooleanstopPublishingBySubscriberId(String subscriberId, String streamId) stopStreaming(Broadcast broadcast, boolean stopSubtracks, String subscriberId) stopWhipBroadcast(String streamId, String sessionId) voidstreamPlayItemPlay(ISubscriberStream stream, IPlayItem item, boolean isLive) Notified when a play item plays.voidstreamPlayItemStop(ISubscriberStream stream, IPlayItem item) Notified when a play item stops.voidNotified when a subscriber closes.voidtrySendClusterPostWithDelay(String url, String clusterCommunicationToken, int retryAttempts, CompletableFuture<Boolean> future, byte[] data) unlinksVoD(String directory) voidupdateAppSettingsBean(AppSettings appSettings, AppSettings newSettings, boolean updateTime) static booleanupdateAppSettingsFile(String appName, AppSettings newAppsettings) updateBroadcastStatus(String streamId, long absoluteStartTimeMs, String publishType, Broadcast broadcast) Update broadcast status to BROADCASTINGupdateBroadcastStatus(String streamId, long absoluteStartTimeMs, String publishType, Broadcast broadcast, BroadcastUpdate broadcastUpdate, String status) voidupdateMainTrackWithRecentlyFinishedBroadcast(Broadcast finishedBroadcast) If multiple threads enter the method at the same time, the following method does not work correctly.booleanupdateSettings(AppSettings newSettings, boolean notifyCluster, boolean checkUpdateTime) voidvoidMethods inherited from class org.red5.server.adapter.MultiThreadedApplicationAdapter
addListener, addScheduledJob, addScheduledJobAfterDelay, addScheduledOnceJob, addScheduledOnceJob, appConnect, appDisconnect, appJoin, appLeave, connect, connect, disconnect, FCPublish, FCSubscribe, FCUnpublish, FCUnpublish, getBroadcastStream, getBroadcastStreamNames, getClientTTL, getGhostConnsCleanupPeriod, getListeners, getOnDemandStream, getScheduledJobNames, getStreamLength, getStreamPlaybackSecurity, getStreamPublishSecurity, getSubscriberStream, handleEvent, hasBroadcastStream, hasOnDemandStream, join, leave, measureBandwidth, measureBandwidth, pauseScheduledJob, registerStreamPlaybackSecurity, registerStreamPublishSecurity, rejectClient, rejectClient, removeListener, removeScheduledJob, resumeScheduledJob, roomConnect, roomDisconnect, roomJoin, roomLeave, roomStart, roomStop, setClientTTL, setGhostConnsCleanupPeriod, start, startTransmit, stop, stopTransmit, stopTransmit, streamBroadcastClose, streamBroadcastStart, streamPlayItemPause, streamPlayItemResume, streamPlayItemSeek, streamPublishStart, streamRecordStart, streamRecordStop, streamSubscriberStart, unregisterStreamPlaybackSecurity, unregisterStreamPublishSecurityMethods inherited from class org.red5.server.adapter.StatefulScopeWrappingAdapter
createChildScope, getAttribute, getAttribute, getAttributeNames, getAttributes, getChildScope, getChildScopeNames, getClients, getConnections, getContext, getDepth, getName, getParent, getPath, getPlugins, getResource, getResources, getScope, hasAttribute, hasChildScope, hasParent, lookupConnections, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes, setPlugins, setScope, sizeMethods inherited from class org.red5.server.adapter.AbstractScopeAdapter
addChildScope, checkBandwidth, checkBandwidthUp, removeChildScope, serviceCall, setCanCallService, setCanConnect, setCanStart, setJoinMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.antmedia.muxer.IAntMediaStreamHandler
getScopeMethods inherited from interface org.red5.server.api.scope.IScopeHandler
addChildScope, removeChildScope, serviceCall
-
Field Details
-
STREAM_TIMEOUT_MS
public static final int STREAM_TIMEOUT_MSTimeout value that stream is considered as finished or stuck- See Also:
-
BEAN_NAME
- See Also:
-
BROADCAST_STATS_RESET
public static final int BROADCAST_STATS_RESET- See Also:
-
HOOK_ACTION_END_LIVE_STREAM
- See Also:
-
HOOK_ACTION_START_LIVE_STREAM
- See Also:
-
HOOK_ACTION_STREAM_STATUS
- See Also:
-
HOOK_ACTION_VOD_READY
- See Also:
-
HOOK_ACTION_PUBLISH_TIMEOUT_ERROR
- See Also:
-
HOOK_ACTION_ENCODER_NOT_OPENED_ERROR
- See Also:
-
HOOK_ACTION_ENDPOINT_FAILED
- See Also:
-
HOOK_IDLE_TIME_EXPIRED
- See Also:
-
HOOK_ACTION_PLAY_STOPPED
This is used to notify that the play is stopped- See Also:
-
HOOK_ACTION_PLAY_STARTED
This is used to notify that the play is started- See Also:
-
HOOK_ACTION_SUBTRACK_ADDED_IN_THE_MAINTRACK
This is used to notify that the subtrack is created in the main track In video conferencing, it means a stream is started in the room- See Also:
-
HOOK_ACTION_SUBTRACK_LEFT_FROM_THE_MAINTRACK
This is used to notify that the subtrack left the main track In video conferencing, it means a stream left the room- See Also:
-
HOOK_ACTION_FIRST_ACTIVE_SUBTRACK_ADDED_IN_THE_MAINTRACK
This is used to notify that the first active subtrack is created in the main track In video conferencing, it means the first stream is started in the room- See Also:
-
HOOK_ACTION_NO_ACTIVE_SUBTRACKS_LEFT_IN_THE_MAINTRACK
This is used to notify that there is no active subtracks left in the main track. In video conferencing, it means there is no active stream left in the room- See Also:
-
STREAMS
- See Also:
-
DEFAULT_LOCALHOST
- See Also:
-
logger
protected static org.slf4j.Logger logger -
serverSettings
-
VOD
- See Also:
-
LIVE_STREAM
- See Also:
-
IP_CAMERA
- See Also:
-
STREAM_SOURCE
- See Also:
-
PLAY_LIST
- See Also:
-
END_POINT_LIMIT
protected static final int END_POINT_LIMIT- See Also:
-
CLUSTER_POST_RETRY_ATTEMPT_COUNT
public static final int CLUSTER_POST_RETRY_ATTEMPT_COUNT- See Also:
-
CLUSTER_POST_TIMEOUT_MS
public static final int CLUSTER_POST_TIMEOUT_MS- See Also:
-
VOD_IMPORT_ALLOWED_DIRECTORY
- See Also:
-
streamPublishSecurityList
-
streamPlaySecurityList
-
onvifCameraList
-
streamFetcherManager
-
muxAdaptors
-
dataStore
-
dataStoreFactory
-
streamAcceptFilter
-
appSettings
-
vertx
private io.vertx.core.Vertx vertx -
encoderBlockedStreams
-
numberOfEncoderNotOpenedErrors
private int numberOfEncoderNotOpenedErrors -
publishTimeoutStreams
protected int publishTimeoutStreams -
publishTimeoutStreamsList
-
shutdownProperly
private boolean shutdownProperly -
webRTCVideoReceiveStats
-
webRTCAudioReceiveStats
-
webRTCVideoSendStats
-
webRTCAudioSendStats
-
clusterNotifier
-
serverShuttingDown
protected boolean serverShuttingDown -
storageClient
-
streamListeners
-
playListSchedulerTimer
-
clusterStreamFetcher
IClusterStreamFetcher clusterStreamFetcher -
subtrackPoller
-
random
-
statsCollector
-
settingsUpdateListenerSet
-
rtmpClusterStreamFetcherMap
-
mainTrackUpdateLocks
-
-
Constructor Details
-
AntMediaApplicationAdapter
public AntMediaApplicationAdapter()
-
-
Method Details
-
appStart
Description copied from class:MultiThreadedApplicationAdapterCalled once on scope (that is, application or application room) start. You overrideMultiThreadedApplicationAdapter.appStart(IScope)orMultiThreadedApplicationAdapter.roomStart(IScope)in your application to make it act the way you want.- Specified by:
appStartin interfaceApplicationMXBean- Overrides:
appStartin classMultiThreadedApplicationAdapter- Parameters:
app- Application scope object- Returns:
trueif scope can be started,falseotherwise
-
schedulePlayList
-
cancelPlaylistSchedule
-
resetBroadcasts
This method is called after ungraceful shutdown- Returns:
-
createSymbolicLink
-
importVoDFolder
Import vod files recursively in the directory. It also created symbolic link to make the files streamable- Parameters:
vodFolderPath- absolute path of the vod folder to be imported- Returns:
-
unlinksVoD
-
deleteUserVoDByStreamId
-
importToDB
-
deleteSymbolicLink
Deletes the symbolic link under the streams directory- Parameters:
vodDirectory-streamsFolder-- Returns:
- Throws:
IOException
-
getListenerHookURL
-
notifyLiveStreamEnded
-
closeBroadcast
This method is used to close the broadcast stream- Parameters:
streamId-subscriberId-parameters-
-
runStreamEndedScript
-
saveMainBroadcast
-
isInstanceAlive
-
isEndpointReachable
-
updateMainTrackWithRecentlyFinishedBroadcast
If multiple threads enter the method at the same time, the following method does not work correctly. So we had made it synchronized, then changed it. We make it synchronized for the same main track (room) IDs. Otherwise, one room was waiting for the others. It fixes the bug that sometimes main track(room) is not deleted in the video conferences mekya- Parameters:
finishedBroadcast-
-
resetHLSStats
-
resetDASHStats
-
streamPlayItemPlay
Description copied from interface:IStreamAwareScopeHandlerNotified when a play item plays.- Specified by:
streamPlayItemPlayin interfaceIStreamAwareScopeHandler- Overrides:
streamPlayItemPlayin classMultiThreadedApplicationAdapter- Parameters:
stream- streamitem- itemisLive- true if live
-
streamPlayItemStop
Description copied from interface:IStreamAwareScopeHandlerNotified when a play item stops.- Specified by:
streamPlayItemStopin interfaceIStreamAwareScopeHandler- Overrides:
streamPlayItemStopin classMultiThreadedApplicationAdapter- Parameters:
stream- streamitem- item
-
streamSubscriberClose
Description copied from interface:IStreamAwareScopeHandlerNotified when a subscriber closes.- Specified by:
streamSubscriberClosein interfaceIStreamAwareScopeHandler- Overrides:
streamSubscriberClosein classMultiThreadedApplicationAdapter- Parameters:
stream- stream
-
startPublish
public void startPublish(String streamId, long absoluteStartTimeMs, String publishType, String subscriberId, Map<String, String> parameters) Description copied from interface:IAntMediaStreamHandlerNotify the handler that stream is started to publish- Specified by:
startPublishin interfaceIAntMediaStreamHandlersubscriberId- : It's the id of the subscriber. It can be null if it's not available.
-
logPublishStartedEvent
-
updateBroadcastStatus
public Broadcast updateBroadcastStatus(String streamId, long absoluteStartTimeMs, String publishType, Broadcast broadcast) Description copied from interface:IAntMediaStreamHandlerUpdate broadcast status to BROADCASTING- Specified by:
updateBroadcastStatusin interfaceIAntMediaStreamHandler- Parameters:
streamId- is the id of the stream.absoluteStartTimeMs- : It's the absolute start time if availablepublishType- : It's RTMP, WebRTC, StreamSourcebroadcast- : It's the broadcast object. If it's null, a new record will be created- Returns:
- broadcast object from database
-
isBroadcastOnThisServer
-
updateBroadcastStatus
public Broadcast updateBroadcastStatus(String streamId, long absoluteStartTimeMs, String publishType, Broadcast broadcast, BroadcastUpdate broadcastUpdate, String status) - Parameters:
streamId-absoluteStartTimeMs-publishType-broadcast- : if it's null, it will be createdbroadcastUpdate- : if it's null, it will be created with getBroadcastUpdateForStatus(publishType, status). It's used to update some specific fieldsstatus- :- Returns:
-
getFreshBroadcastUpdateForStatus
It creates a broadcast update object for a broadcast that is about to start- Parameters:
publishType-status-- Returns:
-
getServerSettings
-
createZombiBroadcast
-
saveUndefinedBroadcast
-
saveBroadcast
-
muxingFinished
public void muxingFinished(Broadcast broadcast, String streamId, File file, long startTime, long duration, int resolution, String previewFilePath, String vodId) Description copied from interface:IAntMediaStreamHandlerCalled by some muxer like MP4Muxer id actually is the name of the file however in some cases file name and the id may be different in some cases like there is already a file with that name- Specified by:
muxingFinishedin interfaceIAntMediaStreamHandler- Parameters:
broadcast- object that muxed is finishedstreamId- is the id of the streamfile- video file that muxed is finishedduration- of the video in millisecondsresolution- height of the videopreviewFilePath- path of the preview file
-
notifyFirstActiveSubtrackInMainTrack
-
notifyNoActiveSubtracksLeftInMainTrack
-
runConfiguredScript
-
getRelativePath
-
sendWebHook
-
notifyHook
public void notifyHook(@NotNull @NotNull String url, String id, String mainTrackId, String action, String streamName, String category, String vodName, String vodId, String metadata, String subscriberId, Map<String, String> parameters) Notify hook with parameters below- Parameters:
streamName- , name of the stream. It is not the name of the file. It is just a user friendly namecategory- , category of the streamurl- is the url of the service to be calledid- is the stream id that is unique for each streammainTrackId- mainTrackId(roomId) of the streamaction- is the name of the action to be notified, it has values such asHOOK_ACTION_END_LIVE_STREAMHOOK_ACTION_START_LIVE_STREAMvodName- name of the vodvodId- id of the vod in the datastoreparameters-
-
notifyWebhookForStreamStatus
public void notifyWebhookForStreamStatus(Broadcast broadcast, int width, int height, long totalByteReceived, int inputQueueSize, int encodingQueueSize, int dropFrameCountInEncoding, int dropPacketCountInIngestion, double speed) Description copied from interface:IAntMediaStreamHandlerNotify the webhook about the stream status- Specified by:
notifyWebhookForStreamStatusin interfaceIAntMediaStreamHandler
-
putToMap
-
sendClusterPost
-
callClusterRestMethod
-
trySendClusterPostWithDelay
public void trySendClusterPostWithDelay(String url, String clusterCommunicationToken, int retryAttempts, CompletableFuture<Boolean> future, byte[] data) -
sendPOST
public void sendPOST(String url, Map<String, Object> variables, int retryAttempts, String contentType) - Parameters:
url-variables-retryAttempts-sendType- the type of the entity to be sent. It can be either "application/x-www-form-urlencoded" or "application/json"
-
retrySendPostWithDelay
-
getHttpClient
public org.apache.http.impl.client.CloseableHttpClient getHttpClient() -
getStreamPublishSecurityList
-
setStreamPublishSecurityList
-
setStreamPlaySecurityList
-
getStreamPlaySecurityList
-
getAppSettings
Description copied from interface:IAntMediaStreamHandlerGet the AppSettings of the application- Specified by:
getAppSettingsin interfaceIAntMediaStreamHandler- Returns:
- AppSettings
-
setAppSettings
-
getStreamAcceptFilter
-
setStreamAcceptFilter
-
isValidStreamParameters
public boolean isValidStreamParameters(int width, int height, int fps, int bitrate, String streamId) Description copied from interface:IAntMediaStreamHandlerChecks a Stream parameters is valid.- Specified by:
isValidStreamParametersin interfaceIAntMediaStreamHandler
-
isStreaming
Important information: Status field of Broadcast class checks the update time to report the status is broadcasting or not.Broadcast.getStatus() -
startStreaming
-
forwardStartStreaming
-
stopStreaming
-
isSubscriberBlocked
-
isSubscriberIdMatching
-
createIdleCheckTimer
-
notifyBroadcastIdleTimeExpired
-
getOnvifCamera
-
getStreamFetcherManager
-
setStreamFetcherManager
-
setQualityParameters
Description copied from interface:IAntMediaStreamHandlerSets quality parameters for the given stream ID. This method is called to update quality-related parameters for the specified stream during the publishing process.- Specified by:
setQualityParametersin interfaceIAntMediaStreamHandler- Parameters:
streamId- The unique identifier of the stream.stats- The current publishing statistics for the stream.currentTimeMillis- The current timestamp in milliseconds.
-
getDataStore
Description copied from interface:IAntMediaStreamHandlerGet the DataStore of the application- Specified by:
getDataStorein interfaceIAntMediaStreamHandler- Returns:
- DataStore
-
setDataStore
-
getDataStoreFactory
-
setDataStoreFactory
-
setVertx
public void setVertx(io.vertx.core.Vertx vertx) This setter for test cases- Parameters:
vertx-
-
fetchRtmpFromOriginIfExist
-
closeRTMPStreams
public void closeRTMPStreams() -
closeStreamFetchers
public void closeStreamFetchers() -
waitUntilLiveStreamsStopped
public void waitUntilLiveStreamsStopped() -
waitUntilThreadsStop
public void waitUntilThreadsStop() -
getActiveVertxThreadCount
private int getActiveVertxThreadCount() -
serverShuttingdown
public void serverShuttingdown()- Specified by:
serverShuttingdownin interfaceIShutdownListener
-
appStop
Description copied from class:MultiThreadedApplicationAdapterHandler method. Called when application is stopped.- Specified by:
appStopin interfaceApplicationMXBean- Overrides:
appStopin classMultiThreadedApplicationAdapter- Parameters:
app- Scope object
-
stopApplication
public void stopApplication(boolean deleteDB) -
closeDB
public void closeDB(boolean deleteDB) -
createInitializationProcess
-
createInitializationFile
public void createInitializationFile(String appName, Result result, File initializedFile) throws IOException - Throws:
IOException
-
createShutdownFile
-
isShutdownProperly
public boolean isShutdownProperly() -
setShutdownProperly
public void setShutdownProperly(boolean shutdownProperly) -
muxAdaptorAdded
Description copied from interface:IAntMediaStreamHandlerAdds a MuxAdaptor when a muxAdaptor is created- Specified by:
muxAdaptorAddedin interfaceIAntMediaStreamHandler
-
muxAdaptorRemoved
Description copied from interface:IAntMediaStreamHandlerRemoves a MuxAdaptor when a muxAdaptor is closingResources- Specified by:
muxAdaptorRemovedin interfaceIAntMediaStreamHandler
-
getMuxAdaptor
Description copied from interface:IAntMediaStreamHandlerGet the MuxAdaptor of the stream. MuxAdaptor is the base class that is responsible for ingesting and distributing the stream- Specified by:
getMuxAdaptorin interfaceIAntMediaStreamHandler- Returns:
-
getMuxAdaptors
-
getNumberOfEncodersBlocked
public int getNumberOfEncodersBlocked()Number of encoders blocked.- Returns:
-
encoderBlocked
-
incrementEncoderNotOpenedError
-
getNumberOfEncoderNotOpenedErrors
public int getNumberOfEncoderNotOpenedErrors() -
getNumberOfPublishTimeoutError
public int getNumberOfPublishTimeoutError() -
publishTimeoutError
-
getWebRTCAudioReceiveStats
-
getWebRTCVideoReceiveStats
-
getWebRTCAudioSendStats
-
getWebRTCVideoSendStats
-
getVertx
public io.vertx.core.Vertx getVertx() -
updateSettings
public boolean updateSettings(AppSettings newSettings, boolean notifyCluster, boolean checkUpdateTime) -
notifySettingsUpdateListeners
-
addSettingsUpdateListener
Description copied from interface:IAntMediaStreamHandlerAdd listener that is notified when the settings are updated- Specified by:
addSettingsUpdateListenerin interfaceIAntMediaStreamHandler
-
isEncoderSettingsValid
-
isTokenSecuritySettingsValid
-
isIncomingSettingsDifferent
- Parameters:
newSettings-checkUpdateTime-- Returns:
- true if time are not equal, it means new settings is different than the current settings
-
setClusterNotifier
-
updateAppSettingsFile
-
updateAppSettingsBean
public void updateAppSettingsBean(AppSettings appSettings, AppSettings newSettings, boolean updateTime) -
setStorageclientSettings
-
setAppSettingsFieldValue
public static boolean setAppSettingsFieldValue(AppSettings appSettings, AppSettings newSettings, Field field) -
setServerSettings
-
isDataChannelEnabled
public boolean isDataChannelEnabled() -
isDataChannelMessagingSupported
public boolean isDataChannelMessagingSupported() -
sendDataChannelMessage
-
doesWebRTCStreamExist
-
addPacketListener
Description copied from interface:IAntMediaStreamHandlerAdd listener to get audio and video packets from the internal of Ant Media Server. 'Packet' is the encoded data of audio/video 'Frame'.- Specified by:
addPacketListenerin interfaceIAntMediaStreamHandler- Returns:
-
endpointFailedUpdate
-
removePacketListener
Description copied from interface:IAntMediaStreamHandlerRemove listener from the Stream Handler to stop getting notified- Specified by:
removePacketListenerin interfaceIAntMediaStreamHandler- Returns:
-
addFrameListener
Description copied from interface:IAntMediaStreamHandlerAdd listener to get raw audio or video frames from the internal of Ant Media Server. The methods are called if the audio/video frames are decoded due to settings such adaptive bitrate etc.. This method does not force the Ant Media Server to decode the streams. 'Frame' is the decoded data of audio/video 'Packet'- Specified by:
addFrameListenerin interfaceIAntMediaStreamHandler
-
createCustomBroadcast
Description copied from interface:IAntMediaStreamHandlerCreate another broadcast. It's useful to create another manipulated version of the original broadcast in the plugins. The returning frame listener should be feed with raw audio and video frames- Specified by:
createCustomBroadcastin interfaceIAntMediaStreamHandler- Returns:
-
createCustomBroadcast
Description copied from interface:IAntMediaStreamHandlerCreate another broadcast. It's useful to create another manipulated version of the original broadcast in the plugins. The returning frame listener should be feed with raw audio and video frames- Specified by:
createCustomBroadcastin interfaceIAntMediaStreamHandler- Returns:
-
stopCustomBroadcast
Description copied from interface:IAntMediaStreamHandlerStop the custom broadcast that is being created. Stop encoders and make database operations.- Specified by:
stopCustomBroadcastin interfaceIAntMediaStreamHandler
-
removeFrameListener
Description copied from interface:IAntMediaStreamHandlerRemove frame listener from the Stream Handler to stop getting notified- Specified by:
removeFrameListenerin interfaceIAntMediaStreamHandler
-
isServerShuttingDown
public boolean isServerShuttingDown()- Specified by:
isServerShuttingDownin interfaceIAntMediaStreamHandler- Returns:
- true if server is shutting down
-
setStorageClient
-
getStorageClient
-
addStreamListener
Description copied from interface:IAntMediaStreamHandlerAdd a stream listener to get notified when a new stream is started or finished.IStreamListenerinterface has callbacks for conference attendees. It's very useful to use in plugins.- Specified by:
addStreamListenerin interfaceIAntMediaStreamHandler
-
removeStreamListener
Description copied from interface:IAntMediaStreamHandlerRemove a stream listener from the Stream Handler to stop getting notified- Specified by:
removeStreamListenerin interfaceIAntMediaStreamHandler
-
startHttpSignaling
public CompletableFuture<Result> startHttpSignaling(PublishParameters publishParameters, String sdp, String sessionId) -
stopWhipBroadcast
-
stopPlayingBySubscriberId
-
stopPublishingBySubscriberId
-
stopPublish
Description copied from interface:IAntMediaStreamHandlerNotify the handler that is stream is stopped- Specified by:
stopPublishin interfaceIAntMediaStreamHandlersubscriberId- : It's the id of the subscriber. It can be null if it's not available.
-
stopPublish
Description copied from interface:IAntMediaStreamHandlerNotify the handler that is stream is stopped- Specified by:
stopPublishin interfaceIAntMediaStreamHandlersubscriberId- : It's the id of the subscriber. It can be null if it's not available.publishParameters- : It's the parameters of the publish. It can be null if it's not available.
-
isClusterMode
public boolean isClusterMode() -
joinedTheRoom
-
leftTheRoom
-
createClusterStreamFetcher
-
getWebRTCClientsMap
-
getSubtrackPoller
-
setSubtrackPoller
-
getPlayListSchedulerTimer
-
getStatsCollector
-
setStatsCollector
-
publishStarted
This is a callback-method and called when a stream is fully started and it means it is called post publish operations has finished It can be called from the cluster side or from the local side to synch subtracks -
publishStopped
This method is called when a stream is fully stopped and it means it is called post publish operations has finished It can be called from the cluster side or from the local side to synch subtracks -
notifyPublishStarted
This method is called to notify the local node and cluster nodes when a stream is started -
notifyPublishStopped
-
getDataChannelRouter
Description copied from interface:IAntMediaStreamHandlerGet data channel router for data channel delivery- Specified by:
getDataChannelRouterin interfaceIAntMediaStreamHandler- Returns:
-
registerSubscriberToNode
-