mfkl / LibVLCSharp-readonly

.NET bindings for LibVLC
GNU Lesser General Public License v2.1
9 stars 2 forks source link

Get FILE * from filename with fopen #9

Open mfkl opened 7 years ago

mfkl commented 7 years ago

libvlcpp offers the ability to set up logging to a specific file.

Code currently is not working. Should be available crossplatform with Mono too.

jeremyVignelles commented 7 years ago

should we use the libvlc function that print to a file or recreate the same feature with .net tools and log callbacks? That would be easier to do, but would be a cheat, not 1-1 aligned with libvlc.

If I remember correctly, FILE is an opaque OS-specific structure

mfkl commented 7 years ago

Yeah, not sure how to get an opaque FILE * from C# in a crossplatform way...

Maybe we should expose another API (even if different from libvlcpp, if it doesn't make sense/hard to do from a C# perspective, probably the best choice). What do you think?

jeremyVignelles commented 7 years ago

We could use FILE* by calling native fopen with IntPtr parameters. For a C# reimplementation, we will need to resolve #5 and be careful of the perfs.

Now that I'm thinking about it, using the native fopen seems to be the most realistic, both for perfs and for ease to implement.

jeremyVignelles commented 7 years ago

But then, your title is misleading. I don't think we can transform a C# FileStream into a C FILE*, but we can give a file name to libvlcsharp so that it creates a FILE* and writes to it.

EDIT: Which is quite useless given that this behavior can be achieved with vlc parameters...

mfkl commented 6 years ago

So to achieve this on Windows we have to DllImport into msvcrt.dll. Info.

How about with Mono on macOS and Linux though?

mfkl commented 6 years ago

Pretty much done in https://github.com/mfkl/libvlcsharp/commit/fd87dff36d5cee6df2bdfc3c0f5daa800238605f

Untested on Linux/OSX. File is created and initial log is written to it, but tests fails as file handle is kept until test execution finishes (even after UnsetLog/Instance.Dispose()) and sharing is not enabled.

mfkl commented 6 years ago

Added fclose in UnsetLog as per your suggestion.

Need to fix #14 to test this on OSX/Linux and close if test is green.