-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.增加了房间号绑定Settings,实现自动保存。 2.增加了自动转码为MP4的功能,可解决Tag不完整问题。 3.移除了UI上一个没有意义的提示label。
- Loading branch information
Showing
14 changed files
with
341 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,109 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.IO; | ||
|
||
namespace AutoLiveRecorder | ||
{ | ||
/// <summary> | ||
/// FLV分析类 | ||
/// </summary> | ||
class FLVAnalysis | ||
{ | ||
/// <summary> | ||
/// 初始化实例 | ||
/// </summary> | ||
/// <param name="filename">文件地址</param> | ||
public FLVAnalysis(string filename) | ||
{ | ||
fs = new FileStream(filename, FileMode.Open); | ||
} | ||
|
||
/// <summary> | ||
/// 分析 | ||
/// </summary> | ||
public void Analysis() | ||
{ | ||
byte[] header = new byte[FLV_TAG_HEADER_SIZE]; | ||
byte[] tmp; | ||
_i = FLV_HEADER_SIZE + FLV_TAG_SIZE_SIZE; | ||
header = FsRead(FLV_TAG_HEADER_SIZE); | ||
int datasize = GetDataSize(header); | ||
byte[] body = new byte[datasize]; | ||
body = FsRead(datasize); | ||
switch (header[0]) | ||
{ | ||
case 0x08: | ||
|
||
break; | ||
case 0x09: | ||
|
||
break; | ||
case 0x12: | ||
|
||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
private int GetDataSize(byte[] header) | ||
{ | ||
byte[] tmp = new byte[3]; | ||
Array.Copy(header, 1, tmp, 0, 3); | ||
return BitConverter.ToInt32(tmp, 0); | ||
} | ||
|
||
private byte[] FsRead(int count) | ||
{ | ||
byte[] tmp = new byte[count]; | ||
if (fs.Length < _i + count) | ||
{ | ||
fs.Read(tmp, _i, count); | ||
_i += count; | ||
return tmp; | ||
}else | ||
{ | ||
fs.Read(tmp, _i, Convert.ToInt32(fs.Length)-_i); | ||
_i = Convert.ToInt32(fs.Length-1); | ||
return tmp; | ||
} | ||
|
||
|
||
} | ||
|
||
private class FLVInfo | ||
{ | ||
|
||
} | ||
|
||
|
||
#region Private 字段 | ||
|
||
private const int FLV_HEADER_SIZE = 9; | ||
|
||
private const int FLV_TAG_HEADER_SIZE = 11; | ||
|
||
private const int FLV_TAG_SIZE_SIZE = 4; | ||
|
||
private FileStream fs; | ||
|
||
private int _i; | ||
|
||
#endregion Private 字段 | ||
} | ||
} | ||
using System; | ||
using System.IO; | ||
|
||
namespace AutoLiveRecorder | ||
{ | ||
/// <summary> | ||
/// FLV分析类 | ||
/// </summary> | ||
internal class FLVAnalysis | ||
{ | ||
#region Private 字段 | ||
|
||
private const int FLV_HEADER_SIZE = 9; | ||
|
||
private const int FLV_TAG_HEADER_SIZE = 11; | ||
|
||
private const int FLV_TAG_SIZE_SIZE = 4; | ||
|
||
private int _i; | ||
|
||
private FileStream fs; | ||
|
||
#endregion Private 字段 | ||
|
||
#region Public 构造函数 | ||
|
||
/// <summary> | ||
/// 初始化实例 | ||
/// </summary> | ||
/// <param name="filename">文件地址</param> | ||
public FLVAnalysis(string filename) | ||
{ | ||
fs = new FileStream(filename, FileMode.Open); | ||
} | ||
|
||
#endregion Public 构造函数 | ||
|
||
#region Public 方法 | ||
|
||
/// <summary> | ||
/// 分析 | ||
/// </summary> | ||
public void Analysis() | ||
{ | ||
byte[] header = new byte[FLV_TAG_HEADER_SIZE]; | ||
byte[] tmp; | ||
_i = FLV_HEADER_SIZE + FLV_TAG_SIZE_SIZE; | ||
header = FsRead(FLV_TAG_HEADER_SIZE); | ||
int datasize = GetDataSize(header); | ||
byte[] body = new byte[datasize]; | ||
body = FsRead(datasize); | ||
switch (header[0]) | ||
{ | ||
case 0x08: | ||
|
||
break; | ||
|
||
case 0x09: | ||
|
||
break; | ||
|
||
case 0x12: | ||
|
||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
#endregion Public 方法 | ||
|
||
#region Private 方法 | ||
|
||
private byte[] FsRead(int count) | ||
{ | ||
byte[] tmp = new byte[count]; | ||
if (fs.Length < _i + count) | ||
{ | ||
fs.Read(tmp, _i, count); | ||
_i += count; | ||
return tmp; | ||
} | ||
else | ||
{ | ||
fs.Read(tmp, _i, Convert.ToInt32(fs.Length) - _i); | ||
_i = Convert.ToInt32(fs.Length - 1); | ||
return tmp; | ||
} | ||
} | ||
|
||
private int GetDataSize(byte[] header) | ||
{ | ||
byte[] tmp = new byte[3]; | ||
Array.Copy(header, 1, tmp, 0, 3); | ||
return BitConverter.ToInt32(tmp, 0); | ||
} | ||
|
||
#endregion Private 方法 | ||
|
||
#region Private 类 | ||
|
||
private class FLVInfo | ||
{ | ||
} | ||
|
||
#endregion Private 类 | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.