Skip to content

Commit

Permalink
Merge pull request ZeBobo5#178 from taktik/subtitle_marshalling_error
Browse files Browse the repository at this point in the history
Subtitle marshalling error
Fix track description struct name encoding issue
  • Loading branch information
ZeBobo5 authored Jul 1, 2016
2 parents 1cd7a9c + 9383954 commit 4ab31fe
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ namespace Vlc.DotNet.Core.Interops.Signatures
/// </summary>
[LibVlcFunction("libvlc_audio_get_track_description")]
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate TrackDescriptionStructure GetAudioTracksDescriptions(IntPtr mediaPlayerInstance);
internal delegate IntPtr GetAudioTracksDescriptions(IntPtr mediaPlayerInstance);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System;
using System.Runtime.InteropServices;

namespace Vlc.DotNet.Core.Interops.Signatures
{
Expand All @@ -7,5 +8,5 @@ namespace Vlc.DotNet.Core.Interops.Signatures
/// </summary>
[LibVlcFunction("libvlc_track_description_list_release")]
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void ReleaseTrackDescription(TrackDescriptionStructure trackDescription);
internal delegate void ReleaseTrackDescription(IntPtr trackDescription);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ namespace Vlc.DotNet.Core.Interops.Signatures
/// </summary>
[LibVlcFunction("libvlc_video_get_spu_description")]
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate TrackDescriptionStructure GetVideoSpuDescription(IntPtr mediaPlayerInstance);
internal delegate IntPtr GetVideoSpuDescription(IntPtr mediaPlayerInstance);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ namespace Vlc.DotNet.Core.Interops.Signatures
/// </summary>
[LibVlcFunction("libvlc_video_get_track_description")]
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate TrackDescriptionStructure GetVideoTracksDescriptions(IntPtr mediaPlayerInstance);
internal delegate IntPtr GetVideoTracksDescriptions(IntPtr mediaPlayerInstance);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Vlc.DotNet.Core.Interops
{
public sealed partial class VlcManager
{
public TrackDescriptionStructure GetAudioTracksDescriptions(VlcMediaPlayerInstance mediaPlayerInstance)
public IntPtr GetAudioTracksDescriptions(VlcMediaPlayerInstance mediaPlayerInstance)
{
if (mediaPlayerInstance == IntPtr.Zero)
throw new ArgumentException("Media player instance is not initialized.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System.Runtime.InteropServices;
using Vlc.DotNet.Core.Interops.Signatures;

namespace Vlc.DotNet.Core.Interops
{
public sealed partial class VlcManager
{
public TrackDescriptionStructure GetVideoSpuDescription(VlcMediaPlayerInstance mediaPlayerInstance)
public IntPtr GetVideoSpuDescription(VlcMediaPlayerInstance mediaPlayerInstance)
{
if (mediaPlayerInstance == IntPtr.Zero)
throw new ArgumentException("Media player instance is not initialized.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Vlc.DotNet.Core.Interops
{
public sealed partial class VlcManager
{
public TrackDescriptionStructure GetVideoTracksDescriptions(VlcMediaPlayerInstance mediaPlayerInstance)
public IntPtr GetVideoTracksDescriptions(VlcMediaPlayerInstance mediaPlayerInstance)
{
if (mediaPlayerInstance == IntPtr.Zero)
throw new ArgumentException("Media player instance is not initialized.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Vlc.DotNet.Core.Interops
{
public sealed partial class VlcManager
{
public void ReleaseTrackDescription(TrackDescriptionStructure trackDescription)
public void ReleaseTrackDescription(IntPtr trackDescription)
{
GetInteropDelegate<ReleaseTrackDescription>().Invoke(trackDescription);
}
Expand Down
12 changes: 7 additions & 5 deletions src/Vlc.DotNet.Core/TrackDescription.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Vlc.DotNet.Core.Interops.Signatures;

namespace Vlc.DotNet.Core
Expand All @@ -16,14 +17,15 @@ internal TrackDescription(int id, string name)
Name = name;
}

internal static List<TrackDescription> GetSubTrackDescription(TrackDescriptionStructure module)
internal static List<TrackDescription> GetSubTrackDescription(IntPtr moduleRef)
{
var result = new List<TrackDescription>();
result.Add(new TrackDescription(module.Id, module.Name));
if (module.NextTrackDescription != IntPtr.Zero)
if (moduleRef != IntPtr.Zero)
{
TrackDescriptionStructure nextModule = (TrackDescriptionStructure)Marshal.PtrToStructure(module.NextTrackDescription, typeof(TrackDescriptionStructure));
var data = GetSubTrackDescription(nextModule);
var module = (TrackDescriptionStructure)Marshal.PtrToStructure(moduleRef, typeof(TrackDescriptionStructure));
var name = Encoding.UTF8.GetString(Encoding.Default.GetBytes(module.Name));
result.Add(new TrackDescription(module.Id, name));
var data = GetSubTrackDescription(module.NextTrackDescription);
result.AddRange(data);
}
return result;
Expand Down

0 comments on commit 4ab31fe

Please sign in to comment.