Skip to content
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

switching handling #8

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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Aug 30 13:59:30 EEST 2016
#Fri Apr 26 16:01:04 PKT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
11 changes: 5 additions & 6 deletions webrtcpeer-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ apply plugin: "com.jfrog.bintray"
version "1.1.1"

android {
compileSdkVersion 25
buildToolsVersion '23.0.2'
compileSdkVersion 28

defaultConfig {
minSdkVersion 15
targetSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.1.1"
}
Expand All @@ -24,9 +23,9 @@ android {

dependencies {
// compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile('fi.vtt.nubomedia:utilities-android:1.0.2@aar') { transitive=true }
compile('io.pristine:libjingle:11139@aar') { transitive=true }
testImplementation 'junit:junit:4.12'
implementation('fi.vtt.nubomedia:utilities-android:1.0.2@aar') { transitive=true }
implementation('io.pristine:libjingle:11139@aar') { transitive=true }
}

def siteUrl = 'https://github.com/nubomedia-vtt/webrtcpeer-android' // Homepage URL of the library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ final class MediaResourceManager implements NBMWebRTCPeer.Observer {
private MediaConstraints audioConstraints;
private MediaConstraints sdpMediaConstraints;
private boolean videoCallEnabled;
private boolean renderVideo;
private boolean renderLocalVideo;
private boolean renderRemoteVideo;
private boolean videoSourceStopped;
private MediaStream localMediaStream;
private VideoSource videoSource;
Expand All @@ -121,7 +122,8 @@ final class MediaResourceManager implements NBMWebRTCPeer.Observer {
this.localMediaStream = null;
this.executor = executor;
this.factory = factory;
renderVideo = true;
renderLocalVideo = true;
renderRemoteVideo = true;
remoteVideoTracks = new HashMap<>();
remoteVideoRenderers = new HashMap<>();
remoteVideoMediaStreams = new HashMap<>();
Expand Down Expand Up @@ -238,7 +240,7 @@ public void run() {
private VideoTrack createCapturerVideoTrack(VideoCapturerAndroid capturer) {
videoSource = factory.createVideoSource(capturer, videoConstraints);
localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource);
localVideoTrack.setEnabled(renderVideo);
localVideoTrack.setEnabled(renderLocalVideo);
localVideoTrack.addRenderer(new VideoRenderer(localRender));
return localVideoTrack;
}
Expand All @@ -259,7 +261,7 @@ public void run() {
// Get the video track
VideoTrack remoteVideoTrack = remoteStream.videoTracks.get(0);
// Set video track enabled if we have enabled video rendering
remoteVideoTrack.setEnabled(renderVideo);
remoteVideoTrack.setEnabled(renderRemoteVideo);

VideoRenderer videoRenderer = remoteVideoRenderers.get(remoteRender);
if (videoRenderer != null) {
Expand Down Expand Up @@ -375,23 +377,35 @@ public void run() {
});
}

void setVideoEnabled(final boolean enable) {
void setLocalVideoEnabled(final boolean enable) {
executor.execute(new Runnable() {
@Override
public void run() {
renderVideo = enable;
renderLocalVideo = enable;
if (localVideoTrack != null) {
localVideoTrack.setEnabled(renderVideo);
localVideoTrack.setEnabled(renderLocalVideo);
}
}
});
}

void setRemoteVideoEnabled(final boolean enable) {
executor.execute(new Runnable() {
@Override
public void run() {
renderRemoteVideo = enable;
for (VideoTrack tv : remoteVideoTracks.values()) {
tv.setEnabled(renderVideo);
tv.setEnabled(renderRemoteVideo);
}
}
});
}

boolean getVideoEnabled(){
return renderVideo;
boolean getRemoteVideoEnabled(){
return renderRemoteVideo;
}
boolean getLocalVideoEnabled(){
return renderLocalVideo;
}

boolean hasCameraPosition(NBMMediaConfiguration.NBMCameraPosition position){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ public SignalingParameters(
* Peer connection parameters.
*/
public static class NBMPeerConnectionParameters {
public final boolean videoCallEnabled;
public final boolean loopback;
public boolean videoCallEnabled;
public boolean loopback;
public final int videoWidth;
public final int videoHeight;
public final int videoFps;
Expand Down Expand Up @@ -608,7 +608,7 @@ public boolean hasCameraPosition(NBMMediaConfiguration.NBMCameraPosition positio
*/
@SuppressWarnings("unused")
public boolean videoEnabled(){
return mediaResourceManager.getVideoEnabled();
return mediaResourceManager.getRemoteVideoEnabled();
}

/**
Expand All @@ -617,7 +617,7 @@ public boolean videoEnabled(){
*/
@SuppressWarnings("unused")
public void enableVideo(boolean enable){
mediaResourceManager.setVideoEnabled(enable);
mediaResourceManager.setLocalVideoEnabled(enable);
}

/**
Expand Down