-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from Kotlin to Java, figure out how to interface with the library
- Loading branch information
1 parent
180df79
commit 94d06e5
Showing
27 changed files
with
2,975 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/> | ||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
<classpathentry kind="output" path="bin/default"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>flutter_ndi</name> | ||
<comment>Project flutter_ndi created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
connection.project.dir=../../andi/android | ||
eclipse.preferences.version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
android/src/main/java/com/example/flutter_ndi/FlutterNdiPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package com.example.flutter_ndi; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import io.flutter.embedding.engine.plugins.FlutterPlugin; | ||
import io.flutter.plugin.common.MethodCall; | ||
import io.flutter.plugin.common.MethodChannel; | ||
import io.flutter.plugin.common.BinaryMessenger; | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
import io.flutter.plugin.common.MethodChannel.Result; | ||
|
||
/// | ||
import android.net.nsd.NsdManager; | ||
import android.net.nsd.NsdServiceInfo; | ||
import android.content.Context; | ||
import android.content.ContextWrapper; | ||
/// | ||
|
||
/** FlutterNdiPlugin */ | ||
public class FlutterNdiPlugin implements FlutterPlugin, MethodCallHandler { | ||
/// The MethodChannel that will the communication between Flutter and native | ||
/// Android | ||
/// | ||
/// This local reference serves to register the plugin with the Flutter Engine | ||
/// and unregister it | ||
/// when the Flutter Engine is detached from the Activity | ||
private MethodChannel channel; | ||
private Context mContext; | ||
private static NsdManager m_nsdManager = null; | ||
|
||
@Override | ||
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { | ||
onAttachedToEngine(binding.getApplicationContext(), binding.getBinaryMessenger()); | ||
} | ||
|
||
private void onAttachedToEngine(Context applicationContext, BinaryMessenger messenger) { | ||
this.mContext = applicationContext; | ||
channel = new MethodChannel(messenger, "flutter_ndi"); | ||
channel.setMethodCallHandler(this); | ||
} | ||
|
||
@Override | ||
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { | ||
switch (call.method) { | ||
case "getPlatformVersion": | ||
result.success("Android ${android.os.Build.VERSION.RELEASE}"); | ||
break; | ||
case "init_os": | ||
if (m_nsdManager == null) { | ||
m_nsdManager = (NsdManager) mContext.getSystemService(Context.NSD_SERVICE); | ||
|
||
NsdServiceInfo serviceInfo = new NsdServiceInfo(); | ||
serviceInfo.setServiceName("aNDI"); | ||
serviceInfo.setServiceType("_ndi._tcp."); | ||
serviceInfo.setPort(1522); | ||
|
||
m_nsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, new NsdManager.RegistrationListener() { | ||
|
||
@Override | ||
public void onServiceRegistered(NsdServiceInfo NsdServiceInfo) { | ||
// Save the service name. Android may have changed it in order to | ||
// resolve a conflict, so update the name you initially requested | ||
// with the name Android actually used. | ||
// mServiceName = NsdServiceInfo.getServiceName(); | ||
} | ||
|
||
@Override | ||
public void onRegistrationFailed(NsdServiceInfo serviceInfo, int errorCode) { | ||
// Registration failed! Put debugging code here to determine why. | ||
} | ||
|
||
@Override | ||
public void onServiceUnregistered(NsdServiceInfo arg0) { | ||
// Service has been unregistered. This only happens when you call | ||
// NsdManager.unregisterService() and pass in this listener. | ||
} | ||
|
||
@Override | ||
public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int errorCode) { | ||
// Unregistration failed. Put debugging code here to determine why. | ||
} | ||
|
||
}); | ||
} | ||
result.success(true); | ||
break; | ||
|
||
default: | ||
result.notImplemented(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { | ||
channel.setMethodCallHandler(null); | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
android/src/main/kotlin/com/example/flutter_ndi/FlutterNdiPlugin.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
example/android/app/src/main/java/com/example/flutter_ndi_example/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.flutter_ndi_example; | ||
|
||
import io.flutter.embedding.android.FlutterActivity; | ||
|
||
public class MainActivity extends FlutterActivity { | ||
} |
6 changes: 0 additions & 6 deletions
6
example/android/app/src/main/kotlin/com/example/flutter_ndi_example/MainActivity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.