Skip to content

Commit

Permalink
Fixed camera selection issue on old androids.
Browse files Browse the repository at this point in the history
  • Loading branch information
Narek committed Sep 5, 2016
1 parent 72072b6 commit f927d17
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/android/com/dooble/phonertc/PhoneRTCPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ public void run() {
_initializedAndroidGlobals = true;
}

_isFrontCamera = config.isFrontCamera();

if (_peerConnectionFactory == null) {
_peerConnectionFactory = new PeerConnectionFactory();
}
Expand Down Expand Up @@ -227,6 +225,8 @@ public void run() {
});
} else if (action.equals("switchCamera")) {
switchCamera();
} else if (action.equals("selectCamera")) {
_isFrontCamera = args.getBoolean(0);
}

callbackContext.error("Invalid action: " + action);
Expand Down
13 changes: 0 additions & 13 deletions src/android/com/dooble/phonertc/SessionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class SessionConfig {
private String _turnServerPassword;
private boolean _audioStreamEnabled;
private boolean _videoStreamEnabled;
private boolean _isFrontCamera;

public String getTurnServerHost() {
return _turnServerHost;
Expand Down Expand Up @@ -60,15 +59,6 @@ public void setVideoStreamEnabled(boolean _videoStreamEnabled) {
this._videoStreamEnabled = _videoStreamEnabled;
}

public boolean isFrontCamera() {
return _isFrontCamera;
}

public void setFrontCamera(boolean isFrontCamera) {
this._isFrontCamera = isFrontCamera;
}


public static SessionConfig fromJSON(JSONObject json) throws JSONException {
SessionConfig config = new SessionConfig();
config.setInitiator(json.getBoolean("isInitiator"));
Expand All @@ -81,9 +71,6 @@ public static SessionConfig fromJSON(JSONObject json) throws JSONException {
JSONObject streams = json.getJSONObject("streams");
config.setAudioStreamEnabled(streams.getBoolean("audio"));
config.setVideoStreamEnabled(streams.getBoolean("video"));
if(config.isVideoStreamEnabled()) {
config.setFrontCamera(streams.getJSONObject("video").getString("facingMode") == "user");
}

return config;
}
Expand Down
8 changes: 4 additions & 4 deletions www/phonertc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ function Session(config) {
};
}

//Small hack to make the original config parser on iOS to work
//Small hack to make the original config parser work
if (config.streams.video) {
var strms = config.streams;
strms.video = true;//Overriding {video:{facingMode: user}} format
config.streams = strms;
var streams = config.streams;
streams.video = true;//Overriding {video:{facingMode: user}} format
config.streams = streams;
}

if (typeof config.isInitiator === 'undefined' ||
Expand Down

0 comments on commit f927d17

Please sign in to comment.