Skip to content

Commit

Permalink
Merge pull request #1 from hypothermic/debug
Browse files Browse the repository at this point in the history
Add an optional RTSP port field to the connect screen.
  • Loading branch information
hypothermic committed Oct 12, 2018
2 parents d63905c + ab044dc commit f984bb6
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/main/java/nl/hypothermic/fscviewer/FoscamViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class FoscamViewer extends Application {
private InterfaceController ic;
private static XLogger log = new XLogger(System.out);


@Override
public void start(Stage xs) throws IOException {
this.xs = xs;
Expand Down Expand Up @@ -75,7 +76,7 @@ public static void main(String[] args) {
}
}
}
avutil.av_log_set_level(avutil.AV_LOG_QUIET);
avutil.av_log_set_level(avutil.AV_LOG_INFO);
launch(args);
}
}
7 changes: 4 additions & 3 deletions src/main/java/nl/hypothermic/fscviewer/ui/Interface.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
<CheckBox fx:id="btnExit" mnemonicParsing="false" onAction="#onExitRequested" styleClass="iface-logo-exitbtn" textAlignment="RIGHT" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="4.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
<AnchorPane fx:id="connectPane" prefHeight="620.0" prefWidth="1080.0" styleClass="iface-connect" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<AnchorPane fx:id="connectPane" prefHeight="620.0" prefWidth="1080.0" styleClass="iface-connect" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<AnchorPane layoutX="441.0" layoutY="167.0" prefHeight="200.0" prefWidth="200.0" styleClass="iface-connect-subground" AnchorPane.bottomAnchor="175.0" AnchorPane.leftAnchor="325.0" AnchorPane.rightAnchor="325.0" AnchorPane.topAnchor="175.0">
<children>
Expand All @@ -225,15 +225,16 @@
</Text>
</children>
</TextFlow>
<TextField fx:id="connectAddr" layoutX="16.0" layoutY="69.0" prefHeight="27.0" prefWidth="287.0" promptText="%iface.connect.fields.address" styleClass="iface-connect-field" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="126.0" AnchorPane.topAnchor="67.0" />
<TextField fx:id="connectAddr" layoutX="16.0" layoutY="69.0" prefHeight="27.0" prefWidth="287.0" promptText="%iface.connect.fields.address" styleClass="iface-connect-field" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="196.0" AnchorPane.topAnchor="67.0" />
<TextField fx:id="connectUser" layoutX="15.0" layoutY="101.0" prefHeight="27.0" prefWidth="186.0" promptText="%iface.connect.fields.username" styleClass="iface-connect-field" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="215.0" AnchorPane.topAnchor="100.0" />
<TextField fx:id="connectPort" layoutX="304.0" layoutY="69.0" prefHeight="27.0" prefWidth="110.0" promptText="%iface.connect.fields.port" styleClass="iface-connect-field" AnchorPane.leftAnchor="304.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="67.0" />
<TextField fx:id="connectPortHttp" layoutX="243.0" layoutY="68.0" prefHeight="27.0" prefWidth="88.0" promptText="%iface.connect.fields.port.http" styleClass="iface-connect-field" AnchorPane.leftAnchor="233.0" AnchorPane.rightAnchor="106.0" AnchorPane.topAnchor="67.0" />
<PasswordField fx:id="connectPwd" layoutX="243.0" layoutY="102.0" promptText="%iface.connect.fields.password" styleClass="iface-connect-field" AnchorPane.leftAnchor="215.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="100.0" />
<Button fx:id="connectBtn" layoutX="14.0" layoutY="229.0" mnemonicParsing="false" onAction="#onConnectRequested" prefHeight="25.0" prefWidth="401.0" styleClass="iface-connect-btn" text="%iface.connect.connectbutton" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" />
<ProgressBar fx:id="connectBar" layoutX="118.0" layoutY="230.0" maxHeight="25.0" minHeight="25.0" prefHeight="25.0" prefWidth="200.0" progress="0.0" styleClass="iface-connect-bar" visible="false" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" />
<ListView fx:id="protocolField" layoutX="17.0" layoutY="136.0" nodeOrientation="LEFT_TO_RIGHT" orientation="HORIZONTAL" prefHeight="27.0" prefWidth="197.0" styleClass="iface-connect-protocol" AnchorPane.leftAnchor="16.0" AnchorPane.rightAnchor="215.0" AnchorPane.topAnchor="135.0" />
<ListView fx:id="codecField" layoutX="216.0" layoutY="136.0" nodeOrientation="LEFT_TO_RIGHT" orientation="HORIZONTAL" prefHeight="27.0" prefWidth="197.0" styleClass="iface-connect-protocol" AnchorPane.leftAnchor="215.0" AnchorPane.rightAnchor="14.0" />
<Label fx:id="errorField" alignment="CENTER" layoutX="14.0" layoutY="54.0" prefHeight="15.0" prefWidth="401.0" text="%iface.connect.error.failed" textAlignment="CENTER" textFill="RED" visible="false" />
<TextField fx:id="connectPortRtsp" layoutX="326.0" layoutY="68.0" opacity="0.6" prefHeight="27.0" prefWidth="88.0" promptText="%iface.connect.fields.port.rtsp" styleClass="iface-connect-field" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="67.0" />
</children>
</AnchorPane>
<Line endX="200.0" startX="-200.0" stroke="WHITE" AnchorPane.leftAnchor="339.5" AnchorPane.rightAnchor="339.5" AnchorPane.topAnchor="224.5" />
Expand Down
62 changes: 46 additions & 16 deletions src/main/java/nl/hypothermic/fscviewer/ui/InterfaceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@
import nl.hypothermic.fscviewer.ui.dynamic.ISingleDialogListener;
import nl.hypothermic.fscviewer.ui.dynamic.SingleDialog;

/*******************************
* \ > InterfaceController.java * FoscamViewer by hypothermic * www.github.com/hypothermic/ * See LICENSE.md for legal * \
*******************************/
/*******************************\
* > InterfaceController.java *
* FoscamViewer by hypothermic *
* www.github.com/hypothermic/ *
* See LICENSE.md for legal *
\*******************************/

public class InterfaceController implements IController {

Expand Down Expand Up @@ -115,18 +118,38 @@ public class InterfaceController implements IController {
@Override public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.TAB) {
event.consume();
connectPort.requestFocus();
connectPortHttp.requestFocus();
}
}
});
connectPort.textProperty().addListener(new ChangeListener<String>() {
connectPortHttp.textProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if (!newValue.matches("\\d*")) {
connectPort.setText(newValue.replaceAll("\\D", ""));
connectPortHttp.setText(newValue.replaceAll("\\D", ""));
}
}
});
connectPort.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
connectPortHttp.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
@Override public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.TAB) {
event.consume();
connectPortRtsp.requestFocus();
}
}
});
connectPortRtsp.textProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if (!newValue.matches("\\d*")) {
connectPortHttp.setText(newValue.replaceAll("\\D", ""));
}
if (newValue.length() >= 1) {
connectPortRtsp.setOpacity(1.0);
} else {
connectPortRtsp.setOpacity(0.6);
}
}
});
connectPortRtsp.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
@Override public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.TAB) {
event.consume();
Expand All @@ -151,7 +174,7 @@ public class InterfaceController implements IController {
codecField.getSelectionModel().select(0);
try {
connectAddr.setText(System.getenv("fscviewer.cam_addr"));
connectPort.setText(System.getenv("fscviewer.cam_port"));
connectPortHttp.setText(System.getenv("fscviewer.cam_port"));
connectUser.setText(System.getenv("fscviewer.cam_username"));
connectPwd.setText(System.getenv("fscviewer.cam_password"));
} catch (Exception e) {
Expand Down Expand Up @@ -248,7 +271,8 @@ public void write(int data) {
// --- Connect screen --- //
@FXML private AnchorPane connectPane;
@FXML private TextField connectAddr;
@FXML private TextField connectPort;
@FXML private TextField connectPortHttp;
@FXML private TextField connectPortRtsp;
@FXML private TextField connectUser;
@FXML private TextField connectPwd;
@FXML private ListView protocolField;
Expand All @@ -262,24 +286,29 @@ public void write(int data) {
errorField.setVisible(false);
connectBar.setVisible(true);
connectBar.setProgress(ProgressBar.INDETERMINATE_PROGRESS);
int httpPort, rtspPort;
try {
if (connectAddr.getText().isEmpty() || connectUser.getText().isEmpty() || connectPwd.getText().isEmpty())
throw new NumberFormatException();
Integer.parseInt(connectPort.getText());
httpPort = Integer.parseInt(connectPortHttp.getText());
if (connectPortRtsp.getText().length() >= 1) {
rtspPort = Integer.parseInt(connectPortRtsp.getText());
} else {
rtspPort = Integer.parseInt(connectPortHttp.getText());
}
} catch (NumberFormatException nfx) {
nfx.printStackTrace();
System.out.println("2");
onConnectFailed();
return;
}
threadpool.execute(new Runnable() {
@Override public void run() {
TransmissionProtocol prot = TransmissionProtocol.match(protocolField.getSelectionModel().getSelectedIndex());
VideoCodec codec = VideoCodec.match(codecField.getSelectionModel().getSelectedIndex());
s = new Session(connectAddr.getText(), Integer.parseInt(connectPort.getText()), connectUser.getText(), connectPwd.getText(), videoView, prot, codec);
s = new Session(connectAddr.getText(), Integer.parseInt(connectPortHttp.getText()), connectUser.getText(), connectPwd.getText(), videoView, prot, codec);
try {
s.ctrlcl.connect();
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("rtsp://" + connectUser.getText() + ":" + connectPwd.getText() + "@" + connectAddr.getText() + ":" + Integer.parseInt(connectPort.getText()) + "/videoMain");
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("rtsp://" + connectUser.getText() + ":" + connectPwd.getText() + "@" + connectAddr.getText() + ":" + rtspPort + "/videoMain");
if (prot == TransmissionProtocol.UDP) {
grabber.setOption("rtsp_transport", "udp");
} else if (prot == TransmissionProtocol.TCP) {
Expand All @@ -303,7 +332,6 @@ public void write(int data) {
}
});
} catch (Exception e) {
System.out.println("1 - " + e.getMessage());
e.printStackTrace();
Platform.runLater(new Runnable() {
@Override public void run() {
Expand Down Expand Up @@ -863,9 +891,11 @@ public void write(int data) {
@FXML private PieChart storageChart;

/*-*/ private void onStorageInit() {
System.out.println("Free: " + Session.f.getFreeStorageCapacity());
System.out.println("Used: " + Session.f.getTotalStorageCapacity());
storageChart.setData(FXCollections.observableArrayList(
new PieChart.Data("Free", Session.f.getFreeStorageCapacity().intValueExact()),
new PieChart.Data("Used", Session.f.getTotalStorageCapacity().intValueExact() - Session.f.getFreeStorageCapacity().intValueExact())));
new PieChart.Data("Free", (Session.f.getFreeStorageCapacity().intValueExact())),
new PieChart.Data("Used", ((Session.f.getTotalStorageCapacity().intValueExact() - Session.f.getFreeStorageCapacity().intValueExact())))));
}

// --- Video view --- //
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/locale/i18n_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ iface.locale.translator = hypothermic
### Connect/login screen:
iface.connect.title = Connect to a Foscam
iface.connect.fields.address = Address
iface.connect.fields.port = Port
iface.connect.fields.port.http = WebPort
iface.connect.fields.port.rtsp = RtspPort
iface.connect.fields.username = Username
iface.connect.fields.password = Password
iface.connect.connectbutton = Connect
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/locale/i18n_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ iface.locale.translator = hypothermic
### Connect/login screen:
iface.connect.title = Verbinden met een Foscam
iface.connect.fields.address = Adres
iface.connect.fields.port = Poort
iface.connect.fields.port.http = WebPoort
iface.connect.fields.port.rtsp = RtspPoort
iface.connect.fields.username = Gebruikersnaam
iface.connect.fields.password = Wachtwoord
iface.connect.connectbutton = Verbind
Expand Down

0 comments on commit f984bb6

Please sign in to comment.