forked from j62/ctbrec
Rename StreamRedirectThread to StreamRedirector
... since it isn't a thread, but a Runnable
This commit is contained in:
parent
2dbc6015d2
commit
808f96c04f
|
@ -15,7 +15,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
@ -133,8 +133,8 @@ public class DesktopIntegration {
|
||||||
msg.replace("-", "\\\\-").replace("\\s", "\\\\ "),
|
msg.replace("-", "\\\\-").replace("\\s", "\\\\ "),
|
||||||
"--icon=dialog-information"
|
"--icon=dialog-information"
|
||||||
});
|
});
|
||||||
new Thread(new StreamRedirectThread(p.getInputStream(), System.out)).start(); // NOSONAR
|
new Thread(new StreamRedirector(p.getInputStream(), System.out)).start(); // NOSONAR
|
||||||
new Thread(new StreamRedirectThread(p.getErrorStream(), System.err)).start(); // NOSONAR
|
new Thread(new StreamRedirector(p.getErrorStream(), System.err)).start(); // NOSONAR
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
LOG.error("Notification failed", e1);
|
LOG.error("Notification failed", e1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.Settings.ProxyType;
|
import ctbrec.Settings.ProxyType;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
|
|
||||||
public class ExternalBrowser implements AutoCloseable {
|
public class ExternalBrowser implements AutoCloseable {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ExternalBrowser.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ExternalBrowser.class);
|
||||||
|
@ -49,11 +49,11 @@ public class ExternalBrowser implements AutoCloseable {
|
||||||
|
|
||||||
p = new ProcessBuilder(OS.getBrowserCommand()).start();
|
p = new ProcessBuilder(OS.getBrowserCommand()).start();
|
||||||
if (LOG.isTraceEnabled()) {
|
if (LOG.isTraceEnabled()) {
|
||||||
new Thread(new StreamRedirectThread(p.getInputStream(), System.out)).start();
|
new Thread(new StreamRedirector(p.getInputStream(), System.out)).start();
|
||||||
new Thread(new StreamRedirectThread(p.getErrorStream(), System.err)).start();
|
new Thread(new StreamRedirector(p.getErrorStream(), System.err)).start();
|
||||||
} else {
|
} else {
|
||||||
new Thread(new StreamRedirectThread(p.getInputStream(), OutputStream.nullOutputStream())).start();
|
new Thread(new StreamRedirector(p.getInputStream(), OutputStream.nullOutputStream())).start();
|
||||||
new Thread(new StreamRedirectThread(p.getErrorStream(), OutputStream.nullOutputStream())).start();
|
new Thread(new StreamRedirector(p.getErrorStream(), OutputStream.nullOutputStream())).start();
|
||||||
}
|
}
|
||||||
LOG.debug("Browser started");
|
LOG.debug("Browser started");
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import ctbrec.Config;
|
||||||
import ctbrec.Model;
|
import ctbrec.Model;
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.Recording;
|
import ctbrec.Recording;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
import ctbrec.io.UrlUtil;
|
import ctbrec.io.UrlUtil;
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
import ctbrec.ui.controls.Dialogs;
|
import ctbrec.ui.controls.Dialogs;
|
||||||
|
@ -165,12 +165,12 @@ public class Player {
|
||||||
|
|
||||||
// create threads, which read stdout and stderr of the player process. these are needed,
|
// create threads, which read stdout and stderr of the player process. these are needed,
|
||||||
// because otherwise the internal buffer for these streams fill up and block the process
|
// because otherwise the internal buffer for these streams fill up and block the process
|
||||||
Thread std = new Thread(new StreamRedirectThread(playerProcess.getInputStream(), OutputStream.nullOutputStream()));
|
Thread std = new Thread(new StreamRedirector(playerProcess.getInputStream(), OutputStream.nullOutputStream()));
|
||||||
//Thread std = new Thread(new StreamRedirectThread(playerProcess.getInputStream(), System.out));
|
//Thread std = new Thread(new StreamRedirectThread(playerProcess.getInputStream(), System.out));
|
||||||
std.setName("Player stdout pipe");
|
std.setName("Player stdout pipe");
|
||||||
std.setDaemon(true);
|
std.setDaemon(true);
|
||||||
std.start();
|
std.start();
|
||||||
Thread err = new Thread(new StreamRedirectThread(playerProcess.getErrorStream(), OutputStream.nullOutputStream()));
|
Thread err = new Thread(new StreamRedirector(playerProcess.getErrorStream(), OutputStream.nullOutputStream()));
|
||||||
//Thread err = new Thread(new StreamRedirectThread(playerProcess.getErrorStream(), System.err));
|
//Thread err = new Thread(new StreamRedirectThread(playerProcess.getErrorStream(), System.err));
|
||||||
err.setName("Player stderr pipe");
|
err.setName("Player stderr pipe");
|
||||||
err.setDaemon(true);
|
err.setDaemon(true);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.event.EventHandlerConfiguration.ActionConfiguration;
|
import ctbrec.event.EventHandlerConfiguration.ActionConfiguration;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
|
|
||||||
public class ExecuteProgram extends Action {
|
public class ExecuteProgram extends Action {
|
||||||
|
|
||||||
|
@ -38,11 +38,11 @@ public class ExecuteProgram extends Action {
|
||||||
|
|
||||||
// create threads, which read stdout and stderr of the player process. these are needed,
|
// create threads, which read stdout and stderr of the player process. these are needed,
|
||||||
// because otherwise the internal buffer for these streams fill up and block the process
|
// because otherwise the internal buffer for these streams fill up and block the process
|
||||||
Thread std = new Thread(new StreamRedirectThread(process.getInputStream(), System.out));
|
Thread std = new Thread(new StreamRedirector(process.getInputStream(), System.out));
|
||||||
std.setName("Player stdout pipe");
|
std.setName("Player stdout pipe");
|
||||||
std.setDaemon(true);
|
std.setDaemon(true);
|
||||||
std.start();
|
std.start();
|
||||||
Thread err = new Thread(new StreamRedirectThread(process.getErrorStream(), System.err));
|
Thread err = new Thread(new StreamRedirector(process.getErrorStream(), System.err));
|
||||||
err.setName("Player stderr pipe");
|
err.setName("Player stderr pipe");
|
||||||
err.setDaemon(true);
|
err.setDaemon(true);
|
||||||
err.start();
|
err.start();
|
||||||
|
|
|
@ -6,13 +6,13 @@ import java.io.OutputStream;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class StreamRedirectThread implements Runnable {
|
public class StreamRedirector implements Runnable {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(StreamRedirectThread.class);
|
private static final Logger LOG = LoggerFactory.getLogger(StreamRedirector.class);
|
||||||
|
|
||||||
private InputStream in;
|
private InputStream in;
|
||||||
private OutputStream out;
|
private OutputStream out;
|
||||||
|
|
||||||
public StreamRedirectThread(InputStream in, OutputStream out) {
|
public StreamRedirector(InputStream in, OutputStream out) {
|
||||||
super();
|
super();
|
||||||
this.in = in;
|
this.in = in;
|
||||||
this.out = out;
|
this.out = out;
|
|
@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.io.DevNull;
|
import ctbrec.io.DevNull;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
|
|
||||||
public class VideoLengthDetector {
|
public class VideoLengthDetector {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(VideoLengthDetector.class);
|
private static final Logger LOG = LoggerFactory.getLogger(VideoLengthDetector.class);
|
||||||
|
@ -39,8 +39,8 @@ public class VideoLengthDetector {
|
||||||
Process ffmpeg = Runtime.getRuntime().exec(cmdline, new String[0], videoFile.getParentFile());
|
Process ffmpeg = Runtime.getRuntime().exec(cmdline, new String[0], videoFile.getParentFile());
|
||||||
int exitCode = 1;
|
int exitCode = 1;
|
||||||
ByteArrayOutputStream stdErrBuffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream stdErrBuffer = new ByteArrayOutputStream();
|
||||||
Thread stdout = new Thread(new StreamRedirectThread(ffmpeg.getInputStream(), new DevNull()));
|
Thread stdout = new Thread(new StreamRedirector(ffmpeg.getInputStream(), new DevNull()));
|
||||||
Thread stderr = new Thread(new StreamRedirectThread(ffmpeg.getErrorStream(), stdErrBuffer));
|
Thread stderr = new Thread(new StreamRedirector(ffmpeg.getErrorStream(), stdErrBuffer));
|
||||||
stdout.start();
|
stdout.start();
|
||||||
stderr.start();
|
stderr.start();
|
||||||
exitCode = ffmpeg.waitFor();
|
exitCode = ffmpeg.waitFor();
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
||||||
|
|
||||||
public class FfmpegMuxer {
|
public class FfmpegMuxer {
|
||||||
|
@ -99,8 +99,8 @@ public class FfmpegMuxer {
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
LOG.debug("Command line: {}", Arrays.toString(cmdline));
|
LOG.debug("Command line: {}", Arrays.toString(cmdline));
|
||||||
Process ffmpeg = Runtime.getRuntime().exec(cmdline);
|
Process ffmpeg = Runtime.getRuntime().exec(cmdline);
|
||||||
Thread stdout = new Thread(new StreamRedirectThread(ffmpeg.getInputStream(), muxLogStream));
|
Thread stdout = new Thread(new StreamRedirector(ffmpeg.getInputStream(), muxLogStream));
|
||||||
Thread stderr = new Thread(new StreamRedirectThread(ffmpeg.getErrorStream(), muxLogStream));
|
Thread stderr = new Thread(new StreamRedirector(ffmpeg.getErrorStream(), muxLogStream));
|
||||||
stdout.start();
|
stdout.start();
|
||||||
stderr.start();
|
stderr.start();
|
||||||
int exitCode = ffmpeg.waitFor();
|
int exitCode = ffmpeg.waitFor();
|
||||||
|
|
|
@ -24,7 +24,7 @@ import ctbrec.Model;
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.Recording;
|
import ctbrec.Recording;
|
||||||
import ctbrec.io.HttpClient;
|
import ctbrec.io.HttpClient;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,8 +73,8 @@ public class FFmpegDownload extends AbstractHlsDownload {
|
||||||
File ffmpegLog = File.createTempFile(targetFile.getName(), ".log");
|
File ffmpegLog = File.createTempFile(targetFile.getName(), ".log");
|
||||||
ffmpegLog.deleteOnExit();
|
ffmpegLog.deleteOnExit();
|
||||||
try (FileOutputStream mergeLogStream = new FileOutputStream(ffmpegLog)) {
|
try (FileOutputStream mergeLogStream = new FileOutputStream(ffmpegLog)) {
|
||||||
Thread stdout = new Thread(new StreamRedirectThread(ffmpeg.getInputStream(), mergeLogStream));
|
Thread stdout = new Thread(new StreamRedirector(ffmpeg.getInputStream(), mergeLogStream));
|
||||||
Thread stderr = new Thread(new StreamRedirectThread(ffmpeg.getErrorStream(), mergeLogStream));
|
Thread stderr = new Thread(new StreamRedirector(ffmpeg.getErrorStream(), mergeLogStream));
|
||||||
stdout.start();
|
stdout.start();
|
||||||
stderr.start();
|
stderr.start();
|
||||||
exitCode = ffmpeg.waitFor();
|
exitCode = ffmpeg.waitFor();
|
||||||
|
|
|
@ -40,7 +40,7 @@ import ctbrec.Recording;
|
||||||
import ctbrec.io.BandwidthMeter;
|
import ctbrec.io.BandwidthMeter;
|
||||||
import ctbrec.io.HttpClient;
|
import ctbrec.io.HttpClient;
|
||||||
import ctbrec.io.HttpException;
|
import ctbrec.io.HttpException;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
import ctbrec.recorder.ProgressListener;
|
import ctbrec.recorder.ProgressListener;
|
||||||
import ctbrec.recorder.download.HttpHeaderFactory;
|
import ctbrec.recorder.download.HttpHeaderFactory;
|
||||||
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
||||||
|
@ -153,8 +153,8 @@ public class MergedFfmpegHlsDownload extends AbstractHlsDownload {
|
||||||
File ffmpegLog = File.createTempFile(target.getName(), ".log");
|
File ffmpegLog = File.createTempFile(target.getName(), ".log");
|
||||||
ffmpegLog.deleteOnExit();
|
ffmpegLog.deleteOnExit();
|
||||||
try (FileOutputStream mergeLogStream = new FileOutputStream(ffmpegLog)) {
|
try (FileOutputStream mergeLogStream = new FileOutputStream(ffmpegLog)) {
|
||||||
Thread stdout = new Thread(new StreamRedirectThread(ffmpeg.getInputStream(), mergeLogStream));
|
Thread stdout = new Thread(new StreamRedirector(ffmpeg.getInputStream(), mergeLogStream));
|
||||||
Thread stderr = new Thread(new StreamRedirectThread(ffmpeg.getErrorStream(), mergeLogStream));
|
Thread stderr = new Thread(new StreamRedirector(ffmpeg.getErrorStream(), mergeLogStream));
|
||||||
stdout.start();
|
stdout.start();
|
||||||
stderr.start();
|
stderr.start();
|
||||||
exitCode = ffmpeg.waitFor();
|
exitCode = ffmpeg.waitFor();
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.Recording;
|
import ctbrec.Recording;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
import ctbrec.recorder.RecordingManager;
|
import ctbrec.recorder.RecordingManager;
|
||||||
|
|
||||||
public class CreateContactSheet extends AbstractPlaceholderAwarePostProcessor {
|
public class CreateContactSheet extends AbstractPlaceholderAwarePostProcessor {
|
||||||
|
@ -85,8 +85,8 @@ public class CreateContactSheet extends AbstractPlaceholderAwarePostProcessor {
|
||||||
File ffmpegLog = File.createTempFile("create_contact_sheet_" + rec.getId() + '_', ".log");
|
File ffmpegLog = File.createTempFile("create_contact_sheet_" + rec.getId() + '_', ".log");
|
||||||
ffmpegLog.deleteOnExit();
|
ffmpegLog.deleteOnExit();
|
||||||
try (FileOutputStream mergeLogStream = new FileOutputStream(ffmpegLog)) {
|
try (FileOutputStream mergeLogStream = new FileOutputStream(ffmpegLog)) {
|
||||||
Thread stdout = new Thread(new StreamRedirectThread(ffmpeg.getInputStream(), mergeLogStream));
|
Thread stdout = new Thread(new StreamRedirector(ffmpeg.getInputStream(), mergeLogStream));
|
||||||
Thread stderr = new Thread(new StreamRedirectThread(ffmpeg.getErrorStream(), mergeLogStream));
|
Thread stderr = new Thread(new StreamRedirector(ffmpeg.getErrorStream(), mergeLogStream));
|
||||||
stdout.start();
|
stdout.start();
|
||||||
stderr.start();
|
stderr.start();
|
||||||
exitCode = ffmpeg.waitFor();
|
exitCode = ffmpeg.waitFor();
|
||||||
|
|
|
@ -14,7 +14,7 @@ import ctbrec.Config;
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.Recording;
|
import ctbrec.Recording;
|
||||||
import ctbrec.io.IoUtils;
|
import ctbrec.io.IoUtils;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
import ctbrec.recorder.RecordingManager;
|
import ctbrec.recorder.RecordingManager;
|
||||||
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ public class Remux extends AbstractPostProcessor {
|
||||||
File ffmpegLog = new File(video.getParentFile(), video.getName() + ".ffmpeg.log");
|
File ffmpegLog = new File(video.getParentFile(), video.getName() + ".ffmpeg.log");
|
||||||
rec.getAssociatedFiles().add(ffmpegLog.getCanonicalPath());
|
rec.getAssociatedFiles().add(ffmpegLog.getCanonicalPath());
|
||||||
try (FileOutputStream mergeLogStream = new FileOutputStream(ffmpegLog)) {
|
try (FileOutputStream mergeLogStream = new FileOutputStream(ffmpegLog)) {
|
||||||
Thread stdout = new Thread(new StreamRedirectThread(ffmpeg.getInputStream(), mergeLogStream));
|
Thread stdout = new Thread(new StreamRedirector(ffmpeg.getInputStream(), mergeLogStream));
|
||||||
Thread stderr = new Thread(new StreamRedirectThread(ffmpeg.getErrorStream(), mergeLogStream));
|
Thread stderr = new Thread(new StreamRedirector(ffmpeg.getErrorStream(), mergeLogStream));
|
||||||
stdout.start();
|
stdout.start();
|
||||||
stderr.start();
|
stderr.start();
|
||||||
exitCode = ffmpeg.waitFor();
|
exitCode = ffmpeg.waitFor();
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.Recording;
|
import ctbrec.Recording;
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirector;
|
||||||
import ctbrec.recorder.RecordingManager;
|
import ctbrec.recorder.RecordingManager;
|
||||||
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
import ctbrec.recorder.download.ProcessExitedUncleanException;
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ public class Script extends AbstractPlaceholderAwarePostProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startLogging(Process process, FileOutputStream logStream) {
|
private void startLogging(Process process, FileOutputStream logStream) {
|
||||||
Thread std = new Thread(new StreamRedirectThread(process.getInputStream(), logStream));
|
Thread std = new Thread(new StreamRedirector(process.getInputStream(), logStream));
|
||||||
std.setName("Process stdout pipe");
|
std.setName("Process stdout pipe");
|
||||||
std.setDaemon(true);
|
std.setDaemon(true);
|
||||||
std.start();
|
std.start();
|
||||||
Thread err = new Thread(new StreamRedirectThread(process.getErrorStream(), logStream));
|
Thread err = new Thread(new StreamRedirector(process.getErrorStream(), logStream));
|
||||||
err.setName("Process stderr pipe");
|
err.setName("Process stderr pipe");
|
||||||
err.setDaemon(true);
|
err.setDaemon(true);
|
||||||
err.start();
|
err.start();
|
||||||
|
|
Loading…
Reference in New Issue