summaryrefslogtreecommitdiff
path: root/vdrmanager/src/de
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 /vdrmanager/src/de
parentd55de8e999c09e12cbf489413b2fbc66b7275c46 (diff)
downloadvdr-manager-1aa3990aca854f1ff5fe45c04d53c7febc0a3e4e.tar.gz
vdr-manager-1aa3990aca854f1ff5fe45c04d53c7febc0a3e4e.tar.bz2
recording streaming
Diffstat (limited to 'vdrmanager/src/de')
-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
5 files changed, 115 insertions, 4 deletions
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());
+ }
}