添加录播姬录制标记

This commit is contained in:
Genteure 2019-01-17 00:28:09 +08:00
parent ef1d6bb10b
commit 4344517bcf
4 changed files with 37 additions and 2 deletions

View File

@ -3,6 +3,7 @@ using BililiveRecorder.FlvProcessor;
using DnsClient; using DnsClient;
using NLog; using NLog;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -250,6 +251,29 @@ namespace BililiveRecorder.Core
Processor.ClipLengthFuture = _config.ClipLengthFuture; Processor.ClipLengthFuture = _config.ClipLengthFuture;
Processor.ClipLengthPast = _config.ClipLengthPast; Processor.ClipLengthPast = _config.ClipLengthPast;
Processor.CuttingNumber = _config.CuttingNumber; Processor.CuttingNumber = _config.CuttingNumber;
Processor.OnMetaData += (sender, e) =>
{
// TODO: Clip 和自动切割时也要更新这里的数据
e.Metadata["BililiveRecorder"] = new Dictionary<string, object>()
{
{
"starttime",
DateTime.UtcNow
},
{
"version",
"TEST"
},
{
"roomid",
RealRoomid.ToString()
},
{
"streamername",
StreamerName
},
};
};
_stream = await _response.Content.ReadAsStreamAsync(); _stream = await _response.Content.ReadAsStreamAsync();
_stream.ReadTimeout = 3 * 1000; _stream.ReadTimeout = 3 * 1000;

View File

@ -1,11 +1,17 @@
namespace BililiveRecorder.FlvProcessor namespace BililiveRecorder.FlvProcessor
{ {
public delegate void FlvMetadataEvent(object sender, FlvMetadataArgs e);
public class FlvMetadataArgs
{
public IFlvMetadata Metadata;
}
public delegate void TagProcessedEvent(object sender, TagProcessedArgs e); public delegate void TagProcessedEvent(object sender, TagProcessedArgs e);
public class TagProcessedArgs public class TagProcessedArgs
{ {
public IFlvTag Tag; public IFlvTag Tag;
} }
public delegate void ClipFinalizedEvent(object sender, ClipFinalizedArgs e); public delegate void ClipFinalizedEvent(object sender, ClipFinalizedArgs e);
public class ClipFinalizedArgs public class ClipFinalizedArgs
{ {

View File

@ -61,6 +61,7 @@ namespace BililiveRecorder.FlvProcessor
public event TagProcessedEvent TagProcessed; public event TagProcessedEvent TagProcessed;
public event StreamFinalizedEvent StreamFinalized; public event StreamFinalizedEvent StreamFinalized;
public event FlvMetadataEvent OnMetaData;
public uint ClipLengthPast { get; set; } = 20; public uint ClipLengthPast { get; set; } = 20;
public uint ClipLengthFuture { get; set; } = 10; public uint ClipLengthFuture { get; set; } = 10;
@ -330,7 +331,7 @@ namespace BililiveRecorder.FlvProcessor
Metadata = funcFlvMetadata(tag.Data); Metadata = funcFlvMetadata(tag.Data);
// TODO: 添加录播姬标记、录制信息 OnMetaData?.Invoke(this, new FlvMetadataArgs() { Metadata = Metadata });
tag.Data = Metadata.ToBytes(); tag.Data = Metadata.ToBytes();
tag.WriteTo(_targetFile); tag.WriteTo(_targetFile);
@ -418,6 +419,9 @@ namespace BililiveRecorder.FlvProcessor
{ {
_data.Dispose(); _data.Dispose();
_targetFile?.Dispose(); _targetFile?.Dispose();
OnMetaData = null;
StreamFinalized = null;
TagProcessed = null;
} }
_tags.Clear(); _tags.Clear();
disposedValue = true; disposedValue = true;

View File

@ -7,6 +7,7 @@ namespace BililiveRecorder.FlvProcessor
{ {
event TagProcessedEvent TagProcessed; event TagProcessedEvent TagProcessed;
event StreamFinalizedEvent StreamFinalized; event StreamFinalizedEvent StreamFinalized;
event FlvMetadataEvent OnMetaData;
int TotalMaxTimestamp { get; } int TotalMaxTimestamp { get; }
int CurrentMaxTimestamp { get; } int CurrentMaxTimestamp { get; }