Exemplo n.º 1
0
static int nsjailStandaloneMode(struct nsjconf_t *nsjconf)
{
	int child_status = 0;
	subprocRunChild(nsjconf, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO);
	for (;;) {
		if (subprocCount(nsjconf) == 0) {
			if (nsjconf->mode == MODE_STANDALONE_ONCE) {
				return child_status;
			}
			subprocRunChild(nsjconf, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO);
		}
		if (nsjailShowProc == true) {
			nsjailShowProc = false;
			subprocDisplay(nsjconf);
		}
		if (nsjailSigFatal > 0) {
			subprocKillAll(nsjconf);
			logStop(nsjailSigFatal);
			return -1;
		}
		pause();
		child_status = subprocReap(nsjconf);
	}
	// not reached
	return child_status;
}
Exemplo n.º 2
0
static void nsjailListenMode(struct nsjconf_t *nsjconf)
{
	int listenfd = netGetRecvSocket(nsjconf->port);
	if (listenfd == -1) {
		return;
	}
	for (;;) {
		if (nsjailSigFatal > 0) {
			subprocKillAll(nsjconf);
			logStop(nsjailSigFatal);
			return;
		}
		if (nsjailShowProc == true) {
			nsjailShowProc = false;
			subprocDisplay(nsjconf);
		}
		int connfd = netAcceptConn(listenfd);
		if (connfd >= 0) {
			subprocRunChild(nsjconf, connfd, connfd, connfd);
			close(connfd);
		}
		subprocReap(nsjconf);
	}
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
    MythExternRecorderCommandLineParser cmdline;

    if (!cmdline.Parse(argc, argv))
    {
        cmdline.PrintHelp();
        return GENERIC_EXIT_INVALID_CMDLINE;
    }

    if (cmdline.toBool("showhelp"))
    {
        cmdline.PrintHelp();
        return GENERIC_EXIT_OK;
    }

    if (cmdline.toBool("showversion"))
    {
        cmdline.PrintVersion();
        return GENERIC_EXIT_OK;
    }

    QCoreApplication app(argc, argv);
    QCoreApplication::setApplicationName("mythexternrecorder");

    int retval;
    if ((retval = cmdline.ConfigureLogging()) != GENERIC_EXIT_OK)
        return retval;
    QString logfile = cmdline.GetLogFilePath();

    MythExternControl *control = new MythExternControl();
    MythExternRecApp  *process = nullptr;

    QString conf_file = cmdline.toString("conf");
    if (!conf_file.isEmpty())
    {
        process = new MythExternRecApp("", conf_file, logfile);
    }
    else if (!cmdline.toString("exec").isEmpty())
    {
        QString command = cmdline.toString("exec");
        process = new MythExternRecApp(command, "", logfile);
    }
    else if (!cmdline.toString("infile").isEmpty())
    {
        QString filename = cmdline.toString("infile");
        QString command = QString("ffmpeg -re -i \"%1\" "
                                  "-c:v copy -c:a copy -f mpegts -")
                          .arg(filename);
        process = new MythExternRecApp(command, "", logfile);
    }

    QObject::connect(process, &MythExternRecApp::Opened,
                     control, &MythExternControl::Opened);
    QObject::connect(process, &MythExternRecApp::Done,
                     control, &MythExternControl::Done);
    QObject::connect(process, &MythExternRecApp::SetDescription,
                     control, &MythExternControl::SetDescription);
    QObject::connect(process, &MythExternRecApp::SendMessage,
                     control, &MythExternControl::SendMessage);
    QObject::connect(process, &MythExternRecApp::ErrorMessage,
                     control, &MythExternControl::ErrorMessage);
    QObject::connect(process, &MythExternRecApp::Streaming,
                     control, &MythExternControl::Streaming);
    QObject::connect(process, &MythExternRecApp::Fill,
                     control, &MythExternControl::Fill);

    QObject::connect(control, &MythExternControl::Close,
                     process, &MythExternRecApp::Close);
    QObject::connect(control, &MythExternControl::StartStreaming,
                     process, &MythExternRecApp::StartStreaming);
    QObject::connect(control, &MythExternControl::StopStreaming,
                     process, &MythExternRecApp::StopStreaming);
    QObject::connect(control, &MythExternControl::LockTimeout,
                     process, &MythExternRecApp::LockTimeout);
    QObject::connect(control, &MythExternControl::HasTuner,
                     process, &MythExternRecApp::HasTuner);
    QObject::connect(control, &MythExternControl::LoadChannels,
                     process, &MythExternRecApp::LoadChannels);
    QObject::connect(control, &MythExternControl::FirstChannel,
                     process, &MythExternRecApp::FirstChannel);
    QObject::connect(control, &MythExternControl::NextChannel,
                     process, &MythExternRecApp::NextChannel);
    QObject::connect(control, &MythExternControl::TuneChannel,
                     process, &MythExternRecApp::TuneChannel);
    QObject::connect(control, &MythExternControl::HasPictureAttributes,
                     process, &MythExternRecApp::HasPictureAttributes);
    QObject::connect(control, &MythExternControl::SetBlockSize,
                     process, &MythExternRecApp::SetBlockSize);

    process->Run();

    delete process;
    delete control;
    logStop();

    LOG(VB_GENERAL, LOG_WARNING, "Finished.");

    return GENERIC_EXIT_OK;
}