Skip to content

Commit 5b13ce7

Browse files
committed
add Subscriber queries
1 parent cc80c08 commit 5b13ce7

File tree

11 files changed

+631
-6
lines changed

11 files changed

+631
-6
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}
@@ -258,6 +259,18 @@ public void onLeft(String streamId) {
258259
callbackCalled(messageText);
259260
}
260261

262+
@Override
263+
public void onSubscriberCount(String streamId, int count) {
264+
String messageText = "On Subscriber Count "+streamId;
265+
callbackCalled(messageText);
266+
}
267+
268+
@Override
269+
public void onSubscriberList(String streamId, Subscriber[] subscribers) {
270+
String messageText = "On Subscriber List "+streamId;
271+
callbackCalled(messageText);
272+
}
273+
261274
@Override
262275
public void onPlayAttempt(String streamId) {
263276
String messageText = "Play attempt for stream "+streamId;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,20 @@ 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);
386+
371387
}

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

Lines changed: 11 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,14 @@ public interface IWebRTCListener {
251252
* It's called when user left P2P room.
252253
*/
253254
void onLeft(String streamId);
255+
256+
/**
257+
* It's called when Subscriber Count received.
258+
*/
259+
void onSubscriberCount(String streamId, int count);
260+
261+
/**
262+
* It's called when Subscriber List received.
263+
*/
264+
void onSubscriberList(String streamId, Subscriber[] subscribers);
254265
}

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
@@ -86,11 +86,29 @@
8686
import io.antmedia.webrtcandroidframework.apprtc.AppRTCAudioManager;
8787
import io.antmedia.webrtcandroidframework.websocket.AntMediaSignallingEvents;
8888
import io.antmedia.webrtcandroidframework.websocket.Broadcast;
89+
import io.antmedia.webrtcandroidframework.websocket.Subscriber;
8990
import io.antmedia.webrtcandroidframework.websocket.WebSocketHandler;
9091

9192
public class WebRTCClient implements IWebRTCClient, AntMediaSignallingEvents {
9293
private static final String TAG = "WebRTCClient";
9394

95+
@Override
96+
public void onSubscriberCount(String streamId, int count) {
97+
this.handler.post(() -> {
98+
if (config.webRTCListener != null) {
99+
config.webRTCListener.onSubscriberCount(streamId, count);
100+
}
101+
});
102+
}
103+
104+
@Override
105+
public void onSubscriberList(String streamId, Subscriber[] subscribers) {
106+
this.handler.post(() -> {
107+
if (config.webRTCListener != null) {
108+
config.webRTCListener.onSubscriberList(streamId, subscribers);
109+
}
110+
});
111+
}
94112

95113
public enum Mode {
96114
PUBLISH, PLAY, P2P, MULTI_TRACK_PLAY
@@ -2853,6 +2871,20 @@ public boolean isSendVideoEnabled() {
28532871
return sendVideoEnabled;
28542872
}
28552873

2874+
@Override
2875+
public void getSubscriberCount(String streamId) {
2876+
if (wsHandler != null && wsHandler.isConnected()) {
2877+
wsHandler.getSubscriberCount(streamId);
2878+
}
2879+
}
2880+
2881+
@Override
2882+
public void getSubscriberList(String streamId, long offset, long size) {
2883+
if (wsHandler != null && wsHandler.isConnected()) {
2884+
wsHandler.getSubscriberList(streamId, offset, size);
2885+
}
2886+
}
2887+
28562888
@Override
28572889
public boolean isSendAudioEnabled() {
28582890
return sendAudioEnabled;

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)