This repository was archived by the owner on Jun 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMainForm.cs
More file actions
64 lines (50 loc) · 1.63 KB
/
Copy pathMainForm.cs
File metadata and controls
64 lines (50 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.IO;
using System.Windows.Forms;
using RTMPStreamReader.RTMP;
namespace RTMPStreamReader
{
public partial class MainForm : Form
{
private readonly string _fileName;
private Client _currentClient;
private Stream _inputStream;
private Stream _outputStream;
public MainForm(string fileName)
{
_fileName = fileName;
InitializeComponent();
}
public void Go()
{
_inputStream = File.OpenRead(_fileName);
_outputStream = new BufferedStream(File.OpenWrite("stream.flv"), 200000000);
_currentClient = new Client(_outputStream);
pbRead.Maximum = (int) _inputStream.Length;
_currentClient.OnPacketReceived += currentClient_OnPacketReceived;
_currentClient.Connect(_inputStream);
timerUpdate.Start();
}
private void currentClient_OnPacketReceived(object sender, EventArgs e)
{
if (_currentClient.Stream.Length != _currentClient.Stream.Position)
return;
timerUpdate.Stop();
_outputStream.Flush();
_outputStream.Close();
_inputStream.Close();
Application.Exit();
_currentClient.ForceStop();
}
private void timerUpdate_Tick(object sender, EventArgs e)
{
if (_currentClient == null)
return;
pbRead.Value = (int) _currentClient.Stream.Position;
}
private void MainForm_Shown(object sender, EventArgs e)
{
Go();
}
}
}