Я создал приложение для потоковой передачи видео с использованием Javafxports. Приложение работает на моем мобильном устройстве huwaei p-smart Android 8, но не может подключиться и загрузить на Android 6 (вкладка Lenovo 10 "). Приложению необходимо обнаружить модуль управления, подключиться к нему и получить данные, определенные в классе FSGuiCommunications (ниже ).
01-17 11:58:30.326 23694 23723 I System.out: Discovering control module in the network1
01-17 11:58:30.328 23694 23723 I System.out: im here1java.net.MulticastSocket@6ba742e
01-17 11:58:30.328 23694 23723 I System.out: im here2/230.0.0.2
01-17 11:58:30.328 23694 23723 I System.out: im here3
01-17 11:58:30.329 23694 23723 I System.out: im here4java.net.DatagramPacket@65dabcf
01-17 11:58:30.329 23694 23723 I System.out: im here5
01-17 11:58:30.335 23694 23720 I System.out: FSGuiCommunications done
01-17 11:58:31.435 23694 23720 W System.err: Loading FontFactory com.sun.javafx.font.freetype.FTFactory
01-17 11:58:31.435 23694 23720 W System.err: Subpixel: enabled
01-17 11:58:31.488 23694 23720 W System.err: Freetype2 Loaded (version 2.5.0)
01-17 11:58:31.488 23694 23720 W System.err: LCD support Enabled
01-17 11:58:31.892 2612 2612 D wpa_supplicant: wlan0: Control interface command 'SIGNAL_POLL'
01-17 11:58:31.905 2612 2612 D wpa_supplicant: CTRL-DEBUG: global_ctrl_sock-sendto: sock=11 sndbuf=163840 outq=0 send_len=48
01-17 11:58:32.689 23694 23720 W art : Before Android 4.1, method double javafx.scene.text.TextFlow.computeChildPrefAreaHeight(javafx.scene.Node, javafx.geometry.Insets) would have incorrectly overridden the package-private method in javafx.scene.layout.Region
01-17 11:58:32.689 23694 23720 W art : Before Android 4.1, method double javafx.scene.text.TextFlow.computeChildPrefAreaWidth(javafx.scene.Node, javafx.geometry.Insets) would have incorrectly overridden the package-private method in javafx.scene.layout.Region
01-17 11:58:32.793 23694 23720 W art : Before Android 4.1, method void com.sun.javafx.scene.transform.TransformUtils$ImmutableTransform.ensureCanTransform2DPoint() would have incorrectly overridden the package-private method in javafx.scene.transform.Transform
01-17 11:58:32.904 23694 23720 I System.out: loading done
01-17 11:58:33.523 23694 23718 I System.out: max rectangle texture cell size = 62
01-17 11:58:33.552 23694 23718 I System.out: wrap rectangle texture = 2 x 2
01-17 11:58:33.558 23694 23718 I System.out: ES2ResourceFactory: Prism - createStockShader: AlphaTexture_Color.frag
01-17 11:58:33.582 23694 23718 I System.out: ES2ResourceFactory: Prism - createStockShader: AlphaTextureDifference_Color.frag
01-17 11:58:33.597 23694 23718 I System.out: ES2ResourceFactory: Prism - createStockShader: Texture_Color.frag
01-17 11:58:33.625 23694 23718 I System.out: ES2ResourceFactory: Prism - createStockShader: FillRoundRect_Color.frag
01-17 11:58:33.639 23694 23718 I System.out: ES2ResourceFactory: Prism - createStockShader: Solid_TextureRGB.frag
01-17 11:58:33.655 23694 23718 I System.out: ES2ResourceFactory: Prism - createStockShader: DrawRoundRect_Color.frag
Это logcat
сгенерированный вывод для Android 6.0.1.
public class FSGuiCommunications extends Thread {
protected MulticastSocket socket = null;
protected byte[] buf = new byte[256];
static FSReceiverCM m_cReceiverCM = null;
int intSenderPort = 6265;
boolean m_bThreadRunning = false;
static boolean preLoaderDiscoveryThread=false;
static boolean preLoaderImgThread=false;
static boolean setStageFlag=false;
static Bitmap currentBitmap;
/*
* Discovering control module in the network
*/
@Override
public void run() {
try {
System.out.println("Discovering control module in the network1");
socket = new MulticastSocket(4444);
System.out.println("im here1"+socket);
InetAddress group = InetAddress.getByName("230.0.0.2");
System.out.println("im here2"+group);
socket.joinGroup(group);
System.out.println("im here3");
DatagramPacket packet = new DatagramPacket(buf, buf.length);
System.out.println("im here4"+packet);
try {
System.out.println("im here5");
socket.receive(packet);
} catch (Exception e) {
System.out.println(e);
}
System.out.println("im here5 again");
String received = new String(packet.getData(), 0, packet.getLength());
System.out.println("im here6"+received);
InetAddress addr = packet.getAddress();
System.out.println("Discovering control module in the network2");
if(addr != null) {
System.out.println("Response from: " + addr);
System.out.println("received: "+received);
preLoaderDiscoveryThread=true;
startServers(addr);
// System.out.println(preLoader_testThread);
}
else {
System.out.println("Not connected to Control Module");
}
System.out.println(preLoaderDiscoveryThread);
socket.leaveGroup(group);
socket.close();
}
catch(IOException e)
{
System.out.println(e);
}
}
/*
* Receive image data from control module
*/
private void startServers(InetAddress address) throws IOException
{
try {
InetAddress local_ip = InetAddress.getLocalHost();
int port = 6562;
System.out.println("startServers");
InetSocketAddress socketAdress = new InetSocketAddress(local_ip, port);
m_cReceiverCM = new FSReceiverCM(socketAdress);
InetSocketAddress GUItoCM = new InetSocketAddress(address, intSenderPort);
m_cReceiverCM.addClientToCM(GUItoCM);
m_cReceiverCM.sendMessageToControlModul("getMCState");
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
String groupID = "233.3.3.2";
int groupPort = 5555;
MulticastSocket socket = new MulticastSocket(groupPort);
InetAddress group = InetAddress.getByName(groupID);
socket.joinGroup(group);
boolean connected = socket.isConnected();
// if(connected)
// GUIMotionComposer.panMusical.setVisible(false);
Thread m_cConnectionThread = new Thread()
{
public void run()
{
byte[] buffer = new byte[600000];
m_bThreadRunning = true;
while (m_bThreadRunning == true) {
try {
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
int iSizeMsg = packet.getLength();
System.out.println("@m_cConnectionThread"+packet);
preLoaderImgThread=true;
// if(iSizeMsg > 0 && getStageFlag()==true)
if(iSizeMsg > 0)
{
Mat frame = new Mat();
buffer = packet.getData();
frame = Imgcodecs.imdecode(new MatOfByte(buffer), Imgcodecs.CV_LOAD_IMAGE_UNCHANGED);
System.out.println(buffer);System.out.println(frame.channels());System.out.println(frame.size());System.out.println(frame);
// Image imageToShow = Utils.mat2Image(frame);
Image imageToShow = Utils.convertMatToImage(frame);
try {
FSMainController.cVideoView.setImage(imageToShow);
} catch (Exception e) {
System.out.println(e);
}
// Utils.onFXThread(mainGui.maincontroller.getImageView().imageProperty(), imageToShow);
}
} catch (IOException e) {
m_bThreadRunning = false;
}
}
}
};
m_cConnectionThread.start();
}
Из logcat я заметил, что управление не перешло в блок startservers () или даже не получило пакет. Связано ли предупреждение с Android 4.1 в logcat с блокировкой потоков? Я не наблюдал такого поведения на своем мобильном устройстве Android 8.
Samsung Android 8.0.1
01-17 13:24:28.756: E/AndroidRuntime(18288): FATAL EXCEPTION: main
01-17 13:24:28.756: E/AndroidRuntime(18288): Process: org.fxgui, PID: 18288
01-17 13:24:28.756: E/AndroidRuntime(18288): java.lang.NumberFormatException: For input string: "56.0dip"
01-17 13:24:28.756: E/AndroidRuntime(18288): at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
01-17 13:24:28.756: E/AndroidRuntime(18288): at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
01-17 13:24:28.756: E/AndroidRuntime(18288): at java.lang.Float.parseFloat(Float.java:452)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.content.res.TypedArray.getFloat(TypedArray.java:416)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.view.ThreadedRenderer.<init>(ThreadedRenderer.java:408)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.view.ThreadedRenderer.create(ThreadedRenderer.java:304)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.view.ViewRootImpl.enableHardwareAcceleration(ViewRootImpl.java:1259)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.view.ViewRootImpl.setView(ViewRootImpl.java:904)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:384)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:101)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3899)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3065)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.app.ActivityThread.-wrap11(Unknown Source:0)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.os.Handler.dispatchMessage(Handler.java:106)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.os.Looper.loop(Looper.java:164)
01-17 13:24:28.756: E/AndroidRuntime(18288): at android.app.ActivityThread.main(ActivityThread.java:7000)
01-17 13:24:28.756: E/AndroidRuntime(18288): at java.lang.reflect.Method.invoke(Native Method)
01-17 13:24:28.756: E/AndroidRuntime(18288): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
01-17 13:24:28.756: E/AndroidRuntime(18288): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)