GWAK
April 5, 2023, 3:49am
1
[Android] - ipcapture library problem
hello. Nice to meet you.
step-7
run-1
run-2
run-3
(HTTPLog)-Static: isSBSettingEnabled false
(HTTPLog)-Static: isSBSettingEnabled false
Unable to open I/O streams (app): http://20....
An error occurs as above.
try {
conn = (HttpURLConnection)url.openConnection();
String user = "admin"; String pass = "jusung_123";
conn.setRequestProperty("Authorization", "Basic " + base64.encode(user + ":" + pass));
}
catch (IOException e) {
System.err.println("Unable to connect: " + e.getMessage());
return;
}
System.out.println("run-3");
try {
// int p_value = 8192; // p_value = 8192;
httpIn = new BufferedInputStream(conn.getInputStream(), p_value);
jpgOut = new ByteArrayOutputStream(p_value);
}
catch (IOException e) {
System.err.println("Unable to open I/O streams(app): " + e.getMessage());
return;
}
System.out.println("run-4");
Does anyone know the cause of the error?
help me~.
It works fine on PC.
It doesnât work in the app.
Why?
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package=""><uses-sdk android:minSdkVersion="15" android:targetSdkVersion="29"/><application android:debuggable="true" android:icon="@drawable/icon" android:label="CCTV" android:requestLegacyExternalStorage="true" android:targetSandboxVersion="2" android:usesCleartextTraffic="true">
<activity android:name=".MainActivity">android:theme="@android:style/Theme.NoTitleBar"><intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/></intent-filter></activity></application><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/><uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/><uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/><uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/><uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/></manifest>
link : Android 9 íě´ěě http ěŹěŠě ěëŹ ë°ě í´ę˛°
android android:networksecurityconfig
I would like to add the above,
It is not added in âProcessingâ.
GWAK
April 5, 2023, 1:28pm
2
I tried to work on it today, but I didnât succeed.
Why is that?
The current phenomenon is as follows.
CCTV Hikvision Model
PC(JAVA Mode) : Work
SmartPhone(Android Mode) : Work
CCTV H Model
PC(JAVA Mode) : Work
Smartphone(Android Mode) : not Work
I donât understand this part too much.
Also, âH Model CCTVâ is not visible even when ânetwork streamingâ is performed through VLC media.
Both PC and Android have the same source code, but why does the operation differ depending on the âCCTV Modelâ?
conn = (HttpURLConnection)url.openConnection();
// conn.setRequestProperty("Authorization", authorizationHeaderValue);
System.out.println("run-2-1");
//conn.setRequestMethod("GET");
//conn.setRequestProperty("Origin", "http://211.104.181.146:10111");
//conn.setRequestProperty("Accept", "application/xml");
//conn.setRequestProperty("Content-Type", "text/html"); //
// conn.setDoOutput(true);
// conn.setDoInput(true);
System.out.println("Status code: " + conn.getResponseCode());
System.out.println("Message: " + conn.getResponseMessage());
Error MSG(println)
Status code: 401
Message: Unauthorized
Are there any seniors? help me~.
GWAK
April 6, 2023, 2:50am
3
conn = null;
conn = (HttpURLConnection)url.openConnection();
System.out.println("---------------------------------------------------");
System.out.println(" conn : " + conn.toString());
System.out.println("---------------------------------------------------");
What Iâve experienced so far
It seems to prevent it when requesting from CCTV to Android. (This is my opinion.)
// JAVA(PC)
conn: sun.net.www.protocol.http.HttpURLConnection:http://ip/stw-cgi/video.cgi?msubmenu=stream&action=view&Profile=10
// Android (Smartphone)
conn: com.android.okhttp.internal.huc.HttpURLConnectionImpl:http://ip/stw-cgi/video.cgi?msubmenu=stream&action=view&Profile=10
The result is as above.
By any chance, while running on Android
Can I send a PC request to CCTV?
Canât I force CCTV to send the information that I am a computer, not a smartphone?
GWAK
April 6, 2023, 9:05am
4
The results of what I have done so far are as follows.
CCTV Model No. 2
It must be âDigest authentication processingâ using âmd5â.
Itâs pretty tough.
DESCRIBE rtsp://192.168.9.100:554/profile2/media.smp RTSP/1.0
CSeq: 2
Authorization: Digest
username="admin",realm="iPOLiS",nonce="C9AB5CEC50A78C07C25704A9675B171E",uri
="rtsp://192.168.9.100:554/profile2/media.smp",cnonce="814ae708b84f4f0f9f2e5
1fe1624166d",nc=00000001,response="40899fab43a5df53c72f8b3683f023e2",qop="au
th"
User-Agent: oscar-rtsp-client
Require: Bestshot
JoseMY
April 9, 2023, 8:53pm
5
Hi!
I donât know if posting credentials is good practice, but at least they take to a private ip not reachable from outside.
About your question, chances are there is a different android version on the non-working machine. Different android versions imply different APIs.
Another possible source of conflict are permissions. Make sure the app is requesting permissions to user, user is granting them and âGoogle Play Protectionâ is not removing permissions. It tends to revoke permissions even when instructed not to do so.
1 Like
svan
April 9, 2023, 9:26pm
6
Both urls may be opened on an Android device if they are opened by a browser. The failure occurs when the urls are opened in a java app (only one will open on my system in Android mode; neither will open in Java mode on my system). According to this reference (second answer) that is a feature of java apps: https://stackoverflow.com/questions/32306509/server-returned-http-response-code-401-for-url-when-using-shopify-api .
1 Like
GWAK
April 9, 2023, 11:10pm
7
@JoseMY / @svan
It must be âDigest authentication processingâ using âmd5â.
The reason is as above. If you do it with an internet browser, the authentication is said to be automatic.
However, in order to weave with Android or a separate WEB code
It must be âDigest authentication processingâ using âmd5â.
The above protocol must be followed.
Because âIPCaputure libraryâ has Basic authentication system, âcorresponding CCTVâ does not operate.
However, as a result of contacting CCTV, it is automatically authenticated when connected to the OS, but when using a separate âiOS, Android, make WEBâ, âmd5â authentication system is required.
Thank you for your interest.
And, as far as I know, iOS is easy to implement. However, Android is quite difficult to implement the above.
@svan // Please delete the image. You will see the CCTV URL. please.
svan
April 9, 2023, 11:45pm
8
Please delete the image.
No problem. Itâs also visible in your second post, so I thought you didnât care.
1 Like
svan
April 10, 2023, 4:55am
9
As a workaround you could launch your android device browser from a Processing app then enter your username and password when prompted. It takes very little code and does work.
import android.content.Intent;
import android.net.Uri;
void setup() {
fullScreen();
Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://xxx.xxx.xxx.xxx:yyyyy/stw-cgi/video.cgi?msubmenu=stream&action=view&Profile=10"));
startActivity(intent);
}
1 Like
GWAK
April 10, 2023, 5:32am
10
@svan
Thank you for your attention. you are right.
It is very difficult to get certified on your own.
So, in the past, the âRTSPâ method was implemented as follows.
Yes please. Show that part of the code!
However, if you use it like that, you cannot process images within the âAndroid APPâ.
There are many ways.
âDigest authentication processing(Android)â using âmd5â. protocol implementation
Create a separate streaming server and implement it as http server âbasic authenticationâ
Receive RTSP address and implement âonline http serverâ. âbasic authenticationâ