Skip to content

Commit ade42c0

Browse files
committed
add subscriber messages
1 parent b711369 commit ade42c0

File tree

8 files changed

+460
-7
lines changed

8 files changed

+460
-7
lines changed

webrtc-android-framework/src/main/java/io/antmedia/webrtcandroidframework/api/DefaultWebRTCListener.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import de.tavendo.autobahn.WebSocket;
1111
import io.antmedia.webrtcandroidframework.core.StreamInfo;
1212
import io.antmedia.webrtcandroidframework.websocket.Broadcast;
13+
import io.antmedia.webrtcandroidframework.websocket.Subscriber;
1314

1415
/**
1516
* Default implementation of {@link IWebRTCListener}
@@ -280,4 +281,16 @@ protected void callbackCalled(String messageText) {
280281
Log.d(DefaultWebRTCListener.class.getName(), messageText);
281282
}
282283

284+
@Override
285+
public void onSubscriberCount(String streamId, int count) {
286+
String messageText = "On Subscriber Count "+streamId;
287+
callbackCalled(messageText);
288+
}
289+
290+
@Override
291+
public void onSubscriberList(String streamId, Subscriber[] subscribers) {
292+
String messageText = "On Subscriber List "+streamId;
293+
callbackCalled(messageText);
294+
}
295+
283296
}

webrtc-android-framework/src/main/java/io/antmedia/webrtcandroidframework/api/IWebRTCClient.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,19 @@ void publish(String streamId, String token, boolean videoCallEnabled, boolean au
368368
*/
369369
boolean isSendVideoEnabled();
370370

371+
/**
372+
* Called to get the subscriber count for a broadcast
373+
*
374+
* @param streamId: id for the broadcast
375+
*/
376+
void getSubscriberCount(String streamId);
377+
378+
/**
379+
* Called to get the subscriber list for a broadcast
380+
*
381+
* @param streamId: id for the broadcast
382+
* @param offset: offset of the list
383+
* @param size: size of the list
384+
*/
385+
void getSubscriberList(String streamId, long offset, long size);
371386
}

webrtc-android-framework/src/main/java/io/antmedia/webrtcandroidframework/api/IWebRTCListener.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import de.tavendo.autobahn.WebSocket;
88
import io.antmedia.webrtcandroidframework.core.StreamInfo;
99
import io.antmedia.webrtcandroidframework.websocket.Broadcast;
10+
import io.antmedia.webrtcandroidframework.websocket.Subscriber;
1011

1112
/**
1213
* Created by karinca on 23.10.2017.
@@ -251,4 +252,15 @@ public interface IWebRTCListener {
251252
* It's called when user left P2P room.
252253
*/
253254
void onLeft(String streamId);
255+
256+
257+
/**
258+
* It's called when Subscriber Count received.
259+
*/
260+
void onSubscriberCount(String streamId, int count);
261+
262+
/**
263+
* It's called when Subscriber List received.
264+
*/
265+
void onSubscriberList(String streamId, Subscriber[] subscribers);
254266
}

webrtc-android-framework/src/main/java/io/antmedia/webrtcandroidframework/core/WebRTCClient.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
import org.webrtc.AMSDefaultVideoEncoderFactory;
8686
import io.antmedia.webrtcandroidframework.websocket.AntMediaSignallingEvents;
8787
import io.antmedia.webrtcandroidframework.websocket.Broadcast;
88+
import io.antmedia.webrtcandroidframework.websocket.Subscriber;
8889
import io.antmedia.webrtcandroidframework.websocket.WebSocketHandler;
8990

9091
public class WebRTCClient implements IWebRTCClient, AntMediaSignallingEvents {
@@ -2872,4 +2873,35 @@ public void setLocalAudioTrack(@androidx.annotation.Nullable AudioTrack localAud
28722873
this.localAudioTrack = localAudioTrack;
28732874
}
28742875

2876+
@Override
2877+
public void onSubscriberCount(String streamId, int count) {
2878+
this.handler.post(() -> {
2879+
if (config.webRTCListener != null) {
2880+
config.webRTCListener.onSubscriberCount(streamId, count);
2881+
}
2882+
});
2883+
}
2884+
2885+
@Override
2886+
public void onSubscriberList(String streamId, Subscriber[] subscribers) {
2887+
this.handler.post(() -> {
2888+
if (config.webRTCListener != null) {
2889+
config.webRTCListener.onSubscriberList(streamId, subscribers);
2890+
}
2891+
});
2892+
}
2893+
2894+
@Override
2895+
public void getSubscriberCount(String streamId) {
2896+
if (wsHandler != null && wsHandler.isConnected()) {
2897+
wsHandler.getSubscriberCount(streamId);
2898+
}
2899+
}
2900+
2901+
@Override
2902+
public void getSubscriberList(String streamId, long offset, long size) {
2903+
if (wsHandler != null && wsHandler.isConnected()) {
2904+
wsHandler.getSubscriberList(streamId, offset, size);
2905+
}
2906+
}
28752907
}

webrtc-android-framework/src/main/java/io/antmedia/webrtcandroidframework/websocket/AntMediaSignallingEvents.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,18 @@ public interface AntMediaSignallingEvents {
152152
* @param streamId Peer to peer room name/id.
153153
*/
154154
void onLeft(String streamId);
155+
156+
/**
157+
* It's called when subscriber count received from server
158+
* @param streamId Stream Id
159+
* @param count Count
160+
*/
161+
void onSubscriberCount(String streamId, int count);
162+
163+
/**
164+
* It's called when subscriber list received from server
165+
* @param streamId Stream Id
166+
* @param subscribers subscriber array
167+
*/
168+
void onSubscriberList(String streamId, Subscriber[] subscribers);
155169
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package io.antmedia.webrtcandroidframework.websocket;
2+
3+
4+
public class Subscriber {
5+
6+
private String subscriberId;
7+
private String streamId;
8+
private boolean connected;
9+
private int currentConcurrentConnections = 0;
10+
private int concurrentConnectionsLimit = 1;
11+
12+
public void setSubscriberId(String subscriberId) {
13+
this.subscriberId = subscriberId;
14+
}
15+
16+
public String getSubscriberId() {
17+
return subscriberId;
18+
}
19+
20+
public void setStreamId(String streamId) {
21+
this.streamId = streamId;
22+
}
23+
24+
public String getStreamId() {
25+
return streamId;
26+
}
27+
public boolean isConnected() {
28+
return connected;
29+
}
30+
public void setConnected(boolean connected) {
31+
this.connected = connected;
32+
}
33+
34+
public int getCurrentConcurrentConnections() {
35+
return currentConcurrentConnections;
36+
}
37+
38+
public void setCurrentConcurrentConnections(int currentConcurrentConnections) {
39+
this.currentConcurrentConnections = currentConcurrentConnections;
40+
}
41+
42+
public int getConcurrentConnectionsLimit() {
43+
return concurrentConnectionsLimit;
44+
}
45+
46+
public void setConcurrentConnectionsLimit(int concurrentConnectionsLimit) {
47+
this.concurrentConnectionsLimit = concurrentConnectionsLimit;
48+
}
49+
}

0 commit comments

Comments
 (0)