Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
burak-58 committed Dec 8, 2023
1 parent 634e89c commit b0071c5
Show file tree
Hide file tree
Showing 20 changed files with 1,373 additions and 296 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@
import android.util.Log;

public class DefaultConferenceWebRTCListener extends DefaultWebRTCListener {
private String roomId;
private String streamId;
private final String roomId;
private final String streamId;

private boolean stoppedStream;
private boolean playOnlyMode = false;
private boolean joined = false;

private boolean videoCallEnabled = true;
private boolean audioCallEnabled = true;
private boolean playMessageSent;

private int ROOM_INFO_POLLING_MILLIS = 5000;
private final int ROOM_INFO_POLLING_MILLIS = 5000;

private Handler handler = new Handler();
private Runnable getRoomInfoRunnable = new Runnable() {
private final Handler handler = new Handler();
private final Runnable getRoomInfoRunnable = new Runnable() {
@Override
public void run() {
getRoomInfo();
Expand Down Expand Up @@ -57,7 +52,6 @@ public void onDisconnected() {
public void onJoinedTheRoom(String streamId, String[] streams) {
super.onJoinedTheRoom(streamId, streams);


if (!webRTCClient.isReconnectionInProgress() && !playOnlyMode) {
publishStream(streamId);
}
Expand All @@ -66,7 +60,6 @@ public void onJoinedTheRoom(String streamId, String[] streams) {
startPlaying(streams);
}

joined = true;
// start periodic polling of room info
scheduleGetRoomInfo();
if (streams.length > 0) {
Expand All @@ -79,12 +72,12 @@ public void onJoinedTheRoom(String streamId, String[] streams) {
public void onLeftTheRoom(String roomId) {
super.onLeftTheRoom(roomId);
clearGetRoomInfoSchedule();
joined = false;
playMessageSent = false;
}

@Override
public void onRoomInformation(String[] streams) {
super.onRoomInformation(streams);
if (webRTCClient != null) {
startPlaying(streams);
}
Expand All @@ -105,8 +98,8 @@ private void clearGetRoomInfoSchedule() {
}

public void publishStream(String streamId) {
if (playOnlyMode) {
webRTCClient.publish(streamId, "", videoCallEnabled, audioCallEnabled, "", "",
if (!playOnlyMode) {
webRTCClient.publish(streamId, "", webRTCClient.getConfig().videoCallEnabled, webRTCClient.getConfig().audioCallEnabled, "", "",
streamId, roomId);
} else {
Log.i(getClass().getSimpleName(), "Play only mode. No publishing");
Expand All @@ -115,7 +108,7 @@ public void publishStream(String streamId) {

private void startPlaying(String[] streams) {
if (!playMessageSent) {
webRTCClient.play(roomId, "", streams, "", "", "");
webRTCClient.play(roomId, streams);
playMessageSent = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

import de.tavendo.autobahn.WebSocket;
import io.antmedia.webrtcandroidframework.core.StreamInfo;
import io.antmedia.webrtcandroidframework.core.WebRTCClientConfig;

public class DefaultWebRTCListener implements IWebRTCListener {
private WebRTCClientConfig config;
protected IWebRTCClient webRTCClient;

public void setWebRTCClient(IWebRTCClient webRTCClient) {
Expand Down Expand Up @@ -109,7 +107,7 @@ public void onNewVideoTrack(VideoTrack track) {
String messageText = "New video track received";
callbackCalled(messageText);

for (SurfaceViewRenderer r : config.remoteVideoRenderers) {
for (SurfaceViewRenderer r : webRTCClient.getConfig().remoteVideoRenderers) {
if (r.getTag() == null) {
r.setTag(track);
webRTCClient.setRendererForVideoTrack(r, track);
Expand All @@ -122,7 +120,7 @@ public void onNewVideoTrack(VideoTrack track) {
public void onVideoTrackEnded(VideoTrack track) {
String messageText = "Video track ended";
callbackCalled(messageText);
for (SurfaceViewRenderer r : config.remoteVideoRenderers) {
for (SurfaceViewRenderer r : webRTCClient.getConfig().remoteVideoRenderers) {
if (r.getTag() == track) {
r.setTag(null);
return;
Expand Down Expand Up @@ -186,12 +184,7 @@ public void onSatatusUpdateFor(String streamId, boolean micStatus, boolean camer
callbackCalled(messageText);
}

@Override
public void setConfig(WebRTCClientConfig webRTCClientConfig) {
this.config = webRTCClientConfig;
}

private void callbackCalled(String messageText) {
protected void callbackCalled(String messageText) {
Log.d(DefaultWebRTCListener.class.getName(), messageText);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
import org.webrtc.VideoTrack;
import org.webrtc.audio.CustomWebRtcAudioRecord;

import io.antmedia.webrtcandroidframework.core.WebRTCClientBuilder;
import io.antmedia.webrtcandroidframework.core.WebRTCClientConfig;

/**
* Created by karinca on 20.10.2017.
*/

public interface IWebRTCClient {


enum StreamSource
{
SCREEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import de.tavendo.autobahn.WebSocket;
import io.antmedia.webrtcandroidframework.core.StreamInfo;
import io.antmedia.webrtcandroidframework.core.WebRTCClientConfig;

/**
* Created by karinca on 23.10.2017.
Expand Down Expand Up @@ -165,11 +164,6 @@ public interface IWebRTCListener {
*/
void onSatatusUpdateFor(String streamId, boolean micStatus, boolean cameraStatus);

/*
* It's called in WebRTCClient constructor when config is set
*/
void setConfig(WebRTCClientConfig webRTCClientConfig);

/*
* It's called in WebRTCClient constructor to set
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.antmedia.webrtcandroidframework.core;
package io.antmedia.webrtcandroidframework.api;

import android.app.Activity;

Expand All @@ -7,8 +7,7 @@

import java.util.Arrays;

import io.antmedia.webrtcandroidframework.api.IDataChannelObserver;
import io.antmedia.webrtcandroidframework.api.IWebRTCListener;
import io.antmedia.webrtcandroidframework.core.WebRTCClient;

public class WebRTCClientBuilder {

Expand All @@ -19,7 +18,6 @@ public WebRTCClientBuilder() {
}

public WebRTCClient build() {
webRTCClientConfig.webRTCListener.setConfig(webRTCClientConfig);
return new WebRTCClient(webRTCClientConfig);
}

Expand Down Expand Up @@ -142,4 +140,8 @@ public WebRTCClientBuilder setReconnectionEnabled(boolean b) {
webRTCClientConfig.reconnectionEnabled = b;
return this;
}

public WebRTCClientConfig getConfig() {
return webRTCClientConfig;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.antmedia.webrtcandroidframework.core;
package io.antmedia.webrtcandroidframework.api;

import android.app.Activity;
import android.content.Intent;
import android.media.projection.MediaProjection;

import org.webrtc.RendererCommon;
Expand Down Expand Up @@ -124,9 +125,9 @@ public class WebRTCClientConfig {

public IDataChannelObserver dataChannelObserver = new DefaultDataChannelObserver();

/*
* MediaProjectionManager for screencapture
*/

public Intent mediaProjectionIntent;

public MediaProjection mediaProjection;
public IWebRTCClient.StreamSource videoSource;
public boolean customVideoCapturerEnabled;
Expand Down
Loading

0 comments on commit b0071c5

Please sign in to comment.