Skip to content

add Subscriber queries #122

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import de.tavendo.autobahn.WebSocket;
import io.antmedia.webrtcandroidframework.core.StreamInfo;
import io.antmedia.webrtcandroidframework.websocket.Broadcast;
import io.antmedia.webrtcandroidframework.websocket.Subscriber;

/**
* Default implementation of {@link IWebRTCListener}
Expand Down Expand Up @@ -258,6 +259,18 @@ public void onLeft(String streamId) {
callbackCalled(messageText);
}

@Override
public void onSubscriberCount(String streamId, int count) {
String messageText = "On Subscriber Count "+streamId;
callbackCalled(messageText);
}

@Override
public void onSubscriberList(String streamId, Subscriber[] subscribers) {
String messageText = "On Subscriber List "+streamId;
callbackCalled(messageText);
}

@Override
public void onPlayAttempt(String streamId) {
String messageText = "Play attempt for stream "+streamId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,20 @@ void publish(String streamId, String token, boolean videoCallEnabled, boolean au
*/
boolean isSendVideoEnabled();

/**
* Called to get the subscriber count for a broadcast
*
* @param streamId: id for the broadcast
*/
void getSubscriberCount(String streamId);

/**
* Called to get the subscriber list for a broadcast
*
* @param streamId: id for the broadcast
* @param offset: offset of the list
* @param size: size of the list
*/
void getSubscriberList(String streamId, long offset, long size);

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import de.tavendo.autobahn.WebSocket;
import io.antmedia.webrtcandroidframework.core.StreamInfo;
import io.antmedia.webrtcandroidframework.websocket.Broadcast;
import io.antmedia.webrtcandroidframework.websocket.Subscriber;

/**
* Created by karinca on 23.10.2017.
Expand Down Expand Up @@ -251,4 +252,14 @@ public interface IWebRTCListener {
* It's called when user left P2P room.
*/
void onLeft(String streamId);

/**
* It's called when Subscriber Count received.
*/
void onSubscriberCount(String streamId, int count);

/**
* It's called when Subscriber List received.
*/
void onSubscriberList(String streamId, Subscriber[] subscribers);
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,29 @@
import io.antmedia.webrtcandroidframework.apprtc.AppRTCAudioManager;
import io.antmedia.webrtcandroidframework.websocket.AntMediaSignallingEvents;
import io.antmedia.webrtcandroidframework.websocket.Broadcast;
import io.antmedia.webrtcandroidframework.websocket.Subscriber;
import io.antmedia.webrtcandroidframework.websocket.WebSocketHandler;

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

@Override
public void onSubscriberCount(String streamId, int count) {
this.handler.post(() -> {
if (config.webRTCListener != null) {
config.webRTCListener.onSubscriberCount(streamId, count);
}
});
}

@Override
public void onSubscriberList(String streamId, Subscriber[] subscribers) {
this.handler.post(() -> {
if (config.webRTCListener != null) {
config.webRTCListener.onSubscriberList(streamId, subscribers);
}
});
}

public enum Mode {
PUBLISH, PLAY, P2P, MULTI_TRACK_PLAY
Expand Down Expand Up @@ -2853,6 +2871,20 @@ public boolean isSendVideoEnabled() {
return sendVideoEnabled;
}

@Override
public void getSubscriberCount(String streamId) {
if (wsHandler != null && wsHandler.isConnected()) {
wsHandler.getSubscriberCount(streamId);
}
}

@Override
public void getSubscriberList(String streamId, long offset, long size) {
if (wsHandler != null && wsHandler.isConnected()) {
wsHandler.getSubscriberList(streamId, offset, size);
}
}

@Override
public boolean isSendAudioEnabled() {
return sendAudioEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,18 @@ public interface AntMediaSignallingEvents {
* @param streamId Peer to peer room name/id.
*/
void onLeft(String streamId);

/**
* It's called when subscriber count received from server
* @param streamId Stream Id
* @param count Count
*/
void onSubscriberCount(String streamId, int count);

/**
* It's called when subscriber list received from server
* @param streamId Stream Id
* @param subscribers subscriber array
*/
void onSubscriberList(String streamId, Subscriber[] subscribers);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.antmedia.webrtcandroidframework.websocket;


public class Subscriber {

private String subscriberId;
private String streamId;
private boolean connected;
private int currentConcurrentConnections = 0;
private int concurrentConnectionsLimit = 1;

public void setSubscriberId(String subscriberId) {
this.subscriberId = subscriberId;
}

public String getSubscriberId() {
return subscriberId;
}

public void setStreamId(String streamId) {
this.streamId = streamId;
}

public String getStreamId() {
return streamId;
}
public boolean isConnected() {
return connected;
}
public void setConnected(boolean connected) {
this.connected = connected;
}

public int getCurrentConcurrentConnections() {
return currentConcurrentConnections;
}

public void setCurrentConcurrentConnections(int currentConcurrentConnections) {
this.currentConcurrentConnections = currentConcurrentConnections;
}

public int getConcurrentConnectionsLimit() {
return concurrentConnectionsLimit;
}

public void setConcurrentConnectionsLimit(int concurrentConnectionsLimit) {
this.concurrentConnectionsLimit = concurrentConnectionsLimit;
}
}
Loading
Loading