mirror of
https://github.com/Maschell/StreamingPluginClient.git
synced 2024-12-01 00:44:16 +01:00
Add FPS to toolbar
This commit is contained in:
parent
a6c3332af4
commit
ec8248a49b
@ -84,8 +84,9 @@ public class ImageStreamer {
|
|||||||
while (true) {
|
while (true) {
|
||||||
if (tcpClient.isConnected()) {
|
if (tcpClient.isConnected()) {
|
||||||
System.out.println("FPS:" + framesThisSecond);
|
System.out.println("FPS:" + framesThisSecond);
|
||||||
|
if(Main.win != null) Main.win.setFps(framesThisSecond);
|
||||||
framesThisSecond = 0;
|
framesThisSecond = 0;
|
||||||
}
|
}else if(Main.win != null) Main.win.setFps(-1);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -102,7 +103,15 @@ public class ImageStreamer {
|
|||||||
tcpClient.send(rawCommand);
|
tcpClient.send(rawCommand);
|
||||||
result = true;
|
result = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
result = false;
|
result = false;
|
||||||
|
tcpClient.abort();
|
||||||
|
try {
|
||||||
|
tcpClient.connect();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -142,12 +151,12 @@ public class ImageStreamer {
|
|||||||
private void udpDataHandler(byte[] data) {
|
private void udpDataHandler(byte[] data) {
|
||||||
if (state == DataState.UNKNOWN) {
|
if (state == DataState.UNKNOWN) {
|
||||||
// System.out.println("GET CRC");
|
// System.out.println("GET CRC");
|
||||||
|
// System.out.println("data.length = "+data.length);
|
||||||
if (data.length == 4) {
|
if (data.length == 4) {
|
||||||
ByteBuffer wrapped = ByteBuffer.wrap(data); // big-endian by default
|
ByteBuffer wrapped = ByteBuffer.wrap(data); // big-endian by default
|
||||||
curcrc32 = wrapped.getInt(); // 1
|
curcrc32 = wrapped.getInt(); // 1
|
||||||
state = DataState.CRC32_RECEIVED;
|
state = DataState.CRC32_RECEIVED;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
state = DataState.UNKNOWN;
|
state = DataState.UNKNOWN;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import org.apache.commons.cli.Options;
|
|||||||
import de.mas.wiiu.streaming.gui.StreamWindow;
|
import de.mas.wiiu.streaming.gui.StreamWindow;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
public static StreamWindow win;
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if(GraphicsEnvironment.isHeadless()) {
|
if(GraphicsEnvironment.isHeadless()) {
|
||||||
System.out.println("This program does not support running in a headless environment!");
|
System.out.println("This program does not support running in a headless environment!");
|
||||||
@ -112,7 +112,7 @@ public class Main {
|
|||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
new StreamWindow(imageStreamer.getImageProvider());
|
win = new StreamWindow(imageStreamer.getImageProvider());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,13 @@
|
|||||||
package de.mas.wiiu.streaming.gui;
|
package de.mas.wiiu.streaming.gui;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuBar;
|
import javax.swing.JMenuBar;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
@ -36,7 +38,7 @@ import javax.swing.WindowConstants;
|
|||||||
public class StreamWindow {
|
public class StreamWindow {
|
||||||
private final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
private final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
private final ImagePanel image = new ImagePanel(screenSize.width-15, screenSize.height-100);
|
private final ImagePanel image = new ImagePanel(screenSize.width-15, screenSize.height-100);
|
||||||
|
private final JLabel lblFps = new JLabel(" FPS: Not Connected!");
|
||||||
public StreamWindow(IImageProvider imageProvider) {
|
public StreamWindow(IImageProvider imageProvider) {
|
||||||
|
|
||||||
JFrame editorFrame = new JFrame("Wii U Streaming Client");
|
JFrame editorFrame = new JFrame("Wii U Streaming Client");
|
||||||
@ -71,9 +73,16 @@ public class StreamWindow {
|
|||||||
mnSettings.add(mntmNewMenuItem);
|
mnSettings.add(mntmNewMenuItem);
|
||||||
mnSettings.add(mntmExit);
|
mnSettings.add(mntmExit);
|
||||||
|
|
||||||
|
|
||||||
|
lblFps.setFont(new Font("Tahoma", Font.PLAIN, 11));
|
||||||
|
menuBar.add(lblFps);
|
||||||
|
|
||||||
editorFrame.pack();
|
editorFrame.pack();
|
||||||
editorFrame.setLocationRelativeTo(null);
|
editorFrame.setLocationRelativeTo(null);
|
||||||
editorFrame.setVisible(true);
|
editorFrame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
public void setFps(int fps){
|
||||||
|
if(fps == -1) this.lblFps.setText(" FPS: Not Connected!");
|
||||||
|
else this.lblFps.setText(" FPS: "+fps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ final public class TCPClient {
|
|||||||
public boolean abort() {
|
public boolean abort() {
|
||||||
try {
|
try {
|
||||||
sock.close();
|
sock.close();
|
||||||
|
log.info("TCP client closed");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.info(e.getMessage()); // TODO: handle
|
log.info(e.getMessage()); // TODO: handle
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user