rework of media handling vis a vis storage and producing. making it more
[mir.git] / source / mircoders / media / MediaHandlerRealAudio.java
1 /*
2  * put your module comment here
3  */
4
5
6 package  mircoders.media;
7
8 import java.util.*;
9
10 import mir.media.*;
11 import mir.entity.*;
12 import mir.misc.*;
13 import mir.storage.*;
14
15
16
17 /**
18  * Handles realAudio .it manages the ram file.
19  *
20  * 03.2002 - reworked Realmedia handling. -mh
21  *
22  * @see mir.media.MediaHandlerGeneric
23  * @see mir.media.MirMedia
24  * @author john <john@manifestor.org>, mh <heckmann@hbe.ca>
25  * @version 11.10.2001
26  */
27
28
29 public class MediaHandlerRealAudio extends MediaHandlerAudio implements
30   MirMedia
31 {
32     public void produce (Entity ent, Entity mediaTypeEnt )
33       throws MirMediaException {
34
35       // first see if the file exists
36       super.produce(ent, mediaTypeEnt);
37
38       String baseName = ent.getId();
39       String date = ent.getValue("date");
40       String datePath = StringUtil.webdbDate2path(date);
41       String rtspDir = MirConfig.getProp("Producer.RealMedia.Path");
42       String rtspMediaHost = MirConfig.getProp("Producer.RealMedia.Host");
43
44       String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
45       String RealMediaFile = datePath+ent.getId()+".ram";
46       try {
47         //write an rm (ram?. -mh) file
48         FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,
49                         RealMediaPointer.getBytes());
50       } catch (Exception e) {
51         theLog.printError(e.toString());
52         throw new MirMediaException(e.toString());
53       }
54     }
55
56     public String getURL(Entity ent, Entity mediaTypeEnt)
57     {
58       int size = Integer.parseInt(ent.getValue("size"), 10)/1024;
59       String title = ent.getValue("title")+" - "+mediaTypeEnt.getValue("name")+
60       " "+size+" KB";
61       return StringUtil.createURLLinks(ent.getValue("publish_server")+"/"+
62         ent.getValue("publish_path"), title, imageRoot, getBigIcon());
63     }
64
65     public String getStoragePath() {
66       return MirConfig.getProp("Producer.RealMedia.Path");
67     }
68
69 }
70         
71         
72