// // Copyright (C) 2008-2009 Jordi Mas i Hernandez, jmas@softcatala.org // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Runtime.InteropServices; using System.Text; using System.IO; using Mistelix.DataModel; using Mistelix.Core; namespace Mistelix.Backends { // Generates XML file for dvdauthor command line tool public class DvdAuthor { Project project; public DvdAuthor (Project project) { this.project = project; } public void Create () { StringBuilder sb = new StringBuilder (2048); sb.Append (String.Format ("\n", Defines.APPNAME, Defines.VERSION)); sb.Append (String.Format ("\n", Path.Combine (project.Details.OutputDir, Defines.DVDAUTHOR_OUTDIR))); sb.Append (GenerateVMGM ()); sb.Append (" \n"); sb.Append (GenerateMenus ()); sb.Append (GenerateTitles ()); sb.Append (" \n"); sb.Append ("\n"); try { using (FileStream fs = File.Create (project.FileToFullPath (Defines.DVDAUTHOR_FILE))) { StreamWriter sw = new StreamWriter (fs); sw.Write (sb.ToString ()); sw.Close (); } } catch (IOException) { Logger.Error ("DvdAuthor.Create. Error accessing file {0}", project.FileToFullPath (Defines.DVDAUTHOR_FILE)); } } public void Destroy () { if (Mistelix.Debugging == false) { File.Delete (project.FileToFullPath (Defines.DVDAUTHOR_FILE)); } } string VideoFormatString { get { string video_format; if (project.Details.Format == VideoFormat.PAL) video_format = "pal"; else video_format = "ntsc"; return video_format; } } string AspectRatioString { get { string aspect_ratio; if (project.Details.AspectRatio == AspectRatio.FourByThree) aspect_ratio = "4:3"; else aspect_ratio = "16:9"; return aspect_ratio; } } // A PGC is just a fancy term for either a menu or a title string GenerateVMGM () { StringBuilder sb = new StringBuilder (2048); sb.Append (" \n"); sb.Append (" \n"); sb.Append (" \n"); sb.Append (" \n"); return sb.ToString (); } string GenerateMenus () { StringBuilder sb = new StringBuilder (4096); sb.Append (" \n"); sb.Append (" \n"); return sb.ToString (); } string GenerateTitles () { StringBuilder sb = new StringBuilder (2048); VisibleProjectElement element; sb.Append (" \n"); sb.Append (" \n"); return sb.ToString (); } } }