Processing is related to Android mode 'RTSP (RTP, SDP)'. Help me

Processing is related to Android mode ‘RTSP (RTP, SDP)’.

The ‘processing.video’ library of the JAVA program makes it easy to resolve ‘RTSP’.

By the way, as far as I know
The ‘processing.video’ library does not support Android mode.
Question 1) Does the ‘processing.video’ library work in Android mode?

import processing.video.*;
 
Movie movie;
 
void setup() {
  size(640, 360);
  Movie.supportedProtocols[0] = "rtsp";
 
  background(0);
  try
    {
    movie = new Movie(this, "rtsp://127.0.0.1:8554/");
    }
  catch (Exception e)
    {
    }
  }
 
void movieEvent(Movie m) {
  m.read();
}
 
void draw() 
  {
  image(movie, 0, 0, width, height);
  }

Question 2) Is there a good way to do ‘RTSP’ in Android mode?

I need your help.

@GWAK ===

1 Like

@akenaton

Thank you for your kind answer.

Can I run that library for processing?
In the above manner,
I want to perform rtsp function.

@GWAK ===
difficult to help you without knowing exactly what you are doing:

  • what kind of codec is used by your cam
  • how the streaming is made (vlc?)
  • what is the stream output codec and url
1 Like

@akenaton

Please check the image.

I would like to check the video and sound of CCTV video on mobile.
You cannot hear the sound with ‘MJPEG’.
So, I think it is necessary to implement ‘RTSP’ on mobile.

[JAVA MODE]

import VLCJVideo.*;

VLCJVideo video;

void setup() {
size(640, 360);
video = new VLCJVideo(this);
video.openAndPlay(“rtsp://admin:aa852456!@myksj1105.iptime.org:8081/11/”);
}

void draw() {
background(0);
image(video, 0, 0);
}

[INFORMATION]

ID : admin
PW : aa852456!
ip address : myksj1105.iptime.org:8081
(port : 8081)

Please review. I want to solve it in ‘Android Mode’.

@GWAK ===
ok, i understand what you are wanting;
one more question: are you sure that you have to use RTP ? Why? - Using http should be more simple with a webView.
Anyway it is not easy to code that using a videoView without any library; there are a lot of problems with codecs and as for now i think that the most sure way is to add the genuine VLC library to your app. It exists for android but is it possible to add it to Processing, i dont know. I have to see.

1 Like

@akenaton,

I can`t be implemented as a webView.
(You can also implement it as ‘webView’?)

I tried, but it doesn’t.
Is there a workaround(solution)?

act = this.getActivity();
wbc = new WebViewClient();

webview = new WebView(act);
webview.setLayoutParams(new RelativeLayout.LayoutParams( 1000, 1500 ));
webview.setX(0);
webview.setY(0);
webview.setWebViewClient(wbc);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl(“rtsp://admin:aa852456!@myksj1105.iptime.org:8081/11/”);

fl = (FrameLayout)act.findViewById(0x1000);
fl.setVisibility(View.VISIBLE);
fl.addView(webview);

@GWAK === what error message, if any, with the webView?

1 Like

@akenaton

link : https://stackoverflow.com/questions/15066571/cant-play-this-video-error-in-android-webview-using-rtsp-stream

act = this.getActivity();
wbc = new WebViewClient();

webview = new WebView(act);
webview.setLayoutParams(new RelativeLayout.LayoutParams( 1000, 1500 ));
webview.setX(0);
webview.setY(0);
webview.setWebViewClient(wbc);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl(“rtsp://admin:aa852456!@myksj1105.iptime.org:8081/11/”);

fl = (FrameLayout)act.findViewById(0x1000);
fl.setVisibility(View.VISIBLE);
fl.addView(webview);

There is no error in the code above.

However, in order to execute ‘rtsp’, ‘ACTION_VIEW’ must be set.
Please refer to the link above.

Can you make the above source code for ‘Processing’?

Please review. Help. And thank you for the answer.

@GWAK === yes, i know that there is no error in this code and that ACTION_VIEW must be set; but when you set it to your URL what happens? What is the error code or what is the message inside the app?

1 Like

@akenaton

import android.app.Activity;
import android.content.Context;
import android.widget.FrameLayout;
import android.view.ViewParent;
import android.widget.RelativeLayout;
import android.text.Editable;
import android.graphics.Color;
import android.widget.Toast;
import android.os.Looper;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import java.net.URI;
import java.net.URISyntaxException;
import android.content.Intent;

Activity act;
FrameLayout fl;

WebView webview;
WebViewClient wbc;

//@Override
public void onStart() {
super.onStart();

act = this.getActivity();

wbc = new WebViewClient();

webview = new WebView(act);
webview.setLayoutParams(new RelativeLayout.LayoutParams( 1200, 800 ));
webview.setX(100);
webview.setY(50);
webview.setWebViewClient(wbc);
webview.getSettings().setJavaScriptEnabled(true);

webview.loadUrl(“rtsp://admin:aa852456!@myksj1105.iptime.org:8081/11/”);

webview.setWebViewClient(new WebViewClient() {

public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (url.startsWith("rtsp")) {
        URI uri = URI.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        act.startActivity(intent);
        return true;
    }
    return super.shouldOverrideUrlLoading(view, url);
}

});

fl = (FrameLayout)act.findViewById(0x1000);
fl.addView(webview);
}

void settings() {
fullScreen();
}

void setup() {
orientation(PORTRAIT);
background(255, 250, 0);
}

void draw() {
}


  1. ERROR in C:\Users\user\AppData\Local\Temp\android6658805089143585074sketch\src\processing\test\webview_test\webVIEW_TEST.java (at line 90)
    URI uri = URI.parse(url);
    ^^^^^
    The method parse(String) is undefined for the type URI

  1. ERROR in C:\Users\user\AppData\Local\Temp\android6658805089143585074sketch\src\processing\test\webview_test\webVIEW_TEST.java (at line 91)
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    The constructor Intent(String, URI) is undefined

5 problems (2 errors, 3 warnings)

I don’t know how to add the source code.

@GWAK ===
the code you have put cannot run; there are at least 3 errors:

  • fl (the frame layout) cannot be acceeded as you do (it was possible before, but now it does not work) ; you have to code:
    fl = (FrameLayout) act.getWindow().getDecorView().getRootView();

your shouldOverrideUrlLoading(WebView view, String url){ method is absolutely useless in your case and it is deprecated; this method is useful when the user wants to change the url and that is not your case; more details here: https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)
so you comment all these lines since webView.set…But if you want to use ACTION_VIEW instead of loadUrl then comment loadURL() and write:

String url = "rtsp://admin:aa852456!@myksj1105.iptime.org:8081/11/";
   Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    act.startActivity(intent);
  • Last problem is that for parsing your import is not the good one; you have to import
    import android.net.Uri;

Now i think that the code will run… Of course i cannot test as i dont know if your cam is running… but with another url it works.
dont forget to ask for internet permission!

1 Like

@akenaton

I solved it thanks to you.

It wasn’t solved within the application screen, but it was connected to ‘video’ and played.

thank you. Thank you very much.

@GWAK === ok, put answered for others

2 Likes

Yes please. Show that part of the code!

import android.app.Activity;
import android.content.Context;
import android.widget.FrameLayout;
import android.view.ViewParent;
import android.widget.RelativeLayout;
import android.text.Editable;
import android.graphics.Color;
import android.widget.Toast;
import android.os.Looper;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
//import java.net.URI;
//import java.net.URISyntaxException;
import android.content.Intent;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import android.net.Uri;

Activity act;
FrameLayout fl;

WebView webview;
WebViewClient wbc;

//@Override
public void onStart() {
super.onStart();

act = this.getActivity();

wbc = new WebViewClient();

webview = new WebView(act);

webview.setLayoutParams(new RelativeLayout.LayoutParams( 1000, 1500 ));
webview.setX(100);
webview.setY(50);
// webview.setWebViewClient(wbc);
webview.getSettings().setJavaScriptEnabled(true);
// webview.loadUrl(“rtsp://admin:aa852456!@myksj1105.iptime.org:8081/11/”);
String url = “rtsp://admin:aa852456!@myksj1105.iptime.org:8081/11/”;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
act.startActivity(intent);

// fl = (FrameLayout)act.findViewById(0x1000);
fl = (FrameLayout) act.getWindow().getDecorView().getRootView();
fl.addView(webview);

}

void settings() {
fullScreen();
}

void setup() {
orientation(PORTRAIT);
background(255, 250, 0);
}

void draw() {
}

1 Like

@akenaton
@noel

What we want to implement through this ‘solution’ is as follows.
Development of real-time verification system through CCTV

thank you.

1 Like

I still don’t understand where the server resides. Because it is is on a local LAN isn’t it.
Is it the camara, that creates a virtual server?

1 Like

@noel

Normally, a floating ip is given.

However, cctv requires a static ip address.
So the workaround can be implemented via ‘DDNS’.

exam1)
site1 ip address: 116.148.4.8
url: myksj1105.iptime.org

exam2)
site1 ip address: 116.148.4.20
url: myksj1105.iptime.org

You can also check it from outside through ‘DDNS’.

CCTV inside,
‘HTTP’
‘RTSP’
‘HTTPS’
Etc. The server is built-in.

We just need to match the ip address.

1 Like