'use strict';
exports.__esModule = true;
var childProcess = require("child_process");
var os = require("os");
var path = require("path");
var log = require("../log");
/**
 * Streams the video to disk.
 */
function default_1(rtmpUrl, rtmpInputPath, swfUrl, filePath, fileExt, mode, verbose, done) {
    var cp;
    var cmd;
    if (mode === 'RTMP') {
        cmd = command('rtmpdump') + ' ' +
            '-r "' + rtmpUrl + '" ' +
            '-y "' + rtmpInputPath + '" ' +
            '-W "' + swfUrl + '" ' +
            '-o "' + filePath + fileExt + '"';
    }
    else if (mode === 'HLS') {
        cmd = command('ffmpeg') + ' ' +
            '-y -xerror ' +
            '-i "' + rtmpInputPath + '" ' +
            '-c copy -bsf:a aac_adtstoasc ' +
            '"' + filePath + '.mp4"';
    }
    else {
        log.error('No such mode: ' + mode);
    }
    cp = childProcess.exec(cmd, {
        maxBuffer: Infinity
    }, done);
    if (verbose === true) {
        cp.stdin.pipe(process.stdin);
        cp.stdout.pipe(process.stdout);
        cp.stderr.pipe(process.stderr);
    }
}
exports["default"] = default_1;
/**
 * Determines the command for the operating system.
 */
function command(exe) {
    if (os.platform() !== 'win32') {
        return exe;
    }
    return '"' + path.join(__dirname, '../../bin/' + exe + '.exe') + '"';
}
//# sourceMappingURL=stream.js.map