Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New webhooks playStart, playStop, recordStart issue #4666 #4738

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a029073
New webhooks playStart, playStop, recordStart issue #4666
Jan 3, 2023
88444c5
New webhooks playStart, playStop, recordStart issue #4666
Jan 3, 2023
364d9bd
Merge branch 'newWebHooks' of https://github.com/ant-media/Ant-Media-…
Jan 8, 2023
f4ec03a
New webhooks playStart, playStop, recordStart issue #4666
Jan 9, 2023
671f9fa
New webhooks playStart, playStop, recordStart issue #4666
Jan 9, 2023
a59ec87
new web hooks
Jan 10, 2023
f7297b1
New webhooks playStart, playStop, recordStart issue #4666
Jan 17, 2023
7b12efc
Merge branch 'master' into newWebHooks
lastpeony Jan 17, 2023
0f612e8
New webhooks playStart, playStop, recordStart issue #4666
Jan 17, 2023
8d66694
Merge branch 'newWebHooks' of https://github.com/ant-media/Ant-Media-…
Jan 17, 2023
878221c
New webhooks playStart, playStop, recordStart issue #4666
Jan 17, 2023
7534766
New webhooks playStart, playStop, recordStart issue #4666
Jan 17, 2023
daa8baa
New webhooks playStart, playStop, recordStart issue #4666
Jan 17, 2023
6a38708
New webhooks playStart, playStop, recordStart issue #4666
Jan 17, 2023
5919807
Merge branch 'master' into newWebHooks
Jan 19, 2023
a29f692
jwt passed to hook
Jan 27, 2023
17a73a9
Merge branch 'master' into newWebHooks
Jan 30, 2023
f68330c
stop webrtc player with play token modification.
Feb 2, 2023
26afa11
Merge branch 'master' into newWebHooks
Feb 23, 2023
9f10b5d
Merge branch 'master' into newWebHooks
Mar 3, 2023
c7fb467
Merge master
mekya Jun 13, 2023
4f6b351
Fix test case
mekya Jun 13, 2023
c50d1e9
Merge branch 'master' into newWebHooks
Jun 13, 2023
6b5c02a
refactoring rest call for backwards comp
Jun 14, 2023
f05961f
Merge branch 'master' into newWebHooks
Jun 20, 2023
e25041a
Merge branch 'master' into newWebHooks
Oct 19, 2023
6b8211b
Merge branch 'master' into newWebHooks
Oct 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
New webhooks playStart, playStop, recordStart issue #4666

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch newWebHooks
# Your branch is up to date with 'origin/newWebHooks'.
#
# Changes to be committed:
# modified: src/main/java/io/antmedia/AntMediaApplicationAdapter.java
# modified: src/main/java/io/antmedia/statistic/ViewerStats.java
# modified: src/test/java/io/antmedia/test/AntMediaApplicationAdaptorUnitTest.java
# modified: src/test/java/io/antmedia/test/statistic/DashViewerStatsTest.java
#
93 changes: 78 additions & 15 deletions src/main/java/io/antmedia/AntMediaApplicationAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.util.Queue;
import java.util.Set;

Expand Down Expand Up @@ -47,8 +46,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.errorprone.annotations.NoAllocation;

import io.antmedia.cluster.ClusterNode;
import io.antmedia.cluster.IClusterNotifier;
import io.antmedia.datastore.db.DataStore;
Expand All @@ -65,7 +62,6 @@
import io.antmedia.plugin.api.IFrameListener;
import io.antmedia.plugin.api.IPacketListener;
import io.antmedia.plugin.api.IStreamListener;
import io.antmedia.plugin.api.StreamParametersInfo;
import io.antmedia.rest.RestServiceBase;
import io.antmedia.rest.model.Result;
import io.antmedia.security.AcceptOnlyStreamsInDataStore;
Expand Down Expand Up @@ -99,6 +95,9 @@ public class AntMediaApplicationAdapter extends MultiThreadedApplicationAdapter
public static final String HOOK_ACTION_PUBLISH_TIMEOUT_ERROR = "publishTimeoutError";
public static final String HOOK_ACTION_ENCODER_NOT_OPENED_ERROR = "encoderNotOpenedError";
public static final String HOOK_ACTION_ENDPOINT_FAILED = "endpointFailed";
public static final String HOOK_ACTION_START_PLAY = "playStart";
public static final String HOOK_ACTION_STOP_PLAY = "playStop";
public static final String HOOK_ACTION_START_RECORD = "recordStart";

public static final String STREAMS = "streams";

Expand Down Expand Up @@ -488,7 +487,7 @@ public void closeBroadcast(String streamId) {
final String name = broadcast.getName();
final String category = broadcast.getCategory();
logger.info("Setting timer to call live stream ended hook for stream:{}",streamId );
vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_END_LIVE_STREAM, name, category, null, null, null));
vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_END_LIVE_STREAM, name, category, null, null, null, null));
}

if (broadcast.isZombi()) {
Expand Down Expand Up @@ -539,13 +538,69 @@ public void resetDASHStats(String streamId) {
}
}

public void sendStartPlayWebHook(final String streamId, final String viewerId){
final Broadcast broadcast = getDataStore().get(streamId);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7% of developers fix this issue

THREAD_SAFETY_VIOLATION: Unprotected write. Non-private method AntMediaApplicationAdapter.sendStartPlayWebHook(...) indirectly writes to field this.dataStore outside of synchronization.
Reporting because another access to the same memory occurs on a background thread, although this access may not.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

if(broadcast == null){
lastpeony marked this conversation as resolved.
Show resolved Hide resolved
return;
}
final String listenerHookURL = broadcast.getListenerHookURL();
if (listenerHookURL == null || listenerHookURL.isEmpty()) {
return;
}
final String name = broadcast.getName();
final String category = broadcast.getCategory();
logger.info("Setting timer to call viewer play started hook for stream:{}", streamId);
vertx.setTimer(10, e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_START_PLAY, name, category,
null, null, viewerId, null));
}

public void sendStopPlayWebHook(final String streamId, final String viewerId){
final Broadcast broadcast = getDataStore().get(streamId);
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
if(broadcast == null){
return;
}
final String listenerHookURL = broadcast.getListenerHookURL();
if (listenerHookURL == null || listenerHookURL.isEmpty()) {
return;
}
final String name = broadcast.getName();
final String category = broadcast.getCategory();
logger.info("Setting timer to call viewer play stopped hook for stream:{}", streamId);
vertx.setTimer(10, e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_STOP_PLAY, name, category,
null, null, viewerId, null));
}

public void sendStartRecordWebHook(final String streamId){
final Broadcast broadcast = getDataStore().get(streamId);
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
if(broadcast == null){
return;
}
final String listenerHookURL = broadcast.getListenerHookURL();
if (listenerHookURL == null || listenerHookURL.isEmpty()) {
return;
}
final String name = broadcast.getName();
final String category = broadcast.getCategory();
logger.info("Setting timer to call stream start recording hook for stream:{}", streamId);
vertx.setTimer(10, e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_START_RECORD, name, category,
null, null, null, null));
}

private String getRtmpViewerId(){
return "rtmp_" + RandomStringUtils.randomNumeric(8);
}

@Override
public void streamPlayItemPlay(ISubscriberStream stream, IPlayItem item, boolean isLive) {
vertx.setTimer(1, l -> getDataStore().updateRtmpViewerCount(item.getName(), true));
final String streamId = item.getName();
sendStartPlayWebHook(streamId, getRtmpViewerId());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7% of developers fix this issue

THREAD_SAFETY_VIOLATION: Unprotected write. Non-private method AntMediaApplicationAdapter.streamPlayItemPlay(...) indirectly writes to field this.dataStore outside of synchronization.
Reporting because another access to the same memory occurs on a background thread, although this access may not.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

vertx.setTimer(1, l -> getDataStore().updateRtmpViewerCount(streamId, true));
}
@Override
public void streamPlayItemStop(ISubscriberStream stream, IPlayItem item) {
vertx.setTimer(1, l -> getDataStore().updateRtmpViewerCount(item.getName(), false));
final String streamId = item.getName();
sendStopPlayWebHook(streamId, getRtmpViewerId());
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
vertx.setTimer(1, l -> getDataStore().updateRtmpViewerCount(streamId, false));
}

@Override
Expand All @@ -557,7 +612,6 @@ public void streamSubscriberClose(ISubscriberStream stream) {
public void startPublish(String streamId, long absoluteStartTimeMs, String publishType) {
vertx.executeBlocking( handler -> {
try {

Broadcast broadcast = updateBroadcastStatus(streamId, absoluteStartTimeMs, publishType, getDataStore().get(streamId));

final String listenerHookURL = getListenerHookURL(broadcast);
Expand All @@ -567,7 +621,13 @@ public void startPublish(String streamId, long absoluteStartTimeMs, String publi
final String category = broadcast.getCategory();
logger.info("Setting timer to call live stream started hook for stream:{}",streamId );
vertx.setTimer(10, e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_START_LIVE_STREAM, name, category,
null, null, null));
null, null, null, null));
}

if ((broadcast.getMp4Enabled() == MuxAdaptor.RECORDING_ENABLED_FOR_STREAM || broadcast.getWebMEnabled() == MuxAdaptor.RECORDING_ENABLED_FOR_STREAM)
|| (appSettings.isMp4MuxingEnabled() || appSettings.isWebMMuxingEnabled())
) {
sendStartRecordWebHook(streamId);
}

int ingestingStreamLimit = appSettings.getIngestingStreamLimit();
Expand Down Expand Up @@ -735,7 +795,7 @@ public void muxingFinished(final String streamId, File file, long startTime, lon
final String baseName = vodName.substring(0, index);
String finalListenerHookURL = listenerHookURL;
logger.info("Setting timer for calling vod ready hook for stream:{}", streamId);
vertx.runOnContext(e -> notifyHook(finalListenerHookURL, streamId, HOOK_ACTION_VOD_READY, null, null, baseName, vodIdFinal, null));
vertx.runOnContext(e -> notifyHook(finalListenerHookURL, streamId, HOOK_ACTION_VOD_READY, null, null, baseName, vodIdFinal, null, null));
}

String muxerFinishScript = appSettings.getMuxerFinishScript();
Expand Down Expand Up @@ -806,7 +866,7 @@ public static String getRelativePath(String filePath){
* @return
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
*/
public StringBuilder notifyHook(String url, String id, String action, String streamName, String category,
String vodName, String vodId, String metadata) {
String vodName, String vodId, String viewerId, String metadata) {
StringBuilder response = null;
logger.info("Running notify hook url:{} stream id: {} action:{} vod name:{} vod id:{}", url, id, action, vodName, vodId);
if (url != null && url.length() > 0) {
Expand All @@ -829,6 +889,10 @@ public StringBuilder notifyHook(String url, String id, String action, String str
variables.put("vodId", vodId);
}

if(viewerId != null){
variables.put("viewerId", viewerId);
}

if (metadata != null) {
variables.put("metadata", metadata);
}
Expand Down Expand Up @@ -1304,7 +1368,7 @@ public synchronized void incrementEncoderNotOpenedError(String streamId) {
final String name = broadcast.getName();
final String category = broadcast.getCategory();
logger.info("Setting timer to call encoder not opened error for stream:{}", streamId);
vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_ENCODER_NOT_OPENED_ERROR, name, category, null, null, null));
vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_ENCODER_NOT_OPENED_ERROR, name, category, null, null, null,null));
}
}
}
Expand All @@ -1329,7 +1393,7 @@ public synchronized void publishTimeoutError(String streamId) {
final String name = broadcast.getName();
final String category = broadcast.getCategory();
logger.info("Setting timer to call hook that means live stream is not started to the publish timeout for stream:{}", streamId);
vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_PUBLISH_TIMEOUT_ERROR, name, category, null, null, null));
vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_PUBLISH_TIMEOUT_ERROR, name, category, null, null, null, null));
}
}
}
Expand Down Expand Up @@ -1441,7 +1505,6 @@ private boolean isEncoderSettingsValid(List<EncoderSettings> encoderSettingsList
/**
*
* @param newSettings
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
* @param checkUpdateTime
* @return true if timing is valid, false if it is invalid
*/
public boolean isIncomingTimeValid(AppSettings newSettings)
Expand Down Expand Up @@ -1686,7 +1749,7 @@ public void endpointFailedUpdate(String streamId, String url) {
logger.info("Setting timer to call rtmp endpoint failed hook for stream:{}", streamId);
JSONObject jsonObject = new JSONObject();
jsonObject.put("rtmp-url", url);
vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_ENDPOINT_FAILED, name, category, null, null, jsonObject.toJSONString()));
vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_ENDPOINT_FAILED, name, category, null, null, null, jsonObject.toJSONString()));
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/antmedia/filter/AbstractFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;

import io.antmedia.AntMediaApplicationAdapter;
import org.apache.catalina.util.NetMask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -154,5 +155,16 @@ public Broadcast getBroadcast(String streamId) {
}
return broadcast;
}

protected AntMediaApplicationAdapter getAntMediaApplicationAdapter(){
AntMediaApplicationAdapter antMediaApplicationAdapter = null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11% of developers fix this issue

Var: Non-constant variable missing @var annotation


Suggested change
AntMediaApplicationAdapter antMediaApplicationAdapter = null;
@Var AntMediaApplicationAdapter antMediaApplicationAdapter = null;

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

ApplicationContext context = getAppContext();
if (context != null)
{
antMediaApplicationAdapter= (AntMediaApplicationAdapter)context.getBean(AntMediaApplicationAdapter.BEAN_NAME);
}
return antMediaApplicationAdapter;

}

}
5 changes: 1 addition & 4 deletions src/main/java/io/antmedia/filter/DashStatisticsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public class DashStatisticsFilter extends AbstractFilter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {


HttpServletRequest httpRequest =(HttpServletRequest)request;

String method = httpRequest.getMethod();
Expand All @@ -52,8 +50,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
logger.debug("req ip {} session id {} stream id {} status {}", request.getRemoteHost(), sessionId, streamId, status);
IStreamStats stats = getStreamStats(DashViewerStats.BEAN_NAME);
if (stats != null) {
stats.registerNewViewer(streamId, sessionId, subscriberId);

stats.registerNewViewer(streamId, sessionId, subscriberId, getAntMediaApplicationAdapter());
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/antmedia/filter/HlsStatisticsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
logger.debug("req ip {} session id {} stream id {} status {}", request.getRemoteHost(), sessionId, streamId, status);
IStreamStats stats = getStreamStats(HlsViewerStats.BEAN_NAME);
if (stats != null) {
stats.registerNewViewer(streamId, sessionId, subscriberId);

stats.registerNewViewer(streamId, sessionId, subscriberId, getAntMediaApplicationAdapter());
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/io/antmedia/muxer/MuxAdaptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,6 @@ private Muxer addMp4Muxer() {
* @return
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

21% of developers fix this issue

EmptyBlockTag: A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.


Suggested change
* @return
*

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sonatype-lift ignore

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've recorded this as ignored for this pull request.
If you change your mind, just comment @sonatype-lift unignore.

*/
public RecordMuxer startRecording(RecordType recordType) {

if (!isRecording.get()) {
logger.warn("Starting recording return false for stream:{} because stream is being prepared", streamId);
return null;
Expand All @@ -1692,7 +1691,6 @@ public RecordMuxer startRecording(RecordType recordType) {
return null;
}


RecordMuxer muxer = null;
if(recordType == RecordType.MP4) {
Mp4Muxer mp4Muxer = createMp4Muxer();
Expand Down Expand Up @@ -1862,10 +1860,15 @@ public Result startRtmpStreaming(String rtmpUrl, int resolutionHeight)
}

public void sendEndpointErrorNotifyHook(String url){
AntMediaApplicationAdapter adaptor = getAntMediaApplicationAdaptor();
adaptor.endpointFailedUpdate(this.streamId, url);
}

protected AntMediaApplicationAdapter getAntMediaApplicationAdaptor(){
IContext context = MuxAdaptor.this.scope.getContext();
ApplicationContext appCtx = context.getApplicationContext();
AntMediaApplicationAdapter adaptor = (AntMediaApplicationAdapter) appCtx.getBean(AntMediaApplicationAdapter.BEAN_NAME);
adaptor.endpointFailedUpdate(this.streamId, url);
return adaptor;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/antmedia/statistic/DashViewerStats.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.antmedia.statistic;


import io.antmedia.AntMediaApplicationAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
Expand Down Expand Up @@ -28,11 +29,11 @@ public void setApplicationContext(ApplicationContext applicationContext) {

AppSettings settings = (AppSettings)applicationContext.getBean(AppSettings.BEAN_NAME);
timeoutMS = getTimeoutMSFromSettings(settings, timeoutMS, DASH_TYPE);

final AntMediaApplicationAdapter antMediaApplicationAdapter = (AntMediaApplicationAdapter)applicationContext.getBean(AntMediaApplicationAdapter.BEAN_NAME);
vertx.setPeriodic(DEFAULT_TIME_PERIOD_FOR_VIEWER_COUNT, yt->
{
synchronized (lock) {
lastpeony marked this conversation as resolved.
Show resolved Hide resolved
updateViewerCountProcess(DASH_TYPE);
updateViewerCountProcess(DASH_TYPE, antMediaApplicationAdapter);
}
});
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/io/antmedia/statistic/HlsViewerStats.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.antmedia.statistic;

import io.antmedia.AntMediaApplicationAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
Expand Down Expand Up @@ -28,11 +29,12 @@ public void setApplicationContext(ApplicationContext applicationContext) {

AppSettings settings = (AppSettings)applicationContext.getBean(AppSettings.BEAN_NAME);
timeoutMS = getTimeoutMSFromSettings(settings, timeoutMS, HLS_TYPE);

final AntMediaApplicationAdapter antMediaApplicationAdapter = (AntMediaApplicationAdapter)applicationContext.getBean(AntMediaApplicationAdapter.BEAN_NAME);

vertx.setPeriodic(DEFAULT_TIME_PERIOD_FOR_VIEWER_COUNT, yt->
{
synchronized (lock) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SynchronizeOnNonFinalField: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

updateViewerCountProcess(HLS_TYPE);
updateViewerCountProcess(HLS_TYPE, antMediaApplicationAdapter);
}
});
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/io/antmedia/statistic/IStreamStats.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package io.antmedia.statistic;

import io.antmedia.AntMediaApplicationAdapter;

public interface IStreamStats {

/**
* Register a new viewer to a stream
*
* @param streamId
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

21% of developers fix this issue

EmptyBlockTag: A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.


Suggested change
* @param streamId
*

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

* @param sessionId
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

21% of developers fix this issue

EmptyBlockTag: A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.


Suggested change
* @param sessionId
*

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

*/
void registerNewViewer(String streamId, String sessionId, String subscriberId);
void registerNewViewer(String streamId, String sessionId, String subscriberId, AntMediaApplicationAdapter antMediaApplicationAdapter);


/**
Expand Down
Loading