Fixed saving settings

This commit is contained in:
Daniele 2021-10-12 22:12:17 +02:00
parent 6ded7dee9b
commit 162ace2858
3 changed files with 15 additions and 30 deletions

View File

@ -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";

View File

@ -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;

View File

@ -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<Camera> cc = settings.getCameras();
// List<Camera> 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,