Commit 2dfae8ad by 鲁志-悦动

缓存的视频流通过滑块在播放器上定位到帧

parent be3d8556
namespace VIZ.FGOUT.Domain
using System.Dynamic;
namespace VIZ.FGOUT.Domain
{
/// <summary>
......@@ -7,5 +9,8 @@
public class ReplayModel
{
public bool IsReplay { get; set; }
public int SliderValue { get; set; }
public bool IsSliderValueChanged { get; set; }
}
}
......@@ -10,11 +10,11 @@ none
false
DEBUG;TRACE
18560433975
1470602451
11-350624472
24771590698
181380438361
1-1441241311
11-1602666439
23-1982761867
Style\Button\Button_NdiView.xaml;Style\Button\Button_Setting.xaml;Style\Button\Button_WindowTop.xaml;Style\CheckBox\CheckBox_NdiView.xaml;Style\CheckBox\CheckBox_Setting.xaml;Style\CheckBox\CheckBox_WindowTop.xaml;Style\ComboBox\ComboBox_Setting.xaml;Style\HotkeyBox\HotkeyBox_Setting.xaml;Style\MessageBox\MessageBoxEx.xaml;Style\RadioButton\RadioButton_FootballSide.xaml;Style\RadioButton\RadioButton_NdiView.xaml;Style\RadioButton\RadioButton_Setting.xaml;Style\Slider\Slider_Setting.xaml;Style\TextBlock\TextBlock_Setting.xaml;Style\TextBox\TextBox_Setting.xaml;Style\ToogleButton\ToogleButton_Setting.xaml;Themes\Generic.xaml;Toolkit\NumericUpDown\NumericUpDown.xaml;
False
True
......@@ -2,6 +2,7 @@
x:Class="VIZ.FGOUT.Module.NDIMainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:domain="clr-namespace:VIZ.FGOUT.Domain;assembly=VIZ.FGOUT.Domain"
......@@ -123,15 +124,24 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!--<Slider
<Slider
Grid.Row="1"
Width="740"
Height="90"
Margin="90,0,0,0"
Margin="80,0,0,0"
IsMoveToPointEnabled="True"
Maximum="150"
IsSnapToTickEnabled="True"
Maximum="{Binding SliderMaxValue, Mode=TwoWay}"
TickFrequency="1"
TickPlacement="BottomRight" />-->
TickPlacement="BottomRight"
Visibility="{Binding SliderVisibility, Mode=TwoWay}"
Value="{Binding SliderValue, Mode=TwoWay}">
<b:Interaction.Triggers>
<b:EventTrigger EventName="ValueChanged">
<b:InvokeCommandAction Command="{Binding SliderValueChangedCommand}" />
</b:EventTrigger>
</b:Interaction.Triggers>
</Slider>
<WrapPanel
Grid.Row="2"
Grid.Column="1"
......@@ -148,8 +158,6 @@
Foreground="White"
IsChecked="{Binding Path=IsAutoEnbale, Mode=TwoWay}"
Style="{StaticResource CheckBox_Setting}" />
</GroupBox>
<GroupBox
......@@ -222,8 +230,16 @@
Height="40"
Margin="10"
Content="Replay"
IsEnabled="{Binding ReplayEnable, Mode=TwoWay}"
Style="{StaticResource ToggleButtonStyle}" />
Style="{StaticResource ToggleButtonStyle}">
<b:Interaction.Triggers>
<b:EventTrigger EventName="Checked">
<b:InvokeCommandAction Command="{Binding ReplayCheckedCommand}" />
</b:EventTrigger>
<b:EventTrigger EventName="Unchecked">
<b:InvokeCommandAction Command="{Binding ReplayUncheckedCommand}" />
</b:EventTrigger>
</b:Interaction.Triggers>
</ToggleButton>
<CheckBox
Grid.Column="2"
......
......@@ -81,6 +81,9 @@ namespace VIZ.FGOUT.Module
// replay
this.ReplayCommand = new VCommand(this.Replay);
this.ReplayCheckedCommand = new VCommand(this.ReplayChecked);
this.ReplayUncheckedCommand = new VCommand(this.ReplayUnchecked);
this.SliderValueChangedCommand = new VCommand(this.SliderValueChanged);
//UESetting
this.UESettingCommand = new VCommand(this.UESetting);
//UEControl
......@@ -452,25 +455,6 @@ namespace VIZ.FGOUT.Module
public VCommand VideoStopCommand { get; set; }
#endregion
#region Replay 命令
public VCommand ReplayCommand { get; set; }
private bool _replayButtonIsEnable = true;
/// <summary>
/// replay 播控功能
/// </summary>
private void Replay()
{
if (_replayButtonIsEnable)
ReplayEnable = _replayButtonIsEnable = false;
else
ReplayEnable = _replayButtonIsEnable = true;
ReplayModel replayModel = new ReplayModel() { IsReplay = !_replayButtonIsEnable };
ApplicationDomainEx.MessageManager.Send(replayModel);
}
#endregion
#region UESetting
public VCommand UESettingCommand { get; set; }
......@@ -555,13 +539,62 @@ namespace VIZ.FGOUT.Module
invalidPlaceModel.IsInvalid = true;
ApplicationDomainEx.MessageManager.Send(invalidPlaceModel);
EndEnable = true;
InvalidEnable = false;
StartEnable = true;
}
#region Replay功能
public VCommand ReplayCommand { get; set; }
//private bool _replayButtonIsEnable = true;
/// <summary>
/// replay 播控功能
/// </summary>
private void Replay()
{
//if (_replayButtonIsEnable)
// ReplayEnable = _replayButtonIsEnable = false;
//else
// ReplayEnable = _replayButtonIsEnable = true;
//ReplayModel replayModel = new ReplayModel() { IsReplay = !_replayButtonIsEnable };
//ApplicationDomainEx.MessageManager.Send(replayModel);
}
public VCommand SliderValueChangedCommand { get; set; }
private int _initialValue = 150;
private void SliderValueChanged()
{
if (_initialValue != SliderValue)
{
_initialValue = SliderValue;
ReplayModel replayModel = new ReplayModel() { IsReplay = true, IsSliderValueChanged = true, SliderValue = SliderValue};
ApplicationDomain.MessageManager.Send(replayModel);
}
}
public VCommand ReplayCheckedCommand { get; set; }
public VCommand ReplayUncheckedCommand { get; set; }
private void ReplayChecked()
{
SliderVisibility = Visibility.Visible;
SliderValue = SliderMaxValue;
ReplayModel replayModel = new ReplayModel() { IsReplay = true };
ApplicationDomain.MessageManager.Send(replayModel);
}
private void ReplayUnchecked()
{
SliderVisibility = Visibility.Hidden;
ReplayModel replayModel = new ReplayModel() { IsReplay = false };
ApplicationDomain.MessageManager.Send(replayModel);
_initialValue = SliderMaxValue;
}
#endregion
/// <summary>
/// 开始位置Command命令
......@@ -674,14 +707,36 @@ namespace VIZ.FGOUT.Module
/// <summary>
/// 开始位置可用性
/// </summary>
private bool replayEnable = true;
//private bool replayEnable = true;
//public bool ReplayEnable
//{
// get { return replayEnable; }
// set { replayEnable = value; this.RaisePropertyChanged(nameof(ReplayEnable)); }
//}
public bool ReplayEnable
private Visibility _sliderVisibility = Visibility.Hidden;
public Visibility SliderVisibility
{
get { return replayEnable; }
set { replayEnable = value; this.RaisePropertyChanged(nameof(ReplayEnable)); }
get => _sliderVisibility;
set { _sliderVisibility = value; this.RaisePropertyChanged(nameof(SliderVisibility)); }
}
private int _sliderValue;
public int SliderValue
{
get => (int)_sliderValue;
set { _sliderValue = value; this.RaisePropertyChanged(nameof(SliderValue)); }
}
private int _sliderMaxValue = 150;
public int SliderMaxValue
{
get => (int)_sliderMaxValue;
set { _sliderMaxValue = value; this.RaisePropertyChanged(nameof(SliderMaxValue)); }
}
/// <summary>
/// 开始位置可用性
/// </summary>
......
using SharpDX;
using SharpDX.Mathematics.Interop;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
......@@ -150,6 +151,22 @@ namespace VIZ.FGOUT.Module
if (view.vm.IsReplay)
{
if (view.vm.IsSliderValueChanged)
{
Queue<DataStreamExtend> buffer = _frameBuffer.GetFrames();
if (buffer.Count > 0)
{
var index = view.vm.SliderValue;
if (index >= 150) index = 149;
if ((buffer.Count - 1) >= index)
{
var dse = buffer.ElementAt(index);
// 更新画面
view.video.UpdateVideoFrame(dse, true);
}
}
}
//Queue<IVideoFrame> buffer = _frameBuffer.GetFrames();
//IVideoFrame buffer = _frameBuffer.GetFrame(index);
......@@ -160,15 +177,15 @@ namespace VIZ.FGOUT.Module
//videoBuffer.Seek(0, SeekOrigin.Begin);
//index++;
Queue<DataStreamExtend> buffer = _frameBuffer.GetFrames();
if (buffer.Count > 0)
{
var dse = buffer.Dequeue();
// 更新画面
view.video.UpdateVideoFrame(dse);
}
else
view.vm.IsReplay = false;
//Queue<DataStreamExtend> buffer = _frameBuffer.GetFrames();
//if (buffer.Count > 0)
//{
// var dse = buffer.Dequeue();
// // 更新画面
// view.video.UpdateVideoFrame(dse);
//}
//else
// view.vm.IsReplay = false;
//// 更新画面
//view.video.UpdateVideoFrame(e.Frame);
......@@ -238,11 +255,11 @@ namespace VIZ.FGOUT.Module
// }
//}
}
}
// 统计裁切FPS
this.ClipFPS.CalcFps();
}
}
}
public class FrameBuffer
{
......
......@@ -159,7 +159,8 @@ namespace VIZ.FGOUT.Module
ueControlPanelView.Show();
}
public int SliderValue = 0;
public bool IsSliderValueChanged = false;
public bool IsReplay =false;
/// <summary>
/// replay 命令
......@@ -169,6 +170,9 @@ namespace VIZ.FGOUT.Module
if (this.ViewKey != "CAM_1")
return;
IsReplay = replayModel.IsReplay;
IsSliderValueChanged = replayModel.IsSliderValueChanged;
SliderValue = replayModel.SliderValue;
//ReplayPanelView replayPanelView = new ReplayPanelView();
//RePlayPanelViewModel rePlayPanelViewModel = replayPanelView.DataContext as RePlayPanelViewModel;
//rePlayPanelViewModel.timecode = timecode;
......
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "D1EE276BCF9FF79DDA3CB0BA74E3A30E55EDABD3082E4ACBD16AD83A17821625"
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "8CDCEAC8E7DBDD5B779B71F4D323D7BC00631C2C10B999E6F39A213317218BE8"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
......@@ -50,7 +50,7 @@ namespace VIZ.FGOUT.Module {
public partial class NDIMainView : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
#line 66 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 67 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox tbFocus;
......@@ -58,7 +58,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 319 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 335 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam1;
......@@ -66,7 +66,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 337 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 353 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam2;
......
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "D1EE276BCF9FF79DDA3CB0BA74E3A30E55EDABD3082E4ACBD16AD83A17821625"
#pragma checksum "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "8CDCEAC8E7DBDD5B779B71F4D323D7BC00631C2C10B999E6F39A213317218BE8"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
......@@ -50,7 +50,7 @@ namespace VIZ.FGOUT.Module {
public partial class NDIMainView : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
#line 66 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 67 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox tbFocus;
......@@ -58,7 +58,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 319 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 335 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam1;
......@@ -66,7 +66,7 @@ namespace VIZ.FGOUT.Module {
#line hidden
#line 337 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
#line 353 "..\..\..\..\..\NDIMainView\View\NDIMainView.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal VIZ.FGOUT.Module.NDIView cam2;
......
......@@ -49,9 +49,9 @@ namespace VIZ.Framework.Common
/// <summary>
/// 更新视频帧
/// </summary>
public void UpdateVideoFrame(IVideoFrame videoFrame)
public void UpdateVideoFrame(IVideoFrame videoFrame, bool isReplay = false)
{
this.videoRender?.UpdateVideoFrame(videoFrame);
this.videoRender?.UpdateVideoFrame(videoFrame, isReplay);
}
/// <summary>
......
......@@ -79,7 +79,7 @@ namespace VIZ.Framework.Common
/// 更新视频帧
/// </summary>
/// <param name="videoFrame">视频帧</param>
public void UpdateVideoFrame(IVideoFrame videoFrame)
public void UpdateVideoFrame(IVideoFrame videoFrame, bool isReplay = false)
{
if (videoFrame == null)
{
......@@ -103,6 +103,7 @@ namespace VIZ.Framework.Common
lock (this.render_lock_object)
{
if (!isReplay)
this.RenderInfo?.Dispose();
this.RenderInfo = info;
}
......
using NewTek;
using NewTek.NDI;
using log4net;
using NewTek;
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Drawing;
using System.Drawing.Imaging;
using OpenCvSharp;
using log4net.Repository.Hierarchy;
using log4net;
namespace VIZ.Framework.Common
{
......

//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace XamlGeneratedNamespace {
/// <summary>
/// GeneratedInternalTypeHelper
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed class GeneratedInternalTypeHelper : System.Windows.Markup.InternalTypeHelper {
/// <summary>
/// CreateInstance
/// </summary>
protected override object CreateInstance(System.Type type, System.Globalization.CultureInfo culture) {
return System.Activator.CreateInstance(type, ((System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic)
| (System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance)), null, null, culture);
}
/// <summary>
/// GetPropertyValue
/// </summary>
protected override object GetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, System.Globalization.CultureInfo culture) {
return propertyInfo.GetValue(target, System.Reflection.BindingFlags.Default, null, null, culture);
}
/// <summary>
/// SetPropertyValue
/// </summary>
protected override void SetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, object value, System.Globalization.CultureInfo culture) {
propertyInfo.SetValue(target, value, System.Reflection.BindingFlags.Default, null, null, culture);
}
/// <summary>
/// CreateDelegate
/// </summary>
protected override System.Delegate CreateDelegate(System.Type delegateType, object target, string handler) {
return ((System.Delegate)(target.GetType().InvokeMember("_CreateDelegate", (System.Reflection.BindingFlags.InvokeMethod
| (System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)), null, target, new object[] {
delegateType,
handler}, null)));
}
/// <summary>
/// AddEventHandler
/// </summary>
protected override void AddEventHandler(System.Reflection.EventInfo eventInfo, object target, System.Delegate handler) {
eventInfo.AddEventHandler(target, handler);
}
}
}
D:\Projects\FGOUT\VIZ.Framework\VIZ.Framework.Common\obj\x64\Debug\GeneratedInternalTypeHelper.g.cs

FD:\Projects\FGOUT\VIZ.Framework\VIZ.Framework.Common\MessageBox\MessageBoxEx.xaml;;
FD:\Projects\FGOUT\VIZ.Framework\VIZ.Framework.Common\MessageBox\MessageBoxExWindow.xaml;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment