Package io.antmedia.datastore.db
Class MapBasedDataStore
java.lang.Object
io.antmedia.datastore.db.DataStore
io.antmedia.datastore.db.MapBasedDataStore
- Direct Known Subclasses:
MapDBStore,RedisStore
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected com.google.gson.Gsonstatic final Stringprotected static org.slf4j.LoggerFields inherited from class io.antmedia.datastore.db.DataStore
appSettings, available, MAX_ITEM_IN_ONE_LIST, REPLACE_CHARS_REGEX, TOTAL_WEBRTC_VIEWER_COUNT_CACHE_TIME, totalWebRTCViewerCount, totalWebRTCViewerCountLastUpdateTime -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanaddEndpoint(String id, Endpoint endpoint) booleanaddSubscriber(String streamId, Subscriber subscriber) adds subscriber to the datastore for this streamAdd VoD record to the datastorebooleanblockSubscriber(String streamId, String subscriberId, String blockedType, int seconds) blocks subscribe from playing or publishingvoidclearStreamInfoList(String streamId) Remove the stream info list from dbbooleanCreates new P2PConnectionbooleanbooleandeleteP2PConnection(String streamId) Deletes a P2PConnectionbooleandeleteSubscriber(String streamId, String subscriberId) deletes subscriber from the datastore for this streambooleandeleteToken(String tokenId) Delete specific tokenbooleanintfetchUserVodList(File filedir) Gets the video files under thefileDirdirectory parameter and saves them to the datastore as USER_VOD inVodclassReturn the broadcast in data storelongReturn the number of active broadcasts in the servergetActiveBroadcastList(String hostAddress) getActiveSubtracks(String mainTrackId, int offset, int size, String role) Get active subtracks with pagination.getActiveSubtracks(String mainTrackId, String role) Get of active subtracks.longgetActiveSubtracksCount(String mainTrackId, String role) Get the count of active subtracks.getBroadcastFromMap(String streamId) getBroadcastList(int offset, int size, String type, String sortBy, String orderBy, String search) Returns the Broadcast List in ordergetBroadcastListV2(String type, String search) longgetConnectedSubscriberCount(String streamId) Returns the number of the subscribers of requested streamgetConnectedSubscribers(String streamId, int offset, int size) Lists connected subscribers of requested streamgetConnectionEvents(String streamId, String subscriberId, int offset, int size) Get connection events for a specific streamId and subscriberId ConnectionEvents are recorded ifAppSettings.isWriteSubscriberEventsToDatastore()is truegetP2PConnection(String streamId) Get the P2PConnection by streamIdlonggetPartialBroadcastNumber(String search) Returns the number of broadcasts which contains searched stringlonggetPartialVodNumber(String search) Returns the number of vods which contains searched stringstatic List<ConnectionEvent>getReturningConnectionEventsList(int offset, int size, List<ConnectionEvent> list) getStreamInfoList(String streamId) Returns stream info list added to dbgetSubscriber(String streamId, String subscriberId) gets subscriber from the datastoregetSubscriberMetaData(String subscriberId) Get subscriber metadatalonggetSubtrackCount(String mainTrackId, String role, String status) Get the count of subtracksgetSubtracks(String mainTrackId, int offset, int size, String role) Get the subtracks of the main trackgetSubtracks(String mainTrackId, int offset, int size, String role, String status, String sortBy, String orderBy, String search) Get the subtracks of the main trackretrieve specific tokenlonglongintThis is used to get total number of WebRTC viewersReturn the vod by idgetVodList(int offset, int size, String sortBy, String orderBy, String streamId, String search) Returns the VoD List in ordergetVodListV2(String streamId, String search) booleanhasSubtracks(String streamId) listAllSubscribers(String streamId, int offset, int size) Lists all subscribers of requested streamlistAllTokens(String streamId, int offset, int size) Lists all tokens of requested streamvoidputSubscriberMetaData(String subscriberId, SubscriberMetadata metadata) Put subscriber metadata.booleanbooleanremoveEndpoint(String id, Endpoint endpoint, boolean checkRTMPUrl) intresetBroadcasts(String hostAddress) Resets the broadcasts in the database.booleansets the connection status of all the subscribers false in the datastore called after an ungraceful shutdownbooleanrevokeSubscribers(String streamId) deletes all subscriber from the datastore for this streambooleanrevokeTokens(String streamId) Delete all tokens of the streamvoidsaveStreamInfo(StreamInfo streamInfo) Saves the stream info to the dbbooleansaves token to storevoidsetBroadcastToMap(Broadcast broadcast, String streamId) booleansetMp4Muxing(String streamId, int enabled) enables or disables mp4 muxing for the streambooleansetWebMMuxing(String streamId, int enabled) enables or disables WebM muxing for the streambooleanupdateBroadcastFields(String streamId, BroadcastUpdate broadcast) Updates the stream's name, description, userName, password, IP address, stream URL if these values is not nullprotected booleanupdateDASHViewerCountLocal(String streamId, int diffCount) protected booleanupdateHLSViewerCountLocal(String streamId, int diffCount) protected booleanupdateRtmpViewerCountLocal(String streamId, boolean increment) booleanupdateStatus(String id, String status) booleanupdateStreamMetaData(String streamId, String metaData) This is used to update meta data for a bradcastbooleanupdateVoDProcessStatus(String id, String status) protected booleanupdateWebRTCViewerCountLocal(String streamId, boolean increment) validateToken(Token token) Validates tokenMethods inherited from class io.antmedia.datastore.db.DataStore
addQueryTime, addSubscriberConnectionEvent, close, get, getActiveBroadcastCount, getActiveBroadcastList, getAverageQueryTimeMs, getBroadcastCount, getConnectionEventListFromCollection, getExecutedQueryCount, getLocalLiveBroadcastCount, getLocalLiveBroadcasts, getSubscriber, getToken, getTotalBroadcastNumber, getTotalVodNumber, getTotalWebRTCViewersCount, getVoD, getVodListV2, handleConnectionEvent, isAvailable, isSubscriberConnected, listAllSubscribers, listAllTokens, saveBroadcast, searchOnServer, searchOnServerVod, setAppSettings, showWarningIfElapsedTimeIsMoreThanThreshold, sortAndCropBroadcastList, sortAndCropVodList, updateDASHViewerCount, updateHLSViewerCount, updateRtmpViewerCount, updateStreamInfo, updateSubscriberBitrateEvent, updateWebRTCViewerCount
-
Field Details
-
INCONSISTENCY_MESSAGE
- See Also:
-
map
-
vodMap
-
detectionMap
-
tokenMap
-
subscriberMap
-
connectionEventsMap
-
conferenceRoomMap
-
webRTCViewerMap
-
subscriberMetadataMap
-
gson
protected com.google.gson.Gson gson -
dbName
-
logger
protected static org.slf4j.Logger logger
-
-
Constructor Details
-
MapBasedDataStore
-
-
Method Details
-
save
-
get
Description copied from class:DataStoreReturn the broadcast in data store -
getVoD
Description copied from class:DataStoreReturn the vod by id -
updateStatus
- Specified by:
updateStatusin classDataStore
-
updateVoDProcessStatus
- Specified by:
updateVoDProcessStatusin classDataStore
-
addEndpoint
- Specified by:
addEndpointin classDataStore
-
removeEndpoint
- Specified by:
removeEndpointin classDataStore
-
removeAllEndpoints
- Specified by:
removeAllEndpointsin classDataStore
-
getActiveBroadcastCount
public long getActiveBroadcastCount()Description copied from class:DataStoreReturn the number of active broadcasts in the server- Specified by:
getActiveBroadcastCountin classDataStore- Returns:
-
getActiveBroadcastList
-
delete
-
getBroadcastListV2
-
getBroadcastList
public List<Broadcast> getBroadcastList(int offset, int size, String type, String sortBy, String orderBy, String search) Description copied from class:DataStoreReturns the Broadcast List in order- Specified by:
getBroadcastListin classDataStore- Parameters:
offset- the number of items to skipsize- batch sizetype- can get "liveStream" or "ipCamera" or "streamSource" or "VoD" values. Default is getting all broadcast types.sortBy- can get "name" or "date" or "status" valuesorderBy- can get "desc" or "asc"search- is used for searching in streamIds and names of the stream- Returns:
-
getVodListV2
-
getVodList
public List<VoD> getVodList(int offset, int size, String sortBy, String orderBy, String streamId, String search) Returns the VoD List in order- Specified by:
getVodListin classDataStore- Parameters:
offset- : the number of items to skipsize- : batch sizesortBy- can get "name" or "date" valuesorderBy- can get "desc" or "asc"streamId- is used for filtering the vod by stream id. If it's null or empty, it's not usedsearch- is used for searching in vodIds and names of the vods.- Returns:
-
addVod
Description copied from class:DataStoreAdd VoD record to the datastore -
getExternalStreamsList
- Specified by:
getExternalStreamsListin classDataStore
-
deleteVod
-
getTotalVodNumber
public long getTotalVodNumber()- Specified by:
getTotalVodNumberin classDataStore
-
getPartialVodNumber
Description copied from class:DataStoreReturns the number of vods which contains searched string- Specified by:
getPartialVodNumberin classDataStore- Parameters:
search- is used for searching in vodIds and names of the vods- Returns:
-
fetchUserVodList
Description copied from class:DataStoreGets the video files under thefileDirdirectory parameter and saves them to the datastore as USER_VOD inVodclass- Specified by:
fetchUserVodListin classDataStore- Returns:
- number of files that are saved to datastore
-
getTotalBroadcastNumber
public long getTotalBroadcastNumber()- Specified by:
getTotalBroadcastNumberin classDataStore
-
getPartialBroadcastNumber
Description copied from class:DataStoreReturns the number of broadcasts which contains searched string- Specified by:
getPartialBroadcastNumberin classDataStore- Parameters:
search- is used for searching in streamIds and names of the stream- Returns:
-
updateBroadcastFields
Updates the stream's name, description, userName, password, IP address, stream URL if these values is not null- Specified by:
updateBroadcastFieldsin classDataStore- Parameters:
streamId-broadcast-- Returns:
-
updateHLSViewerCountLocal
- Specified by:
updateHLSViewerCountLocalin classDataStore
-
updateDASHViewerCountLocal
- Specified by:
updateDASHViewerCountLocalin classDataStore
-
updateWebRTCViewerCountLocal
- Specified by:
updateWebRTCViewerCountLocalin classDataStore
-
updateRtmpViewerCountLocal
- Specified by:
updateRtmpViewerCountLocalin classDataStore
-
clearStreamInfoList
Description copied from class:DataStoreRemove the stream info list from db- Specified by:
clearStreamInfoListin classDataStore
-
getStreamInfoList
Description copied from class:DataStoreReturns stream info list added to db- Specified by:
getStreamInfoListin classDataStore- Returns:
-
saveToken
Description copied from class:DataStoresaves token to store -
validateToken
Description copied from class:DataStoreValidates token- Specified by:
validateTokenin classDataStore- Returns:
- token if validated, null if not
-
revokeTokens
Description copied from class:DataStoreDelete all tokens of the stream- Specified by:
revokeTokensin classDataStore
-
listAllTokens
Description copied from class:DataStoreLists all tokens of requested stream- Specified by:
listAllTokensin classDataStore- Returns:
- lists of tokens
-
getConnectedSubscriberCount
Description copied from class:DataStoreReturns the number of the subscribers of requested stream- Specified by:
getConnectedSubscriberCountin classDataStore- Returns:
- number of the subscribers of requested stream
-
getConnectedSubscribers
Description copied from class:DataStoreLists connected subscribers of requested stream- Specified by:
getConnectedSubscribersin classDataStore- Returns:
- lists of subscribers
-
listAllSubscribers
Description copied from class:DataStoreLists all subscribers of requested stream- Specified by:
listAllSubscribersin classDataStore- Returns:
- lists of subscribers
-
addSubscriber
Description copied from class:DataStoreadds subscriber to the datastore for this stream- Specified by:
addSubscriberin classDataStoresubscriber- - subscriber to be added
-
getConnectionEvents
public List<ConnectionEvent> getConnectionEvents(String streamId, String subscriberId, int offset, int size) Description copied from class:DataStoreGet connection events for a specific streamId and subscriberId ConnectionEvents are recorded ifAppSettings.isWriteSubscriberEventsToDatastore()is true- Specified by:
getConnectionEventsin classDataStore- Returns:
-
getReturningConnectionEventsList
public static List<ConnectionEvent> getReturningConnectionEventsList(int offset, int size, List<ConnectionEvent> list) -
addConnectionEvent
- Specified by:
addConnectionEventin classDataStore
-
blockSubscriber
public boolean blockSubscriber(String streamId, String subscriberId, String blockedType, int seconds) Description copied from class:DataStoreblocks subscribe from playing or publishing- Specified by:
blockSubscriberin classDataStoresubscriberId- - id of the subsciber to be blockedblockedType- - it can be the value of the static fieldSubscriber.PLAY_TYPE,Subscriber.PUBLISH_TYPE,Subscriber.PUBLISH_AND_PLAY_TYPEpublish, play, publish_playseconds- - duration of seconds to block the user
-
deleteSubscriber
Description copied from class:DataStoredeletes subscriber from the datastore for this stream- Specified by:
deleteSubscriberin classDataStoresubscriberId- - id of the subsciber to be deleted
-
revokeSubscribers
Description copied from class:DataStoredeletes all subscriber from the datastore for this stream- Specified by:
revokeSubscribersin classDataStore
-
getSubscriber
Description copied from class:DataStoregets subscriber from the datastore- Specified by:
getSubscriberin classDataStoresubscriberId- - id of the subsciber to be deleted
-
resetSubscribersConnectedStatus
public boolean resetSubscribersConnectedStatus()Description copied from class:DataStoresets the connection status of all the subscribers false in the datastore called after an ungraceful shutdown- Specified by:
resetSubscribersConnectedStatusin classDataStore
-
resetBroadcasts
Description copied from class:DataStoreResets the broadcasts in the database. It sets number of viewers to zero. It also delete the stream if it's zombi stream- Specified by:
resetBroadcastsin classDataStore
-
saveStreamInfo
Description copied from class:DataStoreSaves the stream info to the db- Specified by:
saveStreamInfoin classDataStore
-
setMp4Muxing
Description copied from class:DataStoreenables or disables mp4 muxing for the stream- Specified by:
setMp4Muxingin classDataStore- Parameters:
streamId- - id of the streamenabled- 1 means enabled, -1 means disabled, 0 means no setting for the stream
-
setWebMMuxing
Description copied from class:DataStoreenables or disables WebM muxing for the stream- Specified by:
setWebMMuxingin classDataStore- Parameters:
streamId- - id of the streamenabled- 1 means enabled, -1 means disabled, 0 means no setting for the stream
-
deleteToken
Description copied from class:DataStoreDelete specific token- Specified by:
deleteTokenin classDataStore- Parameters:
tokenId- id of the token
-
getToken
Description copied from class:DataStoreretrieve specific token -
createP2PConnection
Description copied from class:DataStoreCreates new P2PConnection- Specified by:
createP2PConnectionin classDataStore- Parameters:
conn- - P2PConnection object- Returns:
- boolean - success
-
deleteP2PConnection
Description copied from class:DataStoreDeletes a P2PConnection- Specified by:
deleteP2PConnectionin classDataStore- Returns:
- boolean - success
-
getP2PConnection
Description copied from class:DataStoreGet the P2PConnection by streamId- Specified by:
getP2PConnectionin classDataStore- Parameters:
streamId- - stream id for P2PConnection- Returns:
- P2PConnection - if exist else null
-
getTotalWebRTCViewersCount
public int getTotalWebRTCViewersCount()Description copied from class:DataStoreThis is used to get total number of WebRTC viewers- Specified by:
getTotalWebRTCViewersCountin classDataStore
-
updateStreamMetaData
Description copied from class:DataStoreThis is used to update meta data for a bradcast- Specified by:
updateStreamMetaDatain classDataStore- Parameters:
streamId- id for the broadcastmetaData- new meta data
-
setBroadcastToMap
-
getBroadcastFromMap
-
putSubscriberMetaData
Description copied from class:DataStorePut subscriber metadata. It overwrites the metadata, if you need to update something, first get theDataStore.getSubscriberMetaData(String), update it and put it- Specified by:
putSubscriberMetaDatain classDataStore
-
getSubscriberMetaData
Description copied from class:DataStoreGet subscriber metadata- Specified by:
getSubscriberMetaDatain classDataStore- Returns:
-
getConferenceRoomMap
-
getSubtracks
Description copied from class:DataStoreGet the subtracks of the main track- Specified by:
getSubtracksin classDataStore- Parameters:
mainTrackId- the main track to get the subtracksoffset- the offset to get the subtrackssize- number of items to getrole- the role of the subtracks for role based streaming especially in conferences. It can be null- Returns:
-
getSubtracks
public List<Broadcast> getSubtracks(String mainTrackId, int offset, int size, String role, String status, String sortBy, String orderBy, String search) Description copied from class:DataStoreGet the subtracks of the main track- Specified by:
getSubtracksin classDataStore- Parameters:
mainTrackId- the main track to get the subtracksoffset- the offset to get the subtrackssize- number of items to getrole- the role of the subtracks for role based streaming especially in conferences. It can be nullstatus- the status of the stream broadcasting, finished etc. It can be nullsortBy- can get "name" or "date" or "status" valuesorderBy- can get "desc" or "asc"search- is used for searching in streamIds and names of the stream- Returns:
-
getSubtrackCount
Description copied from class:DataStoreGet the count of subtracks- Specified by:
getSubtrackCountin classDataStore- Parameters:
mainTrackId- the main track to get the subtracksrole- the role of the subtracks for role based streaming especially in conferences- Returns:
- number of subtracks
-
getActiveSubtracksCount
Description copied from class:DataStoreGet the count of active subtracks. If subtrack is stucked in broadcasting or preparing, it will not count it.- Specified by:
getActiveSubtracksCountin classDataStore- Returns:
-
getActiveSubtracks
Description copied from class:DataStoreGet of active subtracks. If subtrack is stucked in broadcasting or preparing, it will not return it. This method is generally not recommended to use because it can be very costly. It's implemented for the poll mechanism in Subtracks and poll mechanismi will be replaced with event mechanism- Specified by:
getActiveSubtracksin classDataStore- Returns:
-
getActiveSubtracks
Description copied from class:DataStoreGet active subtracks with pagination. If subtrack is stucked in broadcasting or preparing, it will not return it.- Specified by:
getActiveSubtracksin classDataStore- Parameters:
mainTrackId- the main track to get the active subtracksoffset- the offset to get the active subtrackssize- number of items to getrole- the role of the subtracks for role based streaming especially in conferences. It can be null- Returns:
- list of active subtracks
-
hasSubtracks
- Specified by:
hasSubtracksin classDataStore- Returns:
- If the stream has subtracks, it return true. If not, it returns false
-