mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Normalizing / and \ on windows
This commit is contained in:
parent
79a2cd810b
commit
18c98fb4f1
@ -22,29 +22,40 @@ namespace Kyoo.Controllers
|
|||||||
private const string TranscoderPath = "transcoder";
|
private const string TranscoderPath = "transcoder";
|
||||||
|
|
||||||
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int init();
|
private static extern int init();
|
||||||
|
|
||||||
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
public static int Init() => init();
|
||||||
public static extern int transmux(string path, string outpath, out float playableDuration);
|
|
||||||
|
|
||||||
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
public static extern int transcode(string path, string outpath, out float playableDuration);
|
|
||||||
|
|
||||||
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl,
|
||||||
|
CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
|
||||||
|
private static extern int transmux(string path, string outpath, out float playableDuration);
|
||||||
|
|
||||||
|
public static int Transmux(string path, string outPath, out float playableDuration)
|
||||||
|
{
|
||||||
|
path = path.Replace('\\', '/');
|
||||||
|
outPath = outPath.Replace('\\', '/');
|
||||||
|
return transmux(path, outPath, out playableDuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl,
|
||||||
|
CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
|
||||||
private static extern IntPtr extract_infos(string path,
|
private static extern IntPtr extract_infos(string path,
|
||||||
string outpath,
|
string outpath,
|
||||||
out int length,
|
out uint length,
|
||||||
out int trackCount,
|
out uint trackCount,
|
||||||
bool reextracct);
|
bool reextracct);
|
||||||
|
|
||||||
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
|
||||||
private static extern void free(IntPtr ptr);
|
private static extern void free_streams(IntPtr streams, uint count);
|
||||||
|
|
||||||
|
|
||||||
public static Track[] ExtractInfos(string path, string outPath, bool reextract)
|
public static Track[] ExtractInfos(string path, string outPath, bool reextract)
|
||||||
{
|
{
|
||||||
|
path = path.Replace('\\', '/');
|
||||||
|
outPath = outPath.Replace('\\', '/');
|
||||||
|
|
||||||
int size = Marshal.SizeOf<Stream>();
|
int size = Marshal.SizeOf<Stream>();
|
||||||
IntPtr ptr = extract_infos(path, outPath, out int arrayLength, out int trackCount, reextract);
|
IntPtr ptr = extract_infos(path, outPath, out uint arrayLength, out uint trackCount, reextract);
|
||||||
IntPtr streamsPtr = ptr;
|
IntPtr streamsPtr = ptr;
|
||||||
Track[] tracks;
|
Track[] tracks;
|
||||||
|
|
||||||
@ -68,7 +79,7 @@ namespace Kyoo.Controllers
|
|||||||
tracks = Array.Empty<Track>();
|
tracks = Array.Empty<Track>();
|
||||||
|
|
||||||
if (ptr != IntPtr.Zero)
|
if (ptr != IntPtr.Zero)
|
||||||
free(ptr); // free_streams is not necessary since the Marshal free the unmanaged pointers.
|
free_streams(ptr, trackCount);
|
||||||
return tracks;
|
return tracks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +94,7 @@ namespace Kyoo.Controllers
|
|||||||
_options = options;
|
_options = options;
|
||||||
_library = library;
|
_library = library;
|
||||||
|
|
||||||
if (TranscoderAPI.init() != Marshal.SizeOf<Stream>())
|
if (TranscoderAPI.Init() != Marshal.SizeOf<Stream>())
|
||||||
throw new BadTranscoderException();
|
throw new BadTranscoderException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +133,7 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
string cleanManifest = manifest.Replace('\\', '/');
|
transmuxFailed = TranscoderAPI.Transmux(episode.Path, manifest, out playableDuration) != 0;
|
||||||
transmuxFailed = TranscoderAPI.transmux(episode.Path, cleanManifest, out playableDuration) != 0;
|
|
||||||
}, TaskCreationOptions.LongRunning);
|
}, TaskCreationOptions.LongRunning);
|
||||||
while (playableDuration < 10 || !File.Exists(manifest) && !transmuxFailed)
|
while (playableDuration < 10 || !File.Exists(manifest) && !transmuxFailed)
|
||||||
await Task.Delay(10);
|
await Task.Delay(10);
|
||||||
|
@ -146,7 +146,7 @@ namespace Kyoo.Tasks
|
|||||||
|
|
||||||
string[] subtitles = files
|
string[] subtitles = files
|
||||||
.Where(FileExtensions.IsSubtitle)
|
.Where(FileExtensions.IsSubtitle)
|
||||||
.Where(x => !x.Contains("/Extra/"))
|
.Where(x => !x.Contains("Extra"))
|
||||||
.Where(x => tracks.All(y => y.Path != x))
|
.Where(x => tracks.All(y => y.Path != x))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
percent = 0;
|
percent = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user