示例#1
0
        public VideoCacheManager(LocalDownloadInfoPacket param, DateTime begin, DateTime end) : this(begin, end)
        {
            _vInfo      = param.Info;
            VideoName   = param.Info.VideoName;
            LastestTime = begin;

            _streamProxy.LoadLocal(param);
            Start(begin);
        }
        public void TestLocalDownloadInfoPacket()
        {
            LocalDownloadInfoPacket packet = new LocalDownloadInfoPacket(new VideoInfo("videoId", 1), "path");
            var buffer  = LocalDownloadInfoPacket.Encode(packet);
            var packet2 = LocalDownloadInfoPacket.Decode(buffer);

            Assert.AreNotSame(packet, packet2);
            Assert.AreEqual(packet.Path, packet2.Path);
            Assert.AreNotSame(packet.Info, packet2.Info);
            Assert.AreEqual(packet.Info.VideoId, packet2.Info.VideoId);
            Assert.AreEqual(packet.Info.VideoName, packet2.Info.VideoName);
            Assert.AreEqual(packet.Info.StreamId, packet2.Info.StreamId);
        }
示例#3
0
        public void AddToPlay(string videoId, int streamId, string videoName)
        {
            if (PlaySlider.BeginTime >= PlaySlider.EndTime)
            {
                DialogUtil.ShowWarning("无效查询时间段。");
                return;
            }
            if (Source == null)
            {
                DialogUtil.ShowWarning("无效的数据源。");
                return;
            }

            VideoControlViewModel vm = null;
            string dictKey           = null;

            if (Source.SrcType == SourceType.Local)
            {
                LocalDownloadInfoPacket param = new LocalDownloadInfoPacket(new VideoInfo(videoId, streamId, videoName), Source.LocalSourcePath);
                if (!isContained(param.Info))
                {
                    vm      = new VideoControlViewModel(param, PlaySlider.BeginTime, PlaySlider.EndTime, _replayProcess);
                    dictKey = buildKey(param.Info);
                }
            }
            else
            {
                DownloadInfoParam downloadInfo = new DownloadInfoParam(Source.Storage.Ip, Source.Storage.Port, PlaySlider.BeginTime, PlaySlider.EndTime, videoId, streamId, ConstSettings.CachePath, videoName);
                if (!isContained(downloadInfo))
                {
                    vm      = new VideoControlViewModel(downloadInfo, _replayProcess);
                    dictKey = buildKey(downloadInfo);
                }
            }
            if (vm != null && dictKey != null)
            {
                lock (_videoLockObj)
                {
                    _dictVideoVMS[dictKey] = vm;
                }
                addOrRemoveVideoEvent(vm, true);
                onVideoAdded(vm);
                vm.ProgressOffset = PlaySlider.Slider / (double)PlaySlider.SliderMaximum;
            }
        }
示例#4
0
 public void LoadLocal(LocalDownloadInfoPacket param)
 {
     sendData((int)ParamCode.LocalDownloadBegin, LocalDownloadInfoPacket.Encode(param));
 }
 public VideoDisplayViewModel(LocalDownloadInfoPacket param, DateTime begin, DateTime end, ITimeProcess palyProcess)
 {
     StreamManager = new VideoCacheManager(param, begin, end);
     initDisplayer(StreamManager, palyProcess);
 }
示例#6
0
        private void onReceiveCompleted(object sender, ReceiveEventArgs args)
        {
            try
            {
                if (args.ByteLength > 0)
                {
                    using (MemoryStream ms = new MemoryStream(args.ReceivedBytes))
                    {
                        ParamCode code   = (ParamCode)PacketBase.ReadInt(ms);
                        byte[]    buffer = null;
                        switch (code)
                        {
                        case ParamCode.VideoInfosTimePeriods:
                            updateVideoInfosTimePeriods(VideoDataInfoParam.Decode(ms));
                            break;

                        case ParamCode.DownloadBegin:
                            beginDownload(DownloadInfoParam.Decode(ms));
                            break;

                        case ParamCode.DownloadToLocal:
                            downloadToLocal(PacketBase.ReadString(ms));
                            break;

                        case ParamCode.VideoPacket:
                            getVideoStreamsPacket(VideoDataParam.Decode(ms));
                            break;

                        case ParamCode.ProbeTime:
                            setProbeTime(PacketBase.ReadTime(ms));
                            break;

                        case ParamCode.DownloadInfosAll:
                            feedbackDownloadInfosToClient();
                            break;

                        case ParamCode.DownloadControl:
                            var controlCode = (DownloadControlCode)PacketBase.ReadInt(ms);
                            onDownloadControl(controlCode, ms);
                            break;

                        case ParamCode.LocalDownloadPath:
                            onLocalDownloadPath(PacketBase.ReadString(ms));
                            break;

                        case ParamCode.LocalDownloadBegin:
                            onLocalDownloadStart(LocalDownloadInfoPacket.Decode(ms));
                            break;
                        }
                        if (buffer != null)
                        {
                            send((ParamCode)code, buffer);
                        }
                    }
                }
            }
            catch (IOException ex)
            {
                sendMessage(MessageType.Warn, ex.Message, null);
            }
            catch (Exception ex)
            {
                sendMessage(MessageType.Error, ex.Message, null);
                Console.WriteLine(ex.ToString());
            }
        }
示例#7
0
 private void onLocalDownloadStart(LocalDownloadInfoPacket packet)
 {
     Logger.Default.Trace("播放本地视频,名称:{0} VideoId:{1} Stream:{2} Path:{3}", packet.Info.VideoName, packet.Info.VideoId, packet.Info.StreamId, packet.Path);
     _download = new OfflinePlayManager(packet);
     feedbackBase();
 }
 public VideoControlViewModel(LocalDownloadInfoPacket localDownInfo, DateTime begin, DateTime end, ITimeProcess playProcess)
     : this(begin, end, playProcess)
 {
     VideoInfo    = localDownInfo.Info;
     DisplayModel = new VideoDisplayViewModel(localDownInfo, begin, end, _playProcess);
 }
示例#9
0
 public OfflinePlayManager(LocalDownloadInfoPacket packet)
 {
     _loadInfo = packet;
     _path     = System.IO.Path.Combine(packet.Path, $"{packet.Info.VideoId}_{packet.Info.StreamId}");
     _baseRec  = new VideoBaseFileRecorder(_path);
 }