Skip to content

Commit

Permalink
New webhooks playStart, playStop, recordStart issue #4666
Browse files Browse the repository at this point in the history
  • Loading branch information
lastpeony committed Mar 8, 2023
1 parent 2a3a296 commit 0ecec1f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/main/java/io/antmedia/AntMediaApplicationAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ public void closeBroadcast(String streamId) {
final String category = broadcast.getCategory();
final String metaData = broadcast.getMetaData();
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, metaData));

vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_END_LIVE_STREAM, name, category, null, null, null, metaData));
}

if (broadcast.isZombi()) {
Expand Down Expand Up @@ -923,6 +923,7 @@ public StringBuilder sendPOST(String url, Map<String, String> variables) throws
httpPost.setEntity(postParams);

try (CloseableHttpResponse httpResponse = httpClient.execute(httpPost)) {
System.out.println("http response came");
logger.info("POST Response Status:: {}" , httpResponse.getStatusLine().getStatusCode());

HttpEntity entity = httpResponse.getEntity();
Expand Down Expand Up @@ -1067,10 +1068,14 @@ public void setQualityParameters(String id, String quality, double speed, int pe
}

public DataStore getDataStore() {
System.out.println("get data store called");
//vertx should be initialized before calling this method
if(dataStore == null)
{
System.out.println("data store is null");
dataStore = dataStoreFactory.getDataStore();
System.out.println(dataStore);

}
return dataStore;
}
Expand Down Expand Up @@ -1364,7 +1369,7 @@ public synchronized void incrementEncoderNotOpenedError(String streamId) {
final String category = broadcast.getCategory();
final String metaData = broadcast.getMetaData();
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,metaData));
vertx.runOnContext(e -> notifyHook(listenerHookURL, streamId, HOOK_ACTION_ENCODER_NOT_OPENED_ERROR, name, category, null, null, null, metaData));
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/antmedia/statistic/ViewerStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class ViewerStats {

public void registerNewViewer(String streamId, String sessionId, String subscriberId, String viewerPlayType, AntMediaApplicationAdapter antMediaApplicationAdapter)
{
System.out.println("i got called3!");

//do not block the thread, run in vertx event queue
vertx.runOnContext(h -> {
synchronized (lock) {
Expand All @@ -67,7 +69,9 @@ public void registerNewViewer(String streamId, String sessionId, String subscrib
int streamIncrementCounter = getIncreaseCounterMap(streamId);
streamIncrementCounter++;
increaseCounterMap.put(streamId, streamIncrementCounter);

if(subscriberId != null && !subscriberId.equals("undefined")){
System.out.println("send start play web hook with not null subs id");
antMediaApplicationAdapter.sendStartPlayWebHook(viewerPlayType, streamId, subscriberId);
}else{
antMediaApplicationAdapter.sendStartPlayWebHook(viewerPlayType, streamId, sessionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ public void testSetApplicationContext() {

viewerStats.registerNewViewer(streamId, sessionId, null, ViewerStats.DASH_TYPE, antMediaApplicationAdapter);


Awaitility.await().atMost(30, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(
()->viewerStats.getViewerCount(streamId) == 1 );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ public void testSetApplicationContextSubscribers() {
dsf.getDataStore().addSubscriber(subscriberPlay3.getStreamId(), subscriberPlay3);



viewerStats.registerNewViewer(streamId, sessionId, subscriberPlay.getSubscriberId(), ViewerStats.HLS_TYPE, antMediaApplicationAdapter);

Awaitility.await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(
Expand Down Expand Up @@ -366,6 +365,7 @@ public void testSetApplicationContext() {
assertEquals(10000, viewerStats.getTimeoutMS());

String sessionId = "sessionId" + (int)(Math.random() * 10000);
AntMediaApplicationAdapter antMediaApplicationAdapter = mock(AntMediaApplicationAdapter.class);

viewerStats.registerNewViewer(streamId, sessionId, null, ViewerStats.HLS_TYPE, antMediaApplicationAdapter);

Expand Down

0 comments on commit 0ecec1f

Please sign in to comment.