Patch overdumped MPEG-DASH segments.
All checks were successful
🚀 Pack skyscraper8 / make-zip (push) Successful in 3m25s
All checks were successful
🚀 Pack skyscraper8 / make-zip (push) Successful in 3m25s
This commit is contained in:
parent
30026b2b02
commit
3668cad724
@ -1,13 +1,14 @@
|
||||
using System;
|
||||
using log4net;
|
||||
using MimeKit;
|
||||
using skyscraper5.Skyscraper.IO;
|
||||
using skyscraper8.Ietf.FLUTE;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using MimeKit;
|
||||
using skyscraper5.Skyscraper.IO;
|
||||
using skyscraper8.Ietf.FLUTE;
|
||||
|
||||
namespace skyscraper8.DvbNip
|
||||
{
|
||||
@ -15,6 +16,7 @@ namespace skyscraper8.DvbNip
|
||||
{
|
||||
private DvbNipUtilities() { }
|
||||
|
||||
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
|
||||
private static XmlSerializer multicastGatewayConfigurationXmlSerializer;
|
||||
|
||||
public static bool IsXml(Stream s)
|
||||
@ -225,5 +227,24 @@ namespace skyscraper8.DvbNip
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static FluteListener PatchMpegDashSegment(FluteListener listener)
|
||||
{
|
||||
Stream stream = listener.ToStream();
|
||||
stream.Position = stream.Length - 1;
|
||||
byte readUInt8 = stream.ReadUInt8();
|
||||
if (readUInt8 != 0)
|
||||
return listener;
|
||||
|
||||
logger.WarnFormat("MPEG-DASH segment {0} is overdumped. It will be patched to become playable.", listener.FileAssociation.ContentLocation);
|
||||
stream.Position = stream.Length - 1;
|
||||
while (stream.ReadUInt8() == 0)
|
||||
{
|
||||
stream.Position -= 2;
|
||||
}
|
||||
|
||||
listener.TrimmedLength = stream.Position;
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ namespace skyscraper8.Ietf.FLUTE
|
||||
|
||||
}
|
||||
|
||||
internal bool IsComplete()
|
||||
internal virtual bool IsComplete()
|
||||
{
|
||||
if (_disabled)
|
||||
return false;
|
||||
@ -165,7 +165,11 @@ namespace skyscraper8.Ietf.FLUTE
|
||||
blockPayloads.Sort(new FluteBlockComparer());
|
||||
level1 = new FluteListenerStream(blockPayloads);
|
||||
}
|
||||
|
||||
if (TrimmedLength.HasValue)
|
||||
{
|
||||
level1.SetLength(TrimmedLength.Value);
|
||||
}
|
||||
|
||||
if (FileAssociation != null)
|
||||
{
|
||||
switch(FileAssociation.ContentEncoding)
|
||||
@ -288,5 +292,6 @@ namespace skyscraper8.Ietf.FLUTE
|
||||
}
|
||||
|
||||
public double LastReportedProgress { get; internal set; }
|
||||
public long? TrimmedLength { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,9 +4,8 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using skyscraper8.Ietf.FLUTE;
|
||||
|
||||
namespace skyscraper8.Ietf
|
||||
namespace skyscraper8.Ietf.FLUTE
|
||||
{
|
||||
internal class FluteListenerMime : FluteListener
|
||||
{
|
||||
@ -118,9 +118,17 @@ namespace skyscraper8.Ietf.FLUTE
|
||||
return currentPosition;
|
||||
}
|
||||
|
||||
private bool _isLengthLimited;
|
||||
private long _limitedLength;
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException("Can't modify the length of a ModuleInfo");
|
||||
if (value > myModuleLength)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(String.Format("Argument must be between 0 and {0}", myModuleLength));
|
||||
}
|
||||
|
||||
_limitedLength = value;
|
||||
_isLengthLimited = true;
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
@ -131,7 +139,17 @@ namespace skyscraper8.Ietf.FLUTE
|
||||
public override bool CanRead => true;
|
||||
public override bool CanSeek => true;
|
||||
public override bool CanWrite => false;
|
||||
public override long Length => myModuleLength;
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_isLengthLimited)
|
||||
return _limitedLength;
|
||||
else
|
||||
return myModuleLength;
|
||||
}
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
|
||||
@ -86,7 +86,6 @@ using skyscraper8.GS;
|
||||
using skyscraper8.GSE;
|
||||
using skyscraper8.GSE.GSE;
|
||||
using skyscraper8.Ieee802_1AB;
|
||||
using skyscraper8.Ietf;
|
||||
using skyscraper8.InteractionChannel.Model;
|
||||
using skyscraper8.InteractionChannel.Model2;
|
||||
using skyscraper8.InteractionChannel.Model2.Descriptors;
|
||||
@ -2778,6 +2777,12 @@ namespace skyscraper5.Skyscraper.Scraper
|
||||
knownNipSegments[ep] = new List<string>();
|
||||
knownNipSegments[ep].Add(listener.FileAssociation.ContentLocation);
|
||||
}
|
||||
|
||||
if (extension.Equals(".m4s"))
|
||||
{
|
||||
listener = DvbNipUtilities.PatchMpegDashSegment(listener);
|
||||
}
|
||||
|
||||
ObjectStorage.DvbNipFileArrival(carrier, listener);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user