From e372403058cbe4dbb51369e5e87785697c46dae2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Fri, 13 Oct 2017 22:18:36 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30622 --- client/DxPlay/DxPlayer.cs | 72 +---------- client/DxPlay/MediaDetector.cs | 2 +- .../jobtemplates/fake-noparams.xml | 6 + .../server/steps/FakeNoParamsStep.java | 27 ++++ .../user/jobengine/server/steps/FakeStep.java | 4 +- .../user/commons/nexio/api/MediabaseImpl.java | 116 +++++++++--------- .../server/protocol/NexioServerProtocol.java | 2 + .../protocol/NexioServerProtocolImpl.java | 11 +- .../common/nexio/test/NexioDataMinerTest.java | 18 ++- .../src/user/jobengine/server/JobEngine.java | 6 + .../jobengine/server/JobStepExecutor.java | 1 + 11 files changed, 129 insertions(+), 136 deletions(-) create mode 100644 server/user.jobengine.executors/jobtemplates/fake-noparams.xml create mode 100644 server/user.jobengine.executors/src/user/jobengine/server/steps/FakeNoParamsStep.java diff --git a/client/DxPlay/DxPlayer.cs b/client/DxPlay/DxPlayer.cs index 11531e59..ab20783a 100644 --- a/client/DxPlay/DxPlayer.cs +++ b/client/DxPlay/DxPlayer.cs @@ -236,10 +236,10 @@ namespace DxPlay { //Type typeFromClsid = Type.GetTypeFromCLSID(new Guid("CCE7BD95-3BC4-4cfb-9664-0BF83201BE09")); //splitter = (IBaseFilter)Activator.CreateInstance(typeFromClsid); //m_FilterGraph.AddFilter(splitter, "MXF Splitter"); - splitter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "Sony MXF Splitter"); + //splitter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "Sony MXF Splitter"); - //splitter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "LAV Splitter"); + splitter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "LAV Splitter"); if (splitter == null) throw new Exception("No splitter!"); @@ -296,74 +296,6 @@ namespace DxPlay { #endif } - private void SetupGraphSONY(Control hWin) { - int hr; - - m_videoWidth = MediaDescription.Resolution.Width; - m_videoHeight = MediaDescription.Resolution.Height; - - try { - m_FilterGraph = new FilterGraph() as IFilterGraph2; - - IGraphBuilder graphBuilder = m_FilterGraph as IGraphBuilder; - m_mediaSeek = m_FilterGraph as IMediaSeeking; - m_mediaPosition = m_FilterGraph as IMediaPosition; - m_mediaEvent = m_FilterGraph as IMediaEvent; - m_mediaCtrl = m_FilterGraph as IMediaControl; - m_videoWindow = m_FilterGraph as IVideoWindow; - - IBaseFilter sourceFilter = null; - hr = m_FilterGraph.AddSourceFilter(MediaDescription.FileName, MediaDescription.FileName, out sourceFilter); - DsError.ThrowExceptionForHR(hr); - - Type typeFromClsid = Type.GetTypeFromCLSID(new Guid("CCE7BD95-3BC4-4cfb-9664-0BF83201BE09")); - //IBaseFilter splitter = (IBaseFilter)Activator.CreateInstance(typeFromClsid); - - IBaseFilter splitter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "Sony MXF Splitter"); - if (splitter == null) - throw new Exception("No splitter!"); - - FilterGraphTools.ConnectFilters(graphBuilder, sourceFilter, "Output", splitter, "Input", true); - - IBaseFilter videoDecoder = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "Sony MPEG Video Decoder Pro"); - if (videoDecoder == null) - throw new Exception("No video decoder!"); - - FilterGraphTools.ConnectFilters(graphBuilder, splitter, "Video", videoDecoder, "Input", true); - - IBaseFilter sampGrabber = (IBaseFilter)new SampleGrabber(); - ConfigureSampleGrabber((ISampleGrabber)sampGrabber); - hr = m_FilterGraph.AddFilter(sampGrabber, "Sample Grabber"); - DsError.ThrowExceptionForHR(hr); - - FilterGraphTools.ConnectFilters(graphBuilder, videoDecoder, "Output", sampGrabber, "Input", true); - - m_videoRenderer = (IBaseFilter)new VideoMixingRenderer9(); - hr = m_FilterGraph.AddFilter(m_videoRenderer, "Video Mixing Renderer 9"); - DsError.ThrowExceptionForHR(hr); - - FilterGraphTools.ConnectFilters(graphBuilder, sampGrabber, "Output", m_videoRenderer, "VMR Input0", true); - - ConfigureVideoWindow(hWin); - - if (DsFindPin.ByName(splitter, "Audio") != null) { - IBaseFilter audioDecoder = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "SONY Audio Mixer"); - if (audioDecoder == null) - throw new Exception("No audio decoder!"); - - FilterGraphTools.ConnectFilters(graphBuilder, splitter, "Audio", audioDecoder, "Input", true); - FilterGraphTools.RenderPin(graphBuilder, audioDecoder, "Output"); - } - - SaveSizeInfo(sampGrabber as ISampleGrabber); - - } - catch (Exception e) { - Debug.WriteLine(e.Message); - } - finally { - } - } // Configure the video window private void ConfigureVideoWindow(Control hWin) { diff --git a/client/DxPlay/MediaDetector.cs b/client/DxPlay/MediaDetector.cs index 96b09e56..d5837a3d 100644 --- a/client/DxPlay/MediaDetector.cs +++ b/client/DxPlay/MediaDetector.cs @@ -23,7 +23,7 @@ namespace DxPlay { public static MediaDescription GetDescription(string fileName) { MediaDescription mediaDesc = new MediaDescription(); mediaDesc.fileName = fileName; - return mediaDesc; + //return mediaDesc; logger.Debug("Start MediaInfo"); MediaInfo MI = new MediaInfo(); MI.Open(fileName); diff --git a/server/user.jobengine.executors/jobtemplates/fake-noparams.xml b/server/user.jobengine.executors/jobtemplates/fake-noparams.xml new file mode 100644 index 00000000..aaab8a3c --- /dev/null +++ b/server/user.jobengine.executors/jobtemplates/fake-noparams.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeNoParamsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeNoParamsStep.java new file mode 100644 index 00000000..915a19aa --- /dev/null +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeNoParamsStep.java @@ -0,0 +1,27 @@ +package user.jobengine.server.steps; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import user.jobengine.server.IJobEngine; +import user.jobengine.server.IJobRuntime; + +public class FakeNoParamsStep extends JobStep { + private static final Logger logger = LogManager.getLogger(); + int count = 10; + + @StepEntry + public Object[] execute(IJobEngine jobEngine, IJobRuntime jobRuntime) { + try { + logger.warn("| + | FakeNoParams step"); + jobRuntime.incrementProgress(50); + Thread.sleep(15000); + jobRuntime.incrementProgress(100); + logger.warn("| - | FakeNoParams step"); + } catch (Exception e) { + logger.error(e.getMessage()); + } + return null; + } + +} diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java index 94a7408e..1b10a174 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java @@ -16,14 +16,14 @@ public class FakeStep extends JobStep { @StepEntry public Object[] execute(long itemID, IJobEngine jobEngine, IJobRuntime jobRuntime) { try { - logger.warn(getMarker(), "Starting Fake step"); + logger.warn("Starting Fake step"); String json = "{ houseID: '111222' }"; BasicDBObject o = (BasicDBObject) JSONUtil.jsonToDbObject(json); for (int i = 0; i < count; i++) { if (!canContinue()) break; - Thread.sleep(1000); jobRuntime.incrementProgress((i + 1) * count); + Thread.sleep(10000); // logger.info("Progress {}", jobRuntime.getProgress()); } } catch (Exception e) { diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediabaseImpl.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediabaseImpl.java index 801e12a7..12369a82 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediabaseImpl.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediabaseImpl.java @@ -1,18 +1,64 @@ package user.commons.nexio.api; -import user.commons.nexio.server.protocol.*; - import java.io.IOException; -import java.util.ArrayList; import java.util.Iterator; -import java.util.List; + +import user.commons.nexio.server.protocol.Id; +import user.commons.nexio.server.protocol.NexioServerProtocol; +import user.commons.nexio.server.protocol.ProtocolException; +import user.commons.nexio.server.protocol.Xid; class MediabaseImpl implements Mediabase { + private class Itr implements Iterator { + + private Clip next; + + public Itr() throws IOException, ProtocolException { + Id id = protocol.executeListFirstIDHandle(); + next = id != null ? new ClipImpl(protocol, id) : null; + } + + @Override + public boolean hasNext() { + return next != null; + } + + @Override + public Clip next() { + if (next == null) { + return null; + } + final Clip c = next; + try { + Id id = protocol.executeListNextIDHandle(); + + //next = id != null ? new ClipImpl(protocol, id) : null; + if (id != null) { + next = new ClipImpl(protocol, id); + } else { + next = null; + } + } catch (IOException e) { + throw new RuntimeException(e); + } catch (ProtocolException e) { + throw new RuntimeException(e); + } + + return c; + } + + @Override + public void remove() { + } + + } + private static final String ID = "id"; private final NexioServerProtocol protocol; - private MediaListener mediaListener = null; - + + private MediaListener mediaListener = null; + //KONSTRUKTOR public MediabaseImpl(NexioServerProtocol protocol) { this.protocol = protocol; @@ -20,17 +66,11 @@ class MediabaseImpl implements Mediabase { public MediabaseImpl(NexioServerProtocol protocol, boolean startMediaListener) { this.protocol = protocol; - if(startMediaListener){ - this.mediaListener = new MediaListener(this, protocol.getConnection().getHost(), protocol.getConnection().getPort()); - } - } - - public void startMediaListener(){ - if(this.mediaListener == null){ + if (startMediaListener) { this.mediaListener = new MediaListener(this, protocol.getConnection().getHost(), protocol.getConnection().getPort()); } } - + @Override public Clip getClip(Id id) throws IOException, ProtocolException { if (id == null) { @@ -61,55 +101,17 @@ class MediabaseImpl implements Mediabase { public MediaListener getMediaListener() { return this.mediaListener; } - + @Override public NexioServerProtocol getProtocol() { return this.protocol; } - private class Itr implements Iterator { - - private Clip next; - public Itr() throws IOException, ProtocolException { - Id id = protocol.executeListFirstIDHandle(); - next = id != null ? new ClipImpl(protocol, id) : null; - } - - @Override - public boolean hasNext() { - return next != null; - } - - @Override - public Clip next() { - if (next == null) { - return null; - } - final Clip c = next; - try { - Id id = protocol.executeListNextIDHandle(); - - //next = id != null ? new ClipImpl(protocol, id) : null; - if(id != null){ - next = new ClipImpl(protocol, id); - }else{ - next = null; - } - } catch (IOException e) { - throw new RuntimeException(e); - } catch (ProtocolException e) { - throw new RuntimeException(e); - } - - return c; - } - - @Override - public void remove() { + @Override + public void startMediaListener() { + if (this.mediaListener == null) { + this.mediaListener = new MediaListener(this, protocol.getConnection().getHost(), protocol.getConnection().getPort()); } - } - - } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/NexioServerProtocol.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/NexioServerProtocol.java index 56561855..49450e41 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/NexioServerProtocol.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/NexioServerProtocol.java @@ -27,4 +27,6 @@ public interface NexioServerProtocol { public Connection getConnection(); + void setDescription(String id, String description) throws IOException; + } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/NexioServerProtocolImpl.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/NexioServerProtocolImpl.java index 884621c7..72345194 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/NexioServerProtocolImpl.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/NexioServerProtocolImpl.java @@ -84,8 +84,17 @@ public class NexioServerProtocolImpl implements NexioServerProtocol { @Override public Connection getConnection() { - ; return this.connection; } + @Override + public void setDescription(String id, String description) throws IOException { + byte[] SET_DESCRIPTION = ("...." + id + description).getBytes(); + SET_DESCRIPTION[0] = (byte) 0xCF; + SET_DESCRIPTION[1] = (byte) 0xCC; + SET_DESCRIPTION[2] = (byte) 0xBC; + SET_DESCRIPTION[3] = (byte) 0x12; + connection.write(SET_DESCRIPTION); + connection.flush(); + } } diff --git a/server/user.jobengine.osgi.commons/test/user/common/nexio/test/NexioDataMinerTest.java b/server/user.jobengine.osgi.commons/test/user/common/nexio/test/NexioDataMinerTest.java index 7d01d23f..16474a18 100644 --- a/server/user.jobengine.osgi.commons/test/user/common/nexio/test/NexioDataMinerTest.java +++ b/server/user.jobengine.osgi.commons/test/user/common/nexio/test/NexioDataMinerTest.java @@ -9,10 +9,9 @@ import org.junit.BeforeClass; import org.junit.Test; import user.commons.nexio.NexioDataMiner; +import user.commons.nexio.api.Controller; public class NexioDataMinerTest { - private NexioDataMiner sut; - @BeforeClass public static void initialize() throws Exception { //Naplozas @@ -31,6 +30,14 @@ public class NexioDataMinerTest { System.getProperties().putAll(properties); } + private NexioDataMiner sut; + + @Test + public void reset() { + sut = new NexioDataMiner(); + sut.reset(); + } + @Test public void run() { sut = new NexioDataMiner(); @@ -38,8 +45,9 @@ public class NexioDataMinerTest { } @Test - public void reset() { - sut = new NexioDataMiner(); - sut.reset(); + public void setDesc() throws Exception { + Controller c = new Controller("10.10.1.56"); + c.connect(); + c.getMediabase().getProtocol().setDescription("%0000205", "VALAMI"); } } diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java index 283a227e..5bd09bed 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java @@ -245,6 +245,10 @@ public class JobEngine implements IJobEngine { } } + private void bootstrap() throws JobEngineException { + submit("fake-noparams.xml", "Bootstrap", null); + } + protected Map createJobs() { return new ConcurrentHashMap(); } @@ -736,11 +740,13 @@ public class JobEngine implements IJobEngine { schedulerService = new SchedulerService(this); schedulerService.statrtup(); + bootstrap(); } catch (Exception e) { logger.error(e); } logger.info("JobEngine started"); + } private void submit(IJobRuntime runtime) { diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobStepExecutor.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobStepExecutor.java index 5144c111..b9544737 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobStepExecutor.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobStepExecutor.java @@ -69,6 +69,7 @@ public class JobStepExecutor implements IJobStepExecutor { try { this.join(); } catch (InterruptedException e) { + logger.catching(e); } } } -- 2.54.0