-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #359 from Fooxboy/develop
Merge develop into master
- Loading branch information
Showing
211 changed files
with
7,602 additions
and
6,780 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 was deleted.
Oops, something went wrong.
Submodule FFMediaToolkit
deleted from
cbdabe
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,85 @@ | ||
namespace FFMediaToolkit.Audio | ||
Check warning on line 1 in FFMediaToolkit/Audio/AudioData.cs GitHub Actions / Build and Package
|
||
{ | ||
using System; | ||
using FFMediaToolkit.Common.Internal; | ||
|
||
/// <summary> | ||
/// Represents a lightweight container for audio data. | ||
/// </summary> | ||
public ref struct AudioData | ||
{ | ||
private readonly AudioFrame frame; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AudioData"/> struct. | ||
/// </summary> | ||
/// <param name="frame">frame object containing raw audio data.</param> | ||
internal AudioData(AudioFrame frame) | ||
{ | ||
this.frame = frame; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the number of samples. | ||
/// </summary> | ||
public int NumSamples => frame.NumSamples; | ||
|
||
/// <summary> | ||
/// Gets the number of channels. | ||
/// </summary> | ||
public int NumChannels => frame.NumChannels; | ||
|
||
/// <summary> | ||
/// Fetches raw audio data from this audio frame for specified channel. | ||
/// </summary> | ||
/// <param name="channel">The index of audio channel that should be retrieved, allowed range: [0..<see cref="NumChannels"/>).</param> | ||
/// <returns>The span with samples in range of [-1.0, ..., 1.0].</returns> | ||
public Span<T> GetChannelData<T>(uint channel) | ||
where T : unmanaged | ||
{ | ||
return frame.GetChannelData<T>(channel); | ||
} | ||
|
||
/// <summary> | ||
/// Copies raw multichannel audio data from this frame to a heap allocated array. | ||
/// </summary> | ||
/// <returns> | ||
/// The span with <see cref="NumChannels"/> rows and <see cref="NumSamples"/> columns; | ||
/// samples in range of [-1.0, ..., 1.0]. | ||
/// </returns> | ||
public float[][] GetSampleData() | ||
{ | ||
return frame.GetSampleData(); | ||
} | ||
|
||
/// <summary> | ||
/// Updates the specified channel of this audio frame with the given sample data. | ||
/// </summary> | ||
/// <param name="samples">An array of samples with length <see cref="NumSamples"/>.</param> | ||
/// <param name="channel">The index of audio channel that should be updated, allowed range: [0..<see cref="NumChannels"/>).</param> | ||
public void UpdateChannelData(float[] samples, uint channel) | ||
{ | ||
frame.UpdateChannelData(samples, channel); | ||
} | ||
|
||
/// <summary> | ||
/// Updates this audio frame with the specified multi-channel sample data. | ||
/// </summary> | ||
/// <param name="samples"> | ||
/// A 2D jagged array of multi-channel sample data | ||
/// with <see cref="NumChannels"/> rows and <see cref="NumSamples"/> columns. | ||
/// </param> | ||
public void UpdateFromSampleData(float[][] samples) | ||
{ | ||
frame.UpdateFromSampleData(samples); | ||
} | ||
|
||
/// <summary> | ||
/// Releases all unmanaged resources associated with this instance. | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
frame.Dispose(); | ||
} | ||
} | ||
} |
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,60 @@ | ||
namespace FFMediaToolkit.Audio | ||
Check warning on line 1 in FFMediaToolkit/Audio/SampleFormat.cs GitHub Actions / Build and Package
|
||
{ | ||
using FFmpeg.AutoGen; | ||
|
||
/// <summary> | ||
/// Enumerates common audio sample formats supported by FFmpeg. | ||
/// </summary> | ||
public enum SampleFormat | ||
{ | ||
/// <summary> | ||
/// Unsupported/Unknown. | ||
/// </summary> | ||
None = AVSampleFormat.AV_SAMPLE_FMT_NONE, | ||
|
||
/// <summary> | ||
/// Unsigned 8-bit integer. | ||
/// </summary> | ||
UnsignedByte = AVSampleFormat.AV_SAMPLE_FMT_U8, | ||
|
||
/// <summary> | ||
/// Signed 16-bit integer. | ||
/// </summary> | ||
SignedWord = AVSampleFormat.AV_SAMPLE_FMT_S16, | ||
|
||
/// <summary> | ||
/// Signed 32-bit integer. | ||
/// </summary> | ||
SignedDWord = AVSampleFormat.AV_SAMPLE_FMT_S32, | ||
|
||
/// <summary> | ||
/// Single precision floating point. | ||
/// </summary> | ||
Single = AVSampleFormat.AV_SAMPLE_FMT_FLT, | ||
|
||
/// <summary> | ||
/// Double precision floating point. | ||
/// </summary> | ||
Double = AVSampleFormat.AV_SAMPLE_FMT_DBL, | ||
|
||
/// <summary> | ||
/// Signed 16-bit integer (planar). | ||
/// </summary> | ||
SignedWordP = AVSampleFormat.AV_SAMPLE_FMT_S16P, | ||
|
||
/// <summary> | ||
/// Signed 32-bit integer (planar). | ||
/// </summary> | ||
SignedDWordP = AVSampleFormat.AV_SAMPLE_FMT_S32P, | ||
|
||
/// <summary> | ||
/// Single precision floating point (planar). | ||
/// </summary> | ||
SingleP = AVSampleFormat.AV_SAMPLE_FMT_FLTP, | ||
|
||
/// <summary> | ||
/// Double precision floating point (planar). | ||
/// </summary> | ||
DoubleP = AVSampleFormat.AV_SAMPLE_FMT_DBLP, | ||
} | ||
} |
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,132 @@ | ||
namespace FFMediaToolkit.Common | ||
Check warning on line 1 in FFMediaToolkit/Common/ContainerMetadata.cs GitHub Actions / Build and Package
|
||
{ | ||
using System.Collections.Generic; | ||
using FFmpeg.AutoGen; | ||
|
||
/// <summary> | ||
/// Represents multimedia file metadata info. | ||
/// </summary> | ||
public class ContainerMetadata | ||
{ | ||
private const string TitleKey = "title"; | ||
private const string AuthorKey = "author"; | ||
private const string AlbumKey = "album"; | ||
private const string YearKey = "year"; | ||
private const string GenreKey = "genre"; | ||
private const string DescriptionKey = "description"; | ||
private const string LanguageKey = "language"; | ||
private const string CopyrightKey = "copyright"; | ||
private const string RatingKey = "rating"; | ||
private const string TrackKey = "track"; | ||
private const string DateKey = "date"; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ContainerMetadata"/> class. | ||
/// </summary> | ||
public ContainerMetadata() => Metadata = new Dictionary<string, string>(); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ContainerMetadata"/> class. | ||
/// </summary> | ||
/// <param name="sourceMetadata">The source metadata dictionary.</param> | ||
internal unsafe ContainerMetadata(AVDictionary* sourceMetadata) | ||
=> Metadata = FFDictionary.ToDictionary(sourceMetadata, true); | ||
|
||
/// <summary> | ||
/// Gets or sets the multimedia title. | ||
/// </summary> | ||
public string Title | ||
{ | ||
get => Metadata.ContainsKey(TitleKey) ? Metadata[TitleKey] : string.Empty; | ||
set => Metadata[TitleKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the multimedia author info. | ||
/// </summary> | ||
public string Author | ||
{ | ||
get => Metadata.ContainsKey(AuthorKey) ? Metadata[AuthorKey] : string.Empty; | ||
set => Metadata[AuthorKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the multimedia album name. | ||
/// </summary> | ||
public string Album | ||
{ | ||
get => Metadata.ContainsKey(AlbumKey) ? Metadata[AlbumKey] : string.Empty; | ||
set => Metadata[AlbumKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets multimedia release date/year. | ||
/// </summary> | ||
public string Year | ||
{ | ||
get => Metadata.ContainsKey(YearKey) | ||
? Metadata[YearKey] | ||
: (Metadata.ContainsKey(DateKey) ? Metadata[DateKey] : string.Empty); | ||
set => Metadata[YearKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the multimedia genre. | ||
/// </summary> | ||
public string Genre | ||
{ | ||
get => Metadata.ContainsKey(GenreKey) ? Metadata[GenreKey] : string.Empty; | ||
set => Metadata[GenreKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the multimedia description. | ||
/// </summary> | ||
public string Description | ||
{ | ||
get => Metadata.ContainsKey(DescriptionKey) ? Metadata[DescriptionKey] : string.Empty; | ||
set => Metadata[DescriptionKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the multimedia language. | ||
/// </summary> | ||
public string Language | ||
{ | ||
get => Metadata.ContainsKey(LanguageKey) ? Metadata[LanguageKey] : string.Empty; | ||
set => Metadata[LanguageKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the multimedia copyright info. | ||
/// </summary> | ||
public string Copyright | ||
{ | ||
get => Metadata.ContainsKey(CopyrightKey) ? Metadata[CopyrightKey] : string.Empty; | ||
set => Metadata[CopyrightKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the multimedia rating. | ||
/// </summary> | ||
public string Rating | ||
{ | ||
get => Metadata.ContainsKey(RatingKey) ? Metadata[RatingKey] : string.Empty; | ||
set => Metadata[RatingKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the multimedia track number string. | ||
/// </summary> | ||
public string TrackNumber | ||
{ | ||
get => Metadata.ContainsKey(TrackKey) ? Metadata[TrackKey] : string.Empty; | ||
set => Metadata[TrackKey] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the dictionary containing all metadata fields. | ||
/// </summary> | ||
public Dictionary<string, string> Metadata { get; set; } | ||
} | ||
} |
Oops, something went wrong.