Beispiel #1
0
        void OnDestroy()
        {
            if (_updater != null)
            {
                _updater.Dispose();
                _updater = null;
            }

            if (_decoder != null)
            {
                _decoder.Dispose();
                _decoder = null;
            }

            if (_stream != null)
            {
                _stream.Dispose();
                _stream = null;
            }

            if (_demuxer != null)
            {
                _demuxer.Dispose();
                _demuxer = null;
            }

            Utility.Destroy(_texture);
            Utility.Destroy(_blitMaterial);
        }
Beispiel #2
0
        void OpenInternal()
        {
            // Demuxer instantiation
            _demuxer = new Demuxer(resolvedFilePath);

            if (!_demuxer.IsValid)
            {
                Debug.LogError("Failed to open stream (" + resolvedFilePath + ").");
                _demuxer.Dispose();
                _demuxer = null;
                return;
            }

            // Stream reader instantiation
            _stream = new StreamReader(_demuxer, _time, _speed / 60);
            (_storedTime, _storedSpeed) = (_time, _speed);

            // Decoder instantiation
            _decoder = new Decoder(
                _stream, _demuxer.Width, _demuxer.Height, _demuxer.VideoType
                );

            // Texture initialization
            _texture = new Texture2D(
                _demuxer.Width, _demuxer.Height,
                Utility.DetermineTextureFormat(_demuxer.VideoType), false
                );
            _texture.wrapMode = TextureWrapMode.Clamp;
            _updater          = new TextureUpdater(_texture, _decoder.CallbackID);
        }
Beispiel #3
0
        public StreamReader(Demuxer demuxer, float time, float delta)
        {
            _demuxer = demuxer;

            _leadQueue   = new Queue <ReadBuffer>();
            _freeBuffers = new List <ReadBuffer>();

            // Initial buffer entry allocation
            _freeBuffers.Add(new ReadBuffer());
            _freeBuffers.Add(new ReadBuffer());
            _freeBuffers.Add(new ReadBuffer());
            _freeBuffers.Add(new ReadBuffer());

            // Initial playback settings
            _restart = (time, SafeDelta(delta));

            // Reader thread startup
            _updateEvent = new AutoResetEvent(true);
            _readEvent   = new AutoResetEvent(false);
            _thread      = new Thread(ReaderThread);
            _thread.Start();
        }
Beispiel #4
0
        void OpenInternal()
        {
            // Demuxer instantiation
            _demuxer = new Demuxer(resolvedFilePath);

            if (!_demuxer.IsValid)
            {
                if (Application.isPlaying)
                {
                    // In play mode, show an error message, then disable itself
                    // to prevent spamming the console.
                    Debug.LogError("Failed to open stream (" + resolvedFilePath + ").");
                    enabled = false;
                }
                _demuxer.Dispose();
                _demuxer = null;
                return;
            }

            // Stream reader instantiation
            _stream = new StreamReader(_demuxer, _time, _speed / 60);
            (_storedTime, _storedSpeed) = (_time, _speed);

            // Decoder instantiation
            _decoder = new Decoder(
                _stream, _demuxer.Width, _demuxer.Height, _demuxer.VideoType
                );

            // Texture initialization
            _texture = new Texture2D(
                _demuxer.Width, _demuxer.Height,
                Utility.DetermineTextureFormat(_demuxer.VideoType), false
                );
            _texture.wrapMode  = TextureWrapMode.Clamp;
            _texture.hideFlags = HideFlags.DontSave;

            _updater = new TextureUpdater(_texture, _decoder);
        }