Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions android/app/src/main/java/com/openipc/decoder/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -863,13 +863,15 @@ private void refreshUdpHint() {
if (!text.contentEquals(hint.getText())) hint.setText(text);
}

/** Hint of the U cell: every usable IPv4 address of the device, one per line (#87). */
/**
* Hint of the U cell: every usable IPv4 address of the device, one per line (#87). The
* addresses carry the port, so no separate port line.
*/
static String udpHintText(List<String> ips, int port) {
StringBuilder target = new StringBuilder();
for (String ip : ips) target.append('\n').append(ip).append(':').append(port);
if (target.length() == 0) target.append("\nthis device:").append(port);
return "UDP RTP \u00b7 port " + port + "\nWaiting for a stream\u2026\n\n"
+ "Send the camera's RTP/UDP output to" + target;
return "Waiting for a stream\u2026\n\nSend the camera's RTP/UDP output to\n" + target;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.openipc.decoder;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
Expand Down Expand Up @@ -50,7 +51,8 @@ public void emptyOrMissingUpperSlotsDoNotCount() {
@Test
public void udpCellHintNamesPortAndAddress() {
String t = Decoder.udpHintText(java.util.Arrays.asList("192.168.1.20"), 5600);
assertTrue(t.contains("UDP RTP"));
assertTrue(t, t.startsWith("Waiting for a stream"));
assertFalse(t, t.contains("UDP RTP"));
assertTrue(t.contains("192.168.1.20:5600"));
// Without a known address the hint still tells where to send the stream
assertTrue(Decoder.udpHintText(java.util.Collections.emptyList(), 5600)
Expand All @@ -69,9 +71,9 @@ public void udpHintListsEveryAddress() {
String none = Decoder.udpHintText(java.util.Collections.emptyList(), 5600);
assertTrue(none, none.endsWith("\nthis device:5600"));
String one = Decoder.udpHintText(java.util.Arrays.asList("172.17.32.144"), 5600);
assertTrue(one, one.endsWith("output to\n172.17.32.144:5600"));
assertTrue(one, one.endsWith("output to\n\n172.17.32.144:5600"));
String two = Decoder.udpHintText(
java.util.Arrays.asList("172.17.32.144", "192.168.1.20"), 5600);
assertTrue(two, two.endsWith("output to\n172.17.32.144:5600\n192.168.1.20:5600"));
assertTrue(two, two.endsWith("output to\n\n172.17.32.144:5600\n192.168.1.20:5600"));
}
}
Loading