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); }
public VideoStreamTrack(string label, UnityEngine.Texture source) : this(label, source, CreateRenderTexture(source.width, source.height, WebRTC.GetSupportedGraphicsFormat(UnityEngine.SystemInfo.graphicsDeviceType)), source.width, source.height) { }
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); }
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); }