From af80bd2426282b7491d9ba0ebfb201abb42e3ca4 Mon Sep 17 00:00:00 2001 From: geronimo Date: Wed, 15 Aug 2012 07:55:07 +0200 Subject: next variant of java client --- .../schwarzrot/media/domain/AbstractMediaNode.java | 249 +++++++++++++++++++++ cmpcj/src/de/schwarzrot/media/domain/Audio.java | 72 ++++++ cmpcj/src/de/schwarzrot/media/domain/Config.java | 128 +++++++++++ cmpcj/src/de/schwarzrot/media/domain/DVDImage.java | 47 ++++ cmpcj/src/de/schwarzrot/media/domain/Genre.java | 121 ++++++++++ .../media/domain/LegacyVdrRecording.java | 39 ++++ cmpcj/src/de/schwarzrot/media/domain/Media.java | 55 +++++ .../de/schwarzrot/media/domain/MediaServer.java | 57 +++++ .../src/de/schwarzrot/media/domain/MediaType.java | 55 +++++ cmpcj/src/de/schwarzrot/media/domain/Movie.java | 88 ++++++++ cmpcj/src/de/schwarzrot/media/domain/Picture.java | 78 +++++++ cmpcj/src/de/schwarzrot/media/domain/PlayList.java | 70 ++++++ .../schwarzrot/media/domain/PlayerDefinition.java | 115 ++++++++++ .../de/schwarzrot/media/domain/VdrRecording.java | 67 ++++++ 14 files changed, 1241 insertions(+) create mode 100644 cmpcj/src/de/schwarzrot/media/domain/AbstractMediaNode.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/Audio.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/Config.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/DVDImage.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/Genre.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/LegacyVdrRecording.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/Media.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/MediaServer.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/MediaType.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/Movie.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/Picture.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/PlayList.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/PlayerDefinition.java create mode 100644 cmpcj/src/de/schwarzrot/media/domain/VdrRecording.java (limited to 'cmpcj/src/de/schwarzrot/media/domain') diff --git a/cmpcj/src/de/schwarzrot/media/domain/AbstractMediaNode.java b/cmpcj/src/de/schwarzrot/media/domain/AbstractMediaNode.java new file mode 100644 index 0000000..573726c --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/AbstractMediaNode.java @@ -0,0 +1,249 @@ +/** + * ======================== legal notice ====================== + * + * File: AbstractMediaNode.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.io.File; +import java.io.Serializable; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URLDecoder; +import java.util.Map; +import java.util.TreeMap; + + +public abstract class AbstractMediaNode implements Serializable, Comparable { + public static final String FORMAT_PROPERTY = "format"; + public static final String NAME_PROPERTY = "name"; + public static final String PATH_PROPERTY = "path"; + public static final String TYPE_PROPERTY = "type"; + public static final String SEARCH_PROPERTY = "search"; + private static final long serialVersionUID = 713L; + public enum SupportedMediaType { + Genre, // + Audio, // + Movie, IMovie, DVDImage, IDVDImage, // + LegacyVdrRecording, ILegacyVdrRecording, VdrRecording, IVdrRecording, // + Picture, // + Unknown + } + + + protected AbstractMediaNode(AbstractMediaNode parent, SupportedMediaType type, String mimeType, File path) { + properties = new TreeMap(); + setParent(parent); + setType(type); + setMimeType(mimeType); + setRealPath(path); + originalPath = realPath; + } + + + @Override + public int compareTo(AbstractMediaNode o) { + if (o == null) + return -1; + + if (this != o) { + int rv = type.ordinal() - o.getType().ordinal(); + + if (rv == 0) + rv = getName().compareToIgnoreCase(o.getName()); + + return rv; + } + return 0; + } + + + public String getFormat() { + return format; + } + + + public String getMimeType() { + return mimeType; + } + + + public String getName() { + return name; + } + + + public File getOriginalPath() { + return originalPath; + } + + + public AbstractMediaNode getParent() { + return parent; + } + + + public Map getProperties() { + return properties; + } + + + public File getRealPath() { + return realPath; + } + + + public String getSearch() { + return search; + } + + + public SupportedMediaType getType() { + return type; + } + + + public URI getURI() { + return uri; + } + + + public void setFormat(String format) { + this.format = format; + properties.put(FORMAT_PROPERTY, format); + } + + + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + + public void setName(String name) { + this.name = name; + properties.put(NAME_PROPERTY, name); + } + + + public void setParent(AbstractMediaNode parent) { + if ((this.parent = parent) != null) + refresh(); + } + + + public void setPath(String path) { + if (uri == null) { + try { + // properties.put(PATH_PROPERTY, path); + uri = new URI(path); + properties.put(PATH_PROPERTY, uri.toString()); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + } + try { + File tmp = new File(URLDecoder.decode(path, "UTF-8")); + + if (path != null && originalPath == null) + originalPath = tmp; + setRealPath(tmp); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + + public void setProperty(String key, Object value) { + properties.put(key, value); + } + + + public void setRealPath(File realPath) { + this.realPath = realPath; + if (name == null && realPath != null) + setName(realPath.getName()); + } + + + public void setSearch(String search) { + this.search = search; + properties.put(SEARCH_PROPERTY, search); + } + + + public void setType(int type) { + if (type == SupportedMediaType.Audio.ordinal()) + this.type = SupportedMediaType.Audio; + else if (type == SupportedMediaType.Movie.ordinal()) + this.type = SupportedMediaType.Movie; + else if (type == SupportedMediaType.IMovie.ordinal()) + this.type = SupportedMediaType.IMovie; + else if (type == SupportedMediaType.DVDImage.ordinal()) + this.type = SupportedMediaType.DVDImage; + else if (type == SupportedMediaType.IDVDImage.ordinal()) + this.type = SupportedMediaType.IDVDImage; + else if (type == SupportedMediaType.LegacyVdrRecording.ordinal()) + this.type = SupportedMediaType.LegacyVdrRecording; + else if (type == SupportedMediaType.ILegacyVdrRecording.ordinal()) + this.type = SupportedMediaType.ILegacyVdrRecording; + else if (type == SupportedMediaType.VdrRecording.ordinal()) + this.type = SupportedMediaType.VdrRecording; + else if (type == SupportedMediaType.IVdrRecording.ordinal()) + this.type = SupportedMediaType.IVdrRecording; + else if (type == SupportedMediaType.Picture.ordinal()) + this.type = SupportedMediaType.Picture; + else + throw new EnumConstantNotPresentException(SupportedMediaType.class, "unknown ordinal #" + type); + properties.put(TYPE_PROPERTY, this.type); + } + + + @Override + public String toString() { + return getName(); + } + + + protected void refresh() { + if (parent != null && realPath != null) + realPath = new File(parent.getRealPath(), realPath.getName()); + } + + + protected void setType(SupportedMediaType type) { + this.type = type; + properties.put(TYPE_PROPERTY, this.type); + } + + private File realPath; + private File originalPath; + private URI uri; + private SupportedMediaType type; + private AbstractMediaNode parent; + private String name; + private String mimeType; + private String search; + private String format; + private Map properties; +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/Audio.java b/cmpcj/src/de/schwarzrot/media/domain/Audio.java new file mode 100644 index 0000000..7e3bf20 --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/Audio.java @@ -0,0 +1,72 @@ +/** + * ======================== legal notice ====================== + * + * File: Audio.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + + +public class Audio extends Media { + private static final long serialVersionUID = 713L; + private static final Map knownExtensions; + + + public Audio(Genre parent, File path, String mimeType) { + super(parent, SupportedMediaType.Audio, mimeType, path); + } + + + public static String getContentType(String extension) { + return knownExtensions.get(extension); + } + + + public static boolean isSupportedExtension(String extension) { + return knownExtensions.containsKey(extension); + } + + static { + knownExtensions = new HashMap(); + + knownExtensions.put("aac", "audio/aac"); + knownExtensions.put("aif", "audio/x-aiff"); + knownExtensions.put("aiff", "audio/x-aiff"); + knownExtensions.put("aifc", "audio/x-aiff"); + knownExtensions.put("au", "audio/x-au"); + knownExtensions.put("fla", "audio/flac"); + knownExtensions.put("flac", "audio/flac"); + knownExtensions.put("oga", "audio/ogg"); + knownExtensions.put("ogg", "audio/ogg"); + knownExtensions.put("mka", "audio/x-matroska"); + knownExtensions.put("mp3", "audio/mpeg"); + knownExtensions.put("mp4", "audio/x-mpeg4"); + knownExtensions.put("m4a", "audio/x-m4"); + knownExtensions.put("mpp", "audio/x-musepack"); + knownExtensions.put("ram", "audio/x-realaudio"); + } +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/Config.java b/cmpcj/src/de/schwarzrot/media/domain/Config.java new file mode 100644 index 0000000..d273972 --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/Config.java @@ -0,0 +1,128 @@ +/** + * ======================== legal notice ====================== + * + * File: Config.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class Config { + public Config() { + knownServers = new ArrayList(); + playerMap = new HashMap(); + } + + + public void addServer(MediaServer ms) { + knownServers.add(ms); + } + + + public List getKnownServers() { + return knownServers; + } + + + public int getMainHeight() { + return mainHeight; + } + + + public int getMainWidth() { + return mainWidth; + } + + + public Map getPlayerMap() { + return playerMap; + } + + + public int getPosX() { + return posX; + } + + + public int getPosY() { + return posY; + } + + + public boolean isDebug() { + return debug; + } + + + public void putPlayer(Media.SupportedMediaType type, PlayerDefinition pd) { + playerMap.put(type, pd); + } + + + public void setDebug(boolean debug) { + this.debug = debug; + } + + + public void setKnownServers(List knownServers) { + this.knownServers = knownServers; + } + + + public void setMainHeight(int mainHeight) { + this.mainHeight = mainHeight; + } + + + public void setMainWidth(int mainWidth) { + this.mainWidth = mainWidth; + } + + + public void setPlayerMap(Map playerMap) { + this.playerMap = playerMap; + } + + + public void setPosX(int posX) { + this.posX = posX; + } + + + public void setPosY(int posY) { + this.posY = posY; + } + + private List knownServers; + private Map playerMap; + private boolean debug; + private int posX; + private int posY; + private int mainWidth; + private int mainHeight; +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/DVDImage.java b/cmpcj/src/de/schwarzrot/media/domain/DVDImage.java new file mode 100644 index 0000000..ff5451a --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/DVDImage.java @@ -0,0 +1,47 @@ +/** + * ======================== legal notice ====================== + * + * File: DVDImage.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.io.File; + + +public class DVDImage extends Movie { + private static final long serialVersionUID = 713L; + private static final String DVDContentType = "video/mpeg"; + private static final String BASE_DIR = "VIDEO_TS"; + private static final String KEY_FILE = "VIDEO_TS.IFO"; + + + public DVDImage(Genre parent, File path) { + super(parent, SupportedMediaType.DVDImage, DVDContentType, path); + } + + + public static boolean isKeyFile(File file2Check) { + return file2Check.getName().equals(KEY_FILE) && file2Check.getParentFile().getName().equals(BASE_DIR); + } +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/Genre.java b/cmpcj/src/de/schwarzrot/media/domain/Genre.java new file mode 100644 index 0000000..5bbb463 --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/Genre.java @@ -0,0 +1,121 @@ +/** + * ======================== legal notice ====================== + * + * File: Genre.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + + +public class Genre extends AbstractMediaNode { + private static final long serialVersionUID = 713L; + private static final String MIME_TYPE = "text/plain"; + + + public Genre(File path) { + this(null, path); + } + + + public Genre(Genre parent, File path) { + super(parent, SupportedMediaType.Genre, MIME_TYPE, path); + mediaList = new ArrayList(); + children = new ArrayList(); + if (parent != null) + parent.addGenre(this); + } + + + public void addGenre(Genre g) { + children.add(g); + } + + + public void addMedia(Media m) { + mediaList.add(m); + } + + + public List getChildren() { + return children; + } + + + public List getMediaList() { + return mediaList; + } + + + public void removeGenre(Genre g) { + children.remove(g); + } + + + public void removeMedia(Media m) { + mediaList.remove(m); + } + + + public void setChildren(List children) { + this.children = children; + } + + + public void setMediaList(List mediaList) { + this.mediaList = mediaList; + } + + + public void setParent(Genre parent) { + Genre oldParent = (Genre) getParent(); + + super.setParent(parent); + if (oldParent != null) + oldParent.removeGenre(this); + parent.addGenre(this); + } + + + @Override + public String toString() { + return getName(); + } + + + public void update() { + // instances has moved, so all children and media members must be updated + for (Genre g : children) { + g.refresh(); + g.update(); + } + for (Media m : mediaList) + m.refresh(); + } + + private List mediaList; + private List children; +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/LegacyVdrRecording.java b/cmpcj/src/de/schwarzrot/media/domain/LegacyVdrRecording.java new file mode 100644 index 0000000..b98688f --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/LegacyVdrRecording.java @@ -0,0 +1,39 @@ +/** + * ======================== legal notice ====================== + * + * File: LegacyVdrRecording.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.io.File; + + +public class LegacyVdrRecording extends VdrRecording { + private static final long serialVersionUID = 713L; + + + public LegacyVdrRecording(Genre parent, File path) { + super(parent, SupportedMediaType.LegacyVdrRecording, DEFAULT_MIME_TYPE, path); + } +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/Media.java b/cmpcj/src/de/schwarzrot/media/domain/Media.java new file mode 100644 index 0000000..6cc4aac --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/Media.java @@ -0,0 +1,55 @@ +/** + * ======================== legal notice ====================== + * + * File: Media.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.io.File; + + +public class Media extends AbstractMediaNode { + private static final long serialVersionUID = 713L; + + + public Media() { + super(null, SupportedMediaType.Unknown, null, null); + } + + + public Media(Genre parent, SupportedMediaType type, String mimeType, File path) { + super(parent, type, mimeType, path); + parent.addMedia(this); + } + + + public void setParent(Genre parent) { + Genre oldParent = (Genre) getParent(); + + super.setParent(parent); + if (oldParent != null) + oldParent.removeMedia(this); + parent.addMedia(this); + } +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/MediaServer.java b/cmpcj/src/de/schwarzrot/media/domain/MediaServer.java new file mode 100644 index 0000000..a8968c4 --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/MediaServer.java @@ -0,0 +1,57 @@ +/** + * ======================== legal notice ====================== + * + * File: MediaServer.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +public class MediaServer { + public String getHostName() { + return hostName; + } + + + public int getPort() { + return port; + } + + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + + public void setPort(int port) { + this.port = port; + } + + + @Override + public String toString() { + return hostName; + } + + private String hostName; + private int port; +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/MediaType.java b/cmpcj/src/de/schwarzrot/media/domain/MediaType.java new file mode 100644 index 0000000..b571090 --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/MediaType.java @@ -0,0 +1,55 @@ +/** + * ======================== legal notice ====================== + * + * File: MediaType.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +public class MediaType { + public static final String NAME_PROPERTY = "name"; + public static final String START_PROPERTY = "start"; + + + public String getName() { + return name; + } + + + public long getStart() { + return start; + } + + + public void setName(String name) { + this.name = name; + } + + + public void setStart(long start) { + this.start = start; + } + + private String name; + private long start; +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/Movie.java b/cmpcj/src/de/schwarzrot/media/domain/Movie.java new file mode 100644 index 0000000..1191da3 --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/Movie.java @@ -0,0 +1,88 @@ +/** + * ======================== legal notice ====================== + * + * File: Movie.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + + +public class Movie extends Media { + private static final long serialVersionUID = 713L; + private static final Map knownExtensions; + + + public Movie(Genre parent, File path, String mimeType) { + this(parent, SupportedMediaType.Movie, mimeType, path); + } + + + public Movie(Genre parent, SupportedMediaType type, String mimeType, File path) { + super(parent, type, mimeType, path); + } + + + public boolean isInterlaced() { + return interlaced; + } + + + public void setInterlaced(boolean interlaced) { + this.interlaced = interlaced; + setType(getType().ordinal() + 1); + } + + + public static String getContentType(String extension) { + return knownExtensions.get(extension); + } + + + public static boolean isSupportedExtension(String extension) { + return knownExtensions.containsKey(extension); + } + + boolean interlaced; + static { + knownExtensions = new HashMap(); + + knownExtensions.put("aac", "audio/aac"); + knownExtensions.put("asd", "video/x-ms-asf"); + knownExtensions.put("asf", "video/x-ms-asf"); + knownExtensions.put("avi", "video/x-msvideo"); + knownExtensions.put("dv", "video/x-dv"); + knownExtensions.put("flv", "video/x-flv"); + knownExtensions.put("gl", "video/x-gl"); + knownExtensions.put("iso", "application/x-iso9660-image"); + knownExtensions.put("ogv", "video/ogg"); + knownExtensions.put("mkv", "video/x-matroska"); + knownExtensions.put("mov", "video/quicktime"); + knownExtensions.put("mpg", "video/mpeg"); + knownExtensions.put("mpeg", "video/mpeg"); + knownExtensions.put("swf", "application/x-shockwave-flash"); + } +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/Picture.java b/cmpcj/src/de/schwarzrot/media/domain/Picture.java new file mode 100644 index 0000000..4d0cab9 --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/Picture.java @@ -0,0 +1,78 @@ +/** + * ======================== legal notice ====================== + * + * File: Picture.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + + +public class Picture extends Media { + private static final long serialVersionUID = 713L; + private static final Map knownExtensions; + + + public Picture(Genre parent, File path, String mimeType) { + super(parent, SupportedMediaType.Picture, mimeType, path); + } + + + public static String getContentType(String extension) { + return knownExtensions.get(extension); + } + + + public static boolean isSupportedExtension(String extension) { + return knownExtensions.containsKey(extension); + } + + static { + knownExtensions = new HashMap(); + + knownExtensions.put("aac", "audio/aac"); + knownExtensions.put("bmp", "image/x-windows-bmp"); + knownExtensions.put("gif", "image/gif"); + knownExtensions.put("jff", "image/jpeg"); + knownExtensions.put("jfif", "image/jpeg"); + knownExtensions.put("jif", "image/jpeg"); + knownExtensions.put("jp2", "image/jp2"); + knownExtensions.put("jpe", "image/jpeg"); + knownExtensions.put("jpeg", "image/jpeg"); + knownExtensions.put("jpg", "image/jpeg"); + knownExtensions.put("jpm", "image/jpm"); + knownExtensions.put("jpx", "image/jpx"); + knownExtensions.put("pbm", "image/x-portable-bitmap"); + knownExtensions.put("pct", "image/x-pict"); + knownExtensions.put("pcx", "image/x-pcx"); + knownExtensions.put("png", "image/png"); + knownExtensions.put("pnm", "image/x-portable-anymap"); + knownExtensions.put("ppm", "image/x-portable-pixmap"); + knownExtensions.put("qti", "image/quicktime"); + knownExtensions.put("ras", "image/x-cmu-raster"); + knownExtensions.put("rgb", "image/x-rgb"); + } +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/PlayList.java b/cmpcj/src/de/schwarzrot/media/domain/PlayList.java new file mode 100644 index 0000000..ec7a393 --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/PlayList.java @@ -0,0 +1,70 @@ +/** + * ======================== legal notice ====================== + * + * File: PlayList.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.util.List; + + +public class PlayList { + public static final String TOTAL_PROPERTY = "total"; + public static final String RESULTS_PROPERTY = "results"; + public static final String TYPES_PROPERTY = "types"; + + + public List getResults() { + return results; + } + + + public long getTotal() { + return total; + } + + + public List getTypes() { + return types; + } + + + public void setResults(List results) { + this.results = results; + } + + + public void setTotal(long total) { + this.total = total; + } + + + public void setTypes(List types) { + this.types = types; + } + + private long total; + private List results; + private List types; +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/PlayerDefinition.java b/cmpcj/src/de/schwarzrot/media/domain/PlayerDefinition.java new file mode 100644 index 0000000..05b9bbc --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/PlayerDefinition.java @@ -0,0 +1,115 @@ +/** + * ======================== legal notice ====================== + * + * File: PlayerDefinition.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.util.ArrayList; +import java.util.List; + + +public class PlayerDefinition { + public PlayerDefinition() { + parameters = new ArrayList(); + } + + + public void addParameter(String parameter) { + parameters.add(parameter); + } + + + public String getCommandLine() { + if (commandLine == null) + assembleCommandLine(); + return commandLine; + } + + + public String getExecutable() { + return executable; + } + + + public AbstractMediaNode.SupportedMediaType getMediaType() { + return mediaType; + } + + + public List getParameters() { + return parameters; + } + + + public void setCommandLine(String commandLine) { + this.commandLine = commandLine; + decodeCommandLine(); + } + + + public void setExecutable(String executable) { + this.executable = executable; + assembleCommandLine(); + } + + + public void setMediaType(AbstractMediaNode.SupportedMediaType mediaType) { + this.mediaType = mediaType; + } + + + public void setParameters(List parameters) { + this.parameters = parameters; + assembleCommandLine(); + } + + + protected void assembleCommandLine() { + if (executable == null || parameters == null || parameters.size() < 1) + return; + StringBuilder sb = new StringBuilder(executable); + + for (String p : parameters) { + sb.append(" ").append(p); + } + commandLine = sb.toString(); + } + + + protected void decodeCommandLine() { + String[] parts = commandLine.split("\\s+"); + + executable = parts[0]; + parameters.clear(); + for (int i = 1; i < parts.length; ++i) { + parameters.add(parts[i]); + } + } + + private AbstractMediaNode.SupportedMediaType mediaType; + private String executable; + private String commandLine; + private List parameters; +} diff --git a/cmpcj/src/de/schwarzrot/media/domain/VdrRecording.java b/cmpcj/src/de/schwarzrot/media/domain/VdrRecording.java new file mode 100644 index 0000000..b11cb03 --- /dev/null +++ b/cmpcj/src/de/schwarzrot/media/domain/VdrRecording.java @@ -0,0 +1,67 @@ +/** + * ======================== legal notice ====================== + * + * File: VdrRecording.java + * Created: 13. June 2012, 04:57 + * Author: Geronimo + * Project: cmpc - a java frontend (client) part of compound media player + * uses external players to play the media + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +package de.schwarzrot.media.domain; + + +import java.io.File; + + +public class VdrRecording extends Movie { + private static final long serialVersionUID = 713L; + protected static final String DEFAULT_MIME_TYPE = "video/mpeg"; + protected static final String KEY_FILE = "00001.vdr"; + + + public VdrRecording(Genre parent, File path) { + this(parent, SupportedMediaType.VdrRecording, DEFAULT_MIME_TYPE, path); + } + + + protected VdrRecording(Genre parent, SupportedMediaType type, String mimeType, File path) { + super(parent, type, mimeType, path); + } + + + @Override + public String getName() { + return getRealPath().getParentFile().getName(); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(getName()); + + sb.append(" (").append(super.getName()).append(")"); + + return sb.toString(); + } + + + public static boolean isKeyFile(File file2Check) { + return file2Check.getName().equals(KEY_FILE); + } +} -- cgit v1.2.3