示例#1
0
 public void GetCacheFreeSize()
 {
     if (player == null)
     {
         return;
     }
     Debug.Log(player.GetCacheFreeSize());
 }
示例#2
0
    private void HandleDataCacheList()
    {
        if (dataCache.Count <= 0)
        {
            return;
        }
        if (isNeedDecodeHead)
        {
            lock (dataCache)
            {
                //64个字节为设备名称,2个字节为宽,2个字节为高
                if (dataCache.Count < 68)
                {
                    return;
                }
                isNeedDecodeHead = false;
                byte[] ba         = dataCache.ToArray();
                string devicename = System.Text.Encoding.Default.GetString(ba, 0, 64);
                Debug.Log("device name:" + devicename);
                Debug.Log("width:" + BitConverter.ToUInt16(new byte[2] {
                    ba[65], ba[64]
                }, 0));
                Debug.Log("height:" + BitConverter.ToInt16(new byte[2] {
                    ba[67], ba[66]
                }, 0));
                dataCache.RemoveRange(0, 64);
                player.TryBitStreamDemux();
                //做清理标记
                ClearDevices();
            }
        }

        lock (dataCache)
        {
            byte[] arr  = dataCache.ToArray();
            int    size = Mathf.Min(player.GetCacheFreeSize(), arr.Length);
            if (player.PushStream2Cache(arr, size))
            {
                dataCache.RemoveRange(0, size);
            }
        }
    }