Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Added SetUserAgent and SetAppId
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyVignelles committed Nov 11, 2018
1 parent 87027ee commit d3f1a77
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Runtime.InteropServices;

namespace Vlc.DotNet.Core.Interops.Signatures
{
/// <summary>
/// Sets some meta-information about the application.
/// </summary>
/// <seealso cref="SetUserAgent" />
/// <param name="instance">LibVLC instance</param>
/// <param name="id">Java-style application identifier, e.g. "com.acme.foobar"</param>
/// <param name="version">application version numbers, e.g. "1.2.3"</param>
/// <param name="icon">application icon name, e.g. "foobar"</param>
[LibVlcFunction("libvlc_set_app_id")]
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void SetAppId(IntPtr instance, Utf8StringHandle id, Utf8StringHandle version, Utf8StringHandle icon);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Runtime.InteropServices;

namespace Vlc.DotNet.Core.Interops.Signatures
{
/// <summary>
/// Sets the application name.
/// LibVLC passes this as the user agent string when a protocol requires it.
/// </summary>
/// <param name="instance">LibVLC instance</param>
/// <param name="name">human-readable application name, e.g. "FooBar player 1.2.3"</param>
/// <param name="http">HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0"</param>
[LibVlcFunction("libvlc_set_user_agent")]
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void SetUserAgent(IntPtr instance, Utf8StringHandle name, Utf8StringHandle http);
}
24 changes: 24 additions & 0 deletions src/Vlc.DotNet.Core.Interops/VlcManager.SetAppId.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Vlc.DotNet.Core.Interops.Signatures;

namespace Vlc.DotNet.Core.Interops
{
public sealed partial class VlcManager
{
/// <summary>
/// Sets some meta-information about the application.
/// </summary>
/// <seealso cref="SetUserAgent" />
/// <param name="id">Java-style application identifier, e.g. "com.acme.foobar"</param>
/// <param name="version">application version numbers, e.g. "1.2.3"</param>
/// <param name="icon">application icon name, e.g. "foobar"</param>
public void SetAppId(string id, string version, string icon)
{
using (var idInterop = Utf8InteropStringConverter.ToUtf8StringHandle(id))
using (var versionInterop = Utf8InteropStringConverter.ToUtf8StringHandle(version))
using (var iconInterop = Utf8InteropStringConverter.ToUtf8StringHandle(icon))
{
GetInteropDelegate<SetAppId>().Invoke(this.myVlcInstance, idInterop, versionInterop, iconInterop);
}
}
}
}
22 changes: 22 additions & 0 deletions src/Vlc.DotNet.Core.Interops/VlcManager.SetUserAgent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Vlc.DotNet.Core.Interops.Signatures;

namespace Vlc.DotNet.Core.Interops
{
public sealed partial class VlcManager
{
/// <summary>
/// Sets the application name.
/// LibVLC passes this as the user agent string when a protocol requires it.
/// </summary>
/// <param name="name">human-readable application name, e.g. "FooBar player 1.2.3"</param>
/// <param name="http">HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0"</param>
public void SetUserAgent(string name, string http)
{
using (var nameInterop = Utf8InteropStringConverter.ToUtf8StringHandle(name))
using (var httpInterop = Utf8InteropStringConverter.ToUtf8StringHandle(http))
{
GetInteropDelegate<SetUserAgent>().Invoke(this.myVlcInstance, nameInterop, httpInterop);
}
}
}
}
23 changes: 23 additions & 0 deletions src/Vlc.DotNet.Core/VlcMediaPlayer/VlcMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ internal VlcMediaPlayer(VlcManager manager, string[] options)
/// </summary>
public VlcManager Manager { get; private set; }

/// <summary>
/// Sets some meta-information about the application.
/// </summary>
/// <seealso cref="SetUserAgent" />
/// <param name="id">Java-style application identifier, e.g. "com.acme.foobar"</param>
/// <param name="version">application version numbers, e.g. "1.2.3"</param>
/// <param name="icon">application icon name, e.g. "foobar"</param>
public void SetAppId(string id, string version, string icon)
{
this.Manager.SetAppId(id, version, icon);
}

/// <summary>
/// Sets the application name.
/// LibVLC passes this as the user agent string when a protocol requires it.
/// </summary>
/// <param name="name">human-readable application name, e.g. "FooBar player 1.2.3"</param>
/// <param name="http">HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0"</param>
public void SetUserAgent(string name, string http)
{
this.Manager.SetUserAgent(name, http);
}

public IntPtr VideoHostControlHandle
{
get { return Manager.GetMediaPlayerVideoHostHandle(myMediaPlayerInstance); }
Expand Down

0 comments on commit d3f1a77

Please sign in to comment.