Пример #1
0
        /// <summary>
        /// 点播节目单带节目介绍输出
        /// </summary>
        public static XElement ConLenListRes(VideoNode video, ExFilterBase filter, bool isEx)
        {
            var res  = VideoUtils.FormatStrArray(10, video.Main.VideoWidth, "|", video.Main.VideoHeight);
            var flag = video.Flags.FormatListToStr(SplitArray.Line);
            var v    = new XElement("v",
                                    new XElement("vid", video.Main.ChannelID),
                                    new XElement("playlink", BoxUtils.GetXmlCData(video.PlayLink)),
                                    new XElement("title", video.Language[filter.lang].ChannelName),
                                    new XElement("subtitle", video.Language[filter.lang].SubTitle),
                                    new XElement("type", video.Type),
                                    new XElement("catalog", video.Language[filter.lang].CatalogTags),
                                    new XElement("director", video.Language[filter.lang].Directors),
                                    new XElement("act", video.Language[filter.lang].Actors),
                                    new XElement("year", video.YearTags),
                                    new XElement("area", video.Language[filter.lang].AreaTags),
                                    new XElement("imgurl", video.ResImage),
                                    new XElement("sloturl", ImplUtils.SlogImageJoin(video.SlotImage)),
                                    new XElement("state", video.State),
                                    new XElement("total_state", video.BKInfo.Episode),
                                    new XElement("note", ""),
                                    new XElement("mark", video.BKInfo.Score),
                                    new XElement("hot", ImplUtils.ConvertHot(video.Hot)),
                                    new XElement("pv", video.PV),
                                    new XElement("bitrate", video.Main.BitRate),
                                    new XElement("resolution", res),
                                    new XElement("flag", flag),
                                    new XElement("duration", video.Main.TimeLength / 60),
                                    new XElement("content", BoxUtils.GetXmlCData(video.Language[filter.lang].Introduction.FormateSubStr(filter.conlen))),
                                    new XElement("onlinetime", video.Main.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"))
                                    );

            return(v);
        }
Пример #2
0
        public void ShowVideo(Media.MediaUri uri, Media.VideoEncoderConfiguration encoder, Media.AudioEncoderConfiguration audio)
        {
            try
            {
                _videoWindow = new VideoContainer();
                DeviceEnvironment environment    = ContextController.GetDeviceEnvironment();
                int messageTimeout               = environment.Timeouts.Message;
                Media.TransportProtocol protocol = GetTransportProtocol();
                VideoUtils.AdjustVideo(
                    _videoWindow,
                    environment.Credentials.UserName,
                    environment.Credentials.Password,
                    messageTimeout,
                    protocol,
                    Media.StreamType.RTPUnicast,
                    uri,
                    encoder);
                _videoWindow.KEEPALIVE = true;
                _videoWindow.DebugPage = true;
                _videoWindow.OpenWindow(audio != null);

                Invoke(new Action(() => { btnGetStreams.Text = "Stop Video"; }));
            }
            catch
            {
                _videoWindow.DebugPage = false;
                _videoWindow           = null;
                throw;
            }
        }
Пример #3
0
        public void GetVideoInfo_Test()
        {
            var videoInfo = new VideoUtils().GetVideoInfo(SampleFiles.SampleVideo_5sec);

            Assert.AreEqual(720, videoInfo.Height);
            Assert.AreEqual(1280, videoInfo.Width);
        }
Пример #4
0
 public string TodayUpdate(UpdateFilter filter)
 {
     try
     {
         var    nowvideos    = VideoUtils.ConvertVodIenum(ListCache.Instance.Items[new VideoNodeKey(null, 0, null)].Ver1);
         var    updatevideos = nowvideos.Where(video => video.ModifyTime >= filter.lasttime);                  //.ToList();
         var    deletevideos = YesterdayListCache.Instance.Items.Except(nowvideos, new YesterdayVidCompare()); //.ToList();
         int    count        = updatevideos.Count();
         string lasttime     = filter.lasttime.ToString("HH:mm:ss");
         if (count > 0)
         {
             lasttime = updatevideos.Max(video => video.ModifyTime).ToString("HH:mm:ss");
         }
         //var currentvideos = updatevideos.Skip(filter.c * (filter.s - 1)).Take(filter.c);
         var xml = new XElement("vlist",
                                //new XElement("count", count),
                                //new XElement("page_count", PageUtils.PageCount(count, filter.c)),
                                new XElement("latest_time", lasttime),
                                new XElement("v-update", new XAttribute("count", count),
                                             from video in updatevideos select ResponseUtils.ResponseBack(ListCache.Instance.Dictionary[video.ChannelId])
                                             ),
                                new XElement("v-delete", new XAttribute("count", deletevideos.Count()),
                                             from dv in deletevideos select new XElement("vid", dv.ChannelId)
                                             )
                                );
         return(xml.ToString(SaveOptions.DisableFormatting));
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
Пример #5
0
 public void ShowVideo(Onvif.MediaUri uri, Onvif.VideoEncoderConfiguration encoder)
 {
     try
     {
         _videoWindow = new VideoContainer();
         DeviceEnvironment environment = ContextController.GetDeviceEnvironment();
         int messageTimeout            = environment.Timeouts.Message;
         VideoUtils.AdjustVideo(
             _videoWindow,
             environment.Credentials.UserName,
             environment.Credentials.Password,
             messageTimeout,
             Onvif.TransportProtocol.UDP,
             Onvif.StreamType.RTPUnicast,
             uri,
             encoder);
         _videoWindow.KEEPALIVE = true;
         _videoWindow.OpenWindow(false);
         Invoke(new Action(() => { btnVideo.Text = "Stop Video"; }));
     }
     catch
     {
         _videoWindow = null;
         throw;
     }
 }
Пример #6
0
        /// <summary>
        /// 创建二代直播播放串
        /// </summary>
        public static XElement CreateLivePlayLinkVer2(int vid, ExFilterBase filter, bool isEx)
        {
            var video = LiveListCache.Instance.Dictionary[vid];
            var p     = new XElement("playlink2");
            IEnumerable <int> groups = video.Groups;

            if (isEx && video.Groups.Count > 1)
            {
                var filters = VideoNodesUtil.FormateTagFilter(filter);
                groups = video.Groups.Where(v =>
                {
                    var result = true;
                    var gv     = LiveListCache.Instance.Dictionary[v];
                    foreach (var f in filters)     //过滤不符合的子频道
                    {
                        result = result && f(gv, filter);
                    }
                    return(result);
                });
            }
            foreach (var g in groups)
            {
                var gv  = LiveListCache.Instance.Dictionary[g];
                var res = VideoUtils.FormatStrArray(10, gv.Main.VideoWidth, "|", gv.Main.VideoHeight);
                p.Add(new XElement("source",
                                   new XAttribute("mark", gv.Language[filter.lang].Mark),
                                   new XAttribute("bitrate", gv.Main.BitRate),
                                   new XAttribute("resolution", res),
                                   BoxUtils.GetXmlCData(gv.Main.PlayLink)
                                   ));
            }
            return(p);
        }
Пример #7
0
        /// <summary>
        /// prepare for loop and enable the looping timer
        /// </summary>
        public void InitiateLoopingTask()
        {
            //convert timestamp to seconds
            int start = VideoUtils.ConvertTimestampToSeconds(Player.BeginText);
            int end   = VideoUtils.ConvertTimestampToSeconds(Player.EndText);

            //bail out if the timestamps are invalid
            if (start < 0 || start > Player.TotalDuration ||
                end < 0 || end > Player.TotalDuration ||
                start >= end)
            {
                return;
            }

            //calculate duration, adding once second for padding
            int duration = end - start + 1;

            //store start position in case user changes start time during loop
            _currentLoopStartTime = start;

            //notify looping has started
            IsLooping = true;

            //move current position to start position
            Player.MediaPlayer.Position = TimeSpan.FromSeconds(_currentLoopStartTime);

            //****LOOP STARTED HERE****
            //set duration of loop
            //activate looping dispatcher timer
            _loopTimer.Interval  = TimeSpan.FromSeconds(duration);
            _loopTimer.IsEnabled = true;
        }
Пример #8
0
        protected override void ResetVariables()
        {
            base.ResetVariables();

            videoUtils = new VideoUtils();
            videoUtils.ImageComplete += VideoImage_ImageComplete;
        }
Пример #9
0
 //TODO remove protected attribute - temporary usage only, till GetURI will work fully OK
 protected void AdjustVideo(
     TransportProtocol protocol,
     StreamType streamType,
     MediaUri streamUri,
     VideoEncoderConfiguration conf)
 {
     VideoUtils.AdjustVideo(_videoForm, _username, _password, _messageTimeout, protocol, streamType, streamUri, conf);
 }
Пример #10
0
        public void VideoInfo_Test()
        {
            var videoUtils = new VideoUtils();
            var videoInfo  = videoUtils.GetVideoInfo(this.YoutubeVideoStreamUrl);

            Assert.AreEqual(1080, videoInfo.Height);
            Assert.AreEqual(1920, videoInfo.Width);
        }
Пример #11
0
        /// <summary>
        /// jump to the position stored in the jump text box
        /// </summary>
        public void JumpTo()
        {
            int position = VideoUtils.ConvertTimestampToSeconds(JumpToText);

            if (MediaPlayer.Source != null && position >= 0 && position < TotalDuration)
            {
                MediaPlayer.Position = TimeSpan.FromSeconds(position);
            }
        }
Пример #12
0
        public async void SymbolicLinkAsFFMpegInput_Test()
        {
            var symbolicLink = await FileSystemExtension.CreateFileSymbolicLink(@"D:\Dima\Work\Home\Handball videos\dragūnakturungtynės.mp4");

            var videoInfo = new VideoUtils().GetVideoInfo(symbolicLink);

            Assert.AreEqual(360, videoInfo.Height);
            Assert.AreEqual(640, videoInfo.Width);
        }
Пример #13
0
        private Task <bool> CreateTrimVideo(Tuple <long, long> _bestts)
        {
            Java.IO.File inputFile      = new Java.IO.File(_downloadsfilesdir, _inputfilename);
            var          outputfilename = string.Format("{0}.mp4", DateTime.Now.Ticks);

            Java.IO.File outputFile = new Java.IO.File(_downloadsfilesdir, outputfilename);
            _outputfilepath = outputFile.Path;
            var result = VideoUtils.startTrim(inputFile, outputFile, _bestts.Item1, _bestts.Item2);

            return(Task.FromResult(result));
        }
Пример #14
0
        public void ExtractThumbnailToBagFromInternet()
        {
            var videoUtils    = new VideoUtils();
            var thumbnailTask = videoUtils.GetFrameFromVideoAsByteAsync("https://www.youtube.com/watch?v=Tt5Y78DioZM", 2000);

            thumbnailTask.Wait();
            var thumbnail = thumbnailTask.Result;

            File.WriteAllBytes("Thumbnail.bmp", thumbnail);
            Process.Start("Thumbnail.bmp").WaitForExit();
        }
Пример #15
0
        /// <summary>
        /// shuffle the playlist
        /// </summary>
        public void Shuffle()
        {
            //save current item
            var currentItem = SelectedItem;

            //make copy of items and shuffle to notify property changed
            VideoUtils.shuffleInPlace(Items);

            //update the current info
            CurrentIndex = Items.IndexOf(currentItem);
            SelectedItem = Items[CurrentIndex];
        }
Пример #16
0
 public void Execute(JobExecutionContext context)
 {
     try
     {
         log.Info("UpdateListJob开始更新");
         var yesterday = YesterdayListCache.Instance.Items;
         var todaylist = ListCache.Instance.Items[new VideoNodeKey(null, 0, null)].Ver1;
         var today     = VideoUtils.ConvertVodIenum(todaylist);
         var root      = new XElement("vlist");
         root.Add(new XElement("count", todaylist.Count()));
         XElement updatexml;
         XElement deletexml;
         if (yesterday != null)
         {
             var updatevideo = today.Intersect(yesterday, new YesterdayModifyCompare());
             var addvideo    = today.Except(yesterday, new YesterdayVidCompare());
             var deletevideo = yesterday.Except(today, new YesterdayVidCompare());
             updatexml = new XElement("v-update", new XAttribute("count", updatevideo.Count() + addvideo.Count()));
             foreach (var uv in updatevideo)
             {
                 updatexml.Add(ResponseUtils.ResponseBack(ListCache.Instance.Dictionary[uv.ChannelId]));
             }
             foreach (var av in addvideo)
             {
                 updatexml.Add(ResponseUtils.ResponseBack(ListCache.Instance.Dictionary[av.ChannelId]));
             }
             deletexml = new XElement("v-delete", new XAttribute("count", deletevideo.Count()));
             foreach (var dv in deletevideo)
             {
                 var v = new XElement("vid", dv.ChannelId);
                 deletexml.Add(v);
             }
         }
         else
         {
             updatexml = new XElement("v-update", new XAttribute("count", 0));
             deletexml = new XElement("v-delete", new XAttribute("count", 0));
         }
         root.Add(updatexml);
         root.Add(deletexml);
         string fileName = string.Format("delta_{0}.xml", DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"));
         ResponseUtils.SaveXml(fileName, root);
     }
     catch (Exception ex)
     {
         log.Error(ex);
     }
     finally
     {
         log.Info("UpdateListJob结束更新");
     }
 }
Пример #17
0
        public FFMpegYoutubeTests()
        {
            var videoUtils   = new VideoUtils();
            var webVideoInfo = videoUtils.GetWebVideoInfo(YoutubeVideoUrl);

            this.YoutubeVideoStreamUrl = webVideoInfo.VideoStreamUrl;
            this.YoutubeAudioStreamUrl = webVideoInfo.AudioStreamUrl;

            if (!Directory.Exists(OutputFolder))
            {
                Directory.CreateDirectory(OutputFolder);
            }
        }
Пример #18
0
 private void DoSequence(string codec, string filename, MediaUri Uri, StreamType streamType, TransportProtocol protocol)
 {
     if (NewGenVideo == null)
     {
         NewGenVideo = new VideoContainer2();
     }
     VideoUtils.AdjustGeneral2(NewGenVideo, _username, _password, MessageTimeout, protocol, streamType, Uri);
     VideoUtils.AdjustBackchannel2(NewGenVideo, codec, filename);
     NewGenVideo.EventSink = this;
     NewGenVideo.SetSequence(4);
     NewGenVideo.SilentRun();
     NewGenVideo.EventSink = null;
 }
Пример #19
0
        public static void ProcessLang(VideoNode video)
        {
            video.Language = new Dictionary <string, ChannelLanguageNode>(AppSettingCache.LanguageNum);
            video.YearTags = VideoUtils.FormatBoxTag(video.TagsRank, CustomArray.YearDimension, 15);
            var cnode = new ChannelLanguageNode();

            cnode.ChannelName = video.ChannelName;
            cnode.SubTitle    = video.Main.AliasName;
            cnode.Mark        = ListUtils <VideoNode> .SetMark(video);

            cnode.AreaTags     = VideoUtils.FormatBoxTag(video.TagsRank, CustomArray.AreaDimension);
            cnode.CatalogTags  = VideoUtils.FormatBoxTag(video.TagsRank, CustomArray.CatalogDimension);
            cnode.Actors       = video.BKInfo.Actors;
            cnode.Directors    = video.BKInfo.Directors;
            cnode.Introduction = video.BKInfo.Introduction;
            video.Language[CustomArray.LanguageArray[0]] = cnode;
            ListUtils <VideoNode> .SetViceMaxNum(video, CustomArray.LanguageArray[0]);

            if (AppSettingCache.Instance["LanauageTW"] == "1")
            {
                var node = new TraditionChannelNode(cnode);
                video.Language[CustomArray.LanguageArray[1]] = node;
                ListUtils <VideoNode> .SetViceMaxNum(video, CustomArray.LanguageArray[1]);

                //var node = new ChannelLanguageNode();
                //node.ChannelName = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].ChannelName);
                //node.SubTitle = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].SubTitle);
                //node.Mark = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].Mark);
                //node.AreaTags = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].AreaTags);
                //node.CatalogTags = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].CatalogTags);
                //node.Actors = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].Actors);
                //node.Directors = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].Directors);
                //node.Introduction = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].Introduction);
                //video.Language[CustomArray.LanguageArray[1]] = node;
                //ListUtils<VideoNode>.SetViceMaxNum(video, CustomArray.LanguageArray[1]);
            }
            if (AppSettingCache.Instance["LanauageEN"] == "2")
            {
                var node = new ChannelLanguageNode();
                node.ChannelName = video.Main.NameEng;
                node.SubTitle    = "unknow";
                node.Mark        = "unknow";
                //node.AreaTags = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].AreaTags);
                //node.CatalogTags = LanguageUtils.FormatTraditionChinese(video.Language[CustomArray.LanguageArray[0]].CatalogTags);
                node.Actors       = video.BKInfo.ActorsEng;
                node.Directors    = video.BKInfo.DirectorsEng;
                node.Introduction = video.BKInfo.IntroductionEng;
                video.Language[CustomArray.LanguageArray[2]] = node;
                ListUtils <VideoNode> .SetViceMaxNum(video, CustomArray.LanguageArray[2]);
            }
        }
Пример #20
0
        private void ToxAv_OnVideoFrameReceived(object sender, ToxAvEventArgs.VideoFrameEventArgs e)
        {
            var source = VideoUtils.ToxAvFrameToBitmap(e.Frame);

            MainWindow.Instance.UInvoke(() =>
            {
                var friend = MainWindow.Instance.ViewModel.CurrentFriendListView.FindFriend(e.FriendNumber);
                if (friend == null)
                {
                    return;
                }

                (friend.ConversationView as ConversationViewModel).CurrentFrame = source;
            });
        }
Пример #21
0
        public void CreateThumbnailFromSmallVideo_ParallelTest()
        {
            FFMpeg.DebugModeEnabled = true;
            var allThumbnails = new ConcurrentBag <byte[]>();
            var videoUtils    = new VideoUtils();

            for (int i = 0; i < 100; i++)
            {
                this.ExtractThumbnailToBag(videoUtils, allThumbnails, i % 100);
            }
            while (allThumbnails.Count != 100)
            {
                Thread.Sleep(300);
            }
            Assert.AreEqual(100, allThumbnails.Count);
        }
Пример #22
0
        public static string ResList(VideoNode video, DetailFilter filter, bool isEx)
        {
            var xml  = new XElement("v");
            var res  = VideoUtils.FormatStrArray(10, video.Main.VideoWidth, "|", video.Main.VideoHeight);
            var flag = video.Flags.FormatListToStr(SplitArray.Line);

            xml.Add(
                new XElement("vid", video.Main.ChannelID),
                new XElement("title", video.Language[filter.lang].ChannelName),
                new XElement("subtitle", video.Language[filter.lang].SubTitle),
                new XElement("type", video.Type),
                new XElement("catalog", video.Language[filter.lang].CatalogTags),
                new XElement("director", video.Language[filter.lang].Directors),
                new XElement("act", video.Language[filter.lang].Actors),
                new XElement("year", video.YearTags),
                new XElement("area", video.Language[filter.lang].AreaTags),
                new XElement("imgurl", video.ResImage),
                new XElement("sloturl", ImplUtils.SlogImageJoin(video.SlotImage)),
                new XElement("state", video.State),
                new XElement("total_state", video.BKInfo.Episode),
                new XElement("note", ""),
                new XElement("mark", video.BKInfo.Score),
                new XElement("hot", ImplUtils.ConvertHot(video.Hot)),
                new XElement("pv", video.PV),
                new XElement("bitrate", video.Main.BitRate),
                new XElement("resolution", res),
                new XElement("flag", flag),
                new XElement("duration", video.Main.TimeLength / 60),
                new XElement("content", BoxUtils.GetXmlCData(video.Language[filter.lang].Introduction)),
                new XElement("onlinetime", video.Main.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")),
                new XElement("video_list_count", video.StateCount)
                );
            if (filter.ver <= 1)
            {
                CreateLinkVer1(video, filter, xml);
            }
            else
            {
                CreateLinkVer2(video, filter, xml, isEx);
            }
            return(xml.ToString(SaveOptions.DisableFormatting));
        }
        private void DoSequence(VideoEncoderConfiguration config, MediaUri Uri)
        {
            if (NewGenVideo == null)
            {
                NewGenVideo = new VideoContainer2();
            }
            VideoUtils.AdjustGeneral2(NewGenVideo, _username, _password, MessageTimeout, TransportProtocol.UDP, StreamType.RTPUnicast, Uri);
            VideoUtils.AdjustVideo2(NewGenVideo, config);
            //ValidateStreamSequence22();
            NewGenVideo.EventSink = this;
            NewGenVideo.SetSequence(2, OperationDelay, false, true);
            NewGenVideo.Connect();
            NewGenVideo.SetupWindow();
            VideoIsOpened = true;

            NewGenVideo.Run();
            NewGenVideo.CloseWindow();
            VideoIsOpened         = false;
            NewGenVideo.EventSink = null;
        }
Пример #24
0
        /// <summary>
        /// 自刷新行为
        /// </summary>
        public override void RefreshCache()
        {
            var channels = ChannelCache.Instance.Items;
            var vicecs   = ViceChnanelCache.Instance.Items;

            //过滤BKInfo为空的频道
            var bkinfoquery = from channel in channels let bkid = VideoUtils.FormatStrArray(16, BKTypeCache.Instance[channel.BKType], "/", channel.BKID) let bkinfo = BKInfoCache.Instance[bkid] where bkinfo != null select new VideoNode()
            {
                Main = channel, BKInfo = bkinfo
            };

            //加载Tag信息
            var tagquery = from channel in bkinfoquery join tagrel in ChannelTagRelCache.Instance.Items on channel.Main.ChannelID equals tagrel.ChannelID into tagrels let x = LoadTags(channel, tagrels) where channel.Type != 0 select channel;

            //加载合集
            var vicequery = from channel in tagquery join vice in vicecs on channel.Main.ChannelID equals vice.ParentChannelID into vices let x = LoadChildren(channel, vices) where x && FilterVideo(channel) select channel;

            //根据平台建立索引
            LoadPlatForm(vicequery.OrderByDescending(v => v.Main.Rank).ThenByDescending(v => v.Main.CreateTime));
        }
        protected void AdjustVideo(string recordingToken, TransportProtocol protocol)
        {
            StreamSetup streamSetup = new StreamSetup();

            streamSetup.Transport          = new Transport();
            streamSetup.Transport.Protocol = protocol;
            streamSetup.Stream             = StreamType.RTPUnicast;

            MediaUri replayUri = new MediaUri();

            CreateReplayPortClient();

            RunStep(() =>
            {
                replayUri.Uri = ReplayClient.GetReplayUri(streamSetup, recordingToken);
                LogStepEvent("Replay URI = " + replayUri.Uri);
            }, "Get Replay Uri");

            VideoUtils.AdjustVideo(_videoForm, _username, _password, _messageTimeout,
                                   streamSetup.Transport.Protocol, streamSetup.Stream,
                                   replayUri, null);
        }
Пример #26
0
        /// <summary>
        /// 创建二代点播播放串,合集只写出首集
        /// </summary>
        public static XElement CreateVodPlayLinkVer2(int vid, ExFilterBase filter, bool isEx)
        {
            var video = ListCache.Instance.Dictionary[vid];
            var p     = new XElement("playlink2",
                                     new XAttribute("duration", video.ViceChannels != null && video.ViceChannels.Count > 0 ? video.ViceChannels[0].Duration : video.Main.TimeLength)
                                     //new XAttribute("start_point", 60.22),
                                     //new XAttribute("end_point", 289.22)
                                     );
            IEnumerable <int> groups = video.Groups;

            if (isEx && video.Groups.Count > 1)
            {
                var filters = VideoNodesUtil.FormateTagFilter(filter);
                groups = video.Groups.Where(v =>
                {
                    var result = true;
                    var gv     = ListCache.Instance.Dictionary[v];
                    foreach (var f in filters)     //过滤不符合的子频道
                    {
                        result = result && f(gv, filter);
                    }
                    return(result);
                });
            }
            foreach (var g in groups)
            {
                var gv  = ListCache.Instance.Dictionary[g];
                var res = VideoUtils.FormatStrArray(10, gv.Main.VideoWidth, "|", gv.Main.VideoHeight);
                p.Add(new XElement("source",
                                   new XAttribute("mark", gv.Language[filter.lang].Mark),
                                   new XAttribute("bitrate", gv.Main.BitRate),
                                   new XAttribute("filelength", gv.ViceChannels != null && gv.ViceChannels.Count > 0 ? gv.ViceChannels[0].Duration * gv.Main.BitRate * (1024 / 8) : gv.Main.TimeLength * gv.Main.BitRate * (1024 / 8)),
                                   new XAttribute("resolution", res),
                                   BoxUtils.GetXmlCData(gv.PlayLink)
                                   ));
            }
            return(p);
        }
Пример #27
0
        private void OnToxAvVideoFrameReceived(object sender, ToxAvEventArgs.VideoFrameEventArgs e)
        {
            Bitmap videoFrame = VideoUtils.ToxAvFrameToBitmap(e.Frame, this.cpuHasSsse3);

            if (videoFrame == null)
            {
                return;
            }

            if (this.callInfo == null || !this.callInfo.CanReceiveVideo)
            {
                videoFrame.Dispose();
                return;
            }

            try
            {
                MainForm.Instance.NotifyToxAvVideoFrameReceived(new VideoFrameInfo(e.FriendNumber, videoFrame));
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex.Message);
            }
        }
Пример #28
0
        /// <summary>
        /// 加载频道Tag信息
        /// </summary>
        private object LoadTags(VideoNode video, IEnumerable <ChannelTagRelInfo> tagRels)
        {
            if (tagRels.Count() == 0)
            {
                return(null);
            }
            var acts      = video.BKInfo.Actors.FormatStrToArray(SplitArray.DHArray).Select(v => VideoUtils.FormatStrArray(v.Length + 8, v, ":", CustomArray.ActDimension));
            var directors = video.BKInfo.Directors.FormatStrToArray(SplitArray.DHArray).Select(v => VideoUtils.FormatStrArray(v.Length + 10, v, ":", CustomArray.DirectorDimension));
            var tags      = new Dictionary <string, int>(tagRels.Count() + acts.Count() + directors.Count());

            foreach (var act in acts)
            {
                tags[act] = 0;
            }
            foreach (var director in directors)
            {
                tags[director] = 0;
            }
            foreach (var tagrel in tagRels)
            {
                var tag = BoxTagCache.Instance[tagrel.TagID];
                if (tag == null)
                {
                    continue;
                }
                video.Type = tag.BoxTypeID;
                var tagtype = TagTypeCache.Instance[tag.TagType];
                if (tagtype != null)
                {
                    string dimension = VideoUtils.FormatStrArray(tag.TagName.Length + tagtype.TagTypeLimitName.Length + 2, tag.TagName, ":", tagtype.TagTypeLimitName);
                    tags[dimension] = tagrel.Rank;
                }
            }
            video.TagsRank = tags;
            return(null);
        }
Пример #29
0
        private void VideoEngine_OnFrameAvailable(Bitmap bmp)
        {
            if (_callInfo == null)
            {
                return;
            }

            var frame = VideoUtils.BitmapToToxAvFrame(bmp);

            bmp.Dispose();

            //yes, check again
            if (_callInfo == null)
            {
                return;
            }

            var error = ToxAvErrorSendFrame.Ok;

            if (!_toxAv.SendVideoFrame(_callInfo.FriendNumber, frame, out error))
            {
                Debugging.Write("Could not send video frame: " + error);
            }
        }
Пример #30
0
        protected void MultipleStreamTestReduced(MediaConfigurationChangeLog changeLog,
                                                 GetStreamSetup getStreamSetup)
        {
            //3.	ONVIF Client will invoke GetVideoSourceConfigurationsRequest message to retrieve
            // all DUT video source configurations.
            //4.	Verify the GetVideoSourceConfigurationsResponse message from the DUT.

            VideoSourceConfiguration[] sourceConfigurations = GetVideoSourceConfigurations();
            CheckConfigurationsList(sourceConfigurations, "Video Source Configuration");

            List <VideoSourceConfiguration> selectedConfigs = MediaTestUtils.SelectConfigurations(sourceConfigurations);

            foreach (VideoSourceConfiguration config in selectedConfigs)
            {
                //5.	ONVIF Client will invoke GetGuaranteedNumberOfVideoEncoderInstancesRequest message
                // (ConfigurationToken = “VSCToken1”, where “VSCToken1” is a first video source configuration
                // token from GetVideoSourceConfigurationsResponse message) to retrieve guaranteed number of
                // video encoder instances per first video source configuration.
                int?jpeg;
                int?mpeg;
                int?h264;
                int totalNumber = GetGuaranteedNumberOfVideoEncoderInstances(config.token, out jpeg, out h264, out mpeg);

                //6.	Verify the GetGuaranteedNumberOfVideoEncoderInstancesResponse message from the DUT.
                //7.	Create or find number of profiles equal to TotalNumber from
                // GetGuaranteedNumberOfVideoEncoderInstancesResponse message that contains video source
                // configuration with token “VSCToken1” and video encoder configuration (see Annex A.9).
                List <Profile> profiles = GetProfilesForMultiStreamingTest(config.token,
                                                                           totalNumber,
                                                                           jpeg,
                                                                           mpeg,
                                                                           h264,
                                                                           changeLog);

                Assert(profiles.Count == totalNumber,
                       "Required number of profiles could not be found or created",
                       "Check that required number of profiles has been achieved");

                SetResourcesUsageToMimimal(changeLog, profiles);

                //8.	ONVIF Client invokes GetStreamUriRequest message (Profile Token, RTP-Unicast,
                // UDP transport) to retrieve media stream URI for the first media profile from step 7.


                //9.	DUT sends RTSP URI and parameters defining the lifetime of the URI like
                // ValidUntilConnect, ValidUntilReboot and Timeout in the GetStreamUriResponse message.
                //10.	ONVIF Client verifies the RTSP media stream URI provided by the DUT.
                //11.	ONVIF Client invokes RTSP DESCRIBE request.
                //12.	DUT sends 200 OK message and SDP information.
                //13.	 ONVIF Client invokes RTSP SETUP request with transport parameter as RTP/UDP.
                //14.	DUT sends 200 OK message and the media stream information.
                //15.	ONVIF Client invokes RTSP PLAY request.
                //16.	DUT sends 200 OK message and starts media streaming.
                //17.	DUT sends JPEG RTP media stream to ONVIF Client over UDP.
                //18.	DUT sends RTCP sender report to ONVIF Client.
                //19.	DUT validates the received RTP and RTCP packets, decodes and renders them.
                //20.	Repeat steps 8-20 to start video streaming for all profiles from step 7.
                //21.	ONVIF Client invokes RTSP TEARDOWN control request at the end of media streaming
                // to terminate the RTSP session for each started stream.
                //22.	DUT sends 200 OK Response and terminates the RTSP Session.

                VideoUtils.ShowMultiple(
                    this, _semaphore.StopEvent, _username, _password, _messageTimeout,
                    getStreamSetup, _videoForm.NICIndex, profiles, GetStreamUri,
                    (a, name, failTest) => RunStep2(a, name, failTest),
                    (ex) => StepFailed(ex));

                //23.	Repeat steps 5-23 for the rest of video source configurations.
            }
        }