Browse Source

冲突

ZhangXueYang
zhangxueyang 4 years ago
parent
commit
107bbe68e4

+ 1
- 0
Common/system/DataProvider.cs View File

2
 using System;
2
 using System;
3
 using System.Collections.Generic;
3
 using System.Collections.Generic;
4
 using System.IO;
4
 using System.IO;
5
+using System.Net;
5
 using System.Security.Cryptography;
6
 using System.Security.Cryptography;
6
 using System.Text;
7
 using System.Text;
7
 
8
 

+ 31
- 4
Common/system/FFMpeg.cs View File

54
         /// <param name="size">大小</param>
54
         /// <param name="size">大小</param>
55
         /// <param name="ErrMessage">错误信息返回</param>
55
         /// <param name="ErrMessage">错误信息返回</param>
56
         /// <returns></returns>
56
         /// <returns></returns>
57
-        public bool StartRecordingVideo(string RTMPPath, string NodeKey, Size size, out string ErrMessage)
57
+        public bool StartLiveRecordingVideo(string RTMPPath, string NodeKey, Size size, out string ErrMessage)
58
         {
58
         {
59
             while (myProcess != null)
59
             while (myProcess != null)
60
             {
60
             {
126
 
126
 
127
             if (OutputVideoLog)
127
             if (OutputVideoLog)
128
             {
128
             {
129
-                LogHelper.WriteInfoLog("【录屏】:" + myProcess.StartInfo.Arguments);
129
+                LogHelper.WriteInfoLog("【直播】:" + myProcess.StartInfo.Arguments);
130
             }
130
             }
131
-            FileToolsCommon.AppendText(LogPath, "【录屏】:" + myProcess.StartInfo.Arguments + "\r\n");
131
+            FileToolsCommon.AppendText(LogPath, "【直播】:" + myProcess.StartInfo.Arguments + "\r\n");
132
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
132
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
133
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
133
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
134
             myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
134
             myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
149
                 {
149
                 {
150
                     ErrMessage = ex.Message + " 请关闭杀毒软件或信任此软件后重试!";
150
                     ErrMessage = ex.Message + " 请关闭杀毒软件或信任此软件后重试!";
151
                 }
151
                 }
152
-                LogHelper.WriteErrLog("【录音】(StartRecordingAudio)" + ErrMessage, ex);
152
+                LogHelper.WriteErrLog("【直播】(StartLiveRecordingVideo)" + ErrMessage, ex);
153
                 myProcess.Dispose();
153
                 myProcess.Dispose();
154
                 myProcess = null;
154
                 myProcess = null;
155
                 return false;
155
                 return false;
156
             }
156
             }
157
             return true;
157
             return true;
158
         }
158
         }
159
+        /// <summary>
160
+        /// 结束直播推流
161
+        /// </summary>
162
+        public bool StopLive()
163
+        {
164
+            if (myProcess != null)
165
+            {
166
+                myProcess.StandardInput.WriteLine("q");//在这个进程的控制台中模拟输入q,用于暂停录制
167
+                myProcess.Close();//关闭进程
168
+                myProcess.Dispose();//释放资源
169
+            }
170
+            #region 进程是否已经释放
171
+            bool IsRunning = true;
172
+            while (IsRunning)
173
+            {
174
+                IsRunning = false;
175
+                Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
176
+                foreach (Process KillProcess in ProcessArray)
177
+                {
178
+                    IsRunning = true;
179
+                    Thread.Sleep(100);
180
+                }
181
+            }
182
+            #endregion
183
+            myProcess = null;
184
+            return true;
185
+        }
159
         #endregion
186
         #endregion
160
         /// <summary>
187
         /// <summary>
161
         /// 录制屏幕
188
         /// 录制屏幕

+ 2
- 1
XHZB.Desktop/App.cs View File

268
             myloading = new LoadDialog();
268
             myloading = new LoadDialog();
269
             StopSameProcess();
269
             StopSameProcess();
270
             Killffmpeg();
270
             Killffmpeg();
271
+            UnZipFFmpeg();
271
             try
272
             try
272
             {
273
             {
273
                 if (args != null&&args.Length>1)
274
                 if (args != null&&args.Length>1)
436
         }
437
         }
437
 
438
 
438
         #region 检测解压ffmpeg
439
         #region 检测解压ffmpeg
439
-        public void UnZipFFmpeg()
440
+        public static void UnZipFFmpeg()
440
         {
441
         {
441
             new Thread(o =>
442
             new Thread(o =>
442
             {
443
             {

+ 2
- 2
XHZB.Desktop/AttendanceWindow.xaml View File

118
                 VerticalAlignment="Center"
118
                 VerticalAlignment="Center"
119
                 FontSize="30"
119
                 FontSize="30"
120
                 Foreground="White"
120
                 Foreground="White"
121
-                Text="        考勤统计结果        "/>
121
+                Text="        在线学生        "/>
122
             </Grid>
122
             </Grid>
123
 
123
 
124
             <StackPanel
124
             <StackPanel
127
                 HorizontalAlignment="Right"
127
                 HorizontalAlignment="Right"
128
                 VerticalAlignment="Center"
128
                 VerticalAlignment="Center"
129
                 Orientation="Horizontal">
129
                 Orientation="Horizontal">
130
-                <TextBlock FontSize="26" Text="考勤人数:" />
130
+                <TextBlock FontSize="26" Text="在线人数:" />
131
                 <TextBlock
131
                 <TextBlock
132
                     x:Name="txbOnlineUsers"
132
                     x:Name="txbOnlineUsers"
133
                     Margin="0,0,0,0"
133
                     Margin="0,0,0,0"

+ 2
- 2
XHZB.Desktop/CameraWindow.xaml View File

6
         xmlns:local="clr-namespace:XHZB.Desktop" xmlns:wfi="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
6
         xmlns:local="clr-namespace:XHZB.Desktop" xmlns:wfi="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
7
 xmlns:aforge ="clr-namespace:AForge.Controls;assembly=AForge.Controls"
7
 xmlns:aforge ="clr-namespace:AForge.Controls;assembly=AForge.Controls"
8
         mc:Ignorable="d"
8
         mc:Ignorable="d"
9
-        Title="CameraWindow" Height="180" Width="220" ResizeMode="NoResize"
9
+        Title="摄像头" Height="200" Width="250" ResizeMode="NoResize"
10
     >
10
     >
11
     <Grid>
11
     <Grid>
12
-        <wfi:WindowsFormsHost Grid.Row="0" Grid.Column="1" x:Name="wfhCamera" Height="124" Width="172" HorizontalAlignment="Right" Margin="0,10,30.10,0" VerticalAlignment="Top">
12
+        <wfi:WindowsFormsHost Grid.Row="0" Grid.Column="1" x:Name="wfhCamera" Margin="0">
13
             <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />
13
             <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />
14
         </wfi:WindowsFormsHost>
14
         </wfi:WindowsFormsHost>
15
     </Grid>
15
     </Grid>

+ 4
- 3
XHZB.Desktop/LoginWindow.xaml View File

156
                     Margin="35,-20,0,0"
156
                     Margin="35,-20,0,0"
157
                     FontSize="13"
157
                     FontSize="13"
158
                     Foreground="White"
158
                     Foreground="White"
159
-                    Text="星火智慧校园" />
159
+                    Text="星火直播" />
160
                 <Button
160
                 <Button
161
                     x:Name="btnDown"
161
                     x:Name="btnDown"
162
                     Width="30.8"
162
                     Width="30.8"
200
                     <RowDefinition Height="*" />
200
                     <RowDefinition Height="*" />
201
                 </Grid.RowDefinitions>
201
                 </Grid.RowDefinitions>
202
 
202
 
203
-                <Image
203
+                <!--<Image
204
                     Grid.Row="0"
204
                     Grid.Row="0"
205
                     Width="228"
205
                     Width="228"
206
                     Height="34.5"
206
                     Height="34.5"
207
                     Margin="0,66.2,0,0"
207
                     Margin="0,66.2,0,0"
208
                     HorizontalAlignment="Center"
208
                     HorizontalAlignment="Center"
209
-                    Source=".\Images\Login\智慧校园@2x.png" />
209
+                    Source=".\Images\Login\智慧校园@2x.png" />-->
210
+                <Label Content="星 火 直 播" Grid.Row="0" Width="200"  Margin="0,66.2,0,0" Foreground="White" FontSize="35" FontWeight="Bold" HorizontalContentAlignment="Center" />
210
                 <Border
211
                 <Border
211
                     Grid.Row="2"
212
                     Grid.Row="2"
212
                     Width="272"
213
                     Width="272"

+ 1
- 1
XHZB.Desktop/RollCallWindow.xaml View File

135
                     VerticalAlignment="Center"
135
                     VerticalAlignment="Center"
136
                     FontSize="30"
136
                     FontSize="30"
137
                     Foreground="White"
137
                     Foreground="White"
138
-                    Text="        课堂点名抢答        " />
138
+                    Text="        直播点名抢答        " />
139
             </Grid>
139
             </Grid>
140
             <UniformGrid
140
             <UniformGrid
141
                 Grid.Row="1"
141
                 Grid.Row="1"

+ 67
- 9
XHZB.Desktop/ToolbarWindow.xaml.cs View File

50
         {
50
         {
51
             InitializeComponent();
51
             InitializeComponent();
52
 
52
 
53
+            if (!APP.CheckScreenCapturerRecorder())
54
+            {
55
+                MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“English-OK-Next>-Next>Install”完成安装!");
56
+                APP.InstallScreenCapturerRecorder();
57
+            }
58
+
53
             txbName.Text = APP.LoginUser.username;
59
             txbName.Text = APP.LoginUser.username;
54
 
60
 
55
             heiban_btn.Click += Heiban_btn_Click;
61
             heiban_btn.Click += Heiban_btn_Click;
149
                 if (pageData.tongping)
155
                 if (pageData.tongping)
150
                 {
156
                 {
151
                     //tongpingBegin();
157
                     //tongpingBegin();
152
-                    pageData.menuList[1].Pic = "../Images/ToolBar/img_shared_1.gif";
153
-                    pageData.menuList[1].Name = "正在直播";
154
-
155
-                    if(APP.W_CameraWindow==null)
158
+                    if (StartLive(out string ErrMessage))
156
                     {
159
                     {
157
-                        APP.W_CameraWindow = new CameraWindow();
158
-                        APP.W_CameraWindow.Topmost = true;
159
-                        APP.W_CameraWindow.Left = pwidth - 300;
160
-                        APP.W_CameraWindow.Top = 0;
160
+                        pageData.menuList[1].Pic = "../Images/ToolBar/img_shared_1.gif";
161
+                        pageData.menuList[1].Name = "正在直播";
162
+
163
+                        if (APP.W_CameraWindow == null)
164
+                        {
165
+                            APP.W_CameraWindow = new CameraWindow();
166
+                            APP.W_CameraWindow.Topmost = true;
167
+                            APP.W_CameraWindow.Left = pwidth - 300;
168
+                            APP.W_CameraWindow.Top = 0;
169
+                        }
170
+                        APP.W_CameraWindow.Show();
171
+                    }
172
+                    else
173
+                    {
174
+                        pageData.tongping = !pageData.tongping;
175
+                        MessageWindow.Show(ErrMessage);
161
                     }
176
                     }
162
-                    APP.W_CameraWindow.Show();
163
                 }
177
                 }
164
                 else
178
                 else
165
                 {
179
                 {
166
                     //tongpingEnd();
180
                     //tongpingEnd();
181
+                    EndLive();
167
                     pageData.menuList[1].Pic = "../Images/ToolBar/直播@2x.png";
182
                     pageData.menuList[1].Pic = "../Images/ToolBar/直播@2x.png";
168
                     pageData.menuList[1].Name = "直播";
183
                     pageData.menuList[1].Name = "直播";
169
                     APP.W_CameraWindow.Hide();
184
                     APP.W_CameraWindow.Hide();
808
             //ZSocketServer.getInstance().startWsServer();
823
             //ZSocketServer.getInstance().startWsServer();
809
         }
824
         }
810
         #endregion
825
         #endregion
826
+        #region 直播
827
+        /// <summary>
828
+        /// 直播间节点和房号
829
+        /// </summary>
830
+        string NodeKey = "live/test";
831
+        /// <summary>
832
+        /// 开始直播
833
+        /// </summary>
834
+        public bool StartLive(out string ErrMessage)
835
+        {
836
+            try
837
+            {
838
+
839
+
840
+
841
+                //NodeKey=Node+Key;
842
+                System.Drawing.Size DesktopSize = PrimaryScreen.DESKTOP;
843
+                //开始直播
844
+                if(APP.FFmpeg.StartLiveRecordingVideo(APP.RTMPServerPath, NodeKey, DesktopSize,out ErrMessage))
845
+                {
846
+                    return true;
847
+                }
848
+                else
849
+                {
850
+                    return false;
851
+                }
852
+                 
853
+            }
854
+            catch (Exception ex)
855
+            {
856
+                ErrMessage = "无法开始直播:" + ex.Message;
857
+                LogHelper.WriteErrLog(ErrMessage, ex);
858
+                return false;
859
+            }
860
+        }
861
+        /// <summary>
862
+        /// 结束直播
863
+        /// </summary>
864
+        public void EndLive()
865
+        {
866
+            APP.FFmpeg.StopLive();
867
+        }
868
+        #endregion
811
     }
869
     }
812
     /// <summary>
870
     /// <summary>
813
     /// 工具栏模型
871
     /// 工具栏模型

+ 4
- 0
XHZB.Model/XHZB.Model.csproj View File

41
     <Reference Include="System.Xml" />
41
     <Reference Include="System.Xml" />
42
   </ItemGroup>
42
   </ItemGroup>
43
   <ItemGroup>
43
   <ItemGroup>
44
+    <Compile Include="BodyModel.cs" />
44
     <Compile Include="Class1.cs" />
45
     <Compile Include="Class1.cs" />
45
     <Compile Include="ClassListModel.cs" />
46
     <Compile Include="ClassListModel.cs" />
46
     <Compile Include="ClassStudentListModel.cs" />
47
     <Compile Include="ClassStudentListModel.cs" />
51
     <Compile Include="OnlineUserModel.cs" />
52
     <Compile Include="OnlineUserModel.cs" />
52
     <Compile Include="Properties\AssemblyInfo.cs" />
53
     <Compile Include="Properties\AssemblyInfo.cs" />
53
     <Compile Include="REQStartClassModel.cs" />
54
     <Compile Include="REQStartClassModel.cs" />
55
+    <Compile Include="ResourceMyListModel.cs" />
56
+    <Compile Include="ResourceMyListsModel.cs" />
54
     <Compile Include="RollCallModel.cs" />
57
     <Compile Include="RollCallModel.cs" />
55
     <Compile Include="SavefileModel.cs" />
58
     <Compile Include="SavefileModel.cs" />
59
+    <Compile Include="SocketModel.cs" />
56
     <Compile Include="TsubjectbookListModel.cs" />
60
     <Compile Include="TsubjectbookListModel.cs" />
57
     <Compile Include="ZBMenuModel.cs" />
61
     <Compile Include="ZBMenuModel.cs" />
58
     <Compile Include="ZBPageModel.cs" />
62
     <Compile Include="ZBPageModel.cs" />

Loading…
Cancel
Save