forked from filoe/cscore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for ffmpeg logging and enumerating support formats. See filoe…
- Loading branch information
Showing
7 changed files
with
417 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Configuration; | ||
|
||
namespace CSCore.Ffmpeg | ||
{ | ||
/// <summary> | ||
/// Encapsulates configuration properties for CSCore.Ffmpeg. | ||
/// </summary> | ||
public class FfmpegConfigurationSection : ConfigurationSection | ||
{ | ||
/// <summary> | ||
/// Gets or sets the HTTP proxy. | ||
/// </summary> | ||
/// <value> | ||
/// A proxy with the following format: http://[User@]MyProxy.MyDomain:Port/. | ||
/// </value> | ||
[ConfigurationProperty("httpProxy", DefaultValue = "", IsRequired = false)] | ||
public string HttpProxy | ||
{ | ||
get { return (string)this["httpProxy"]; } | ||
set { this["httpProxy"] = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a whitelist where no proxy should be used. | ||
/// </summary> | ||
/// <value> | ||
/// The proxy whitelist. For examples see https://ffmpeg.org/doxygen/3.2/noproxy_8c_source.html. | ||
/// </value> | ||
[ConfigurationProperty("proxyWhitelist", DefaultValue = "*", IsRequired = false)] | ||
public string ProxyWhitelist | ||
{ | ||
get { return (string) this["proxyWhitelist"]; } | ||
set { this["proxyWhitelist"] = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the log level. For more details see <see cref="FfmpegUtils.LogLevel"/>. | ||
/// </summary> | ||
/// <value> | ||
/// The log level. | ||
/// </value> | ||
[ConfigurationProperty("loglevel", DefaultValue = null, IsRequired = false)] | ||
public LogLevel? LogLevel | ||
{ | ||
get | ||
{ | ||
var obj = this["loglevel"]; | ||
if (obj is LogLevel && Enum.IsDefined(typeof (LogLevel), obj)) | ||
{ | ||
return (LogLevel?) obj; | ||
} | ||
return null; | ||
} | ||
set { this["loglevel"] = value; } | ||
} | ||
} | ||
} |
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,98 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using CSCore.Ffmpeg.Interops; | ||
|
||
namespace CSCore.Ffmpeg | ||
{ | ||
/// <summary> | ||
/// Provides data for the <see cref="FfmpegUtils.FfmpegLogReceived"/> event. | ||
/// </summary> | ||
public class FfmpegLogReceivedEventArgs : EventArgs | ||
{ | ||
/// <summary> | ||
/// Gets the message. | ||
/// </summary> | ||
/// <value> | ||
/// The message. | ||
/// </value> | ||
public string Message { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the level of the message. | ||
/// </summary> | ||
/// <value> | ||
/// The level of the message. | ||
/// </value> | ||
public LogLevel Level { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the name of the class. | ||
/// </summary> | ||
/// <value> | ||
/// The name of the class. | ||
/// </value> | ||
public string ClassName { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the item name of the class. | ||
/// </summary> | ||
/// <value> | ||
/// The item name of the class. | ||
/// </value> | ||
public string ItemName { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the name of the parent log context class. | ||
/// </summary> | ||
/// <value> | ||
/// The name of the parent log context class. Might me empty. | ||
/// </value> | ||
public string ParentLogContextClassName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the item name of the parent log context class. | ||
/// </summary> | ||
/// <value> | ||
/// The item name of the parent log context class. Might me empty. | ||
/// </value> | ||
public string ParentLogContextItemName { get; set; } | ||
|
||
private delegate IntPtr ItemNameFunc(IntPtr avClass); | ||
|
||
internal unsafe FfmpegLogReceivedEventArgs(AVClass? avClass, AVClass? parentLogContext, LogLevel level, string line, void* ptr, void* ptr1) | ||
{ | ||
ItemNameFunc itemNameFunc; | ||
IntPtr strPtr; | ||
|
||
Message = line; | ||
Level = level; | ||
|
||
if (avClass != null) | ||
{ | ||
AVClass avc = avClass.Value; | ||
|
||
ClassName = Marshal.PtrToStringAnsi((IntPtr)avc.class_name); | ||
if (avc.item_name != IntPtr.Zero) | ||
{ | ||
itemNameFunc = (ItemNameFunc) Marshal.GetDelegateForFunctionPointer(avc.item_name, typeof(ItemNameFunc)); | ||
strPtr = itemNameFunc((IntPtr)ptr); | ||
if (strPtr != IntPtr.Zero) | ||
ItemName = Marshal.PtrToStringAnsi(strPtr); | ||
} | ||
} | ||
if (parentLogContext != null) | ||
{ | ||
AVClass pavc = parentLogContext.Value; | ||
|
||
ParentLogContextClassName = Marshal.PtrToStringAnsi((IntPtr)pavc.class_name); | ||
if (pavc.item_name != IntPtr.Zero) | ||
{ | ||
itemNameFunc = (ItemNameFunc) Marshal.GetDelegateForFunctionPointer(pavc.item_name, typeof(ItemNameFunc)); | ||
strPtr = itemNameFunc((IntPtr) ptr1); | ||
if (strPtr != IntPtr.Zero) | ||
ParentLogContextItemName = Marshal.PtrToStringAnsi(strPtr); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.