private void CreateGUI()
    {
        try
        {
            if (!AVProMovieCapturePlugin.Init())
            {
                Debug.LogError("[AVProMovieCapture] Failed to initialise");
                return;
            }
        }
        catch (System.DllNotFoundException e)
        {
            _isFailedInit = true;
            Debug.LogError("[AVProMovieCapture] Unity couldn't find the plugin DLL, please move the 'Plugins' folder to the root of your project.");
            throw e;
        }

        // Video codec enumeration
        int numVideoCodecs = Mathf.Max(0, AVProMovieCapturePlugin.GetNumAVIVideoCodecs());

        _videoCodecNames           = new string[numVideoCodecs + 2];
        _videoCodecNames[0]        = "Uncompressed";
        _videoCodecNames[1]        = null;
        _videoCodecConfigurable    = new bool[numVideoCodecs + 2];
        _videoCodecConfigurable[0] = false;
        _videoCodecConfigurable[1] = false;
        for (int i = 0; i < numVideoCodecs; i++)
        {
            _videoCodecNames[i + 2]        = i.ToString("D2") + ") " + AVProMovieCapturePlugin.GetAVIVideoCodecName(i).Replace("/", "_");
            _videoCodecConfigurable[i + 2] = AVProMovieCapturePlugin.IsConfigureVideoCodecSupported(i);
        }

        // Audio device enumeration
        int numAudioDevices = Mathf.Max(0, AVProMovieCapturePlugin.GetNumAVIAudioInputDevices());

        _audioDeviceNames    = new string[numAudioDevices + 2];
        _audioDeviceNames[0] = "Unity";
        _audioDeviceNames[1] = null;
        for (int i = 0; i < numAudioDevices; i++)
        {
            _audioDeviceNames[i + 2] = i.ToString("D2") + ") " + AVProMovieCapturePlugin.GetAVIAudioInputDeviceName(i).Replace("/", "_");
        }

        // Audio codec enumeration
        int numAudioCodecs = Mathf.Max(0, AVProMovieCapturePlugin.GetNumAVIAudioCodecs());

        _audioCodecNames           = new string[numAudioCodecs + 2];
        _audioCodecNames[0]        = "Uncompressed";
        _audioCodecNames[1]        = null;
        _audioCodecConfigurable    = new bool[numAudioCodecs + 2];
        _audioCodecConfigurable[0] = false;
        _audioCodecConfigurable[1] = false;
        for (int i = 0; i < numAudioCodecs; i++)
        {
            _audioCodecNames[i + 2]        = i.ToString("D2") + ") " + AVProMovieCapturePlugin.GetAVIAudioCodecName(i).Replace("/", "_");
            _audioCodecConfigurable[i + 2] = AVProMovieCapturePlugin.IsConfigureAudioCodecSupported(i);
        }

        _isInit = true;
    }
Exemplo n.º 2
0
    public void SelectAudioDevice(bool display)
    {
        // Enumerate
        int num = AVProMovieCapturePlugin.GetNumAVIAudioInputDevices();

        if (display)
        {
            for (int i = 0; i < num; i++)
            {
                Debug.Log("AudioDevice " + i + ": " + AVProMovieCapturePlugin.GetAVIAudioInputDeviceName(i));
            }
        }

        // The user has specified their own device index
        if (_forceAudioDeviceIndex >= 0)
        {
            if (_forceAudioDeviceIndex < num)
            {
                _audioDeviceName  = AVProMovieCapturePlugin.GetAVIAudioInputDeviceName(_forceAudioDeviceIndex);
                _audioDeviceIndex = _forceAudioDeviceIndex;
            }
        }
        else
        {
            /*_audioDeviceIndex = -1;
             * // Try to find one of the loopback devices
             * for (int i = 0; i < num; i++)
             * {
             *      StringBuilder sbName = new StringBuilder(512);
             *      if (AVProMovieCapturePlugin.GetAVIAudioInputDeviceName(i, sbName))
             *      {
             *              string[] loopbackNames = { "Stereo Mix", "What U Hear", "What You Hear", "Waveout Mix", "Mixed Output" };
             *              for (int j = 0; j < loopbackNames.Length; j++)
             *              {
             *                      if (sbName.ToString().Contains(loopbackNames[j]))
             *                      {
             *                              _audioDeviceIndex = i;
             *                              _audioDeviceName = sbName.ToString();
             *                      }
             *              }
             *      }
             *      if (_audioDeviceIndex >= 0)
             *              break;
             * }
             *
             * if (_audioDeviceIndex < 0)
             * {
             *      // Resort to the no recording device
             *      _audioDeviceName = "Unity";
             *      _audioDeviceIndex = -1;
             * }*/

            _audioDeviceName  = "Unity";
            _audioDeviceIndex = -1;
        }
    }
Exemplo n.º 3
0
    private void CreateGUI()
    {
        _downScales    = new string[6];
        _downScales[0] = "Original";
        _downScales[1] = "Half";
        _downScales[2] = "Quarter";
        _downScales[3] = "Eighth";
        _downScales[4] = "Sixteenth";
        _downScales[5] = "Specific";
        switch (_movieCapture._downScale)
        {
        default:
        case AVProMovieCaptureBase.DownScale.Original:
            _downScaleIndex = 0;
            break;

        case AVProMovieCaptureBase.DownScale.Half:
            _downScaleIndex = 1;
            break;

        case AVProMovieCaptureBase.DownScale.Quarter:
            _downScaleIndex = 2;
            break;

        case AVProMovieCaptureBase.DownScale.Eighth:
            _downScaleIndex = 3;
            break;

        case AVProMovieCaptureBase.DownScale.Sixteenth:
            _downScaleIndex = 4;
            break;

        case AVProMovieCaptureBase.DownScale.Specific:
            _downScaleIndex = 5;
            break;
        }

        _frameRates    = new string[6];
        _frameRates[0] = "15";
        _frameRates[1] = "24";
        _frameRates[2] = "25";
        _frameRates[3] = "30";
        _frameRates[4] = "50";
        _frameRates[5] = "60";
        switch (_movieCapture._frameRate)
        {
        default:
        case AVProMovieCaptureBase.FrameRate.Fifteen:
            _frameRateIndex = 0;
            break;

        case AVProMovieCaptureBase.FrameRate.TwentyFour:
            _frameRateIndex = 1;
            break;

        case AVProMovieCaptureBase.FrameRate.TwentyFive:
            _frameRateIndex = 2;
            break;

        case AVProMovieCaptureBase.FrameRate.Thirty:
            _frameRateIndex = 3;
            break;

        case AVProMovieCaptureBase.FrameRate.Fifty:
            _frameRateIndex = 4;
            break;

        case AVProMovieCaptureBase.FrameRate.Sixty:
            _frameRateIndex = 5;
            break;
        }

        int numVideoCodecs = AVProMovieCapturePlugin.GetNumAVIVideoCodecs();

        if (numVideoCodecs > 0)
        {
            _videoCodecNames        = new string[numVideoCodecs + 1];
            _videoCodecNames[0]     = "Uncompressed";
            _videoCodecConfigurable = new bool[numVideoCodecs];
            for (int i = 0; i < numVideoCodecs; i++)
            {
                _videoCodecNames[i + 1]    = AVProMovieCapturePlugin.GetAVIVideoCodecName(i);
                _videoCodecConfigurable[i] = AVProMovieCapturePlugin.IsConfigureVideoCodecSupported(i);
            }
        }

        int numAudioDevices = AVProMovieCapturePlugin.GetNumAVIAudioInputDevices();

        if (numAudioDevices > 0)
        {
            _audioDeviceNames    = new string[numAudioDevices + 1];
            _audioDeviceNames[0] = "Unity";
            for (int i = 0; i < numAudioDevices; i++)
            {
                _audioDeviceNames[i + 1] = AVProMovieCapturePlugin.GetAVIAudioInputDeviceName(i);
            }
        }

        int numAudioCodecs = AVProMovieCapturePlugin.GetNumAVIAudioCodecs();

        if (numAudioCodecs > 0)
        {
            _audioCodecNames        = new string[numAudioCodecs + 1];
            _audioCodecNames[0]     = "Uncompressed";
            _audioCodecConfigurable = new bool[numAudioCodecs];
            for (int i = 0; i < numAudioCodecs; i++)
            {
                _audioCodecNames[i + 1]    = AVProMovieCapturePlugin.GetAVIAudioCodecName(i);
                _audioCodecConfigurable[i] = AVProMovieCapturePlugin.IsConfigureAudioCodecSupported(i);
            }
        }

        _movieCapture.SelectCodec(false);
        _movieCapture.SelectAudioCodec(false);
        _movieCapture.SelectAudioDevice(false);
    }