Browse Source

冲突

ZhangXueYang
zhangxueyang 3 years ago
parent
commit
107bbe68e4

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

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

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

@@ -54,7 +54,7 @@ namespace Common.system
54 54
         /// <param name="size">大小</param>
55 55
         /// <param name="ErrMessage">错误信息返回</param>
56 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 59
             while (myProcess != null)
60 60
             {
@@ -126,9 +126,9 @@ namespace Common.system
126 126
 
127 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 132
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
133 133
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
134 134
             myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
@@ -149,13 +149,40 @@ namespace Common.system
149 149
                 {
150 150
                     ErrMessage = ex.Message + " 请关闭杀毒软件或信任此软件后重试!";
151 151
                 }
152
-                LogHelper.WriteErrLog("【录音】(StartRecordingAudio)" + ErrMessage, ex);
152
+                LogHelper.WriteErrLog("【直播】(StartLiveRecordingVideo)" + ErrMessage, ex);
153 153
                 myProcess.Dispose();
154 154
                 myProcess = null;
155 155
                 return false;
156 156
             }
157 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 186
         #endregion
160 187
         /// <summary>
161 188
         /// 录制屏幕

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

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

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

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

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

@@ -6,10 +6,10 @@
6 6
         xmlns:local="clr-namespace:XHZB.Desktop" xmlns:wfi="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
7 7
 xmlns:aforge ="clr-namespace:AForge.Controls;assembly=AForge.Controls"
8 8
         mc:Ignorable="d"
9
-        Title="CameraWindow" Height="180" Width="220" ResizeMode="NoResize"
9
+        Title="摄像头" Height="200" Width="250" ResizeMode="NoResize"
10 10
     >
11 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 13
             <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />
14 14
         </wfi:WindowsFormsHost>
15 15
     </Grid>

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

@@ -156,7 +156,7 @@
156 156
                     Margin="35,-20,0,0"
157 157
                     FontSize="13"
158 158
                     Foreground="White"
159
-                    Text="星火智慧校园" />
159
+                    Text="星火直播" />
160 160
                 <Button
161 161
                     x:Name="btnDown"
162 162
                     Width="30.8"
@@ -200,13 +200,14 @@
200 200
                     <RowDefinition Height="*" />
201 201
                 </Grid.RowDefinitions>
202 202
 
203
-                <Image
203
+                <!--<Image
204 204
                     Grid.Row="0"
205 205
                     Width="228"
206 206
                     Height="34.5"
207 207
                     Margin="0,66.2,0,0"
208 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 211
                 <Border
211 212
                     Grid.Row="2"
212 213
                     Width="272"

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

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

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

@@ -50,6 +50,12 @@ namespace XHZB.Desktop
50 50
         {
51 51
             InitializeComponent();
52 52
 
53
+            if (!APP.CheckScreenCapturerRecorder())
54
+            {
55
+                MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“English-OK-Next>-Next>Install”完成安装!");
56
+                APP.InstallScreenCapturerRecorder();
57
+            }
58
+
53 59
             txbName.Text = APP.LoginUser.username;
54 60
 
55 61
             heiban_btn.Click += Heiban_btn_Click;
@@ -149,21 +155,30 @@ namespace XHZB.Desktop
149 155
                 if (pageData.tongping)
150 156
                 {
151 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 178
                 else
165 179
                 {
166 180
                     //tongpingEnd();
181
+                    EndLive();
167 182
                     pageData.menuList[1].Pic = "../Images/ToolBar/直播@2x.png";
168 183
                     pageData.menuList[1].Name = "直播";
169 184
                     APP.W_CameraWindow.Hide();
@@ -808,6 +823,49 @@ namespace XHZB.Desktop
808 823
             //ZSocketServer.getInstance().startWsServer();
809 824
         }
810 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 870
     /// <summary>
813 871
     /// 工具栏模型

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

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

Loading…
Cancel
Save