Esempio n. 1
0
        public long StartReplay(IReplayModel iReplayModel)
        {
            ReplayModel replayModel = iReplayModel as ReplayModel;

            if (!ValidateReplayParam(replayModel))
            {
                return(-1);
            }

            if (!VideoRecordCache.HasTimeSpecificRecordFile(replayModel.ReplayCamera.ChannelID, replayModel.ReplayTimeRange.BeginTime))
            {
                return(-1);
            }

            long replayHandle = ReplayAdapter.StartReplay(replayModel);

            if (replayHandle < 0)
            {
                return(-1);
            }

            RelayStatusModel playStatus = new RelayStatusModel
            {
                Camera = replayModel.ReplayCamera,
                PlayingScreenHandle = replayModel.ScreenHandle,
                StartPlayDateTime   = replayModel.ReplayTimeRange.BeginTime,
                PlayingHandle       = replayHandle,
                PlayingStatus       = PlayStatus.Play,
                PlayingSpeed        = 1,
            };

            _replayingStatusModelDict.TryAdd(replayModel.ScreenHandle, playStatus);

            return(replayHandle);
        }
Esempio n. 2
0
        /// <summary>
        /// 查询单个录像播放的进度
        /// </summary>
        /// <param name="replayStatus"></param>
        private void QueryReplayStatus(RelayStatusModel replayStatus)
        {
            if (replayStatus == null)
            {
                return;
            }

            //非播放状态下的录像回放无需进行进度查询
            if (!IsNeedQueryReplayPosition(replayStatus))
            {
                return;
            }

            //查询失败或得到错误的结果时不做任何处理
            DateTime replayDateTime = ReplayAdapter.GetReplayPositon(replayStatus.PlayingHandle);

            if (replayDateTime == DateTime.MinValue)
            {
                return;
            }

            //如果播放时间进度已经超过录像文件的最大时间,则通知消息订阅者停止播放
            if (VideoRecordCache.IsTimeBeyondTimeRangeOfVideoFiles(replayStatus.Camera.ChannelID, replayDateTime))
            {
                ReplayPositionChangedEvent?.Invoke(replayStatus.PlayingScreenHandle, DateTime.MaxValue);
                return;
            }

            ReplayPositionChangedEvent?.Invoke(replayStatus.PlayingScreenHandle, replayDateTime);
        }
Esempio n. 3
0
        private bool DirectlySetReplayPosition(RelayStatusModel replayStatus, DateTime replayTime)
        {
            if (replayStatus.PlayingStatus == PlayStatus.Pause)
            {
                ResumeReplay(replayStatus.PlayingScreenHandle);
                Thread.Sleep(200);
            }

            bool result = ReplayAdapter.SetReplayPositon(replayStatus.PlayingHandle, replayTime);

            if (result)
            {
                replayStatus.PlayingStatus = PlayStatus.Play;
            }

            return(true);
        }
Esempio n. 4
0
        public bool StopReplay(IntPtr screenHandle)
        {
            RelayStatusModel replayStatus;

            if (!TryGetReplayStatusByScreenHandle(screenHandle, out replayStatus))
            {
                return(false);
            }

            bool result = ReplayAdapter.StopReplay(replayStatus.PlayingHandle);

            if (result)
            {
                _replayingStatusModelDict.TryRemove(screenHandle, out replayStatus);
            }

            return(result);
        }
Esempio n. 5
0
        public bool ResumeReplay(IntPtr screenHandle)
        {
            RelayStatusModel replayStatus;

            if (!TryGetReplayStatusByScreenHandle(screenHandle, out replayStatus))
            {
                return(false);
            }

            bool result = ReplayAdapter.ResumeReplay(replayStatus.PlayingHandle);

            if (result)
            {
                _replayingStatusModelDict[screenHandle].PlayingStatus = PlayStatus.Play;
            }

            return(result);
        }
Esempio n. 6
0
        private bool SetReplaySpeed(RelayStatusModel replayStatus, double replaySpeed)
        {
            if (replayStatus.PlayingStatus != PlayStatus.Play)
            {
                LogHelper.Default.Debug("设置回放速度失败,当前回放不处于播放状态中,无法设置播放速度");
                return(false);
            }

            if (!ValidateSettingReplaySpeed(replaySpeed))
            {
                return(false);
            }

            bool result = ReplayAdapter.SetReplaySpeed(replayStatus.PlayingHandle, replaySpeed);

            if (result)
            {
                replayStatus.PlayingSpeed = replaySpeed;
            }

            return(result);
        }