git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorRendek Róbert <robert.rendek@userrendszerhaz.hu>
Tue, 3 Oct 2017 14:05:18 +0000 (14:05 +0000)
committerRendek Róbert <robert.rendek@userrendszerhaz.hu>
Tue, 3 Oct 2017 14:05:18 +0000 (14:05 +0000)
server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java
server/user.jobengine.osgi.commons/src/user/commons/nexio/api/ClipEvent.java
server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediaListener.java
server/user.jobengine.osgi.commons/src/user/commons/nexio/api/Mediabase.java
server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediabaseImpl.java
server/user.jobengine.osgi.commons/src/user/commons/nexio/api/samples/ListMetabaseContents.java

index 26eaee080f93b672b0bac3fa3872727ea85362ae..e7d8db2d67579bbabec1b2638bea008a10b3491d 100644 (file)
@@ -80,6 +80,7 @@ public class NexioClipEventDispatcher implements ClipEventListener {
 \r
        private Controller controller = null;\r
 \r
+       //KONSTRUKTOR\r
        //KONSTRUKTOR\r
        public NexioClipEventDispatcher() {\r
                try {\r
@@ -101,6 +102,7 @@ public class NexioClipEventDispatcher implements ClipEventListener {
                        logger.info("NexioClipEventDispatcher nexio server is connected.");\r
 \r
                        this.progressListenerList = new EventListenerList();\r
+\r
                        this.dropAllClipsFromMongo();\r
                        this.ensureIndexes();\r
 \r
@@ -132,15 +134,18 @@ public class NexioClipEventDispatcher implements ClipEventListener {
        @Override\r
        public void clipEventPerformed(ClipEvent evt) {\r
                try {\r
-                       if (isValidClip(evt.getClip())) {\r
-                               BasicDBObject jsClip = convertClipToJSON(evt.getClip());\r
-                               if (evt.getEventType() == ClipEventType.CLIP_ADDED) {\r
+                       //DELETE-nel csak az id van kitoltve a CLIP-en, ezert exception jon!!!\r
+                       if (evt.getEventType() == ClipEventType.CLIP_ADDED) {\r
+//                             if (isValidClip(evt.getClip())) {\r
+                                       BasicDBObject jsClip = convertClipToJSON(evt.getClip());\r
                                        //cache???\r
                                        Map<String, BasicDBObject> mongoClips = loadClipsFromMongo();\r
                                        saveClipIntoMongo(jsClip, mongoClips);\r
-                               } else if (evt.getEventType() == ClipEventType.CLIP_DELETED) {\r
-                                       removeDeleted(jsClip);\r
-                               }\r
+//                             }\r
+                       } else if (evt.getEventType() == ClipEventType.CLIP_DELETED) {\r
+                               BasicDBObject jsClip = new BasicDBObject();\r
+                               jsClip.put(ID, evt.getClip().getId().get());    //Unique internal ID \r
+                               removeDeleted(jsClip);\r
                        }\r
                } catch (Exception exc) {\r
                        logger.error("", exc);\r
@@ -148,9 +153,8 @@ public class NexioClipEventDispatcher implements ClipEventListener {
        }\r
 \r
        //END OF R\r
-\r
-       private BasicDBObject convertClipToJSON(Clip clip) throws Exception {\r
-               BasicDBObject jsClip = new BasicDBObject();\r
+/*\r
+       private void extendJSONClip(BasicDBObject jsClip, Clip clip) throws Exception {\r
                jsClip.put(ID, clip.getId().get()); //Unique internal ID\r
                jsClip.put(LONGNAMEID, clip.getXid().get()); //Extended ID (Filename)\r
                jsClip.put(DURATION, clip.getDuration());\r
@@ -163,6 +167,55 @@ public class NexioClipEventDispatcher implements ClipEventListener {
                //jsClip.put(EXTAGENCY, rs.getString(i++));\r
                //jsClip.put(START, rs.getString(i++));\r
                //System.out.println(String.format("ID = '%s'\tXID = '%s'\tDuration = '%s'\tModified = '%s'\tVideoFormat = '%s'\tVideoBitrate = '%s'", id, xid, duration, modifiedTimestamp.getTime(), videoFormat, videoBitrate));\r
+       }\r
+*/     \r
+       \r
+       private BasicDBObject convertClipToJSON(Clip clip) throws Exception {\r
+               BasicDBObject jsClip = new BasicDBObject();\r
+               try{\r
+                       jsClip.put(ID, clip.getId().get()); //Unique internal ID\r
+               }catch(Exception e){\r
+                       System.out.println(e);\r
+               }\r
+               try{\r
+                       jsClip.put(LONGNAMEID, clip.getXid().get()); //Extended ID (Filename)\r
+               }catch(Exception e){\r
+                       System.out.println(e);\r
+               }\r
+               try{\r
+                       jsClip.put(DURATION, clip.getDuration());\r
+               }catch(Exception e){\r
+                       System.out.println(e);\r
+               }\r
+               try{\r
+                       jsClip.put(MODIFIEDTIMESTAMP, clip.getModifiedTimestamp().getTime());\r
+               }catch(Exception e){\r
+                       System.out.println(e);\r
+               }\r
+               try{\r
+                       jsClip.put(VIDEO_FORMAT, clip.getVideoFormat());\r
+               }catch(Exception e){\r
+                       System.out.println(e);\r
+               }\r
+               try{\r
+                       jsClip.put(VIDEO_BITRATE, clip.getVideoBitrate());\r
+               }catch(Exception e){\r
+                       System.out.println(e);\r
+               }\r
+               try{\r
+                       jsClip.put(FILESIZE, clip.getFileSize());\r
+               }catch(Exception e){\r
+                       System.out.println(e);\r
+               }\r
+               try{\r
+                       jsClip.put(EXTAGENCY, clip.getExtendedField(GetExtendedFieldCommand.FN_AGENCY));\r
+               }catch(Exception e){\r
+                       System.out.println(e);\r
+               }\r
+               //jsClip.put(RECORDDATE, new DateTime(rs.getString(i++)).toDate());\r
+               //jsClip.put(EXTAGENCY, rs.getString(i++));\r
+               //jsClip.put(START, rs.getString(i++));\r
+               //System.out.println(String.format("ID = '%s'\tXID = '%s'\tDuration = '%s'\tModified = '%s'\tVideoFormat = '%s'\tVideoBitrate = '%s'", id, xid, duration, modifiedTimestamp.getTime(), videoFormat, videoBitrate));\r
                return jsClip;\r
        }\r
 \r
index eca3e1e62a40c271efa3eb425bfb85ad36d26581..a4e57068c25daa73c81abb0942ff16e31d22c04f 100644 (file)
@@ -9,7 +9,7 @@ public class ClipEvent {
        }\r
        \r
        public ClipEvent(Clip _clip, ClipEventType _eventType){\r
-               this.clip = clip;\r
+               this.clip = _clip;\r
                this.eventType = _eventType;\r
        }\r
        \r
index b15c6efc9b23346ce60f53277ba4747b159f0fb7..e04d2017ecddbdd3d9c762baed2dc3b98f04dd6c 100644 (file)
@@ -88,7 +88,8 @@ public class MediaListener implements Runnable {
                if (notificationNumber == NN_ID_ADDED) {\r
                        evt = new ClipEvent(mediaBase.getClip(id), ClipEventType.CLIP_ADDED);\r
                } else if (notificationNumber == NN_ID_DELETED) {\r
-                       evt = new ClipEvent(mediaBase.getClip(id), ClipEventType.CLIP_DELETED);\r
+                       Clip deletedClip = new ClipImpl(mediaBase.getProtocol(), id);\r
+                       evt = new ClipEvent(deletedClip, ClipEventType.CLIP_DELETED);\r
                }\r
                for (ClipEventListener cel : this.clipEventListeners) {\r
                        cel.clipEventPerformed(evt);\r
index d952990673f9833affa7eae191a8ac0d50315133..d16c3bbdec834872fedda30eaa72afe230af3c5a 100644 (file)
@@ -13,4 +13,6 @@ public interface Mediabase {
        public Iterator<Clip> getClips() throws IOException, ProtocolException;
 
        public MediaListener getMediaListener();
+       
+       public NexioServerProtocol getProtocol();
 }
index 6fc16c397362a9d07e832c1673597d8c8e66ca1a..67a36a4a636e0975cd2550b7ecc71b058959e500 100644 (file)
@@ -50,7 +50,10 @@ class MediabaseImpl implements Mediabase {
                return this.mediaListener;
        }
        
-       
+       @Override
+       public NexioServerProtocol getProtocol() {
+               return this.protocol;
+       }
        private class Itr implements Iterator<Clip> {
 
                private Clip next;
@@ -94,5 +97,7 @@ class MediabaseImpl implements Mediabase {
                }
 
        }
+
+       
        
 }
index 47cf63f2127e634075e6384aa33b910f69735aa1..8eebed25e53b96b0ea433782e7930a1fa4416153 100644 (file)
@@ -49,7 +49,7 @@ public class ListMetabaseContents implements ClipEventListener{
        private Mediabase mediaBase = null;
 
        private int nexioPort = 557;
-       private String nexioHost = "10.228.43.18";      //echo: "10.10.1.55";   vmware: "10.228.43.18"
+       private String nexioHost = "10.228.43.38";      //echo: "10.10.1.55";   vmware: "10.228.43.18"
        private Connection connection = null;