From 162ace2858a078cce7bce76b6e7be9efcf4e915f Mon Sep 17 00:00:00 2001 From: Daniele Date: Tue, 12 Oct 2021 22:12:17 +0200 Subject: [PATCH] Fixed saving settings --- .../java/it/danieleverducci/ojo/Settings.java | 3 +- .../danieleverducci/ojo/entities/Camera.java | 4 +- .../ojo/ui/SurveillanceFragment.java | 38 +++++-------------- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/it/danieleverducci/ojo/Settings.java b/app/src/main/java/it/danieleverducci/ojo/Settings.java index c0599a0..84dcad3 100644 --- a/app/src/main/java/it/danieleverducci/ojo/Settings.java +++ b/app/src/main/java/it/danieleverducci/ojo/Settings.java @@ -10,6 +10,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -19,7 +20,7 @@ import it.danieleverducci.ojo.entities.Camera; /** * Manages the settings persistence */ -public class Settings { +public class Settings implements Serializable { private static final String FILENAME = "settings.bin"; private static final String TAG = "Settings"; diff --git a/app/src/main/java/it/danieleverducci/ojo/entities/Camera.java b/app/src/main/java/it/danieleverducci/ojo/entities/Camera.java index 3f9e8c9..3a1512f 100644 --- a/app/src/main/java/it/danieleverducci/ojo/entities/Camera.java +++ b/app/src/main/java/it/danieleverducci/ojo/entities/Camera.java @@ -1,6 +1,8 @@ package it.danieleverducci.ojo.entities; -public class Camera { +import java.io.Serializable; + +public class Camera implements Serializable { private String name; private String rtspUrl; diff --git a/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java b/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java index ac04e90..fc0ee80 100644 --- a/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java +++ b/app/src/main/java/it/danieleverducci/ojo/ui/SurveillanceFragment.java @@ -32,16 +32,20 @@ import it.danieleverducci.ojo.Settings; import it.danieleverducci.ojo.databinding.FragmentSurveillanceBinding; import it.danieleverducci.ojo.entities.Camera; +/** + * Some streams to test: + * rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov + * rtsp://demo:demo@ipvmdemo.dyndns.org:5541/onvif-media/media.amp?profile=profile_1_h264&sessiontimeout=60&streamtype=unicast + */ public class SurveillanceFragment extends Fragment implements MediaPlayer.EventListener, IVLCVout.Callback { final static private String[] VLC_OPTIONS = new String[]{ "--aout=opensles", - "--audio-time-stretch", // time stretching - "-vvv", // verbosity - "--aout=opensles", + //"--audio-time-stretch", // time stretching + //"-vvv", // verbosity "--avcodec-codec=h264", - "--file-logging", - "--logfile=vlc-log.txt" + //"--file-logging", + //"--logfile=vlc-log.txt" }; private FragmentSurveillanceBinding binding; @@ -61,31 +65,9 @@ public class SurveillanceFragment extends Fragment implements MediaPlayer.EventL public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); -// binding.buttonFirst.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// NavHostFragment.findNavController(SurveillanceFragment.this) -// .navigate(R.id.action_FirstFragment_to_SecondFragment); -// } -// }); - - // Start stream on surface view 1 - Settings settings = Settings.fromDisk(getContext()); List cc = settings.getCameras(); -// List cc = new ArrayList<>(); -// String rtspUrl = "rtsp://admin:Du4gdtPmXGCWT29@192.168.1.200:554/Streaming/Channels/101"; -// Camera camera = new Camera("Camera 1", rtspUrl); -// cc.add(camera); -// rtspUrl = "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"; -// camera = new Camera("Bunny", rtspUrl); -// cc.add(camera); -// rtspUrl = "rtsp://demo:demo@ipvmdemo.dyndns.org:5541/onvif-media/media.amp?profile=profile_1_h264&sessiontimeout=60&streamtype=unicast"; -// camera = new Camera("Ipvm Demo", rtspUrl); -// cc.add(camera); - - int elemsPerSide = calcGridSideElements(cc.size()); int camIdx = 0; for (int r = 0; r < elemsPerSide; r++) { @@ -105,7 +87,7 @@ public class SurveillanceFragment extends Fragment implements MediaPlayer.EventL } else { // Cameras are less than the maximum number of cells in grid: fill remaining cells with empty views View ev = new View(getContext()); - ev.setBackgroundColor(Color.BLACK); + ev.setBackgroundColor(Color.BLUE); LinearLayout.LayoutParams evParams = new LinearLayout.LayoutParams( 0, LinearLayout.LayoutParams.MATCH_PARENT,