summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2012-01-22 23:14:08 +0100
committerlado <herrlado@gmail.com>2012-01-22 23:14:08 +0100
commit1aa3990aca854f1ff5fe45c04d53c7febc0a3e4e (patch)
treeea520a414081d39114617aa0328045d80d332aae
parentd55de8e999c09e12cbf489413b2fbc66b7275c46 (diff)
downloadvdr-manager-1aa3990aca854f1ff5fe45c04d53c7febc0a3e4e.tar.gz
vdr-manager-1aa3990aca854f1ff5fe45c04d53c7febc0a3e4e.tar.bz2
recording streaming
-rw-r--r--vdrmanager/res/values/arrays.xml6
-rw-r--r--vdrmanager/res/values/preferences.xml14
-rw-r--r--vdrmanager/res/xml/preferences.xml1
-rw-r--r--vdrmanager/res/xml/vdr_prefs.xml18
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java8
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java43
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java8
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java10
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java50
9 files changed, 153 insertions, 5 deletions
diff --git a/vdrmanager/res/values/arrays.xml b/vdrmanager/res/values/arrays.xml
index 647865e..2baad7c 100644
--- a/vdrmanager/res/values/arrays.xml
+++ b/vdrmanager/res/values/arrays.xml
@@ -26,5 +26,11 @@
<item>imdb.it</item>
<item>imdb.pt</item>
</string-array>
+
+
+ <string-array name="recstream_entry_values">
+ <item>vdr-live</item>
+ </string-array>
+
</resources> \ No newline at end of file
diff --git a/vdrmanager/res/values/preferences.xml b/vdrmanager/res/values/preferences.xml
index ab2e584..85ef268 100644
--- a/vdrmanager/res/values/preferences.xml
+++ b/vdrmanager/res/values/preferences.xml
@@ -150,4 +150,18 @@
<string name="vdr_name_title">Name</string>
<string name="vdr_name_summary">A name for this device</string>
<string name="vdr_device_delete_qeustion">Delete this device?</string>
+
+ <string name="recstream">Streaming of recordings</string>
+ <string name="recstream_enable_title">Streaming of recordings</string>
+ <string name="recstream_enable_summary">Enable Streaming of recordings</string>
+
+
+ <string-array name="recstream_entries">
+ <item>VDR live plugin</item>
+ </string-array>
+
+ <string name="recstream_method_title">Streaming method</string>
+ <string name="recstream_method_summary">Currently Streaming over VDR live plugin is supported</string>
+ <string name="settings_live_port">VDR live plugin port</string>
+ <string name="settings_live_port_summary">VDR live plugin has default port 8008.</string>
</resources>
diff --git a/vdrmanager/res/xml/preferences.xml b/vdrmanager/res/xml/preferences.xml
index 824522a..c17e4ff 100644
--- a/vdrmanager/res/xml/preferences.xml
+++ b/vdrmanager/res/xml/preferences.xml
@@ -54,4 +54,5 @@
android:key="@string/gui_custom_locale_key" android:summary="@string/gui_custom_locale_sum"
android:title="@string/gui_custom_locale_title" />
</PreferenceCategory>
+
</PreferenceScreen> \ No newline at end of file
diff --git a/vdrmanager/res/xml/vdr_prefs.xml b/vdrmanager/res/xml/vdr_prefs.xml
index b5a48a2..3128f8e 100644
--- a/vdrmanager/res/xml/vdr_prefs.xml
+++ b/vdrmanager/res/xml/vdr_prefs.xml
@@ -29,7 +29,6 @@
android:enabled="false"
android:summary="@string/vdr_ssl_summary" android:title="@string/vdr_ssl_title" />
-
</PreferenceCategory>
<PreferenceCategory android:key="filter_preferences"
@@ -132,6 +131,23 @@
android:summary="@string/remux_parameter_summary" android:title="@string/remux_parameter_title" />
</PreferenceCategory>
+<PreferenceCategory android:title="@string/recstream">
+
+ <CheckBoxPreference android:key="key_rec_stream_enable"
+ android:defaultValue="false"
+ android:summary="@string/recstream_enable_summary" android:title="@string/recstream_enable_title" />
+
+ <ListPreference android:defaultValue="vdr-live" android:dependency="key_rec_stream_enable"
+ android:entries="@array/recstream_entries" android:entryValues="@array/recstream_entry_values"
+ android:key="key_recstream_method"
+ android:summary="@string/recstream_method_summary" android:title="@string/recstream_method_title" />
+
+ <EditTextPreference android:defaultValue="8008"
+ android:dependency="key_rec_stream_enable"
+ android:inputType="number" android:key="key_live_port"
+ android:summary="@string/settings_live_port_summary" android:title="@string/settings_live_port" />
+
+</PreferenceCategory>
<PreferenceScreen android:title="Advanced">
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
index 8cc6a39..d0fc5b1 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
@@ -244,7 +244,15 @@ public class Preferences {
public boolean isAliveCheckEnabled() {
return getCurrentVdr().isAliveCheckEnabled();
}
+
+ public boolean isEnableRecStream(){
+ return getCurrentVdr().isEnableRecStreaming();
+ }
+ public int getLivePort(){
+ return getCurrentVdr().getLivePort();
+ }
+
/**
* Gets the time between alive checks
*
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java
index 6b8c6dd..8dd150f 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java
@@ -173,6 +173,41 @@ public class Vdr {
@DatabaseField
private String streamingPassword;
+
+ @DatabaseField
+ private int livePort;
+
+ @DatabaseField
+ private String recStreamMethod;
+
+ @DatabaseField
+ private boolean enableRecStreaming = false;
+
+
+ public String getRecStreamMethod() {
+ return recStreamMethod;
+ }
+
+ public void setRecStreamMethod(String recStreamMethod) {
+ this.recStreamMethod = recStreamMethod;
+ }
+
+ public int getLivePort() {
+ return livePort;
+ }
+
+ public void setLivePort(int livePort) {
+ this.livePort = livePort;
+ }
+
+ public boolean isEnableRecStreaming() {
+ return enableRecStreaming;
+ }
+
+ public void setEnableRecStreaming(boolean enableRecStreaming) {
+ this.enableRecStreaming = enableRecStreaming;
+ }
+
public String getStreamingPassword() {
return streamingPassword;
@@ -505,7 +540,9 @@ public class Vdr {
map.put("remux_command", remuxCommand);
map.put("remux_parameter", remuxParameter);
map.put("remux_enable", enableRemux);
-
+ map.put("key_rec_stream_enable", enableRecStreaming);
+ map.put("key_live_port", livePort);
+ map.put("key_recstream_method", recStreamMethod );
return map;
}
@@ -544,6 +581,10 @@ public class Vdr {
remuxCommand = get(map, "remux_command");
remuxParameter = get(map, "remux_parameter");
enableRemux = getBoolean(map, "remux_enable");
+
+ enableRecStreaming = getBoolean(map, "key_rec_stream_enable");
+ livePort = getInteger(map, "key_live_port");
+ recStreamMethod = get(map, "key_recstream_method");
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
index 1b03a97..9acf580 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
@@ -338,7 +338,7 @@ public class EpgDetailsActivity extends ICSBaseActivity implements OnClickListen
b = view.findViewById(R.id.epg_event_livetv);
- if (Utils.isLive(event) == false) {
+ if (Utils.isLive(event) == false && (event instanceof Recording == false || Preferences.get().isEnableRecStream() == false)) {
b.setVisibility(View.GONE);
} else {
b.setVisibility(View.VISIBLE);
@@ -424,7 +424,11 @@ public class EpgDetailsActivity extends ICSBaseActivity implements OnClickListen
public void onClick(final View v) {
switch (v.getId()) {
case R.id.epg_event_livetv:
- Utils.stream(this, cEvent.getChannelNumber());
+ if(cEvent instanceof Recording){
+ Utils.streamRecording(this, (Recording)cEvent);
+ } else {
+ Utils.stream(this, cEvent.getChannelNumber());
+ }
break;
case R.id.epg_event_create_timer:
final ArrayAdapter<Wrapper> ada = new ArrayAdapter<Wrapper>(this,
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
index 31cc4fa..3a9351c 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
@@ -3,6 +3,7 @@ package de.bjusystems.vdrmanager.gui;
import java.util.Calendar;
import android.os.Bundle;
+import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuInflater;
@@ -15,6 +16,7 @@ import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.EventListItem;
+import de.bjusystems.vdrmanager.data.Preferences;
import de.bjusystems.vdrmanager.data.Recording;
import de.bjusystems.vdrmanager.tasks.DeleteRecordingTask;
import de.bjusystems.vdrmanager.utils.date.DateFormatter;
@@ -92,9 +94,14 @@ public class RecordingListActivity extends BaseEventListActivity<Recording>
menu.setHeaderTitle(formatter.getTitle());
inflater.inflate(R.menu.recording_list_item_menu, menu);
+ if(Preferences.get().isEnableRecStream() == false){
+ menu.removeItem(R.id.recording_item_menu_stream);
+ }
+
}
super.onCreateContextMenu(menu, v, menuInfo);
}
+
@Override
public boolean onContextItemSelected(final MenuItem item) {
@@ -116,7 +123,8 @@ public class RecordingListActivity extends BaseEventListActivity<Recording>
break;
}
case R.id.recording_item_menu_stream: {
- say("Sorry, not yet. It would be. File -> " + rec.getFileName());
+ Utils.streamRecording(this, rec);
+ //say("Sorry, not yet. It would be. File -> " + rec.getFileName());
break;
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
index 7998936..bccff8c 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
@@ -1,11 +1,14 @@
package de.bjusystems.vdrmanager.gui;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -18,16 +21,21 @@ import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
+import android.util.Log;
import android.util.Pair;
+import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.C;
import de.bjusystems.vdrmanager.data.Channel;
import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.Preferences;
+import de.bjusystems.vdrmanager.data.Recording;
public class Utils {
+ public static final String TAG = Utils.class.getName();
+
public static final List EMPTY_LIST = new ArrayList(0);
public static final ForegroundColorSpan HIGHLIGHT_TEXT = new ForegroundColorSpan(
Color.RED);
@@ -191,11 +199,39 @@ public class Utils {
}
public static void startStream(Activity activity, String url) {
+ try{
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url.toString()), "video/*");
activity.startActivityForResult(intent, 1);
+ }catch(ActivityNotFoundException anfe){
+ Log.w(TAG,anfe);
+ Toast.makeText(activity, anfe.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
+ }
}
+ public static final String md5(final String s) {
+ try {
+ // Create MD5 Hash
+ MessageDigest digest = java.security.MessageDigest
+ .getInstance("MD5");
+ digest.update(s.getBytes());
+ byte messageDigest[] = digest.digest();
+
+ // Create Hex String
+ StringBuffer hexString = new StringBuffer();
+ for (int i = 0; i < messageDigest.length; i++) {
+ String h = Integer.toHexString(0xFF & messageDigest[i]);
+ while (h.length() < 2)
+ h = "0" + h;
+ hexString.append(h);
+ }
+ return hexString.toString();
+
+ } catch (NoSuchAlgorithmException e) {
+ Log.w(TAG,e);
+ }
+ return "";
+ }
public static int getDuration(Event event) {
long millis = event.getDuration();
int minuts = (int) (millis / 1000 / 60);
@@ -261,4 +297,18 @@ public class Utils {
}
return false;
}
+
+ public static void streamRecording(Activity ctx, Recording rec){
+
+ StringBuilder url = new StringBuilder();
+ url.append("http://")
+ .append(Preferences.get().getSvdrpHost())//
+ .append(":")
+ .append(Integer.valueOf(Preferences.get().getLivePort()))//
+ .append("/recstream.html?recid=recording_").append(Utils.md5(rec.getFileName()));
+ //http://192.168.1.119:8008/b0cdedeed2d36508dfd924f0876a851b
+ String urlstring = url.toString();
+ Log.d(TAG, "try stream: " + urlstring);
+ Utils.startStream(ctx, url.toString());
+ }
}