From 1aa3990aca854f1ff5fe45c04d53c7febc0a3e4e Mon Sep 17 00:00:00 2001 From: lado Date: Sun, 22 Jan 2012 23:14:08 +0100 Subject: recording streaming --- vdrmanager/res/values/arrays.xml | 6 +++ vdrmanager/res/values/preferences.xml | 14 ++++++ vdrmanager/res/xml/preferences.xml | 1 + vdrmanager/res/xml/vdr_prefs.xml | 18 +++++++- .../de/bjusystems/vdrmanager/data/Preferences.java | 8 ++++ .../src/de/bjusystems/vdrmanager/data/Vdr.java | 43 ++++++++++++++++++- .../vdrmanager/gui/EpgDetailsActivity.java | 8 +++- .../vdrmanager/gui/RecordingListActivity.java | 10 ++++- .../src/de/bjusystems/vdrmanager/gui/Utils.java | 50 ++++++++++++++++++++++ 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 @@ imdb.it imdb.pt + + + + vdr-live + + \ 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 @@ Name A name for this device Delete this device? + + Streaming of recordings + Streaming of recordings + Enable Streaming of recordings + + + + VDR live plugin + + + Streaming method + Currently Streaming over VDR live plugin is supported + VDR live plugin port + VDR live plugin has default port 8008. 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" /> + \ 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" /> - + + + + + + + + + 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 ada = new ArrayAdapter(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 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 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()); + } } -- cgit v1.2.3