Difference between revisions of "Talk:Main Page"
(New section: ".Net Interface to VLC" marshals strings falsely) |
|||
Line 18: | Line 18: | ||
-- Need to brush up the EN entries on the main page. How do I do that? PRedditt | -- Need to brush up the EN entries on the main page. How do I do that? PRedditt | ||
+ | |||
+ | == ".Net Interface to VLC" marshals strings falsely == | ||
+ | |||
+ | ".Net Interface to VLC" marshals strings falsely. For ex,playlist_AddExt, can not add a file to playlist if the path/filename contains a non-english char such as ğ,ü,ş,i,ö,ç etc. | ||
+ | More correct approach can be like below: | ||
+ | |||
+ | |||
+ | NativeLibVlc.cs | ||
+ | --------------- | ||
+ | |||
+ | static extern VlcError playlist_AddExt( | ||
+ | IntPtr p_playlist, | ||
+ | [MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(UTF8Marshaler))] String mrl, | ||
+ | [MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(UTF8Marshaler))] String mrlDuplicate, | ||
+ | Mode mode, | ||
+ | Int32 pos, | ||
+ | Int64 mtime_t, | ||
+ | [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))] string[] Options, | ||
+ | int OptionsCount); | ||
+ | |||
+ | |||
+ | |||
+ | class UTF8Marshaler : ICustomMarshaler | ||
+ | { | ||
+ | static UTF8Marshaler _MyCustomMarshaler = null; | ||
+ | |||
+ | public static ICustomMarshaler GetInstance(string Cookie) | ||
+ | { | ||
+ | if (_MyCustomMarshaler == null) | ||
+ | { | ||
+ | _MyCustomMarshaler = new UTF8Marshaler(); | ||
+ | } | ||
+ | return _MyCustomMarshaler; | ||
+ | } | ||
+ | |||
+ | public void CleanUpManagedData(object ManagedObj) | ||
+ | { | ||
+ | } | ||
+ | |||
+ | public void CleanUpNativeData(IntPtr pNativeData) | ||
+ | { | ||
+ | } | ||
+ | |||
+ | public int GetNativeDataSize() | ||
+ | { | ||
+ | return -1; | ||
+ | } | ||
+ | |||
+ | public IntPtr MarshalManagedToNative(object ManagedObj) | ||
+ | { | ||
+ | if (ManagedObj is string) | ||
+ | { | ||
+ | unsafe | ||
+ | { | ||
+ | byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes((string)ManagedObj); | ||
+ | fixed (void* ptr = &buf[0]) | ||
+ | { | ||
+ | return new IntPtr(ptr); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | if (ManagedObj is string[]) | ||
+ | { | ||
+ | unsafe | ||
+ | { | ||
+ | string[] array = (string[])ManagedObj; | ||
+ | IntPtr[] buf = new IntPtr[array.Length]; | ||
+ | for (int i = 0; i < buf.Length; i++) | ||
+ | { | ||
+ | byte[] b = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(array[i]); | ||
+ | fixed(void *p=&b[0]){ | ||
+ | buf[i] = (IntPtr)p; | ||
+ | } | ||
+ | } | ||
+ | fixed (void* ptr = &buf[0]) | ||
+ | { | ||
+ | return new IntPtr(ptr); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | throw new Exception("UTF8Marshaler can only be used for \"string\" or \"string[]\". "); | ||
+ | } | ||
+ | |||
+ | public object MarshalNativeToManaged(IntPtr pNativeData) | ||
+ | { | ||
+ | return null; | ||
+ | } | ||
+ | } |
Revision as of 21:10, 31 October 2008
Ticket #156 (closed defect: fixed) Is restarting VLC the fix
Is this fixed or is restarting VLC the fix? I am sending HD streams and after about 1 hour to 2 hours the CPU begins to spike at specific intervals corrupting the multicast stream that I am sending. I have to stop and restart VLC 0.8.5 to recover.
"VLC on VTHR leaks memory (see videolan@vthr:prod/vlc.sh) while doing intensive TS/UDP multicast streaming input/output.
A restart is needed after some time. "
- Hmmm... I don't know, try both or something. The thing 02:06, 19 September 2006 (CEST)
Link to Developer's Site is broken
Please replace the current link to the developer's site (located in the to right corner) with this one http://wiki.videolan.org/Developers_Corner.
Cheers, --Materthron 14:59, 19 December 2007 (CET)
- done.
-- Need to brush up the EN entries on the main page. How do I do that? PRedditt
".Net Interface to VLC" marshals strings falsely
".Net Interface to VLC" marshals strings falsely. For ex,playlist_AddExt, can not add a file to playlist if the path/filename contains a non-english char such as ğ,ü,ş,i,ö,ç etc. More correct approach can be like below:
NativeLibVlc.cs
static extern VlcError playlist_AddExt(
IntPtr p_playlist, [MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(UTF8Marshaler))] String mrl, [MarshalAs(UnmanagedType.CustomMarshaler,MarshalTypeRef=typeof(UTF8Marshaler))] String mrlDuplicate,
Mode mode,
Int32 pos, Int64 mtime_t, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))] string[] Options,
int OptionsCount);
class UTF8Marshaler : ICustomMarshaler
{ static UTF8Marshaler _MyCustomMarshaler = null;
public static ICustomMarshaler GetInstance(string Cookie) { if (_MyCustomMarshaler == null) { _MyCustomMarshaler = new UTF8Marshaler(); } return _MyCustomMarshaler; }
public void CleanUpManagedData(object ManagedObj) { }
public void CleanUpNativeData(IntPtr pNativeData) { }
public int GetNativeDataSize() { return -1; }
public IntPtr MarshalManagedToNative(object ManagedObj) { if (ManagedObj is string) { unsafe { byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes((string)ManagedObj); fixed (void* ptr = &buf[0]) { return new IntPtr(ptr); } } } if (ManagedObj is string[])
{
unsafe { string[] array = (string[])ManagedObj; IntPtr[] buf = new IntPtr[array.Length]; for (int i = 0; i < buf.Length; i++) { byte[] b = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(array[i]); fixed(void *p=&b[0]){ buf[i] = (IntPtr)p; } } fixed (void* ptr = &buf[0]) { return new IntPtr(ptr); } } } throw new Exception("UTF8Marshaler can only be used for \"string\" or \"string[]\". "); }
public object MarshalNativeToManaged(IntPtr pNativeData) { return null; } }