Skip to content

Commit

Permalink
All tests now working in Javascript port. Requires changes to CN1 cor…
Browse files Browse the repository at this point in the history
…e and JS port that will be available friday. codenameone/CodenameOne@d8f491e

shannah/cn1-teavm-port@db6b3e3
  • Loading branch information
shannah committed Sep 10, 2020
1 parent 3e5606d commit 0f7c1c1
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Versions.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
#Wed Sep 09 14:43:51 PDT 2020
#Thu Sep 10 09:57:31 PDT 2020
CodeNameOneBuildClientJar=105
CodenameOne_SRCzip=143
CodenameOneJar=143
Expand Down
Binary file modified bin/webrtc.cn1lib
Binary file not shown.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
vendor="${codename1.vendor}"
subtitle="${codename1.secondaryTitle}"

targetType="javascript"
targetType="debug_javascript_steve"
automated="${automated}"
/>
</target>
Expand Down
1 change: 1 addition & 0 deletions src/com/codename1/webrtc/WebRTCDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void init(Object context) {

// Pro only feature
Log.bindCrashProtection(true);
CN.setEnableAsyncStackTraces(true);

addNetworkErrorListener(err -> {
// prevent the event from propagating
Expand Down
15 changes: 11 additions & 4 deletions src/com/codename1/webrtc/demos/ChangeCodecsDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,17 @@ private void onIceStateChange(RTCPeerConnection pc, Event event) {

private void hangup() {
System.out.println("Ending call");
pc1.close();
pc2.close();
pc1 = null;
pc2 = null;
if (pc1 != null) {
pc1.close();
pc1.release();
pc1 = null;
}
if (pc2 != null) {
pc2.close();
pc2.release();
pc2 = null;
}

hangupButton.setEnabled(false);
callButton.setEnabled(true);
codecPreferences.setEnabled(true);
Expand Down
3 changes: 2 additions & 1 deletion src/com/codename1/webrtc/demos/MungeSdpDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ public MungeSdpDemo() {

FontImage.setMaterialIcon(viewSource, FontImage.MATERIAL_LINK);
viewSource.addActionListener(evt->CN.execute("https://github.com/shannah/CN1WebRTC/blob/master/src/com/codename1/webrtc/demos/MungeSdpDemo.java"));

Log.p("About to create RTC");
RTC.createRTC().ready(rtc->{
Log.p("Inside createRTC() ready callback");
this.rtc = rtc;
Component videoCom = rtc.getVideoComponent();
videoCom.setPreferredH(CN.getDisplayHeight()/2);
Expand Down
15 changes: 11 additions & 4 deletions src/com/codename1/webrtc/demos/PeerConnectionDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,17 @@ private void onIceStateChange(RTCPeerConnection pc, Event event) {

private void hangup() {
System.out.println("Ending call");
pc1.close();
pc2.close();
pc1 = null;
pc2 = null;
if (pc1 != null) {
pc1.close();
pc1.release();
pc1 = null;
}
if (pc2 != null) {
pc2.close();
pc2.release();
pc2 = null;
}

hangupButton.setEnabled(false);
callButton.setEnabled(true);
}
Expand Down
2 changes: 2 additions & 0 deletions src/com/codename1/webrtc/demos/TrickleIceDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ private void addCandidateRow(long time, RTCIceCandidate candidate) {
c.add(tl.createConstraint(row, col++), pipe(candidate.getIp(), ""));
c.add(tl.createConstraint(row, col++), candidate.getPort()+"");
c.add(tl.createConstraint(row, col++), formatPriority(candidate.getPriority()));
revalidateWithAnimationSafety();

}

Expand All @@ -432,6 +433,7 @@ private void addCandidatesTableHeader() {
c.add(tl.createConstraint(0, col++), header);
}
numCandidateRows++;
revalidateWithAnimationSafety();
}


Expand Down
18 changes: 17 additions & 1 deletion webrtc/src/com/codename1/webrtc/RTC.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ private void init(String htmlBody, String css) {
}
web = new BrowserComponent();

// Javascript port breaks RTC stuff if iframe is removed from the document
// so we need to NOT remove iframe until we are actually done.
// This client property will piped to the Javascript native peer, and
// will cause it to NOT be removed from the DOM even when the BrowserComponent
// is deinitialized.
// It will only be removed from the DOM when this flag is set back to true
// in the close() method.
web.putClientProperty("HTML5Peer.removeOnDeinitialize", false);


ActionListener bootstrapCallback = e->{

Expand Down Expand Up @@ -331,6 +340,12 @@ protected void onReady() {
*/
@Override
public void close() throws Exception {
if (web != null) {
// For the javascript port, we had previously set this flag to false so that
// the iframe won't be removed from the DOM when the BrowserComponent is deinitialized.
// But now we need it to be removed since we're closing the rtc session.
web.putClientProperty("HTML5Peer.removeOnDeinitialize", true);
}
for (RefCounted ref : registry.values()) {
if (ref instanceof AutoCloseable) {
((AutoCloseable)ref).close();
Expand All @@ -339,6 +354,7 @@ public void close() throws Exception {
if (cordovaApp != null) {
cordovaApp.dispose();
}

}

/**
Expand Down Expand Up @@ -2935,7 +2951,7 @@ public RTCRtpSender addTrack(MediaStreamTrack track, MediaStream... stream) {
@Override
public void close() {

close(true);
close(false);

}

Expand Down

1 comment on commit 0f7c1c1

@shannah
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.