Example #1
0
        private static void Update(WorkspaceContainer pContainer, VideoInfoProvider pVideoInfoProvider, WorkspaceType pType, FSEventInfo pEvent)
        {
            var objWSItem = WorkspaceItemMatcher.FindMatch(pContainer.GetAll(), pType, pEvent.Args.FullPath);

            if (objWSItem != null)
            {
                switch (pType)
                {
                case WorkspaceType.Final:
                    var path = pEvent.Args.FullPath;
                    if (pEvent.Args.ChangeType != WatcherChangeTypes.Deleted)
                    {
                        if (File.GetAttributes(path).HasFlag(FileAttributes.Directory))
                        {
                            if (objWSItem.Project != null)
                            {
                                if (File.Exists(objWSItem.Project.TargetPath))
                                {
                                    path = objWSItem.Project.TargetPath;
                                }
                            }
                        }
                    }
                    _ = objWSItem.UpdateFinal(
                        File.Exists(path) ? pVideoInfoProvider.Get(path) : null
                        );
                    break;

                case WorkspaceType.New:
                    _ = objWSItem.UpdateNew(pVideoInfoProvider.Get(pEvent.Args.FullPath));
                    break;

                case WorkspaceType.Project:
                    _ = objWSItem.UpdateProject(new MLT.MLTProject(pEvent.Args.FullPath, pVideoInfoProvider));
                    break;
                }
            }
            else
            {
                switch (pType)
                {
                case WorkspaceType.Final:
                    pContainer.Add(new WorkspaceItem(null, null, pVideoInfoProvider.Get(pEvent.Args.FullPath)));
                    break;

                case WorkspaceType.New:
                    pContainer.Add(new WorkspaceItem(null, pVideoInfoProvider.Get(pEvent.Args.FullPath), null));
                    break;

                case WorkspaceType.Project:
                    pContainer.Add(new WorkspaceItem(new MLT.MLTProject(pEvent.Args.FullPath, pVideoInfoProvider), null, null));
                    break;
                }
            }
        }
        /// <summary>
        /// Links the new, final and projects together
        /// </summary>
        /// <param name="pNew"></param>
        /// <param name="pFinal"></param>
        /// <param name="pProjects"></param>
        /// <returns></returns>
        private List <WorkspaceItem> GetMatches(IEnumerable <string> pNew, IEnumerable <string> pFinal, IEnumerable <string> pProjects)
        {
            var matches     = new List <WorkspaceItem>();
            var lstNew      = new List <VideoInfo>();
            var lstFinal    = new List <VideoInfo>();
            var lstProjects = new List <MLTProject>();

            pNew.ToList().ForEach(n => {
                var i = VideoInfoProvider.Get(n);
                if (i != null)
                {
                    lstNew.Add(i);
                }
            });
            pFinal.ToList().ForEach(f => {
                var i = VideoInfoProvider.Get(f);
                if (f != null)
                {
                    lstFinal.Add(i);
                }
            });
            pProjects.ToList().ForEach(p => {
                var mp = new MLTProject(p, VideoInfoProvider);
                if (mp != null)
                {
                    lstProjects.Add(mp);
                }
            });

            //The project links the new and final files together
            //Without it a link to the final file cannot be made
            //
            //Note: It can, but then the name needs to be calculated here based on the video info
            //      If needed this can be added, but if it is not a problem, leave as is
            new List <MLTProject>(lstProjects).ForEach(p => {
                _ = lstProjects.Remove(p);

                var final = lstFinal.Where(f => f.Path.Equals(p.TargetPath)).FirstOrDefault();
                if (final != null)
                {
                    _ = lstFinal.Remove(final);
                }
                var newfile = lstNew.Where(n => n.Path.Equals(p.SourcePath)).FirstOrDefault();
                if (newfile != null)
                {
                    _ = lstNew.Remove(newfile);
                }
                matches.Add(new WorkspaceItem(p, newfile, final));
            });
            lstNew.ForEach(n => matches.Add(new WorkspaceItem(null, n, null)));
            lstFinal.ForEach(f => matches.Add(new WorkspaceItem(null, null, f)));
            return(matches);
        }
Example #3
0
 public void Reload()
 {
     Config.Reload();
     if (TargetExists)
     {
         _objTargetInfo = VideoInfoProvider.Get(TargetPath);
     }
     if (SourceExists)
     {
         _objSourceInfo = VideoInfoProvider.Get(SourcePath);
     }
 }
Example #4
0
        public MLTProject(string pFullPath, VideoInfoProvider pVideoInfoCache)
        {
            VideoInfoProvider = pVideoInfoCache;
            ID = Guid.NewGuid();
            Directory.CreateDirectory(Path.Combine(Settings.TempDirectory, ID.ToString()));

            _objProjectFile = new FileInfo(pFullPath);

            Config = new MeltConfig(this, VideoInfoProvider);
            if (TargetExists)
            {
                _objTargetInfo = VideoInfoProvider.Get(TargetPath);
            }
            if (SourceExists)
            {
                _objSourceInfo = VideoInfoProvider.Get(SourcePath);
            }

            Job = new MeltJob(this); // -- ToDo: pass null or the config for the job, not the project itself
            Job.ProgressChanged += (object sender, System.EventArgs e) => {
                ProjectChanged?.Invoke(sender, this);
            };
            Job.StatusChanged += (object sender, JobStatus e) => {
                Log.Info("Project was changed - notify everyone");
                switch (e)
                {
                case JobStatus.Failed:
                case JobStatus.Success:
                    Reload();
                    break;

                case JobStatus.Paused:
                case JobStatus.Running:
                case JobStatus.Scheduled:
                case JobStatus.UnScheduled:
                    break;
                }
                ProjectChanged?.Invoke(sender, this);
            };
        }
Example #5
0
        private void AddConsumer()
        {
            //working
            if (string.IsNullOrEmpty(SourceFile))
            {
                return;
            }

            var objInfo = VideoInfoProvider.Get(SourceFile);

            if (objInfo == null)
            {
                return;
            }

            _dicConsumerProperties           = Settings.ConsumerProperties; //get settings from configuration
            _dicConsumerProperties["target"] = TempTargetPath;              //Path.Combine(Settings.FinalDirectory, TargetPath);

            //VIDEO
            _dicConsumerProperties["vcodec"] = objInfo.VideoCodec;
            _dicConsumerProperties["width"]  = objInfo.Width.ToString();
            _dicConsumerProperties["height"] = objInfo.Height.ToString();
            _dicConsumerProperties["acodec"] = objInfo.AudioCodec;

            //create consumer element
            var objEl = new XElement("consumer");

            foreach (var objKvp in _dicConsumerProperties)
            {
                objEl.Add(new XAttribute(objKvp.Key, objKvp.Value));
            }

            //add consumer below the profile
            _objConfig.Element("mlt").Descendants("profile").First().AddAfterSelf(objEl);

            //we need a root element set in the mlt file
            _objConfig.Root.SetAttributeValue("root", Settings.ProjectDirectory);
        }