make RealMedia mediaHandlers have their own getUrl() method. acts like mp3 now
authormh <mh>
Tue, 2 Apr 2002 23:41:43 +0000 (23:41 +0000)
committermh <mh>
Tue, 2 Apr 2002 23:41:43 +0000 (23:41 +0000)
source/mircoders/media/MediaHandlerRealAudio.java
source/mircoders/media/MediaHandlerRealVideo.java

index 0aad13c..f6d513e 100755 (executable)
@@ -32,39 +32,62 @@ import mir.storage.*;
 public class MediaHandlerRealAudio extends MediaHandlerAudio implements
   MirMedia
 {
-    public void produce (Entity ent, Entity mediaTypeEnt )
-      throws MirMediaException {
-
-      // first see if the file exists
-      super.produce(ent, mediaTypeEnt);
-
-      String baseName = ent.getId();
-      String date = ent.getValue("date");
-      String datePath = StringUtil.webdbDate2path(date);
-      String rtspDir = MirConfig.getProp("Producer.RealMedia.Path");
-      String rtspMediaHost = MirConfig.getProp("Producer.RealMedia.Host");
-
-      String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
-      String RealMediaFile = datePath+ent.getId()+".ram";
-      try {
-        //write an rm (ram?. -mh) file
-        FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,
-                        RealMediaPointer.getBytes());
-      } catch (Exception e) {
-        theLog.printError(e.toString());
-        throw new MirMediaException(e.toString());
-      }
-    }
-
-    public String getStoragePath()
-    {
-      return MirConfig.getProp("Producer.RealMedia.Path");
-    }
-
-    public String getDescr()
-    {
-      return "RealMedia Audio";
+  public void produce (Entity ent, Entity mediaTypeEnt )
+    throws MirMediaException {
+
+    // first see if the file exists
+    super.produce(ent, mediaTypeEnt);
+
+    String baseName = ent.getId();
+    String date = ent.getValue("date");
+    String datePath = StringUtil.webdbDate2path(date);
+    String rtspDir = MirConfig.getProp("Producer.RealMedia.Path");
+    String rtspMediaHost = MirConfig.getProp("Producer.RealMedia.Host");
+
+    String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
+    String RealMediaFile = datePath+ent.getId()+".ram";
+    try {
+      //write an rm (ram?. -mh) file
+      FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,
+                      RealMediaPointer.getBytes());
+    } catch (Exception e) {
+      theLog.printError(e.toString());
+      throw new MirMediaException(e.toString());
     }
+  }
+
+  public SimpleList getURL(Entity ent, Entity mediaTypeEnt)
+  {
+    SimpleList theList = new SimpleList();
+
+    //String stringSize = ent.getValue("size");
+    //int size = Integer.parseInt(stringSize, 10)/1024;
+    theList.add(ent);
+   
+    String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
+                                            ".ra$","");
+
+    // @todo the texts ("title") below urgently need to be sanely localizaeble
+    // somehow
+    SimpleHash ramHash = new SimpleHash();
+    ramHash.put("publish_path", basePath+".ram");
+    ramHash.put("publish_server", ent.getValue("publish_server"));
+    ramHash.put("title", "stream URL");
+    theList.add(ramHash);
+
+    return theList;
+
+  }
+
+  public String getStoragePath()
+  {
+    return MirConfig.getProp("Producer.RealMedia.Path");
+  }
+
+  public String getDescr()
+  {
+    return "RealMedia Audio";
+  }
 
 }
         
index d41cfef..c728817 100755 (executable)
@@ -32,39 +32,62 @@ import mir.storage.*;
 public class MediaHandlerRealVideo extends MediaHandlerVideo implements
   MirMedia
 {
-    public void produce (Entity ent, Entity mediaTypeEnt )
-      throws MirMediaException {
-
-      // first see if the file exists
-      super.produce(ent, mediaTypeEnt);
-
-      String baseName = ent.getId();
-      String date = ent.getValue("date");
-      String datePath = StringUtil.webdbDate2path(date);
-      String rtspDir = MirConfig.getProp("Producer.RealMedia.Path");
-      String rtspMediaHost = MirConfig.getProp("Producer.RealMedia.Host");
-
-      String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
-      String RealMediaFile = datePath+ent.getId()+".ram";
-      try {
-        //write an rm (ram?. -mh) file
-        FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,
-                        RealMediaPointer.getBytes());
-      } catch (Exception e) {
-        theLog.printError(e.toString());
-        throw new MirMediaException(e.toString());
-      }
-    }
-
-    public String getStoragePath()
-    {
-      return MirConfig.getProp("Producer.RealMedia.Path");
-    }
-
-    public String getDescr()
-    {
-      return "RealMedia Video";
+  public void produce (Entity ent, Entity mediaTypeEnt )
+    throws MirMediaException {
+
+    // first see if the file exists
+    super.produce(ent, mediaTypeEnt);
+
+    String baseName = ent.getId();
+    String date = ent.getValue("date");
+    String datePath = StringUtil.webdbDate2path(date);
+    String rtspDir = MirConfig.getProp("Producer.RealMedia.Path");
+    String rtspMediaHost = MirConfig.getProp("Producer.RealMedia.Host");
+
+    String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
+    String RealMediaFile = datePath+ent.getId()+".ram";
+    try {
+      //write an rm (ram?. -mh) file
+      FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,
+                      RealMediaPointer.getBytes());
+    } catch (Exception e) {
+      theLog.printError(e.toString());
+      throw new MirMediaException(e.toString());
     }
+  }
+
+  public SimpleList getURL(Entity ent, Entity mediaTypeEnt)
+  {
+    SimpleList theList = new SimpleList();
+
+    //String stringSize = ent.getValue("size");
+    //int size = Integer.parseInt(stringSize, 10)/1024;
+    theList.add(ent);
+   
+    String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
+                                            ".rm$","");
+
+    // @todo the texts ("title") below urgently need to be sanely localizaeble
+    // somehow
+    SimpleHash ramHash = new SimpleHash();
+    ramHash.put("publish_path", basePath+".ram");
+    ramHash.put("publish_server", ent.getValue("publish_server"));
+    ramHash.put("title", "stream URL");
+    theList.add(ramHash);
+
+    return theList;
+
+  }
+
+  public String getStoragePath()
+  {
+    return MirConfig.getProp("Producer.RealMedia.Path");
+  }
+
+  public String getDescr()
+  {
+    return "RealMedia Video";
+  }
 
 }