Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
LibVLCSharp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Finkel
LibVLCSharp
Commits
2de68eff
Commit
2de68eff
authored
Jan 14, 2019
by
Martin Finkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add comments for generic MarshalUtils functions
parent
fbe92e54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
LibVLCSharp/Shared/Helpers/MarshalUtils.cs
LibVLCSharp/Shared/Helpers/MarshalUtils.cs
+50
-0
No files found.
LibVLCSharp/Shared/Helpers/MarshalUtils.cs
View file @
2de68eff
...
...
@@ -69,6 +69,17 @@ namespace LibVLCSharp.Shared.Helpers
}
}
/// <summary>
/// Generic marshalling function to retrieve structs from a libvlc linked list
/// </summary>
/// <typeparam name="T">Internal struct type</typeparam>
/// <typeparam name="TU">publicly facing struct type</typeparam>
/// <param name="getRef">Native libvlc call: retrieve collection start pointer from parent reference</param>
/// <param name="retrieve">Retrieve the internal struct by marshalling the native pointer</param>
/// <param name="create">Create a publicly facing struct from the internal struct values</param>
/// <param name="next">Access next element in the list</param>
/// <param name="releaseRef">Native libvlc call: release resources allocated with the getRef call</param>
/// <returns>An array of publicly facing struct types</returns>
internal
static
TU
[]
Retrieve
<
T
,
TU
>(
Func
<
IntPtr
>
getRef
,
Func
<
IntPtr
,
T
>
retrieve
,
Func
<
T
,
TU
>
create
,
Func
<
T
,
IntPtr
>
next
,
Action
<
IntPtr
>
releaseRef
)
where
T
:
struct
...
...
@@ -112,6 +123,18 @@ namespace LibVLCSharp.Shared.Helpers
}
}
/// <summary>
/// Generic marshalling function to retrieve structs from libvlc by reading from unmanaged memory with offsets
/// This supports uint libvlc signatures.
/// </summary>
/// <typeparam name="T">Internal struct type</typeparam>
/// <typeparam name="TU">publicly facing struct type</typeparam>
/// <param name="nativeRef">native reference of the parent</param>
/// <param name="getRef">Native libvlc call: retrieve collection start pointer from parent reference</param>
/// <param name="retrieve">Retrieve the internal struct by marshalling the native pointer</param>
/// <param name="create">Create a publicly facing struct from the internal struct values</param>
/// <param name="releaseRef">Native libvlc call: release the array allocated with the getRef call with the given element count</param>
/// <returns>An array of publicly facing struct types</returns>
internal
static
TU
[]
Retrieve
<
T
,
TU
>(
IntPtr
nativeRef
,
ArrayOut
getRef
,
Func
<
IntPtr
,
T
>
retrieve
,
Func
<
T
,
TU
>
create
,
Action
<
IntPtr
,
uint
>
releaseRef
)
where
T
:
struct
...
...
@@ -155,6 +178,18 @@ namespace LibVLCSharp.Shared.Helpers
}
}
/// <summary>
/// Generic marshalling function to retrieve structs from libvlc by reading from unmanaged memory with offsets
/// This supports ulong libvlc signatures.
/// </summary>
/// <typeparam name="T">Internal struct type</typeparam>
/// <typeparam name="TU">publicly facing struct type</typeparam>
/// <param name="nativeRef">native reference of the parent</param>
/// <param name="getRef">Native libvlc call: retrieve collection start pointer from parent reference</param>
/// <param name="retrieve">Retrieve the internal struct by marshalling the native pointer</param>
/// <param name="create">Create a publicly facing struct from the internal struct values</param>
/// <param name="releaseRef">Native libvlc call: release the array allocated with the getRef call with the given element count</param>
/// <returns>An array of publicly facing struct types</returns>
internal
static
TU
[]
Retrieve
<
T
,
TU
>(
IntPtr
nativeRef
,
ArrayLongOut
getRef
,
Func
<
IntPtr
,
T
>
retrieve
,
Func
<
T
,
TU
>
create
,
Action
<
IntPtr
,
ulong
>
releaseRef
)
where
T
:
struct
...
...
@@ -200,6 +235,20 @@ namespace LibVLCSharp.Shared.Helpers
}
}
/// <summary>
/// Generic marshalling function to retrieve structs from libvlc by reading from unmanaged memory with offsets
/// This supports ulong libvlc signatures and an additional enum configuration parameter.
/// </summary>
/// <typeparam name="T">Internal struct type</typeparam>
/// <typeparam name="TU">publicly facing struct type</typeparam>
/// <typeparam name="TE">Additional enum confugation type</typeparam>
/// <param name="nativeRef">native reference of the parent</param>
/// <param name="extraParam">Additional enum confugation type</param>
/// <param name="getRef">Native libvlc call: retrieve collection start pointer from parent reference</param>
/// <param name="retrieve">Retrieve the internal struct by marshalling the native pointer</param>
/// <param name="create">Create a publicly facing struct from the internal struct values</param>
/// <param name="releaseRef">Native libvlc call: release the array allocated with the getRef call with the given element count</param>
/// <returns>An array of publicly facing struct types</returns>
internal
static
TU
[]
Retrieve
<
T
,
TU
,
TE
>(
IntPtr
nativeRef
,
TE
extraParam
,
CategoryArrayOut
<
TE
>
getRef
,
Func
<
IntPtr
,
T
>
retrieve
,
Func
<
T
,
TU
>
create
,
Action
<
IntPtr
,
ulong
>
releaseRef
)
where
T
:
struct
...
...
@@ -245,6 +294,7 @@ namespace LibVLCSharp.Shared.Helpers
}
}
// These delegates allow the definition of generic functions with [OUT] parameters
internal
delegate
ulong
CategoryArrayOut
<
T
>(
IntPtr
nativeRef
,
T
enumType
,
out
IntPtr
array
)
where
T
:
Enum
;
internal
delegate
uint
ArrayOut
(
IntPtr
nativeRef
,
out
IntPtr
array
);
internal
delegate
ulong
ArrayLongOut
(
IntPtr
nativeRef
,
out
IntPtr
array
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment