-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
196 additions
and
11 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Mpeg4Lib.Boxes | ||
{ | ||
//https://mutagen.readthedocs.io/en/latest/api/mp4.html | ||
public class FreeformTagBox : AppleTagBox | ||
{ | ||
public MeanBox Mean => GetChild<MeanBox>(); | ||
public NameBox Name => GetChild<NameBox>(); | ||
|
||
public static FreeformTagBox Create(AppleListBox parent, string domain, string tagName, byte[] data, AppleDataType dataType) | ||
{ | ||
int size | ||
= 12 /* empty FullBox size*/ + Encoding.UTF8.GetByteCount(domain) | ||
+ 12 /* empty FullBox size*/ + Encoding.UTF8.GetByteCount(tagName) | ||
+ 8 /* empty Box size*/ + data.Length + 2; | ||
|
||
BoxHeader header = new BoxHeader((uint)size, "----"); | ||
|
||
var tagBox = new FreeformTagBox(header, parent); | ||
MeanBox.Create(tagBox, domain); | ||
NameBox.Create(tagBox, tagName); | ||
AppleDataBox.Create(tagBox, data, dataType); | ||
|
||
parent.Children.Add(tagBox); | ||
return tagBox; | ||
} | ||
|
||
protected FreeformTagBox(BoxHeader header, IBox parent) : base(header, parent) { } | ||
|
||
public FreeformTagBox(Stream file, BoxHeader header, IBox parent) : base(header, parent) | ||
{ | ||
LoadChildren(file); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Mpeg4Lib.Util; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Mpeg4Lib.Boxes | ||
{ | ||
public class MeanBox : FullBox | ||
{ | ||
public override long RenderSize => base.RenderSize + Encoding.UTF8.GetByteCount(ReverseDnsDomain); | ||
public string ReverseDnsDomain { get; set; } | ||
public MeanBox(Stream file, BoxHeader header, IBox parent) : base(file, header, parent) | ||
{ | ||
var stringSize = RemainingBoxLength(file); | ||
var stringData = file.ReadBlock((int)stringSize); | ||
ReverseDnsDomain = Encoding.UTF8.GetString(stringData); | ||
} | ||
|
||
public static void Create(IBox parent, string domain) | ||
{ | ||
int size = Encoding.UTF8.GetByteCount(domain) + 12 /* empty FullBox size*/; | ||
BoxHeader header = new BoxHeader((uint)size, "mean"); | ||
|
||
MeanBox meanBox = new MeanBox(header, parent, domain); | ||
|
||
parent.Children.Add(meanBox); | ||
} | ||
|
||
private MeanBox(BoxHeader header, IBox parent, string domain) : base(new byte[4], header, parent) | ||
{ | ||
ReverseDnsDomain = domain; | ||
} | ||
|
||
protected override void Render(Stream file) | ||
{ | ||
base.Render(file); | ||
file.Write(Encoding.UTF8.GetBytes(ReverseDnsDomain)); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Mpeg4Lib.Util; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Mpeg4Lib.Boxes | ||
{ | ||
public class NameBox : FullBox | ||
{ | ||
public override long RenderSize => base.RenderSize + Encoding.UTF8.GetByteCount(Name); | ||
public string Name { get; set; } | ||
public NameBox(Stream file, BoxHeader header, IBox parent) : base(file, header, parent) | ||
{ | ||
var stringSize = RemainingBoxLength(file); | ||
var stringData = file.ReadBlock((int)stringSize); | ||
Name = Encoding.UTF8.GetString(stringData); | ||
} | ||
|
||
public static void Create(IBox parent, string name) | ||
{ | ||
int size = Encoding.UTF8.GetByteCount(name) + 12 /* empty FullBox size*/; | ||
BoxHeader header = new BoxHeader((uint)size, "name"); | ||
|
||
NameBox nameBox = new NameBox(header, parent, name); | ||
|
||
parent.Children.Add(nameBox); | ||
} | ||
|
||
private NameBox(BoxHeader header, IBox parent, string name) : base(new byte[4], header, parent) | ||
{ | ||
Name = name; | ||
} | ||
|
||
protected override void Render(Stream file) | ||
{ | ||
base.Render(file); | ||
file.Write(Encoding.UTF8.GetBytes(Name)); | ||
} | ||
} | ||
} |
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