Ejemplo n.º 1
0
        private static RenderTexture CreateRenderTexture(int width, int height)
        {
            var format = WebRTC.GetSupportedGraphicsFormat(SystemInfo.graphicsDeviceType);
            var tex    = new RenderTexture(width, height, 0, format);

            tex.Create();
            return(tex);
        }
Ejemplo n.º 2
0
 public VideoStreamTrack(string label, UnityEngine.Texture source)
     : this(label,
            source,
            CreateRenderTexture(source.width, source.height,
                                WebRTC.GetSupportedGraphicsFormat(UnityEngine.SystemInfo.graphicsDeviceType)),
            source.width,
            source.height)
 {
 }
Ejemplo n.º 3
0
        public Texture InitializeReceiver(int width, int height)
        {
            if (IsDecoderInitialized)
            {
                throw new InvalidOperationException("Already initialized receiver, use Texture property");
            }

            m_needFlip = true;
            var format = WebRTC.GetSupportedGraphicsFormat(SystemInfo.graphicsDeviceType);

            m_sourceTexture = new Texture2D(width, height, format, TextureCreationFlags.None);
            m_destTexture   = CreateRenderTexture(m_sourceTexture.width, m_sourceTexture.height);

            m_renderer = new UnityVideoRenderer(WebRTC.Context.CreateVideoRenderer(), this);

            return(m_destTexture);
        }
Ejemplo n.º 4
0
        private void OnVideoFrameResizeInternal(int width, int height)
        {
            if (Texture != null &&
                Texture.width == width &&
                Texture.height == height)
            {
                return;
            }

            if (Texture != null)
            {
                WebRTC.DestroyOnMainThread(Texture);
                Texture = null;
            }

            var format = WebRTC.GetSupportedGraphicsFormat(SystemInfo.graphicsDeviceType);

            Texture = new Texture2D(width, height, format, TextureCreationFlags.None);
            track.OnVideoFrameResize(Texture);
        }