From: Vásáry Dániel Date: Tue, 22 May 2018 10:27:56 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=c438553f55f18f12130eb0b456a14318bec40b55;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C31095 --- diff --git a/client/Maestro/Configuration/configuration-studio.json b/client/Maestro/Configuration/-configuration-studio.json similarity index 100% rename from client/Maestro/Configuration/configuration-studio.json rename to client/Maestro/Configuration/-configuration-studio.json diff --git a/client/Maestro/Configuration/configuration-grafika.json b/client/Maestro/Configuration/configuration-grafika.json index 59127046..8cdf4a35 100644 --- a/client/Maestro/Configuration/configuration-grafika.json +++ b/client/Maestro/Configuration/configuration-grafika.json @@ -12,7 +12,7 @@ "$type": "UNCSource", "filter": "png,tga,mov,mxf,wav", "local": { - "address": "file://C:/x/", + "address": "file://10.10.1.100/braavos/ingest", "userName": "mediacube", "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", "timeout": 1000 diff --git a/client/Maestro/FolderScanner.cs b/client/Maestro/FolderScanner.cs deleted file mode 100644 index 3d260606..00000000 --- a/client/Maestro/FolderScanner.cs +++ /dev/null @@ -1,63 +0,0 @@ -using NLog; -using System; -using System.Collections.Concurrent; -using System.IO; - -namespace Maestro { - - public class FolderScanner { - private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - public delegate void FoundFileSystemEntry(T parent, string entry, string label, bool isDirectory); - public event FoundFileSystemEntry OnFoundFileSystemEntry; - private ConcurrentDictionary cache; - - public void EnumerateDirectories(string path) { - if (!Directory.Exists(path)) - return; - try { - foreach (string entry in Directory.GetDirectories(path)) { - logger.Info(entry); - T parent = Get(Path.GetDirectoryName(entry)); - string label = Uri.UnescapeDataString(Path.GetFileName(entry)); - OnFoundFileSystemEntry?.Invoke(parent, entry, label, true); - EnumerateDirectories(entry); - } - } - catch (Exception e) { - logger.Error(e); - } - - //var directories = Directory.EnumerateDirectories(path, "*", SearchOption.AllDirectories); - //try { - // foreach (var entry in directories) { - // logger.Info(entry); - // T parent = Get(Path.GetDirectoryName(entry)); - // string label = Uri.UnescapeDataString(Path.GetFileName(entry)); - // OnFoundFileSystemEntry?.Invoke(parent, entry, label, true); - // } - //} - //catch (Exception e) { - // logger.Error(e); - //} - } - - public void Put(string key, T value) { - if (cache == null) - cache = new ConcurrentDictionary(); - cache.TryAdd(key, value); - } - - private string GetLastSegment(string path) { - - return Uri.UnescapeDataString(Path.GetFileName(path)); - } - - private T Get(string key) { - T result = default(T); - if (cache == null) - return result; - cache.TryGetValue(key, out result); - return result; - } - } -} diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index 619c9e42..3a46a424 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -163,7 +163,6 @@ - Form @@ -173,6 +172,9 @@ Form + + Form + Form @@ -333,7 +335,7 @@ Always - + Always diff --git a/client/Maestro/MaestroForm.Designer.cs b/client/Maestro/MaestroForm.Designer.cs index f3a3bec3..48103fbc 100644 --- a/client/Maestro/MaestroForm.Designer.cs +++ b/client/Maestro/MaestroForm.Designer.cs @@ -218,8 +218,10 @@ namespace Maestro { this.treeFolders.TabIndex = 18; this.treeFolders.Visible = false; this.treeFolders.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.OnBeforeExpandFolder); + this.treeFolders.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.OnAfterCollapseFolder); this.treeFolders.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.OnAfterFolderSelect); this.treeFolders.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnFolderMouseDown); + this.treeFolders.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnKeyUpFolder); // // ilFolders // diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 885fcdf3..de12fd08 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -80,129 +80,6 @@ namespace Maestro { treeFolders.NodeDoubleClick += OnDoubleClickFolder; } - private string GetLastSegment(string path) { - Uri uri = new Uri(path); - return Uri.UnescapeDataString(uri.Segments[uri.Segments.Length - 1]); - } - - private void ShowFolders() { - dgSource.Visible = false; - treeFolders.Visible = true; - treeFolders.Dock = DockStyle.Fill; - FileSystemSource source = bindingSource.DataSource as FileSystemSource; - if (source == null) { - HideFolders(); - btnShowFolders.CheckState = CheckState.Unchecked; - } - Uri address = Configuration.Source.Local.Address; - - - if (!Directory.Exists(address.LocalPath)) - return; - string label = Path.GetFileName(address.LocalPath); - label = String.IsNullOrEmpty(label) ? address.LocalPath : label; - TreeNode rootNode = treeFolders.Nodes.Add(label); - //FolderScanner scanner = new FolderScanner(); - //scanner.Put(address.LocalPath, rootNode); - //scanner.OnFoundFileSystemEntry += (parent, entry, label, isDirectory) => { - // //logger.Trace($"{parent} *** {entry}"); - // TreeNode node = parent.Nodes.Add(label); - // scanner.Put(entry, node); - //}; - - //treeFolders.BeginUpdate(); - //scanner.EnumerateDirectories(address.LocalPath); - //if ((Configuration.Source as UNCSource).FoldersAutoExpand) - // treeFolders.ExpandAll(); - //rootNode.EnsureVisible(); - //treeFolders.Sort(); - //treeFolders.EndUpdate(); - AddFolders(address, rootNode); - } - - private void AddFolders(Uri address, TreeNode parent) { - string[] folders = null; - try { - folders = Directory.GetDirectories(address.LocalPath); - } - catch (Exception ex) { - MsgBox.Error(ex.Message); - } - if (folders == null) - return; - - Array.Sort(folders, StringComparer.InvariantCultureIgnoreCase); - treeFolders.BeginUpdate(); - foreach (var folder in folders) { - TreeNode folderNode = parent.Nodes.Add(GetLastSegment(folder)); - folderNode.Nodes.Add(".."); - } - //treeFolders.Sort(); - parent.EnsureVisible(); - treeFolders.EndUpdate(); - } - - private void OnBeforeExpandFolder(object sender, TreeViewCancelEventArgs e) { - logger.Info(" Nothing to do"); - return; - } - e.Node.Nodes.Clear(); - Uri address = new Uri(Path.Combine(Configuration.Source.Local.Address.LocalPath, GetPath(e.Node))); - AddFolders(address, e.Node); - logger.Info("OnBeforeExpandFolder>"); - } - - private void OnDoubleClickFolder(object sender, TreeNodeMouseClickEventArgs args) { - //if (e.Action != TreeViewAction.ByMouse) - // return; - txtSourceFilter.Text = null; - FileSystemSource source = bindingSource.DataSource as FileSystemSource; - Uri address = null; - if (args.Node.Level == 0) - address = Configuration.Source.Local.Address; - else - address = new Uri(Uri.UnescapeDataString(Path.Combine(Configuration.Source.Local.Address.LocalPath, GetPath(args.Node)))); - if (!String.IsNullOrEmpty(address.LocalPath)) - formTooltip.SetToolTip(groupSource, address.LocalPath); - - if (source.Reset(address.LocalPath)) - SelectedSource = null; - - btnShowFolders.Checked = false; - HideFolders(); - } - - private void HideFolders() { - dgSource.Visible = true; - treeFolders.Visible = false; - treeFolders.Nodes.Clear(); - } - - private string GetPath(TreeNode node) { - TreeNode treeNode = node; - StringBuilder sb = new StringBuilder(); - sb.Append(treeNode.Text); - while (treeNode.Level != 1) { - treeNode = treeNode.Parent; - sb.Insert(0, "/"); - sb.Insert(0, treeNode.Text); - } - return sb.ToString(); - } - - private void OnShowFolders(object sender, EventArgs e) { - if (btnShowFolders.CheckState == CheckState.Checked) { - HideFolders(); - btnShowFolders.CheckState = CheckState.Unchecked; - } else { - ResetSourceSearch(); - ShowFolders(); - btnShowFolders.CheckState = CheckState.Checked; - } - } - private void dataGridSource_CellMouseEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1 && IsPlayColumn(e.ColumnIndex)) dgSource.Cursor = Cursors.Hand; @@ -461,10 +338,6 @@ namespace Maestro { } } - private void SearchFolders() { - throw new NotImplementedException(); - } - private void textSelectedSource_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Return || !btnLookupBySource.Enabled) return; diff --git a/client/Maestro/MaestroForm.SourceFolders.cs b/client/Maestro/MaestroForm.SourceFolders.cs new file mode 100644 index 00000000..d159a26f --- /dev/null +++ b/client/Maestro/MaestroForm.SourceFolders.cs @@ -0,0 +1,203 @@ +using Maestro.Sources; +using MaestroShared.Commons; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Windows.Forms; + +namespace Maestro { + + public partial class MaestroForm { + private string GetLastSegment(string path) { + Uri uri = new Uri(path); + return Uri.UnescapeDataString(uri.Segments[uri.Segments.Length - 1]); + } + + private void ShowFolders() { + FileSystemSource source = bindingSource.DataSource as FileSystemSource; + if (source == null) { + btnShowFolders.CheckState = CheckState.Unchecked; + return; + } + Uri address = Configuration.Source.Local.Address; + if (!Directory.Exists(address.LocalPath)) + return; + + treeFolders.Dock = DockStyle.Fill; + + if (treeFolders.Nodes.Count == 0) { + string label = Path.GetFileName(address.LocalPath); + label = String.IsNullOrEmpty(label) ? address.LocalPath : label; + TreeNode rootNode = treeFolders.Nodes.Add(label); + rootNode.Nodes.Add(".."); + } + + dgSource.Visible = false; + treeFolders.Visible = true; + treeFolders.Focus(); + if (treeFolders.Nodes.Count > 0) + treeFolders.Nodes[0].Expand(); + } + + private void AddFolders(Uri address, TreeNode parent) { + string[] folders = null; + try { + folders = Directory.GetDirectories(address.LocalPath); + } + catch (Exception ex) { + MsgBox.Error(ex.Message); + } + treeFolders.BeginUpdate(); + parent.Nodes.Clear(); + if (folders != null) { + Array.Sort(folders, StringComparer.InvariantCultureIgnoreCase); + foreach (var folder in folders) { + TreeNode folderNode = parent.Nodes.Add(GetLastSegment(folder)); + folderNode.Nodes.Add(".."); + } + } + parent.EnsureVisible(); + treeFolders.EndUpdate(); + } + + private void OnBeforeExpandFolder(object sender, TreeViewCancelEventArgs e) { + if (e.Node.Nodes.Count != 1 || !"..".Equals(e.Node.Nodes[0].Text)) + return; + treeFolders.SelectedNode = e.Node; + Uri address = GetSelectedNodeUri(); + if (address == null) + return; + Cursor = Cursors.Hand; + AddFolders(address, e.Node); + Cursor = Cursors.Default; + } + + private void OnAfterCollapseFolder(object sender, TreeViewEventArgs e) { + treeFolders.BeginUpdate(); + e.Node.Nodes.Clear(); + e.Node.Nodes.Add(".."); + treeFolders.EndUpdate(); + } + + private Uri GetSelectedNodeUri() { + if (treeFolders.SelectedNode == null) + return null; + Uri result = null; + if (treeFolders.SelectedNode.Level == 0) + result = Configuration.Source.Local.Address; + else + result = new Uri(Uri.UnescapeDataString(Path.Combine(Configuration.Source.Local.Address.LocalPath, GetPath(treeFolders.SelectedNode)))); + return result; + } + + private void OnDoubleClickFolder(object sender, TreeNodeMouseClickEventArgs args) { + SelectFolder(); + } + + private void SelectFolder() { + Uri address = GetSelectedNodeUri(); + if (address == null) + return; + + txtSourceFilter.Text = null; + if (!String.IsNullOrEmpty(address.LocalPath)) + formTooltip.SetToolTip(groupSource, address.LocalPath); + + FileSystemSource source = bindingSource.DataSource as FileSystemSource; + if (source.Reset(address.LocalPath)) + SelectedSource = null; + + btnShowFolders.Checked = false; + HideFolders(); + } + + private void OnKeyUpFolder(object sender, KeyEventArgs e) { + if (e.KeyCode == Keys.Return) + SelectFolder(); + } + + private void HideFolders() { + dgSource.Visible = true; + treeFolders.Visible = false; + //treeFolders.Nodes.Clear(); + } + + private string GetPath(TreeNode node) { + TreeNode treeNode = node; + StringBuilder sb = new StringBuilder(); + sb.Append(treeNode.Text); + while (treeNode.Level != 1) { + treeNode = treeNode.Parent; + sb.Insert(0, "/"); + sb.Insert(0, treeNode.Text); + } + return sb.ToString(); + } + + private void OnShowFolders(object sender, EventArgs e) { + if (btnShowFolders.CheckState == CheckState.Checked) { + HideFolders(); + btnShowFolders.CheckState = CheckState.Unchecked; + } else { + ResetSourceSearch(); + ShowFolders(); + btnShowFolders.CheckState = CheckState.Checked; + } + } + + private void SearchFolders() { + if (treeFolders.Nodes.Count == 0) + return; + string address = formTooltip.GetToolTip(groupSource); + List searchResult = SearchDirectories(address, txtSourceFilter.Text); + //logger.Info(searchResult.Count); + treeFolders.BeginUpdate(); + TreeNode rootNode = treeFolders.Nodes[0]; + rootNode.Nodes.Clear(); + treeFolders.SelectedNode = rootNode; + + Uri rootPath = GetSelectedNodeUri(); + foreach (String path in searchResult) { + logger.Info(path.Substring(rootPath.LocalPath.Length)); + string entry = path.Replace("\\", "/"); + + TreeNode node = rootNode; + string[] entries = entry.Split('/'); + foreach (string segment in entries) { + + if (node.Nodes.ContainsKey(segment)) + node = node.Nodes.Find(segment, false)[0]; + else + node = node.Nodes.Add(segment); + // treeFolders.Get + } + } + if (rootNode.Nodes.Count == 0) + treeFolders.Nodes.Clear(); + treeFolders.EndUpdate(); + + } + + private List SearchDirectories(string path, string pattern) { + if (!Directory.Exists(path)) + return null; + List result = new List(); + try { + foreach (string entry in Directory.GetDirectories(path)) { + string label = Uri.UnescapeDataString(Path.GetFileName(entry)); + if (label.ToLower().Contains(pattern.ToLower())) + result.Add(entry); + List childResult = SearchDirectories(entry, pattern); + if (childResult != null && childResult.Count > 0) + result.AddRange(childResult); + } + } + catch (Exception e) { + logger.Error(e); + } + return result; + } + + } +} diff --git a/client/MaestroShared/Controls/DoubleClickTreeView.cs b/client/MaestroShared/Controls/DoubleClickTreeView.cs index f736de40..c0cb5070 100644 --- a/client/MaestroShared/Controls/DoubleClickTreeView.cs +++ b/client/MaestroShared/Controls/DoubleClickTreeView.cs @@ -13,6 +13,10 @@ namespace MaestroShared.Controls { if (m.Msg == 0x203) { var point = PointToClient(Cursor.Position); TreeNode node = GetNodeAt(point); + if (node == null || PointToClient(Cursor.Position).X < node.Bounds.X - 20) + return; + + logger.Info("{0} {1}", PointToClient(Cursor.Position), node.Bounds); TreeNodeMouseClickEventArgs args = new TreeNodeMouseClickEventArgs(node, MouseButtons.Left, 2, point.X, point.Y); NodeDoubleClick?.Invoke(this, args); m.Result = IntPtr.Zero; diff --git a/server/-configuration/run-mediacube-server-bsh.launch b/server/-configuration/run-mediacube-server-bsh.launch index c987230e..ec4eca74 100644 --- a/server/-configuration/run-mediacube-server-bsh.launch +++ b/server/-configuration/run-mediacube-server-bsh.launch @@ -19,7 +19,7 @@ - + diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java index d1092deb..76abc690 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java @@ -7,6 +7,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Marker; +import com.ibm.nosql.json.api.BasicDBObject; +import com.ibm.nosql.json.api.DB; +import com.ibm.nosql.json.api.DBCollection; +import com.ibm.nosql.json.api.DBObject; + +import user.commons.nosql.NoSQLUtils; import user.jobengine.db.ItemDAOEx; import user.jobengine.db.ItemManager; import user.jobengine.db.Media; @@ -23,15 +29,28 @@ public class CreateMissingLowresStep extends JobStep { marker = jobRuntime.getMarker(); ItemDAOEx dao = new ItemDAOEx((ItemManager) jobEngine.getItemManager()); List medias = dao.getUntranscodedMedias(); + + DB db = NoSQLUtils.getNoSQLDB(); + DBCollection collection = db.getCollection("missing_lowres"); try { if (medias == null || medias.size() == 0) { throw new Exception("Nincs feldolgozandó hiány."); } - result[0] = medias.get(0); - ArchiveItem archiveItem = new ArchiveItem(); - archiveItem.setMediaFile(Paths.get(localHiresPath, medias.get(0).getMediaFilesName()).toString()); - result[1] = archiveItem; + for (Media media : medias) { + String name = media.getMediaFilesName(); + DBObject existing = collection.findOne(new BasicDBObject("name", name)); + if (existing != null) + continue; + + result[0] = media; + ArchiveItem archiveItem = new ArchiveItem(); + archiveItem.setMediaFile(Paths.get(localHiresPath, name).toString()); + result[1] = archiveItem; + collection.save(new BasicDBObject("name", name)); + break; + } + } catch (Exception e) { logger.catching(e); logger.error(marker, e.getMessage()); diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeFFAStranStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeFFAStranStep.java index 3be025a2..4a95df9d 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeFFAStranStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeFFAStranStep.java @@ -85,7 +85,7 @@ public class TranscodeFFAStranStep extends JobStep { return null; } - private void postprocess(Path transcodedFilePath, String webPath) { + private void postprocess(Path transcodedFilePath, String webPath) throws IOException { Path lowresPath = null; try { String transcodedFileName = transcodedFilePath.getFileName().toString(); @@ -101,9 +101,9 @@ public class TranscodeFFAStranStep extends JobStep { Files.move(transcodedFilePath, lowresPath); } } catch (IOException e) { - lowresPath = transcodedFilePath; logger.catching(e); - logger.error(marker, "A '{}' állomány mozgatása a '{}' helyre nem sikerült.", transcodedFilePath, transcodedFilePath); + logger.error(marker, "A '{}' állomány mozgatása a '{}' helyre nem sikerült.", transcodedFilePath, lowresPath); + throw e; } } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/FFAStransAPI.java b/server/user.jobengine.osgi.commons/src/user/commons/FFAStransAPI.java index 37ec202b..55c4df67 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/FFAStransAPI.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/FFAStransAPI.java @@ -7,6 +7,8 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.commons.lang.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; @@ -46,12 +48,9 @@ public class FFAStransAPI implements IFFAStransAPI { // } // } + private static final Logger logger = LogManager.getLogger(); private ResteasyWebTarget webTarget; - private IProgressChangedListener listener; - - private String inputFile; - private String jobId; public FFAStransAPI(String apiAddress, IProgressChangedListener listener) { @@ -94,9 +93,12 @@ public class FFAStransAPI implements IFFAStransAPI { BasicDBObject result = null; try { Response apiResponse = target.request().get(); + logger.info("Transoder response code: {}", apiResponse.getStatus()); + if (apiResponse.getStatus() != 200) return null; String json = apiResponse.readEntity(String.class); + logger.info("Transoder response: {}", json); BasicDBObject resultObject = (BasicDBObject) JSONUtil.jsonToDbObject(json); List jobs = NoSQLUtils.asList(resultObject, "jobs"); if (jobs == null) @@ -109,7 +111,7 @@ public class FFAStransAPI implements IFFAStransAPI { } } catch (Exception e) { - System.out.println(e.getClass() + " " + e.getMessage()); + logger.error(e.getClass() + " " + e.getMessage()); } return result; @@ -183,7 +185,6 @@ public class FFAStransAPI implements IFFAStransAPI { @Override public void submit(String workflowName, String inputFile) throws Exception { - this.inputFile = inputFile; List workflows = getWorkflows(); if (workflows == null) throw new Exception("No workflows"); @@ -199,7 +200,7 @@ public class FFAStransAPI implements IFFAStransAPI { if (apiResponse.getStatus() != 202) throw new Exception("Can not submit, response status is: " + apiResponse.getStatus()); String json = apiResponse.readEntity(String.class); - + logger.info("Transoder response: {}", json); if (StringUtils.isBlank(json)) throw new Exception("Can not submit, response JSON is empty"); BasicDBObject resultObject = (BasicDBObject) JSONUtil.jsonToDbObject(json); diff --git a/server/user.jobengine.osgi.commons/src/user/commons/mediatool/MediaInfo.java b/server/user.jobengine.osgi.commons/src/user/commons/mediatool/MediaInfo.java index ed7b3ab0..033300b8 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/mediatool/MediaInfo.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/mediatool/MediaInfo.java @@ -3,16 +3,17 @@ package user.commons.mediatool; import java.io.IOException; import java.nio.file.Path; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import io.humble.video.Decoder; import io.humble.video.Demuxer; import io.humble.video.DemuxerStream; -import io.humble.video.Global; import io.humble.video.MediaDescriptor; public class MediaInfo { - + private static final Logger logger = LogManager.getLogger(); private long frames; - private Path filePath; public MediaInfo(Path filePath) { @@ -25,32 +26,35 @@ public class MediaInfo { public void process() throws InterruptedException, IOException { final Demuxer demuxer = Demuxer.make(); - demuxer.open(filePath.toString(), null, false, true, null, null); - int bitRate = demuxer.getBitRate() / 1000; - double start = demuxer.getStartTime() == Global.NO_PTS ? 0 : demuxer.getStartTime() / 1000000.0; - - int numStreams = demuxer.getNumStreams(); - - frames = 0; - int videoStreamId = -1; - long streamStartTime = Global.NO_PTS; - Decoder videoDecoder = null; - for (int i = 0; i < numStreams; i++) { - final DemuxerStream stream = demuxer.getStream(i); - streamStartTime = stream.getStartTime(); - final Decoder decoder = stream.getDecoder(); - - if (decoder != null && decoder.getCodecType() == MediaDescriptor.Type.MEDIA_VIDEO) { - videoStreamId = i; - videoDecoder = decoder; - frames = stream.getDuration(); - break; + try { + demuxer.open(filePath.toString(), null, false, true, null, null); + int numStreams = demuxer.getNumStreams(); + frames = 0; + int videoStreamId = -1; + for (int i = 0; i < numStreams; i++) { + final DemuxerStream stream = demuxer.getStream(i); + final Decoder decoder = stream.getDecoder(); + + if (decoder != null && decoder.getCodecType() == MediaDescriptor.Type.MEDIA_VIDEO) { + videoStreamId = i; + frames = stream.getDuration(); + break; + } + } + if (videoStreamId == -1) + throw new RuntimeException("could not find video stream in container: " + filePath); + + } catch (Exception e) { + logger.catching(e); + throw e; + } finally { + try { + demuxer.close(); + } catch (Exception e) { + logger.catching(e); + throw e; } } - if (videoStreamId == -1) - throw new RuntimeException("could not find video stream in container: " + filePath); - - demuxer.close(); } } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java index 4fffa70e..774bdee7 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java @@ -216,24 +216,6 @@ public class NexioDispatcher implements ClipEventListener { logger.info("NEXIO metadata import completed."); } - //END OF R - /* - private void extendJSONClip(BasicDBObject jsClip, Clip clip) throws Exception { - jsClip.put(ID, clip.getId().get()); //Unique internal ID - jsClip.put(LONGNAMEID, clip.getXid().get()); //Extended ID (Filename) - jsClip.put(DURATION, clip.getDuration()); - jsClip.put(MODIFIEDTIMESTAMP, clip.getModifiedTimestamp().getTime()); - jsClip.put(VIDEO_FORMAT, clip.getVideoFormat()); - jsClip.put(VIDEO_BITRATE, clip.getVideoBitrate()); - jsClip.put(FILESIZE, clip.getFileSize()); - jsClip.put(EXTAGENCY, clip.getExtendedField(GetExtendedFieldCommand.FN_AGENCY)); - //jsClip.put(RECORDDATE, new DateTime(rs.getString(i++)).toDate()); - //jsClip.put(EXTAGENCY, rs.getString(i++)); - //jsClip.put(START, rs.getString(i++)); - //System.out.println(String.format("ID = '%s'\tXID = '%s'\tDuration = '%s'\tModified = '%s'\tVideoFormat = '%s'\tVideoBitrate = '%s'", id, xid, duration, modifiedTimestamp.getTime(), videoFormat, videoBitrate)); - } - */ - public void dropAllClipsFromMongo() { db.getCollection(CLIP_COLLECTION_NAME).drop(); } @@ -245,6 +227,29 @@ public class NexioDispatcher implements ClipEventListener { collection.ensureIndex(LONGNAMEID); } + private void innerStartup() { + boolean[] useMOSGateway = { Boolean.parseBoolean(System.getProperty(NEXIO_USE_MOS_GATEWAY)) }; + + worker = new Thread(() -> { + try { + logger.info("Initial clip import started"); + if (useMOSGateway[0]) { + NexioDataMiner dm = new NexioDataMiner(); + dm.transferClips(); + } else { + copyClipsIntoMongo(); + } + logger.info("Initial clip import completed"); + Mediabase mediabase = NexioDispatcher.this.controller.getMediabase(); + mediaListener = mediabase.createMediaListener(disabled, NexioDispatcher.this); + mediaListener.startListener(); + } catch (Exception e) { + logger.catching(e); + } + }); + worker.start(); + } + /* Nem foglalkozunk a clippel ha: C8 84 Get Special ID Attributes @@ -358,57 +363,37 @@ public class NexioDispatcher implements ClipEventListener { } public void shutdown() { - if (mediaListener != null) { - mediaListener.disconnect(); - mediaListener = null; - } - if (controller != null) { - controller.disconnect(); - controller = null; - } - try { - worker.join(); - } catch (InterruptedException e) { - logger.catching(e); + if (!disabled) { + if (mediaListener != null) { + mediaListener.disconnect(); + mediaListener = null; + } + if (controller != null) { + controller.disconnect(); + controller = null; + } + try { + worker.join(); + } catch (InterruptedException e) { + logger.catching(e); + } } } public void startup() { - this.controller = new Controller(NEXIO_HOST); - try { - this.controller.connect(); - } catch (Exception e) { - logger.catching(e); - return; - } - if (!disabled) { - this.dropAllClipsFromMongo(); - this.ensureIndexes(); - } - - boolean[] useMOSGateway = { Boolean.parseBoolean(System.getProperty(NEXIO_USE_MOS_GATEWAY)) }; - - worker = new Thread(() -> { + this.controller = new Controller(NEXIO_HOST); try { - logger.info("Initial clip import started"); - if (!disabled) { - if (useMOSGateway[0]) { - NexioDataMiner dm = new NexioDataMiner(); - dm.transferClips(); - } else { - copyClipsIntoMongo(); - } - } - logger.info("Initial clip import completed"); - Mediabase mediabase = NexioDispatcher.this.controller.getMediabase(); - mediaListener = mediabase.createMediaListener(disabled, NexioDispatcher.this); - mediaListener.startListener(); + this.controller.connect(); } catch (Exception e) { logger.catching(e); + return; } - }); - worker.start(); + dropAllClipsFromMongo(); + ensureIndexes(); + innerStartup(); + } else + logger.info("Nexio service is disabled"); } } diff --git a/server/user.jobengine.osgi.server/WEB-INF/web.xml b/server/user.jobengine.osgi.server/WEB-INF/web.xml index e34f10d5..992b6297 100644 --- a/server/user.jobengine.osgi.server/WEB-INF/web.xml +++ b/server/user.jobengine.osgi.server/WEB-INF/web.xml @@ -21,8 +21,12 @@ org.zkoss.zk.au.http.DHtmlUpdateServlet - + + Test servlet for jetty + testservlet + user.jobengine.servlet.TestServlet + 2 + @@ -40,11 +44,14 @@ /zkau/* - + + testservlet + /actions/* + - zkLoader - /test + zkLoader + /test diff --git a/server/user.jobengine.osgi.server/foo.jsp b/server/user.jobengine.osgi.server/foo.jsp new file mode 100644 index 00000000..71d31ad2 --- /dev/null +++ b/server/user.jobengine.osgi.server/foo.jsp @@ -0,0 +1,5 @@ +<%@ page import="java.util.*, java.io.*, java.net.*, user.jobengine.zk.util.SessionUtil"%> + +<% + out.println("HELLO"); +%> \ No newline at end of file diff --git a/server/user.jobengine.osgi.server/index.jsp b/server/user.jobengine.osgi.server/index.jsp index de97bff5..3fd615c7 100644 --- a/server/user.jobengine.osgi.server/index.jsp +++ b/server/user.jobengine.osgi.server/index.jsp @@ -1,5 +1,6 @@ <%@ page import="java.util.*, java.io.*, java.net.*, user.jobengine.zk.util.SessionUtil"%> <% - pageContext.forward("/pages/index.zul"); + String action = request.getParameter("action"); + pageContext.forward("/pages/index.zul?action=" + action); %> \ No newline at end of file diff --git a/server/user.jobengine.osgi.server/pages/index.zul b/server/user.jobengine.osgi.server/pages/index.zul index 089654fb..697ac54c 100644 --- a/server/user.jobengine.osgi.server/pages/index.zul +++ b/server/user.jobengine.osgi.server/pages/index.zul @@ -48,11 +48,12 @@ });//zk.afterLoad - + -
+
@@ -85,7 +86,7 @@
- +
diff --git a/server/user.jobengine.osgi.server/pages/joblist.zul b/server/user.jobengine.osgi.server/pages/joblist.zul index 107351b7..22d7e530 100644 --- a/server/user.jobengine.osgi.server/pages/joblist.zul +++ b/server/user.jobengine.osgi.server/pages/joblist.zul @@ -3,7 +3,7 @@