void OpenVideoFromRTSP(string url) { ffmpeg = new SharpFFmpeg.SharpFFmpeg(); bool ret = ffmpeg.OpenStream(url, out width, out heigth); if (ret == false) { return; } hit.SetActive(false); tmpTex = new Texture2D(width, heigth, TextureFormat.RGB24, false); ShowTex.mainTexture = tmpTex; ShowTex.shader = Shader.Find("Unlit/Masked Colored"); samples = new byte[width * heigth * 3]; buffer = IntPtr.Zero; StartCoroutine("UpdateVideo"); }
void OnDestroy() { readData = false; StopCoroutine("readMemUpdate"); if (ffmpeg != null) { //StopCoroutine("UpdateVideo"); ffmpeg.CloseStream(); ffmpeg = null; } if (txt2dtest != null) { Destroy(txt2dtest); } if (tmpTex != null) { Destroy(tmpTex); } }
/// <summary> /// 向控制器提交关闭操作 /// </summary> public void Close() { ParentHandle.SendMessage("StopVideo", CamaraRef); readData = false; StopCoroutine("readMemUpdate"); if (ffmpeg != null) { //StopCoroutine("UpdateVideo"); ffmpeg.CloseStream(); ffmpeg = null; } if (txt2dtest != null) { Destroy(txt2dtest); } if (tmpTex != null) { Destroy(tmpTex); tmpTex = null; } }