summaryrefslogtreecommitdiff
path: root/cmpcj/src/de/schwarzrot/cmpc
diff options
context:
space:
mode:
authorgeronimo <geronimo013@gmx.de>2012-08-15 07:55:07 +0200
committergeronimo <geronimo013@gmx.de>2012-08-15 07:55:07 +0200
commitaf80bd2426282b7491d9ba0ebfb201abb42e3ca4 (patch)
tree8aeac09a815f3133773cb927597738d4150030f1 /cmpcj/src/de/schwarzrot/cmpc
parent7eb41fd1431019f44227af6f5d707e7c98e0416e (diff)
downloadcmp-af80bd2426282b7491d9ba0ebfb201abb42e3ca4.tar.gz
cmp-af80bd2426282b7491d9ba0ebfb201abb42e3ca4.tar.bz2
next variant of java client
Diffstat (limited to 'cmpcj/src/de/schwarzrot/cmpc')
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/app/ConfigFactory.java132
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/app/IMediaPlayer.java46
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java190
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/domain/Config.java73
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/domain/Media.java141
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/domain/MediaServer.java51
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java51
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/domain/PlayList.java65
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/domain/PlayerDefinition.java65
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/ui/AppSelector.java90
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/ui/MediaClient.java270
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaClientExecutor.java34
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaComparator.java40
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaExecutor.java57
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaForTypeMatcher.java54
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java124
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaPool2TypeList.java60
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaTableFormat.java94
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaTextFilterator.java41
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java170
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java172
21 files changed, 0 insertions, 2020 deletions
diff --git a/cmpcj/src/de/schwarzrot/cmpc/app/ConfigFactory.java b/cmpcj/src/de/schwarzrot/cmpc/app/ConfigFactory.java
deleted file mode 100644
index f1c4685..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/app/ConfigFactory.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: ConfigFactory.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.app;
-
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import de.schwarzrot.cmpc.domain.Config;
-import de.schwarzrot.cmpc.domain.Media;
-import de.schwarzrot.cmpc.domain.MediaServer;
-import de.schwarzrot.cmpc.domain.PlayerDefinition;
-
-
-public class ConfigFactory {
- protected static final Pattern SETUP_MASK = Pattern.compile("^\\s*(\\S+)\\s*=\\s*(.+)$");
-
-
- public ConfigFactory(File configDirectory) {
- baseDir = configDirectory;
- }
-
-
- public Config getConfig() {
- if (config == null) {
- config = readConfig();
- }
- return config;
- }
-
-
- protected Config readConfig() {
- File setupFile = new File(baseDir, "srclient.conf");
- BufferedReader br = null;
- Config rv = new Config();
-
- if (setupFile.exists()) {
- try {
- br = new BufferedReader(new FileReader(setupFile));
- String line, trimmedLine;
-
- while ((line = br.readLine()) != null) {
- trimmedLine = line.trim();
-
- if (trimmedLine.isEmpty() || trimmedLine.startsWith("#"))
- continue;
- Matcher m = SETUP_MASK.matcher(trimmedLine);
-
- if (m.matches()) {
- String key = m.group(1);
- String value = m.group(2);
-
- if (key.compareToIgnoreCase("server") == 0) {
- String[] parts = value.split("\\s*\\:\\s*");
- MediaServer ms = null;
-
- if (parts.length > 1) {
- ms = new MediaServer();
- ms.setHostName(parts[0]);
- ms.setPort(Integer.decode(parts[1]));
-
- rv.addServer(ms);
- }
- } else if (key.compareToIgnoreCase("player") == 0) {
- String[] parts = value.split("\\s*\\:\\s*");
- PlayerDefinition pd = null;
-
- if (parts.length > 1) {
- pd = new PlayerDefinition();
- String[] cmdline = parts[1].split("\\s+");
-
- pd.setExecutable(cmdline[0]);
-
- for (int i = 1; i < cmdline.length; ++i) {
- pd.addParameter(cmdline[i]);
- }
- if (parts[0].compareTo("*") == 0) {
- // default player
- for (Media.SupportedMediaType cmt : Media.SupportedMediaType.values())
- rv.putPlayer(cmt, pd);
- } else {
- for (Media.SupportedMediaType cmt : Media.SupportedMediaType.values()) {
- if (parts[0].compareTo(cmt.name()) == 0)
- rv.putPlayer(cmt, pd);
- }
- }
- }
- }
- }
- }
- } catch (Throwable t) {
- t.printStackTrace();
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- }
- }
- }
- }
- return rv;
- }
- private Config config;
- private File baseDir;
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/app/IMediaPlayer.java b/cmpcj/src/de/schwarzrot/cmpc/app/IMediaPlayer.java
deleted file mode 100644
index d68adbc..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/app/IMediaPlayer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: IMediaPlayer.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.app;
-
-
-import de.schwarzrot.cmpc.domain.Config;
-
-
-public interface IMediaPlayer {
- public Config getConfig();
-
-
- public String getCurrentMediaCenter();
-
-
- public boolean isDebug();
-
-
- public void selectApp();
-
-
- public void startApp(String name, int port);
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java b/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java
deleted file mode 100644
index 0448549..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: SRMediaPlayer.java Created: Author: <a
- * href="mailto:geronimo013@gmx.de">Geronimo</a> 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.cmpc.app;
-
-
-import java.awt.CardLayout;
-import java.awt.Container;
-import java.io.File;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.UIManager;
-import javax.swing.UIManager.LookAndFeelInfo;
-import de.schwarzrot.cmpc.domain.Config;
-import de.schwarzrot.cmpc.ui.AppSelector;
-import de.schwarzrot.cmpc.ui.MediaClient;
-
-
-public class SRMediaPlayer implements IMediaPlayer {
- private static final String DEFAULT_TITLE = "client";
- private static final String USER_HOME = "user.home";
- private static final String TITLE_MASK = "Compound Media Player (%s)";
- private static final String MAIN = "MediaServerSelector";
- private static final String CLIENT = "MediaClient";
-
-
- public SRMediaPlayer(String[] args, ConfigFactory cf) {
- for (String a : args) {
- if (a.compareTo("-d") == 0 || a.compareTo("--debug") == 0)
- debug = true;
- }
- configFactory = cf;
- }
-
-
- public void createAndShowGUI() {
- JFrame.setDefaultLookAndFeelDecorated(false);
-
- config = configFactory.getConfig();
- try {
- for (LookAndFeelInfo lfi : UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(lfi.getName())) {
- UIManager.setLookAndFeel(lfi.getClassName());
- JFrame.setDefaultLookAndFeelDecorated(true);
- }
- }
- } catch (Throwable t) {
- t.printStackTrace();
- System.exit(-1);
- }
- mainFrame = new JFrame("JMediaPlayer");
-
- //Add components to it.
- Container contentPane = mainFrame.getContentPane();
- setupMainView(contentPane);
-
- mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setTitle(DEFAULT_TITLE);
- mainFrame.setSize(1000, 700);
- mainFrame.setLocationRelativeTo(null); //center it
- mainFrame.setVisible(true);
- }
-
-
- @Override
- public Config getConfig() {
- return config;
- }
-
-
- public ConfigFactory getConfigFactory() {
- return configFactory;
- }
-
-
- @Override
- public String getCurrentMediaCenter() {
- return currentMediaCenter;
- }
-
-
- @Override
- public boolean isDebug() {
- return debug;
- }
-
-
- @Override
- public void selectApp() {
- setTitle(DEFAULT_TITLE);
- switchView(MAIN);
- }
-
-
- public void setConfigFactory(ConfigFactory configFactory) {
- this.configFactory = configFactory;
- }
-
-
- @Override
- public void startApp(String name, int port) {
- currentMediaCenter = name;
- setTitle(name);
- switchView(CLIENT);
- try {
- mediaClientPane.startConnection(name, port);
- } catch (Throwable t) {
- mediaClientPane.setActive(false);
- switchView(MAIN);
- }
- }
-
-
- protected void setTitle(String title) {
- mainFrame.setTitle(String.format(TITLE_MASK, title));
- }
-
-
- protected void setupMainView(Container clientArea) {
- stakker = new CardLayout();
- switchingPane = new JPanel(stakker);
- mediaClientPane = new MediaClient(CLIENT, this);
- appSelectorPane = new AppSelector(MAIN, config.getKnownServers());
-
- mediaClientPane.setup(this);
- appSelectorPane.setup(this);
-
- switchingPane.add(appSelectorPane, MAIN);
- switchingPane.add(mediaClientPane, CLIENT);
- clientArea.add(switchingPane);
- }
-
-
- protected void switchView(String name) {
- stakker.show(switchingPane, name);
- }
-
-
- public static void main(final String[] args) {
- appInfo();
- javax.swing.SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- File configDir = new File(System.getProperty(USER_HOME), ".cmp");
- SRMediaPlayer app = new SRMediaPlayer(args, new ConfigFactory(configDir));
- app.createAndShowGUI();
- }
- });
- }
-
-
- protected static void appInfo() {
- System.err.println("cmpcj - the java frontend of CMP (compound media player)");
- System.err.println(" serves to browse a medialist from remote systems and to start a player");
- System.err.println(" for selected media.");
- System.err.println(" (c) 2012 - Reinhard Mantey - some rights reserved.");
- System.err.println(" CMP is published as open source under Creative Commons by-sa");
- }
- private boolean debug = false;
- private JFrame mainFrame;
- private Config config;
- private CardLayout stakker;
- private JPanel switchingPane;
- private MediaClient mediaClientPane;
- private AppSelector appSelectorPane;
- private ConfigFactory configFactory;
- private String currentMediaCenter;
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/domain/Config.java b/cmpcj/src/de/schwarzrot/cmpc/domain/Config.java
deleted file mode 100644
index f803811..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/domain/Config.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: Config.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.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<MediaServer>();
- playerMap = new HashMap<Media.SupportedMediaType, PlayerDefinition>();
- }
-
-
- public void addServer(MediaServer ms) {
- knownServers.add(ms);
- }
-
-
- public List<MediaServer> getKnownServers() {
- return knownServers;
- }
-
-
- public Map<Media.SupportedMediaType, PlayerDefinition> getPlayerMap() {
- return playerMap;
- }
-
-
- public void putPlayer(Media.SupportedMediaType type, PlayerDefinition pd) {
- playerMap.put(type, pd);
- }
-
-
- public void setKnownServers(List<MediaServer> knownServers) {
- this.knownServers = knownServers;
- }
-
-
- public void setPlayerMap(Map<Media.SupportedMediaType, PlayerDefinition> playerMap) {
- this.playerMap = playerMap;
- }
-
- private List<MediaServer> knownServers;
- private Map<Media.SupportedMediaType, PlayerDefinition> playerMap;
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/domain/Media.java b/cmpcj/src/de/schwarzrot/cmpc/domain/Media.java
deleted file mode 100644
index a7e575f..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/domain/Media.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: Media.java Created: Author: <a
- * href="mailto:geronimo013@gmx.de">Geronimo</a> 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.cmpc.domain;
-
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-
-
-public class Media {
- public enum SupportedMediaType {
- Invalid, Audio, Movie, IMovie, DVDImage, IDVDImage, LegacyVdrRecording, ILegacyVdrRecording, VdrRecording, IVdrRecording, Picture, Unknown
- };
-
-
- public String getFormat() {
- return format;
- }
-
-
- public int getHeight() {
- return height;
- }
-
-
- public String getName() {
- return name;
- }
-
-
- public String getPath() {
- return path;
- }
-
-
- public String getSearch() {
- return search;
- }
-
-
- public SupportedMediaType getType() {
- return type;
- }
-
-
- public int getWidth() {
- return width;
- }
-
-
- public boolean isHD() {
- return height > 576;
- }
-
-
- public void setFormat(String format) {
- this.format = format;
- }
-
-
- public void setHeight(int height) {
- this.height = height;
- }
-
-
- public void setName(String name) {
- this.name = name;
- }
-
-
- public void setPath(String path) {
- this.path = path;
- try {
- search = URLDecoder.decode(path, "utf8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
-
-
- 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
- this.type = SupportedMediaType.Invalid;
- }
-
-
- public void setWidth(int width) {
- this.width = width;
- }
-
- private String name;
- private SupportedMediaType type;
- private String format;
- private String path;
- private String search;
- private int width;
- private int height;
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/domain/MediaServer.java b/cmpcj/src/de/schwarzrot/cmpc/domain/MediaServer.java
deleted file mode 100644
index e6f2683..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/domain/MediaServer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaServer.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.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;
- }
-
- private String hostName;
- private int port;
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java b/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java
deleted file mode 100644
index 57f320f..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaType.java Created: Author: <a
- * href="mailto:geronimo013@gmx.de">Geronimo</a> 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.cmpc.domain;
-
-
-public class MediaType {
- 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/cmpc/domain/PlayList.java b/cmpcj/src/de/schwarzrot/cmpc/domain/PlayList.java
deleted file mode 100644
index e1aa7d2..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/domain/PlayList.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: PlayList.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.domain;
-
-
-import java.util.List;
-
-
-public class PlayList {
- public List<Media> getResults() {
- return results;
- }
-
-
- public long getTotal() {
- return total;
- }
-
-
- public List<MediaType> getTypes() {
- return types;
- }
-
-
- public void setResults(List<Media> results) {
- this.results = results;
- }
-
-
- public void setTotal(long total) {
- this.total = total;
- }
-
-
- public void setTypes(List<MediaType> types) {
- this.types = types;
- }
-
- private long total;
- private List<Media> results;
- private List<MediaType> types;
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/domain/PlayerDefinition.java b/cmpcj/src/de/schwarzrot/cmpc/domain/PlayerDefinition.java
deleted file mode 100644
index 5bc4df0..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/domain/PlayerDefinition.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: PlayerDefinition.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.domain;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-public class PlayerDefinition {
- public PlayerDefinition() {
- parameters = new ArrayList<String>();
- }
-
-
- public void addParameter(String parameter) {
- parameters.add(parameter);
- }
-
-
- public String getExecutable() {
- return executable;
- }
-
-
- public List<String> getParameters() {
- return parameters;
- }
-
-
- public void setExecutable(String executable) {
- this.executable = executable;
- }
-
-
- public void setParameters(List<String> parameters) {
- this.parameters = parameters;
- }
-
- private String executable;
- private List<String> parameters;
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/ui/AppSelector.java b/cmpcj/src/de/schwarzrot/cmpc/ui/AppSelector.java
deleted file mode 100644
index 75d3e3c..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/ui/AppSelector.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: AppSelector.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.ui;
-
-
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.util.List;
-import javax.swing.AbstractAction;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import de.schwarzrot.cmpc.app.IMediaPlayer;
-import de.schwarzrot.cmpc.domain.MediaServer;
-
-
-public class AppSelector extends JComponent {
- private static final long serialVersionUID = 713L;
-
-
- public AppSelector(String id, List<MediaServer> mediaServerHosts) {
- this.myPanelName = id;
- this.knownMediaCenters = mediaServerHosts;
- }
-
-
- @Override
- public String getName() {
- return myPanelName;
- }
-
-
- public void setup(final IMediaPlayer mp) {
- setLayout(new GridLayout(1, 2));
- JPanel knownHosts = new JPanel();
-
- knownHosts.setLayout(new GridLayout(knownMediaCenters.size(), 1));
- for (MediaServer ms : knownMediaCenters) {
- JButton bt = new JButton(ms.getHostName());
- AbstractAction a = new AbstractAction() {
- private static final long serialVersionUID = 713L;
-
-
- @Override
- public void actionPerformed(ActionEvent e) {
- String host = (String) this.getValue("mediaCenterHost");
- Integer port = (Integer) this.getValue("mediaCenterPort");
-
- System.out.println("shall connect " + host + ":" + port);
- mp.startApp(host, port);
- }
- };
- a.putValue("mediaCenterHost", ms.getHostName());
- a.putValue("mediaCenterPort", ms.getPort());
- bt.addActionListener(a);
- knownHosts.add(bt);
- }
- add(knownHosts);
- JButton setup = new JButton("Setup");
-
- add(setup);
- doLayout();
- }
-
- private String myPanelName;
- private List<MediaServer> knownMediaCenters;
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/ui/MediaClient.java b/cmpcj/src/de/schwarzrot/cmpc/ui/MediaClient.java
deleted file mode 100644
index 70da17f..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/ui/MediaClient.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaClient.java Created: Author: <a
- * href="mailto:geronimo013@gmx.de">Geronimo</a> 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.cmpc.ui;
-
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Image;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.image.BufferedImage;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import javax.imageio.ImageIO;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.table.DefaultTableCellRenderer;
-import ca.odell.glazedlists.EventList;
-import ca.odell.glazedlists.FilterList;
-import ca.odell.glazedlists.SortedList;
-import ca.odell.glazedlists.swing.DefaultEventTableModel;
-import ca.odell.glazedlists.swing.GlazedListsSwing;
-import ca.odell.glazedlists.swing.TableComparatorChooser;
-import ca.odell.glazedlists.swing.TextComponentMatcherEditor;
-import de.schwarzrot.cmpc.app.IMediaPlayer;
-import de.schwarzrot.cmpc.domain.Media;
-import de.schwarzrot.cmpc.domain.PlayerDefinition;
-import de.schwarzrot.cmpc.util.MediaClientExecutor;
-import de.schwarzrot.cmpc.util.MediaComparator;
-import de.schwarzrot.cmpc.util.MediaExecutor;
-import de.schwarzrot.cmpc.util.MediaListLoader;
-import de.schwarzrot.cmpc.util.MediaTableFormat;
-import de.schwarzrot.cmpc.util.MediaTextFilterator;
-import de.schwarzrot.cmpc.util.MediaTypeSelect;
-
-
-public class MediaClient extends JComponent implements MediaClientExecutor {
- private static final long serialVersionUID = 713L;
-
-
- public MediaClient(String id, IMediaPlayer player) {
- this.myPanelName = id;
- this.player = player;
- setLayout(new BorderLayout());
- listLoader = new MediaListLoader();
- mediaPool = listLoader.getMediaPool();
- }
-
-
- @Override
- public String getName() {
- return myPanelName;
- }
-
-
- public boolean isActive() {
- return active;
- }
-
-
- @Override
- public void playMedia(Media m) {
- List<String> command = new ArrayList<String>();
- PlayerDefinition pd = player.getConfig().getPlayerMap().get(m.getType());
- StringBuilder sb = new StringBuilder("http://");
-
- sb.append(curHostName);
- sb.append(":");
- sb.append(curPort);
- sb.append(m.getPath());
-
- command.add(pd.getExecutable());
- for (String param : pd.getParameters()) {
- command.add(param);
- }
- command.add(sb.toString());
- ProcessBuilder pb = new ProcessBuilder(command);
-
- pb.redirectErrorStream(true);
- try {
- Process proc = pb.start();
- BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- String line;
-
- if (player.isDebug()) {
- while ((line = br.readLine()) != null) {
- System.err.println(line);
- }
- } else {
- while ((line = br.readLine()) != null)
- ;
- }
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
-
- public void setActive(boolean active) {
- this.active = active;
- }
-
-
- public void setup(final IMediaPlayer mp) {
- add(createClientPane(), BorderLayout.CENTER);
- }
-
-
- public void startConnection(String hostname, int port) {
- setHost(hostname);
- setPort(port);
- mediaPool.getReadWriteLock().writeLock().lock();
- mediaPool.clear();
- mediaPool.getReadWriteLock().writeLock().unlock();
- listLoader.loadMedia(curHostName, curPort);
- }
-
-
- protected JComponent createClientPane() {
- JPanel clientPane = new JPanel();
-
- loadImages();
- mediaPool.getReadWriteLock().readLock().lock();
- try {
- SortedList<Media> sortedMedias = new SortedList<Media>(GlazedListsSwing.swingThreadProxyList(mediaPool),
- new MediaComparator());
- MediaTypeSelect mtSelect = new MediaTypeSelect(sortedMedias);
- FilterList<Media> filteredMedias = new FilterList<Media>(sortedMedias, mtSelect);
- JTextField filterEdit = new JTextField(30);
- FilterList<Media> textFilteredMedia = new FilterList<Media>(filteredMedias,
- new TextComponentMatcherEditor<Media>(filterEdit, new MediaTextFilterator()));
- MediaTableFormat tf = new MediaTableFormat();
- DefaultEventTableModel<Media> mediaTableModel = new DefaultEventTableModel<Media>(textFilteredMedia, tf);
- JTable mediaJTable = new JTable(mediaTableModel);
- @SuppressWarnings({ "unused", "rawtypes" })
- TableComparatorChooser tableSorter = TableComparatorChooser.install(mediaJTable, sortedMedias,
- TableComparatorChooser.MULTIPLE_COLUMN_MOUSE_WITH_UNDO);
- JScrollPane mediaTableScrollPane = new JScrollPane(mediaJTable);
- JScrollPane mediaTypesScrollPane = new JScrollPane(mtSelect.getJList());
- JLabel filter = new JLabel(" Filter: ");
- JButton exitButton = new JButton(images[0]);
- JButton preferences = new JButton(images[1]);
-
- filter.setForeground(Color.GRAY);
- filterEdit.setBackground(Color.LIGHT_GRAY);
- exitButton.setBackground(Color.BLACK);
- preferences.setBackground(Color.BLACK);
- exitButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- player.selectApp();
- }
- });
- mediaTypesScrollPane.setPreferredSize(new Dimension(100, 100));
- mediaTypesScrollPane.setBackground(Color.BLACK);
- int mx = mediaJTable.getColumnModel().getColumnCount();
- for (int i = 0; i < mx; ++i) {
- int cw = tf.getColumnWidth(i);
-
- if (cw > 0)
- mediaJTable.getColumnModel().getColumn(i).setMaxWidth(cw);
- }
- mediaJTable.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer());
- mediaJTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer());
- mediaJTable.addMouseListener(new MediaExecutor(mediaJTable, textFilteredMedia, this));
- clientPane.setLayout(new GridBagLayout());
-
- clientPane.add(exitButton, new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
- clientPane.add(preferences, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
-
- clientPane.add(mediaTypesScrollPane, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
-
- clientPane.add(filter, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 10, 0));
-
- clientPane.add(filterEdit, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
-
- clientPane.add(mediaTableScrollPane, new GridBagConstraints(2, 1, 2, 2, 1.0, 1.0,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
- clientPane.setOpaque(true);
- clientPane.setBackground(Color.BLACK);
- } finally {
- mediaPool.getReadWriteLock().readLock().unlock();
- }
- return clientPane;
- }
-
-
- protected void loadImages() {
- BufferedImage img = null;
- ClassLoader cl = getClass().getClassLoader();
- URL url;
-
- images = new ImageIcon[iconFiles.length];
- for (int i = 0; i < iconFiles.length; ++i) {
- try {
- url = cl.getResource(iconFiles[i]);
-
- img = ImageIO.read(url);
- images[i] = new ImageIcon(img.getScaledInstance(64, 64, Image.SCALE_SMOOTH));
- } catch (Throwable t) {
- System.err.println("failed to read image from " + iconFiles[i]);
- t.printStackTrace();
- }
- }
- }
-
-
- protected void setHost(String hostname) {
- curHostName = hostname;
- }
-
-
- protected void setPort(Integer port) {
- curPort = port;
- }
-
- private IMediaPlayer player;
- private MediaListLoader listLoader;
- private EventList<Media> mediaPool;
- private String myPanelName;
- private int curPort;
- private String curHostName;
- private boolean active;
- private ImageIcon[] images;
- private static final String[] iconFiles;
- static {
- iconFiles = new String[] { "images/black_exit.png", "images/black_preferences.png" };
- }
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaClientExecutor.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaClientExecutor.java
deleted file mode 100644
index 620c373..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaClientExecutor.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaClientExecutor.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.util;
-
-
-import de.schwarzrot.cmpc.domain.Media;
-
-
-public interface MediaClientExecutor {
- public void playMedia(Media m);
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaComparator.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaComparator.java
deleted file mode 100644
index a719032..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaComparator.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaComparator.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.util;
-
-
-import java.util.Comparator;
-import de.schwarzrot.cmpc.domain.Media;
-
-
-public class MediaComparator implements Comparator<Media> {
- @Override
- public int compare(Media a, Media b) {
- if (a.getType() == b.getType())
- return a.getName().compareToIgnoreCase(b.getName());
- return a.getType().ordinal() - b.getType().ordinal();
- }
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaExecutor.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaExecutor.java
deleted file mode 100644
index 8cdea21..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaExecutor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaExecutor.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.util;
-
-
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import javax.swing.JTable;
-import ca.odell.glazedlists.EventList;
-import de.schwarzrot.cmpc.domain.Media;
-
-
-public class MediaExecutor extends MouseAdapter {
- public MediaExecutor(JTable table, EventList<Media> list, MediaClientExecutor mce) {
- this.table = table;
- this.list = list;
- executor = mce;
- }
-
-
- @Override
- public void mouseClicked(MouseEvent e) {
- if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1) {
- int i = table.rowAtPoint(e.getPoint());
- Media m = list.get(i);
-
- executor.playMedia(m);
- }
- }
-
- private JTable table;
- private EventList<Media> list;
- private MediaClientExecutor executor;
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaForTypeMatcher.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaForTypeMatcher.java
deleted file mode 100644
index 18820cf..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaForTypeMatcher.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaForTypeMatcher.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.util;
-
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import ca.odell.glazedlists.matchers.Matcher;
-import de.schwarzrot.cmpc.domain.Media;
-
-
-public class MediaForTypeMatcher implements Matcher<Media> {
- public MediaForTypeMatcher(Collection<Media.SupportedMediaType> mediaTypes) {
- this.mediaTypes.addAll(mediaTypes);
- }
-
-
- @Override
- public boolean matches(Media m) {
- if (m == null)
- return false;
- if (mediaTypes.isEmpty())
- return true;
- Media.SupportedMediaType mt = m.getType();
-
- return mediaTypes.contains(mt);
- }
-
- private Set<Media.SupportedMediaType> mediaTypes = new HashSet<Media.SupportedMediaType>();
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java
deleted file mode 100644
index 983fdd3..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaListLoader.java Created: Author: <a
- * href="mailto:geronimo013@gmx.de">Geronimo</a> 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.cmpc.util;
-
-
-import java.net.ConnectException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Date;
-import ca.odell.glazedlists.BasicEventList;
-import ca.odell.glazedlists.EventList;
-import de.schwarzrot.cmpc.domain.Media;
-import de.schwarzrot.cmpc.domain.PlayList;
-
-
-public class MediaListLoader implements Runnable {
- public EventList<Media> getMediaPool() {
- return mediaPool;
- }
-
-
- public void loadMedia(String hostname, int port) {
- this.hostName = hostname;
- this.port = port;
-
- Thread backgroundThread = new Thread(this);
-
- backgroundThread.setName("load media list from " + hostName);
- backgroundThread.setDaemon(true);
- backgroundThread.start();
- }
-
-
- @Override
- public void run() {
- URL request = null;
- Date start, end;
-
- try {
- start = new Date();
- request = new URL("http", hostName, port, "/?format=json");
- URLConnection conn = request.openConnection();
- final PlayList firstPlaylist = jsonParser.parseListChunk(conn.getInputStream());
-
- mediaPool.getReadWriteLock().writeLock().lock();
- for (Media m : firstPlaylist.getResults()) {
- mediaPool.add(m);
- }
- mediaPool.getReadWriteLock().writeLock().unlock();
-
- end = new Date();
- System.out.println("processing of first playlist-part took " + (end.getTime() - start.getTime()) + " ms.");
- PlayList next;
- long total = firstPlaylist.getTotal();
- long n = firstPlaylist.getResults().size();
- String uri;
-
- start = new Date();
- try {
- while (n < total) {
- uri = String.format("/?start=%d&limit=%d&format=json", n, 100);
- request = new URL("http", hostName, port, uri);
- conn = request.openConnection();
- next = jsonParser.parseListChunk(conn.getInputStream());
- mediaPool.getReadWriteLock().writeLock().lock();
- for (Media m : next.getResults()) {
- mediaPool.add(m);
- }
- mediaPool.getReadWriteLock().writeLock().unlock();
- n += next.getResults().size();
- Thread.sleep(10);
- }
- } catch (Throwable t) {
- System.out.println("Oups, media list contains now #" + mediaPool.size() + " entries.");
- System.err.println("Error on chunk #" + n);
- t.printStackTrace();
- } finally {
- try {
- mediaPool.getReadWriteLock().writeLock().unlock();
- } catch (Throwable t) {
- }
- }
- end = new Date();
- System.out.println("processing of rest of playlist took " + (end.getTime() - start.getTime()) + " ms.");
- } catch (ConnectException ce) {
- System.out.println("media server " + hostName + " is not available ...");
- } catch (Throwable t) {
- t.printStackTrace();
- } finally {
- try {
- mediaPool.getReadWriteLock().writeLock().unlock();
- } catch (Throwable t) {
- }
- }
- }
-
- private String hostName;
- private int port;
- private MedialistParser jsonParser = new MedialistParser();
- private EventList<Media> mediaPool = new BasicEventList<Media>();
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaPool2TypeList.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaPool2TypeList.java
deleted file mode 100644
index de93246..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaPool2TypeList.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaPool2TypeList.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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.cmpc.util;
-
-
-import ca.odell.glazedlists.EventList;
-import ca.odell.glazedlists.TransformedList;
-import ca.odell.glazedlists.event.ListEvent;
-import de.schwarzrot.cmpc.domain.Media;
-
-
-public class MediaPool2TypeList extends TransformedList<Media, Media.SupportedMediaType> {
- public MediaPool2TypeList(EventList<Media> source) {
- super(source);
- source.addListEventListener(this);
- }
-
-
- @Override
- public Media.SupportedMediaType get(int index) {
- Media m = source.get(index);
-
- return m.getType();
- }
-
-
- @Override
- public void listChanged(ListEvent<Media> listChanges) {
- updates.forwardEvent(listChanges);
- }
-
-
- @Override
- protected boolean isWritable() {
- return false;
- }
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTableFormat.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaTableFormat.java
deleted file mode 100644
index d427e83..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTableFormat.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaTableFormat.java Created: Author: <a
- * href="mailto:geronimo013@gmx.de">Geronimo</a> 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.cmpc.util;
-
-
-import ca.odell.glazedlists.gui.TableFormat;
-import de.schwarzrot.cmpc.domain.Media;
-
-
-public class MediaTableFormat implements TableFormat<Media> {
- @Override
- public int getColumnCount() {
- return 5;
- }
-
-
- @Override
- public String getColumnName(int column) {
- switch (column) {
- case 0:
- return "Type";
- case 1:
- return "Format";
- case 2:
- return "Width";
- case 3:
- return "Height";
- case 4:
- return "Name";
- default:
- throw new IllegalStateException();
- }
- }
-
-
- @Override
- public Object getColumnValue(Media m, int column) {
- switch (column) {
- case 0:
- return m.getType();
- case 1:
- return m.getFormat();
- case 2:
- return m.getWidth();
- case 3:
- return m.getHeight();
- case 4:
- return m.getName();
- default:
- throw new IllegalStateException();
- }
- }
-
-
- public int getColumnWidth(int column) {
- switch (column) {
- case 0:
- return 80;
- case 1:
- return 100;
- case 2:
- return 60;
- case 3:
- return 60;
- case 4:
- return -1;
- default:
- throw new IllegalStateException();
- }
- }
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTextFilterator.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaTextFilterator.java
deleted file mode 100644
index aa035d9..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTextFilterator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaTextFilterator.java Created: Author: <a
- * href="mailto:geronimo013@gmx.de">Geronimo</a> 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.cmpc.util;
-
-
-import java.util.List;
-import ca.odell.glazedlists.TextFilterator;
-import de.schwarzrot.cmpc.domain.Media;
-
-
-public class MediaTextFilterator implements TextFilterator<Media> {
- @Override
- public void getFilterStrings(List<String> baseList, Media m) {
- baseList.add(m.getName());
- baseList.add(m.getSearch());
- baseList.add(m.getFormat());
- }
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java
deleted file mode 100644
index bde865a..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: MediaTypeSelect.java Created: Author: <a
- * href="mailto:geronimo013@gmx.de">Geronimo</a> 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.cmpc.util;
-
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.net.URL;
-import javax.imageio.ImageIO;
-import javax.swing.ImageIcon;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.ListCellRenderer;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import ca.odell.glazedlists.EventList;
-import ca.odell.glazedlists.UniqueList;
-import ca.odell.glazedlists.matchers.AbstractMatcherEditor;
-import ca.odell.glazedlists.matchers.Matcher;
-import ca.odell.glazedlists.swing.DefaultEventListModel;
-import ca.odell.glazedlists.swing.DefaultEventSelectionModel;
-import de.schwarzrot.cmpc.domain.Media;
-
-
-public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements ListSelectionListener {
- public class MediaTypeCellRenderer extends JLabel implements ListCellRenderer {
- private static final long serialVersionUID = 713L;
-
-
- public MediaTypeCellRenderer() {
- loadImages();
- }
-
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
- boolean cellHasFocus) {
- ImageIcon icon = null;
-
- if (isSelected) {
- setBackground(list.getSelectionBackground());
- setForeground(list.getSelectionForeground());
- icon = selImages[((Media.SupportedMediaType) value).ordinal()];
- } else {
- setBackground(list.getBackground());
- setForeground(list.getForeground());
- icon = stdImages[((Media.SupportedMediaType) value).ordinal()];
- }
- setSize(110, 110);
- setHorizontalAlignment(JLabel.CENTER);
-
- if (icon != null) {
- setIcon(icon);
- setText("");
- } else {
- setText(value.toString());
- }
- return this;
- }
-
-
- protected void loadImages() {
- BufferedImage img = null;
- ClassLoader cl = getClass().getClassLoader();
- URL url;
-
- stdImages = new ImageIcon[iconFiles.length];
- for (int i = 0; i < iconFiles.length; ++i) {
- try {
- url = cl.getResource(iconFiles[i]);
-
- img = ImageIO.read(url);
- stdImages[i] = new ImageIcon(img.getScaledInstance(110, 110, Image.SCALE_SMOOTH));
- } catch (Throwable t) {
- System.err.println("failed to read image from " + iconFiles[i]);
- t.printStackTrace();
- }
- }
-
- selImages = new ImageIcon[activeIconFiles.length];
- for (int i = 0; i < activeIconFiles.length; ++i) {
- try {
- url = cl.getResource(activeIconFiles[i]);
-
- img = ImageIO.read(url);
- selImages[i] = new ImageIcon(img.getScaledInstance(110, 110, Image.SCALE_SMOOTH));
- } catch (Throwable t) {
- System.err.println("failed to read image from " + activeIconFiles[i]);
- t.printStackTrace();
- }
- }
- }
-
- ImageIcon[] stdImages;
- ImageIcon[] selImages;
- }
-
-
- public MediaTypeSelect(EventList<Media> source) {
- EventList<Media.SupportedMediaType> mediaTypeNonUnique = new MediaPool2TypeList(source);
-
- mediaTypeList = new UniqueList<Media.SupportedMediaType>(mediaTypeNonUnique);
- DefaultEventListModel<Media.SupportedMediaType> mediaTypeListModel = new DefaultEventListModel<Media.SupportedMediaType>(
- mediaTypeList);
-
- mediaTypeJList = new JList(mediaTypeListModel);
- DefaultEventSelectionModel<Media.SupportedMediaType> mediaTypeSelectionModel = new DefaultEventSelectionModel<Media.SupportedMediaType>(
- mediaTypeList);
-
- mediaTypeJList.setSelectionModel(mediaTypeSelectionModel);
- selectedTypes = mediaTypeSelectionModel.getSelected();
- mediaTypeJList.addListSelectionListener(this);
- mediaTypeJList.setCellRenderer(new MediaTypeCellRenderer());
- mediaTypeJList.setBackground(Color.BLACK);
- }
-
-
- public JList getJList() {
- return mediaTypeJList;
- }
-
-
- @Override
- public void valueChanged(ListSelectionEvent e) {
- Matcher<Media> newMatcher = new MediaForTypeMatcher(selectedTypes);
-
- fireChanged(newMatcher);
- }
-
- private EventList<Media.SupportedMediaType> mediaTypeList;
- private EventList<Media.SupportedMediaType> selectedTypes;
- private JList mediaTypeJList;
- private static final String[] iconFiles;
- private static final String[] activeIconFiles;
- static {
- iconFiles = new String[] { "images/sr_default.png", "images/sr_music.png", "images/sr_movies.png",
- "images/sr_movies_i.png", "images/sr_dvd.png", "images/sr_dvd_i.png", "images/sr_lvdr.png",
- "images/sr_lvdr_i.png", "images/sr_vdr.png", "images/sr_vdr_i.png", "images/sr_photos.png",
- "images/sr_default.png" };
- activeIconFiles = new String[] { "images/sradefault.png", "images/sramusic.png", "images/sramovies.png",
- "images/sramovies_i.png", "images/sradvd.png", "images/sradvd_i.png", "images/sralvdr.png",
- "images/sralvdr_i.png", "images/sravdr.png", "images/sravdr_i.png", "images/sraphotos.png",
- "images/sradefault.png" };
- }
-}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java b/cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java
deleted file mode 100644
index 4b46a13..0000000
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java
+++ /dev/null
@@ -1,172 +0,0 @@
-package de.schwarzrot.cmpc.util;
-
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import com.google.gson.stream.JsonReader;
-import de.schwarzrot.cmpc.domain.Media;
-import de.schwarzrot.cmpc.domain.MediaType;
-import de.schwarzrot.cmpc.domain.PlayList;
-
-
-public class MedialistParser {
- public PlayList parseListChunk(InputStream is) {
- JsonReader reader = null;
- PlayList rv = null;
-
- try {
- reader = new JsonReader(new InputStreamReader(is, "UTF-8"));
-
- rv = readPlayList(reader);
- } catch (Throwable t) {
- t.printStackTrace();
- } finally {
- try {
- reader.close();
- } catch (Throwable t) {
- }
- }
- return rv;
- }
-
-
- // @Test
- public void testJSonParsing() {
- FileInputStream fis = null;
-
- try {
- fis = new FileInputStream(new File("test.json"));
- parseListChunk(fis);
- fis.close();
- fis = null;
- } catch (Throwable t) {
- t.printStackTrace();
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (Throwable t) {
- }
- }
- }
- }
-
-
- protected Media readMedia(JsonReader reader) {
- Media rv = new Media();
-
- try {
- reader.beginObject();
- while (reader.hasNext()) {
- String name = reader.nextName();
-
- if ("name".equals(name)) {
- rv.setName(reader.nextString());
- } else if ("type".equals(name)) {
- rv.setType(reader.nextInt());
- } else if ("format".equals(name)) {
- rv.setFormat(reader.nextString());
- } else if ("width".equals(name)) {
- rv.setWidth(reader.nextInt());
- } else if ("height".equals(name)) {
- rv.setHeight(reader.nextInt());
- } else if ("path".equals(name)) {
- rv.setPath(reader.nextString());
- } else {
- reader.skipValue();
- }
- }
- reader.endObject();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- return rv;
- }
-
-
- protected List<Media> readMediaArray(JsonReader reader) {
- List<Media> rv = new ArrayList<Media>();
-
- try {
- reader.beginArray();
- while (reader.hasNext()) {
- rv.add(readMedia(reader));
- }
- reader.endArray();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- return rv;
- }
-
-
- protected MediaType readMediaType(JsonReader reader) {
- MediaType rv = new MediaType();
-
- try {
- reader.beginObject();
- while (reader.hasNext()) {
- String name = reader.nextName();
-
- if ("name".equals(name)) {
- rv.setName(reader.nextString());
- } else if ("start".equals(name)) {
- rv.setStart(reader.nextLong());
- } else {
- reader.skipValue();
- }
- }
- reader.endObject();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- return rv;
- }
-
-
- protected PlayList readPlayList(JsonReader reader) {
- PlayList rv = new PlayList();
-
- try {
- reader.beginObject();
- while (reader.hasNext()) {
- String name = reader.nextName();
-
- if ("total".equals(name)) {
- rv.setTotal(reader.nextLong());
- } else if ("types".equals(name)) {
- rv.setTypes(readTypeArray(reader));
- } else if ("results".equals(name)) {
- rv.setResults(readMediaArray(reader));
- } else {
- reader.skipValue();
- }
- }
- reader.endObject();
- } catch (Throwable t) {
- t.printStackTrace();
- rv = null;
- }
- return rv;
- }
-
-
- protected List<MediaType> readTypeArray(JsonReader reader) {
- List<MediaType> rv = new ArrayList<MediaType>();
-
- try {
- reader.beginArray();
- while (reader.hasNext()) {
- rv.add(readMediaType(reader));
- }
- reader.endArray();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- return rv;
- }
-}