private void initDecoder() { _ffmpegDecoder = new FfmpegDecoder(); _hikm4Decoder = new HikM4Decoder(); _univiewDecoder = new UniviewDecoder(); _hikm4Decoder.VideoFrameEvent += hikm4Decoder_VideoFrameEvent; _univiewDecoder.VideoFrameEvent += univiewDecoder_VideoFrameEvent; }
void run() { UniviewDecoder decoder = new UniviewDecoder(); decoder.VideoFrameEvent += univiewVideoFrameEvent; int index = 0; int wait = 0; while (!_disposeEvent.WaitOne(wait)) { wait = 1; if (_records.Length > 0) { bool reposed = false; DateTime startRealTime; DateTime startPlayTime; lock (_playTimeLockObj) { startRealTime = _startRealTime; startPlayTime = _startPlayTime; reposed = _reposed; _reposed = false; } if (_playing || reposed) { DateTime curPlayTime = startPlayTime + new TimeSpan((long)Math.Round((DateTime.Now - startRealTime).Ticks * _speed)); if (curPlayTime > EndTime) { curPlayTime = EndTime; } Record <UniviewPackage> record = null; if (reposed) { for (index = 0; index < _records.Length; index++) { if (_records[index].Time >= curPlayTime) { break; } } if (index < _records.Length) { record = _records[index]; } } else { int next = index + 1; if (next < _records.Length && _records[next].Time < curPlayTime) { index = next; record = _records[index]; } } if (record != null) { _currentTime = record.Time; decoder.InputData(record.Package.DecodeTag, record.Package.Data); wait = 0; } } } } }
public void Dispose() { _decoder?.Dispose(); _decoder = null; }
public UniviewStreamDecoder() { _decoder = new UniviewDecoder(); _decoder.VideoFrameEvent += onVideoFrame; }