Package io.antmedia.datastore.db
Class InMemoryDataStore
java.lang.Object
io.antmedia.datastore.db.DataStore
io.antmedia.datastore.db.InMemoryDataStore
-
Field Summary
Modifier and TypeFieldDescriptionprivate Map<String,
Queue<ConnectionEvent>> private Map<String,
List<TensorFlowObject>> protected static org.slf4j.Logger
private Map<String,
Subscriber> private Map<String,
SubscriberMetadata> private Map<String,
WebRTCViewerInfo> Fields 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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addConnectionEvent
(ConnectionEvent connectionEvent) boolean
addEndpoint
(String id, Endpoint endpoint) boolean
addSubscriber
(String streamId, Subscriber subscriber) adds subscriber to the datastore for this streamboolean
addSubTrack
(String mainTrackId, String subTrackId) Add VoD record to the datastoreboolean
blockSubscriber
(String streamId, String subscriberId, String blockedType, int seconds) blocks subscribe from playing or publishingvoid
clearStreamInfoList
(String streamId) Remove the stream info list from dbvoid
close
(boolean deleteDB) Closes the databaseboolean
Creates new P2PConnectionboolean
boolean
deleteP2PConnection
(String streamId) Deletes a P2PConnectionboolean
deleteSubscriber
(String streamId, String subscriberId) deletes subscriber from the datastore for this streamboolean
deleteToken
(String tokenId) Delete specific tokenboolean
boolean
deleteWebRTCViewerInfo
(String viewerId) This is used to delete a WebRTC Viewer Info from datastoreint
fetchUserVodList
(File userfile) Gets the video files under thefileDir
directory parameter and saves them to the datastore as USER_VOD inVod
classReturn the broadcast in data storelong
Return the number of active broadcasts in the servergetActiveSubtracks
(String mainTrackId, String role) Get of active subtracks.long
getActiveSubtracksCount
(String mainTrackId, String role) Get the count of active subtracks.long
Use getTotalBroadcastNumbergetBroadcastList
(int offset, int size, String type, String sortBy, String orderBy, String search) Returns the Broadcast List in ordergetConnectionEvents
(String streamId, String subscriberId, int offset, int size) Get connection events for a specific streamId and subscriberId ConnectionEvents are recorded ifAppSettings.isWriteSubscriberEventsToDatastore()
is truegetDetection
(String id) getDetectionList
(String idFilter, int offsetSize, int batchSize) long
getLocalLiveBroadcastCount
(String hostAddress) getLocalLiveBroadcasts
(String hostAddress) long
Returns the total number of detected objects in the streamgetP2PConnection
(String streamId) Get the P2PConnection by streamIdlong
getPartialBroadcastNumber
(String search) Returns the number of broadcasts which contains searched stringlong
getPartialVodNumber
(String search) Returns the number of vods which contains searched stringgetStreamInfoList
(String streamId) Returns stream info list added to dbgetSubscriber
(String streamId, String subscriberId) gets subscriber from the datastoregetSubscriberMetaData
(String subscriberId) Get subscriber metadatalong
getSubtrackCount
(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) Get the subtracks of the main trackretrieve specific tokenlong
long
int
This is used to get total number of WebRTC viewersReturn the vod by idgetVodList
(int offset, int size, String sortBy, String orderBy, String filterStreamId, String search) Returns the VoD List in ordergetWebRTCViewerList
(int offset, int size, String sortBy, String orderBy, String search) Get list of webrtc viewersboolean
hasSubtracks
(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 streamvoid
Move ConferenceRoom to Broadcastvoid
putSubscriberMetaData
(String subscriberId, SubscriberMetadata subscriberMetadata) Put subscriber metadata.boolean
boolean
removeEndpoint
(String id, Endpoint endpoint, boolean checkRTMPUrl) boolean
removeSubTrack
(String mainTrackId, String subTrackId) int
resetBroadcasts
(String hostAddress) Resets the broadcasts in the database.boolean
sets the connection status of all the subscribers false in the datastore called after an ungraceful shutdownboolean
revokeSubscribers
(String streamId) deletes all subscriber from the datastore for this streamboolean
revokeTokens
(String streamId) Delete all tokens of the streamvoid
saveDetection
(String id, long timeElapsed, List<TensorFlowObject> detectedObjects) void
saveStreamInfo
(StreamInfo streamInfo) Saves the stream info to the dbboolean
saves token to storevoid
This is used to save WebRTC Viewer Info to datastoreboolean
setMp4Muxing
(String streamId, int enabled) enables or disables mp4 muxing for the streamboolean
setWebMMuxing
(String streamId, int enabled) enables or disables WebM muxing for the streamboolean
updateBroadcastFields
(String streamId, BroadcastUpdate broadcast) Updates the Broadcast objects fields if it's not null.boolean
updateDASHViewerCountLocal
(String streamId, int diffCount) boolean
updateHLSViewerCountLocal
(String streamId, int diffCount) boolean
updateRtmpViewerCountLocal
(String streamId, boolean increment) boolean
updateStatus
(String id, String status) boolean
updateStreamMetaData
(String streamId, String metaData) This is used to update meta data for a bradcastboolean
updateVoDProcessStatus
(String id, String status) boolean
updateWebRTCViewerCountLocal
(String streamId, boolean increment) validateToken
(Token token) Validates tokenMethods inherited from class io.antmedia.datastore.db.DataStore
addQueryTime, addSubscriberConnectionEvent, broadcastToConference, conferenceToBroadcast, conferenceUpdateToBroadcastUpdate, get, getActiveBroadcastCount, getActiveBroadcastList, getAverageQueryTimeMs, getBroadcastCount, getConnectionEventListFromCollection, getDetection, getDetectionList, getExecutedQueryCount, getObjectDetectedTotal, getSubscriber, getToken, getTotalBroadcastNumber, getTotalVodNumber, getTotalWebRTCViewersCount, getVoD, getVodListV2, getWebRTCViewerList, handleConnectionEvent, isAvailable, isSubscriberConnected, listAllSubscribers, listAllSubscriberStats, listAllTokens, saveBroadcast, searchOnServer, searchOnServerVod, searchOnWebRTCViewerInfo, setAppSettings, showWarningIfElapsedTimeIsMoreThanThreshold, sortAndCropBroadcastList, sortAndCropVodList, sortAndCropWebRTCViewerInfoList, updateDASHViewerCount, updateHLSViewerCount, updateRtmpViewerCount, updateStreamInfo, updateSubscriberBitrateEvent, updateWebRTCViewerCount
-
Field Details
-
logger
protected static org.slf4j.Logger logger -
broadcastMap
-
vodMap
-
detectionMap
-
tokenMap
-
subscriberMap
-
connectionEvents
-
subscriberMetadataMap
-
webRTCViewerMap
-
-
Constructor Details
-
InMemoryDataStore
-
-
Method Details
-
save
-
get
Description copied from class:DataStore
Return the broadcast in data store -
getVoD
Description copied from class:DataStore
Return the vod by id -
updateStatus
- Specified by:
updateStatus
in classDataStore
-
addEndpoint
- Specified by:
addEndpoint
in classDataStore
-
removeEndpoint
- Specified by:
removeEndpoint
in classDataStore
-
getBroadcastCount
public long getBroadcastCount()Description copied from class:DataStore
Use getTotalBroadcastNumber- Specified by:
getBroadcastCount
in classDataStore
-
getActiveBroadcastCount
public long getActiveBroadcastCount()Description copied from class:DataStore
Return the number of active broadcasts in the server- Specified by:
getActiveBroadcastCount
in classDataStore
- Returns:
-
getLocalLiveBroadcastCount
- Specified by:
getLocalLiveBroadcastCount
in classDataStore
-
getLocalLiveBroadcasts
- Specified by:
getLocalLiveBroadcasts
in classDataStore
-
delete
-
getBroadcastList
public List<Broadcast> getBroadcastList(int offset, int size, String type, String sortBy, String orderBy, String search) Description copied from class:DataStore
Returns the Broadcast List in order- Specified by:
getBroadcastList
in 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:
-
getExternalStreamsList
- Specified by:
getExternalStreamsList
in classDataStore
-
close
public void close(boolean deleteDB) Description copied from class:DataStore
Closes the database -
addVod
Description copied from class:DataStore
Add VoD record to the datastore -
updateVoDProcessStatus
- Specified by:
updateVoDProcessStatus
in classDataStore
-
getVodList
public List<VoD> getVodList(int offset, int size, String sortBy, String orderBy, String filterStreamId, String search) Description copied from class:DataStore
Returns the VoD List in order- Specified by:
getVodList
in classDataStore
- Parameters:
offset
- : the number of items to skipsize
- : batch sizesortBy
- can get "name" or "date" valuesorderBy
- can get "desc" or "asc"filterStreamId
- 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:
-
deleteVod
-
removeAllEndpoints
- Specified by:
removeAllEndpoints
in classDataStore
-
getTotalVodNumber
public long getTotalVodNumber()- Specified by:
getTotalVodNumber
in classDataStore
-
fetchUserVodList
Description copied from class:DataStore
Gets the video files under thefileDir
directory parameter and saves them to the datastore as USER_VOD inVod
class- Specified by:
fetchUserVodList
in classDataStore
- Returns:
- number of files that are saved to datastore
-
getTotalBroadcastNumber
public long getTotalBroadcastNumber()- Specified by:
getTotalBroadcastNumber
in classDataStore
-
saveDetection
- Specified by:
saveDetection
in classDataStore
-
getPartialBroadcastNumber
Description copied from class:DataStore
Returns the number of broadcasts which contains searched string- Specified by:
getPartialBroadcastNumber
in classDataStore
- Parameters:
search
- is used for searching in streamIds and names of the stream- Returns:
-
getPartialVodNumber
Description copied from class:DataStore
Returns the number of vods which contains searched string- Specified by:
getPartialVodNumber
in classDataStore
- Parameters:
search
- is used for searching in vodIds and names of the vods- Returns:
-
getDetectionList
- Specified by:
getDetectionList
in classDataStore
-
getObjectDetectedTotal
Description copied from class:DataStore
Returns the total number of detected objects in the stream- Specified by:
getObjectDetectedTotal
in classDataStore
- Returns:
- total number of detected objects
-
getDetection
- Specified by:
getDetection
in classDataStore
-
updateBroadcastFields
Description copied from class:DataStore
Updates the Broadcast objects fields if it's not null. The updated fields are as follows name, description, userName, password, IP address, streamUrl- Specified by:
updateBroadcastFields
in classDataStore
- Returns:
-
updateHLSViewerCountLocal
- Specified by:
updateHLSViewerCountLocal
in classDataStore
-
updateDASHViewerCountLocal
- Specified by:
updateDASHViewerCountLocal
in classDataStore
-
updateWebRTCViewerCountLocal
- Specified by:
updateWebRTCViewerCountLocal
in classDataStore
-
updateRtmpViewerCountLocal
- Specified by:
updateRtmpViewerCountLocal
in classDataStore
-
saveToken
Description copied from class:DataStore
saves token to store -
validateToken
Description copied from class:DataStore
Validates token- Specified by:
validateToken
in classDataStore
- Returns:
- token if validated, null if not
-
revokeTokens
Description copied from class:DataStore
Delete all tokens of the stream- Specified by:
revokeTokens
in classDataStore
-
listAllTokens
Description copied from class:DataStore
Lists all tokens of requested stream- Specified by:
listAllTokens
in classDataStore
- Returns:
- lists of tokens
-
listAllSubscribers
Description copied from class:DataStore
Lists all subscribers of requested stream- Specified by:
listAllSubscribers
in classDataStore
- Returns:
- lists of subscribers
-
addSubscriber
Description copied from class:DataStore
adds subscriber to the datastore for this stream- Specified by:
addSubscriber
in classDataStore
subscriber
- - subscriber to be added
-
getConnectionEvents
public List<ConnectionEvent> getConnectionEvents(String streamId, String subscriberId, int offset, int size) Description copied from class:DataStore
Get connection events for a specific streamId and subscriberId ConnectionEvents are recorded ifAppSettings.isWriteSubscriberEventsToDatastore()
is true- Specified by:
getConnectionEvents
in classDataStore
- Returns:
-
addConnectionEvent
- Specified by:
addConnectionEvent
in classDataStore
-
deleteSubscriber
Description copied from class:DataStore
deletes subscriber from the datastore for this stream- Specified by:
deleteSubscriber
in classDataStore
subscriberId
- - id of the subsciber to be deleted
-
blockSubscriber
public boolean blockSubscriber(String streamId, String subscriberId, String blockedType, int seconds) Description copied from class:DataStore
blocks subscribe from playing or publishing- Specified by:
blockSubscriber
in classDataStore
subscriberId
- - 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_TYPE
publish, play, publish_playseconds
- - duration of seconds to block the user
-
revokeSubscribers
Description copied from class:DataStore
deletes all subscriber from the datastore for this stream- Specified by:
revokeSubscribers
in classDataStore
-
getSubscriber
Description copied from class:DataStore
gets subscriber from the datastore- Specified by:
getSubscriber
in classDataStore
subscriberId
- - id of the subsciber to be deleted
-
resetSubscribersConnectedStatus
public boolean resetSubscribersConnectedStatus()Description copied from class:DataStore
sets the connection status of all the subscribers false in the datastore called after an ungraceful shutdown- Specified by:
resetSubscribersConnectedStatus
in classDataStore
-
getStreamInfoList
Description copied from class:DataStore
Returns stream info list added to db- Specified by:
getStreamInfoList
in classDataStore
- Returns:
-
clearStreamInfoList
Description copied from class:DataStore
Remove the stream info list from db- Specified by:
clearStreamInfoList
in classDataStore
-
setMp4Muxing
Description copied from class:DataStore
enables or disables mp4 muxing for the stream- Specified by:
setMp4Muxing
in 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:DataStore
enables or disables WebM muxing for the stream- Specified by:
setWebMMuxing
in classDataStore
- Parameters:
streamId
- - id of the streamenabled
- 1 means enabled, -1 means disabled, 0 means no setting for the stream
-
saveStreamInfo
Description copied from class:DataStore
Saves the stream info to the db- Specified by:
saveStreamInfo
in classDataStore
-
deleteToken
Description copied from class:DataStore
Delete specific token- Specified by:
deleteToken
in classDataStore
- Parameters:
tokenId
- id of the token
-
getToken
Description copied from class:DataStore
retrieve specific token -
createP2PConnection
Description copied from class:DataStore
Creates new P2PConnection- Specified by:
createP2PConnection
in classDataStore
- Parameters:
conn
- - P2PConnection object- Returns:
- boolean - success
-
deleteP2PConnection
Description copied from class:DataStore
Deletes a P2PConnection- Specified by:
deleteP2PConnection
in classDataStore
- Returns:
- boolean - success
-
getP2PConnection
Description copied from class:DataStore
Get the P2PConnection by streamId- Specified by:
getP2PConnection
in classDataStore
- Parameters:
streamId
- - stream id for P2PConnection- Returns:
- P2PConnection - if exist else null
-
addSubTrack
- Specified by:
addSubTrack
in classDataStore
- Parameters:
mainTrackId
- - main track idsubTrackId
- - main track id- Returns:
- boolean - success
-
removeSubTrack
- Specified by:
removeSubTrack
in classDataStore
- Parameters:
mainTrackId
- - main track idsubTrackId
- - main track id- Returns:
- boolean - success
-
resetBroadcasts
Description copied from class:DataStore
Resets the broadcasts in the database. It sets number of viewers to zero. It also delete the stream if it's zombi stream- Specified by:
resetBroadcasts
in classDataStore
-
getTotalWebRTCViewersCount
public int getTotalWebRTCViewersCount()Description copied from class:DataStore
This is used to get total number of WebRTC viewers- Specified by:
getTotalWebRTCViewersCount
in classDataStore
-
saveViewerInfo
Description copied from class:DataStore
This is used to save WebRTC Viewer Info to datastore- Specified by:
saveViewerInfo
in classDataStore
- Parameters:
info
- information for the WebRTC Viewer
-
getWebRTCViewerList
public List<WebRTCViewerInfo> getWebRTCViewerList(int offset, int size, String sortBy, String orderBy, String search) Description copied from class:DataStore
Get list of webrtc viewers- Specified by:
getWebRTCViewerList
in classDataStore
- Returns:
- list of webrtc viewers
-
deleteWebRTCViewerInfo
Description copied from class:DataStore
This is used to delete a WebRTC Viewer Info from datastore- Specified by:
deleteWebRTCViewerInfo
in classDataStore
- Parameters:
viewerId
- WebRTC Viewer Id
-
updateStreamMetaData
Description copied from class:DataStore
This is used to update meta data for a bradcast- Specified by:
updateStreamMetaData
in classDataStore
- Parameters:
streamId
- id for the broadcastmetaData
- new meta data
-
getSubscriberMetaData
Description copied from class:DataStore
Get subscriber metadata- Specified by:
getSubscriberMetaData
in classDataStore
- Returns:
-
putSubscriberMetaData
Description copied from class:DataStore
Put subscriber metadata. It overwrites the metadata, if you need to update something, first get theDataStore.getSubscriberMetaData(String)
, update it and put it- Specified by:
putSubscriberMetaData
in classDataStore
-
migrateConferenceRoomsToBroadcasts
public void migrateConferenceRoomsToBroadcasts()Description copied from class:DataStore
Move ConferenceRoom to Broadcast- Specified by:
migrateConferenceRoomsToBroadcasts
in classDataStore
-
getSubtracks
Description copied from class:DataStore
Get the subtracks of the main track- Specified by:
getSubtracks
in 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) Description copied from class:DataStore
Get the subtracks of the main track- Specified by:
getSubtracks
in 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 null- Returns:
-
getSubtrackCount
Description copied from class:DataStore
Get the count of subtracks- Specified by:
getSubtrackCount
in 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:DataStore
Get the count of active subtracks. If subtrack is stucked in broadcasting or preparing, it will not count it.- Specified by:
getActiveSubtracksCount
in classDataStore
- Returns:
-
getActiveSubtracks
Description copied from class:DataStore
Get 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:
getActiveSubtracks
in classDataStore
- Returns:
-
hasSubtracks
- Specified by:
hasSubtracks
in classDataStore
- Returns:
- If the stream has subtracks, it return true. If not, it returns false
-