Example #1
0
        void MountBlobs()
        {
            IBlob file_blob = null;

            BlobInfos = new List <BlobInfo>();
            foreach (var ccf in IN_CompileJob.OUT_CompiledCueFiles)
            {
                var bi = new BlobInfo();
                BlobInfos.Add(bi);

                switch (ccf.Type)
                {
                case CompiledCueFileType.BIN:
                case CompiledCueFileType.Unknown:
                {
                    //raw files:
                    var blob = new Disc.Blob_RawFile {
                        PhysicalPath = ccf.FullPath
                    };
                    OUT_Disc.DisposableResources.Add(file_blob = blob);
                    bi.Length = blob.Length;
                    break;
                }

                case CompiledCueFileType.ECM:
                {
                    var blob = new Disc.Blob_ECM();
                    OUT_Disc.DisposableResources.Add(file_blob = blob);
                    blob.Load(ccf.FullPath);
                    bi.Length = blob.Length;
                    break;
                }

                case CompiledCueFileType.WAVE:
                {
                    var blob = new Disc.Blob_WaveFile();
                    OUT_Disc.DisposableResources.Add(file_blob = blob);
                    blob.Load(ccf.FullPath);
                    bi.Length = blob.Length;
                    break;
                }

                case CompiledCueFileType.DecodeAudio:
                {
                    FFMpeg ffmpeg = new FFMpeg();
                    if (!ffmpeg.QueryServiceAvailable())
                    {
                        throw new DiscReferenceException(ccf.FullPath, "No decoding service was available (make sure ffmpeg.exe is available. even though this may be a wav, ffmpeg is used to load oddly formatted wave files. If you object to this, please send us a note and we'll see what we can do. It shouldn't be too hard.)");
                    }
                    AudioDecoder dec  = new AudioDecoder();
                    byte[]       buf  = dec.AcquireWaveData(ccf.FullPath);
                    var          blob = new Disc.Blob_WaveFile();
                    OUT_Disc.DisposableResources.Add(file_blob = blob);
                    blob.Load(new MemoryStream(buf));
                    bi.Length = buf.Length;
                    break;
                }

                default:
                    throw new InvalidOperationException();
                }                 //switch(file type)

                //wrap all the blobs with zero padding
                bi.Blob = new Disc.Blob_ZeroPadAdapter(file_blob, bi.Length);
            }
        }
Example #2
0
        void MountBlobs()
        {
            IBlob file_blob = null;

            BlobInfos = new List<BlobInfo>();
            foreach (var ccf in IN_CompileJob.OUT_CompiledCueFiles)
            {
                var bi = new BlobInfo();
                BlobInfos.Add(bi);

                switch (ccf.Type)
                {
                    case CompiledCueFileType.BIN:
                    case CompiledCueFileType.Unknown:
                        {
                            //raw files:
                            var blob = new Disc.Blob_RawFile { PhysicalPath = ccf.FullPath };
                            OUT_Disc.DisposableResources.Add(file_blob = blob);
                            bi.Length = blob.Length;
                            break;
                        }
                    case CompiledCueFileType.ECM:
                        {
                            var blob = new Disc.Blob_ECM();
                            OUT_Disc.DisposableResources.Add(file_blob = blob);
                            blob.Load(ccf.FullPath);
                            bi.Length = blob.Length;
                            break;
                        }
                    case CompiledCueFileType.WAVE:
                        {
                            var blob = new Disc.Blob_WaveFile();
                            OUT_Disc.DisposableResources.Add(file_blob = blob);
                            blob.Load(ccf.FullPath);
                            bi.Length = blob.Length;
                            break;
                        }
                    case CompiledCueFileType.DecodeAudio:
                        {
                            FFMpeg ffmpeg = new FFMpeg();
                            if (!ffmpeg.QueryServiceAvailable())
                            {
                                throw new DiscReferenceException(ccf.FullPath, "No decoding service was available (make sure ffmpeg.exe is available. even though this may be a wav, ffmpeg is used to load oddly formatted wave files. If you object to this, please send us a note and we'll see what we can do. It shouldn't be too hard.)");
                            }
                            AudioDecoder dec = new AudioDecoder();
                            byte[] buf = dec.AcquireWaveData(ccf.FullPath);
                            var blob = new Disc.Blob_WaveFile();
                            OUT_Disc.DisposableResources.Add(file_blob = blob);
                            blob.Load(new MemoryStream(buf));
                            bi.Length = buf.Length;
                            break;
                        }
                    default:
                        throw new InvalidOperationException();
                } //switch(file type)

                //wrap all the blobs with zero padding
                bi.Blob = new Disc.Blob_ZeroPadAdapter(file_blob, bi.Length);
            }
        }
Example #3
0
        void OpenFile(CUE_File.Command.FILE f)
        {
            if (curr_file != null)
            {
                CloseFile();
            }

            curr_blobIndex++;
            curr_fileHasTrack = false;

            var Resolver = IN_CueContext.Resolver;

            //TODO - smart audio file resolving only for AUDIO types. not BINARY or MOTOROLA or AIFF or ECM or what have you

            var    options = Resolver.Resolve(f.Path);
            string choice  = null;

            if (options.Count == 0)
            {
                Error($"Couldn't resolve referenced cue file: {f.Path} ; you can commonly repair the cue file yourself, or a file might be missing");
                //add a null entry to keep the count from being wrong later (quiets a warning)
                OUT_CompiledCueFiles.Add(null);
                return;
            }
            else
            {
                choice = options[0];
                if (options.Count > 1)
                {
                    Warn($"Multiple options resolving referenced cue file; choosing: {Path.GetFileName(choice)}");
                }
            }

            var cfi = new CompiledCueFile();

            curr_file = cfi;
            OUT_CompiledCueFiles.Add(cfi);

            cfi.FullPath = choice;

            //determine the CueFileInfo's type, based on extension and extra checking
            //TODO - once we reorganize the file ID stuff, do legit checks here (this is completely redundant with the fileID system
            //TODO - decode vs stream vs unpossible policies in input policies object (including ffmpeg availability-checking callback (results can be cached))
            string blobPathExt = Path.GetExtension(choice).ToUpperInvariant();

            if (blobPathExt == ".BIN" || blobPathExt == ".IMG")
            {
                cfi.Type = CompiledCueFileType.BIN;
            }
            else if (blobPathExt == ".ISO")
            {
                cfi.Type = CompiledCueFileType.BIN;
            }
            else if (blobPathExt == ".WAV")
            {
                //quickly, check the format. turn it to DecodeAudio if it can't be supported
                //TODO - fix exception-throwing inside
                //TODO - verify stream-disposing semantics
                var fs = File.OpenRead(choice);
                using var blob = new Disc.Blob_WaveFile();
                try
                {
                    blob.Load(fs);
                    cfi.Type = CompiledCueFileType.WAVE;
                }
                catch
                {
                    cfi.Type = CompiledCueFileType.DecodeAudio;
                }
            }
            else if (blobPathExt == ".APE")
            {
                cfi.Type = CompiledCueFileType.DecodeAudio;
            }
            else if (blobPathExt == ".MP3")
            {
                cfi.Type = CompiledCueFileType.DecodeAudio;
            }
            else if (blobPathExt == ".MPC")
            {
                cfi.Type = CompiledCueFileType.DecodeAudio;
            }
            else if (blobPathExt == ".FLAC")
            {
                cfi.Type = CompiledCueFileType.DecodeAudio;
            }
            else if (blobPathExt == ".ECM")
            {
                cfi.Type = CompiledCueFileType.ECM;
                if (!Disc.Blob_ECM.IsECM(choice))
                {
                    Error($"an ECM file was specified or detected, but it isn't a valid ECM file: {Path.GetFileName(choice)}");
                    cfi.Type = CompiledCueFileType.Unknown;
                }
            }
            else
            {
                Error($"Unknown cue file type. Since it's likely an unsupported compression, this is an error: {Path.GetFileName(choice)}");
                cfi.Type = CompiledCueFileType.Unknown;
            }

            //TODO - check for mismatches between track types and file types, or is that best done when interpreting the commands?
        }
Example #4
0
		void OpenFile(CUE_File.Command.FILE f)
		{
			if (curr_file != null)
				CloseFile();

			curr_blobIndex++;
			curr_fileHasTrack = false;

			var Resolver = IN_CueContext.Resolver;

			//TODO - smart audio file resolving only for AUDIO types. not BINARY or MOTOROLA or AIFF or ECM or what have you

			var options = Resolver.Resolve(f.Path);
			string choice = null;
			if (options.Count == 0)
			{
				Error(string.Format("Couldn't resolve referenced cue file: {0} ; you can commonly repair the cue file yourself, or a file might be missing", f.Path));
				//add a null entry to keep the count from being wrong later (quiets a warning)
				OUT_CompiledCueFiles.Add(null);
				return;
			}
			else
			{
				choice = options[0];
				if (options.Count > 1)
					Warn("Multiple options resolving referenced cue file; choosing: " + Path.GetFileName(choice));
			}

			var cfi = new CompiledCueFile();
			OUT_CompiledCueFiles.Add(cfi);

			cfi.FullPath = choice;

			//determine the CueFileInfo's type, based on extension and extra checking
			//TODO - once we reorganize the file ID stuff, do legit checks here (this is completely redundant with the fileID system
			//TODO - decode vs stream vs unpossible policies in input policies object (including ffmpeg availability-checking callback (results can be cached))
			string blobPathExt = Path.GetExtension(choice).ToUpperInvariant();
			if (blobPathExt == ".BIN" || blobPathExt == ".IMG") cfi.Type = CompiledCueFileType.BIN;
			else if (blobPathExt == ".ISO") cfi.Type = CompiledCueFileType.BIN;
			else if (blobPathExt == ".WAV")
			{
				//quickly, check the format. turn it to DecodeAudio if it can't be supported
				//TODO - fix exception-throwing inside
				//TODO - verify stream-disposing semantics
				var fs = File.OpenRead(choice);
				using (var blob = new Disc.Blob_WaveFile())
				{
					try
					{
						blob.Load(fs);
						cfi.Type = CompiledCueFileType.WAVE;
					}
					catch
					{
						cfi.Type = CompiledCueFileType.DecodeAudio;
					}
				}
			}
			else if (blobPathExt == ".APE") cfi.Type = CompiledCueFileType.DecodeAudio;
			else if (blobPathExt == ".MP3") cfi.Type = CompiledCueFileType.DecodeAudio;
			else if (blobPathExt == ".MPC") cfi.Type = CompiledCueFileType.DecodeAudio;
			else if (blobPathExt == ".FLAC") cfi.Type = CompiledCueFileType.DecodeAudio;
			else if (blobPathExt == ".ECM")
			{
				cfi.Type = CompiledCueFileType.ECM;
				if (!Disc.Blob_ECM.IsECM(choice))
				{
					Error("an ECM file was specified or detected, but it isn't a valid ECM file: " + Path.GetFileName(choice));
					cfi.Type = CompiledCueFileType.Unknown;
				}
			}
			else
			{
				Error("Unknown cue file type. Since it's likely an unsupported compression, this is an error: ", Path.GetFileName(choice));
				cfi.Type = CompiledCueFileType.Unknown;
			}

			//TODO - check for mismatches between track types and file types, or is that best done when interpreting the commands?
		}