Exemple #1
0
    public void Close()
    {
        _enableBackground = false;
        _backgroundEncoder?.Wait();
        _backgroundEncoder = null;

        VpxDllCall.EncodeClose();
        _srcTexture = null;
    }
Exemple #2
0
    public void Setup(int width, int hight, int bitrate, int useCpu, Texture srcTexture)
    {
        this.Width = Mathf.Min(Screen.width, width);
        this.Hight = Mathf.Min(Screen.height, hight);

        VpxDllCall.EncodeSetup(this.Width, this.Hight, bitrate, useCpu);
        _srcTexture = null;

        // 出力
        this.WriteBuffer();

        _enableBackground = true;

        _updateState = UpState.Non;
        _srcTexture  = srcTexture;

        _backgroundEncoder = Task.Run(BackGroundEncode);
    }
Exemple #3
0
    public event Action <IntPtr, int> OnEncoded = null;         // エンコード時



    private void WriteBuffer()
    {
        while (true)
        {
            int size = 0;
            var ptr  = VpxDllCall.EncodeGetData(ref size);

            if (ptr == IntPtr.Zero)
            {
                break;
            }

            if (size == 0)
            {
                break;
            }


            this.OnEncoded?.Invoke(ptr, size);
        }
    }
Exemple #4
0
    // フレームバッファを変換して任意のバッファに保存
    private bool Encode()
    {
        try
        {
            this.ImgId++;
            var gcH = GCHandle.Alloc(_pixBuffer, GCHandleType.Pinned);

//			var size = _pixBuffer.Length * Marshal.SizeOf(typeof(Color32));
            var size = _pixBufferSize * Marshal.SizeOf(typeof(Color32));
            VpxDllCall.EncodeSetFrameYUV(gcH.AddrOfPinnedObject(), size, this.Width, 0, this.ImgId);

            gcH.Free();
        }
        catch (Exception e)
        {
            Debug.LogError($"error : {e.Message}");
        }

        this.WriteBuffer();

        return(true);           // 更新あり
    }