mirror of https://github.com/OpenVidu/openvidu.git
openvidu-test-e2e: fix kurentoReconnectTest
parent
c8fd7d7889
commit
76b2895a25
|
@ -2762,7 +2762,7 @@ public class OpenViduTestAppE2eTest {
|
||||||
return "data:image/png;base64," + screenshotBase64;
|
return "data:image/png;base64," + screenshotBase64;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean recordedFileFine(File file, Recording recording) {
|
private boolean recordedFileFine(File file, Recording recording) throws IOException {
|
||||||
this.checkMultimediaFile(file, recording.hasAudio(), recording.hasVideo(), recording.getDuration(),
|
this.checkMultimediaFile(file, recording.hasAudio(), recording.hasVideo(), recording.getDuration(),
|
||||||
recording.getResolution(), "aac", "h264", true);
|
recording.getResolution(), "aac", "h264", true);
|
||||||
|
|
||||||
|
@ -2790,7 +2790,7 @@ public class OpenViduTestAppE2eTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIndividualRecording(String recPath, Recording recording, int numberOfVideoFiles,
|
private void checkIndividualRecording(String recPath, Recording recording, int numberOfVideoFiles,
|
||||||
String audioDecoder, String videoDecoder, boolean checkAudio) {
|
String audioDecoder, String videoDecoder, boolean checkAudio) throws IOException {
|
||||||
|
|
||||||
// Should be only 2 files: zip and metadata
|
// Should be only 2 files: zip and metadata
|
||||||
File folder = new File(recPath);
|
File folder = new File(recPath);
|
||||||
|
@ -2864,7 +2864,7 @@ public class OpenViduTestAppE2eTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMultimediaFile(File file, boolean hasAudio, boolean hasVideo, double duration, String resolution,
|
private void checkMultimediaFile(File file, boolean hasAudio, boolean hasVideo, double duration, String resolution,
|
||||||
String audioDecoder, String videoDecoder, boolean checkAudio) {
|
String audioDecoder, String videoDecoder, boolean checkAudio) throws IOException {
|
||||||
// Check tracks, duration, resolution, framerate and decoders
|
// Check tracks, duration, resolution, framerate and decoders
|
||||||
MultimediaFileMetadata metadata = new MultimediaFileMetadata(file.getAbsolutePath());
|
MultimediaFileMetadata metadata = new MultimediaFileMetadata(file.getAbsolutePath());
|
||||||
|
|
||||||
|
@ -2945,11 +2945,13 @@ public class OpenViduTestAppE2eTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopKms() {
|
private void stopKms() {
|
||||||
|
log.info("Stopping KMS");
|
||||||
commandLine.executeCommand("sudo kill -9 $(pidof kurento-media-server)");
|
commandLine.executeCommand("sudo kill -9 $(pidof kurento-media-server)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startKms() {
|
private void startKms() {
|
||||||
commandLine.executeCommand("/usr/bin/kurento-media-server");
|
log.info("Starting KMS");
|
||||||
|
commandLine.executeCommand("/usr/bin/kurento-media-server &> /kms.log &");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restartKms() {
|
private void restartKms() {
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class CommandLineExecutor {
|
||||||
String output = "";
|
String output = "";
|
||||||
Process p = null;
|
Process p = null;
|
||||||
try {
|
try {
|
||||||
p = Runtime.getRuntime().exec(command);
|
p = Runtime.getRuntime().exec((new String[] { "/bin/sh", "-c", command }));
|
||||||
p.waitFor();
|
p.waitFor();
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||||
String line = "";
|
String line = "";
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
|
|
||||||
package io.openvidu.test.e2e.utils;
|
package io.openvidu.test.e2e.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -48,12 +54,20 @@ public class MultimediaFileMetadata {
|
||||||
private int videoHeight;
|
private int videoHeight;
|
||||||
private int framerate;
|
private int framerate;
|
||||||
|
|
||||||
public MultimediaFileMetadata(String fileAbsolutePath) {
|
public MultimediaFileMetadata(String fileAbsolutePath) throws IOException {
|
||||||
|
|
||||||
log.info("Extracting media metadata info from file {}", fileAbsolutePath);
|
log.info("Extracting media metadata info from file {}", fileAbsolutePath);
|
||||||
|
|
||||||
this.json = this.executeFfprobeCommand(fileAbsolutePath);
|
this.json = this.executeFfprobeCommand(fileAbsolutePath);
|
||||||
this.formatJson = json.get("format").getAsJsonObject();
|
this.formatJson = json.get("format").getAsJsonObject();
|
||||||
|
|
||||||
|
if (formatJson.get("duration") == null) {
|
||||||
|
// Webm file has not been properly closed (i.e. media server stopped)
|
||||||
|
this.fixWebmFile(fileAbsolutePath);
|
||||||
|
this.json = this.executeFfprobeCommand(fileAbsolutePath);
|
||||||
|
this.formatJson = json.get("format").getAsJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
JsonArray streams = json.get("streams").getAsJsonArray();
|
JsonArray streams = json.get("streams").getAsJsonArray();
|
||||||
|
|
||||||
streams.forEach(e -> { // Only supposed for 2 streams max
|
streams.forEach(e -> { // Only supposed for 2 streams max
|
||||||
|
@ -142,6 +156,16 @@ public class MultimediaFileMetadata {
|
||||||
return this.parser.parse(this.executer.executeCommand(cmd)).getAsJsonObject();
|
return this.parser.parse(this.executer.executeCommand(cmd)).getAsJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fixWebmFile(String filePath) throws IOException {
|
||||||
|
Path source = Paths.get(filePath);
|
||||||
|
String pathCopy = null;
|
||||||
|
pathCopy = Files.move(source, source.resolveSibling("COPY.webm")).toString();
|
||||||
|
log.warn("Fixing file '{}' with ffmpeg", filePath);
|
||||||
|
String cmd = "ffmpeg -i " + pathCopy + " -vcodec copy -acodec copy " + filePath;
|
||||||
|
this.executer.executeCommand(cmd);
|
||||||
|
new File(pathCopy).delete();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "{duration=" + this.duration + ", format=" + this.format + ", bitrate=" + this.bitrate + ", hasAudio="
|
return "{duration=" + this.duration + ", format=" + this.format + ", bitrate=" + this.bitrate + ", hasAudio="
|
||||||
|
|
Loading…
Reference in New Issue