// instrument by jscoverage, do not modifly this file
(function () {
  var BASE;
  if (typeof global === 'object') {
    BASE = global;
  } else if (typeof window === 'object') {
    BASE = window;
  } else {
    throw new Error('[jscoverage] unknow ENV!');
  }
  if (!BASE._$jscoverage) {
    BASE._$jscoverage = {};
    BASE._$jscoverage_cond = {};
    BASE._$jscoverage_done = function (file, line, express) {
      if (arguments.length === 2) {
        BASE._$jscoverage[file][line] ++;
      } else {
        BASE._$jscoverage_cond[file][line] ++;
        return express;
      }
    };
    BASE._$jscoverage_init = function (base, file, lines) {
      var tmp = [];
      for (var i = 0; i < lines.length; i ++) {
        tmp[lines[i]] = 0;
      }
      base[file] = tmp;
    };
  }
})();
_$jscoverage_init(_$jscoverage, "lib/options/inputs.js",[4,10,26,29,31,32,33,36,37,40,41,44,46,47,50,56,70,73,74,77,78,93,101,102,105,106,120,122,123,126,128,141,142,143,146,148,149,152]);
_$jscoverage_init(_$jscoverage_cond, "lib/options/inputs.js",[31,32,32,40,73,101,122,142,148]);
_$jscoverage["lib/options/inputs.js"].source = ["/*jshint node:true*/","'use strict';","","var utils = require('../utils');","","/*"," *! Input-related methods"," */","","module.exports = function(proto) {","  /**","   * Add an input to command","   *","   * Also switches \"current input\", that is the input that will be affected","   * by subsequent input-related methods.","   *","   * Note: only one stream input is supported for now.","   *","   * @method FfmpegCommand#input","   * @category Input","   * @aliases mergeAdd,addInput","   *","   * @param {String|Readable} source input file path or readable stream","   * @return FfmpegCommand","   */","  proto.mergeAdd =","  proto.addInput =","  proto.input = function(source) {","    var isFile = false;","","    if (typeof source !== 'string') {","      if (!('readable' in source) || !(source.readable)) {","        throw new Error('Invalid input');","      }","","      var hasInputStream = this._inputs.some(function(input) {","        return typeof input.source !== 'string';","      });","","      if (hasInputStream) {","        throw new Error('Only one input stream is supported');","      }","","      source.pause();","    } else {","      var protocol = source.match(/^([a-z]{2,}):/i);","      isFile = !protocol || protocol[0] === 'file';","    }","","    this._inputs.push(this._currentInput = {","      source: source,","      isFile: isFile,","      options: utils.args()","    });","","    return this;","  };","","","  /**","   * Specify input format for the last specified input","   *","   * @method FfmpegCommand#inputFormat","   * @category Input","   * @aliases withInputFormat,fromFormat","   *","   * @param {String} format input format","   * @return FfmpegCommand","   */","  proto.withInputFormat =","  proto.inputFormat =","  proto.fromFormat = function(format) {","    if (!this._currentInput) {","      throw new Error('No input specified');","    }","","    this._currentInput.options('-f', format);","    return this;","  };","","","  /**","   * Specify input FPS for the last specified input","   * (only valid for raw video formats)","   *","   * @method FfmpegCommand#inputFps","   * @category Input","   * @aliases withInputFps,withInputFPS,withFpsInput,withFPSInput,inputFPS,inputFps,fpsInput","   *","   * @param {Number} fps input FPS","   * @return FfmpegCommand","   */","  proto.withInputFps =","  proto.withInputFPS =","  proto.withFpsInput =","  proto.withFPSInput =","  proto.inputFPS =","  proto.inputFps =","  proto.fpsInput =","  proto.FPSInput = function(fps) {","    if (!this._currentInput) {","      throw new Error('No input specified');","    }","","    this._currentInput.options('-r', fps);","    return this;","  };","","","  /**","   * Specify input seek time for the last specified input","   *","   * @method FfmpegCommand#seekInput","   * @category Input","   * @aliases setStartTime,seekTo","   *","   * @param {String|Number} seek seek time in seconds or as a '[hh:[mm:]]ss[.xxx]' string","   * @return FfmpegCommand","   */","  proto.setStartTime =","  proto.seekInput = function(seek) {","    if (!this._currentInput) {","      throw new Error('No input specified');","    }","","    this._currentInput.options('-ss', seek);","","    return this;","  };","","","  /**","   * Loop over the last specified input","   *","   * @method FfmpegCommand#loop","   * @category Input","   *","   * @param {String|Number} [duration] loop duration in seconds or as a '[[hh:]mm:]ss[.xxx]' string","   * @return FfmpegCommand","   */","  proto.loop = function(duration) {","    if (!this._currentInput) {","      throw new Error('No input specified');","    }","","    this._currentInput.options('-loop', '1');","","    if (typeof duration !== 'undefined') {","      this.duration(duration);","    }","","    return this;","  };","};",""];
"use strict";

_$jscoverage_done("lib/options/inputs.js", 4);
var utils = require("../utils");

_$jscoverage_done("lib/options/inputs.js", 10);
module.exports = function(proto) {
    _$jscoverage_done("lib/options/inputs.js", 26);
    proto.mergeAdd = proto.addInput = proto.input = function(source) {
        _$jscoverage_done("lib/options/inputs.js", 29);
        var isFile = false;
        _$jscoverage_done("lib/options/inputs.js", 31);
        if (_$jscoverage_done("lib/options/inputs.js", 31, typeof source !== "string")) {
            _$jscoverage_done("lib/options/inputs.js", 32);
            if (_$jscoverage_done("lib/options/inputs.js", 32, !("readable" in source)) || _$jscoverage_done("lib/options/inputs.js", 32, !source.readable)) {
                _$jscoverage_done("lib/options/inputs.js", 33);
                throw new Error("Invalid input");
            }
            _$jscoverage_done("lib/options/inputs.js", 36);
            var hasInputStream = this._inputs.some(function(input) {
                _$jscoverage_done("lib/options/inputs.js", 37);
                return typeof input.source !== "string";
            });
            _$jscoverage_done("lib/options/inputs.js", 40);
            if (_$jscoverage_done("lib/options/inputs.js", 40, hasInputStream)) {
                _$jscoverage_done("lib/options/inputs.js", 41);
                throw new Error("Only one input stream is supported");
            }
            _$jscoverage_done("lib/options/inputs.js", 44);
            source.pause();
        } else {
            _$jscoverage_done("lib/options/inputs.js", 46);
            var protocol = source.match(/^([a-z]{2,}):/i);
            _$jscoverage_done("lib/options/inputs.js", 47);
            isFile = !protocol || protocol[0] === "file";
        }
        _$jscoverage_done("lib/options/inputs.js", 50);
        this._inputs.push(this._currentInput = {
            source: source,
            isFile: isFile,
            options: utils.args()
        });
        _$jscoverage_done("lib/options/inputs.js", 56);
        return this;
    };
    _$jscoverage_done("lib/options/inputs.js", 70);
    proto.withInputFormat = proto.inputFormat = proto.fromFormat = function(format) {
        _$jscoverage_done("lib/options/inputs.js", 73);
        if (_$jscoverage_done("lib/options/inputs.js", 73, !this._currentInput)) {
            _$jscoverage_done("lib/options/inputs.js", 74);
            throw new Error("No input specified");
        }
        _$jscoverage_done("lib/options/inputs.js", 77);
        this._currentInput.options("-f", format);
        _$jscoverage_done("lib/options/inputs.js", 78);
        return this;
    };
    _$jscoverage_done("lib/options/inputs.js", 93);
    proto.withInputFps = proto.withInputFPS = proto.withFpsInput = proto.withFPSInput = proto.inputFPS = proto.inputFps = proto.fpsInput = proto.FPSInput = function(fps) {
        _$jscoverage_done("lib/options/inputs.js", 101);
        if (_$jscoverage_done("lib/options/inputs.js", 101, !this._currentInput)) {
            _$jscoverage_done("lib/options/inputs.js", 102);
            throw new Error("No input specified");
        }
        _$jscoverage_done("lib/options/inputs.js", 105);
        this._currentInput.options("-r", fps);
        _$jscoverage_done("lib/options/inputs.js", 106);
        return this;
    };
    _$jscoverage_done("lib/options/inputs.js", 120);
    proto.setStartTime = proto.seekInput = function(seek) {
        _$jscoverage_done("lib/options/inputs.js", 122);
        if (_$jscoverage_done("lib/options/inputs.js", 122, !this._currentInput)) {
            _$jscoverage_done("lib/options/inputs.js", 123);
            throw new Error("No input specified");
        }
        _$jscoverage_done("lib/options/inputs.js", 126);
        this._currentInput.options("-ss", seek);
        _$jscoverage_done("lib/options/inputs.js", 128);
        return this;
    };
    _$jscoverage_done("lib/options/inputs.js", 141);
    proto.loop = function(duration) {
        _$jscoverage_done("lib/options/inputs.js", 142);
        if (_$jscoverage_done("lib/options/inputs.js", 142, !this._currentInput)) {
            _$jscoverage_done("lib/options/inputs.js", 143);
            throw new Error("No input specified");
        }
        _$jscoverage_done("lib/options/inputs.js", 146);
        this._currentInput.options("-loop", "1");
        _$jscoverage_done("lib/options/inputs.js", 148);
        if (_$jscoverage_done("lib/options/inputs.js", 148, typeof duration !== "undefined")) {
            _$jscoverage_done("lib/options/inputs.js", 149);
            this.duration(duration);
        }
        _$jscoverage_done("lib/options/inputs.js", 152);
        return this;
    };
};