Closed anayajoshi closed 3 years ago
show me your code.
I am using the same example you have given, compiled in android studio and run on android tab. I am using CPPlus camera which is ONVIF supported and I have checked it with native android application. It works ok with native android application. Then why its giving error with flutter application? Please guide.
I am using the same example you have given, compiled in android studio and run on android tab. I am using CPPlus camera which is ONVIF supported and I have checked it with native android application. It works ok with native android application. Then why its giving error with flutter application? Please guide.
I am waiting for reply. Please guide.
show me your code.
I am sending here two main files code. I am using the same code as you have given. Which file code you want to see?
main.dart file code as below:
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_app_onvifcamera/onvif/Model/OnvifDevice.dart'; import 'package:flutter_app_onvifcamera/onvif/ONVIF.dart'; import 'VideoPlayer.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: 'Flutter Demo Home Page'), ); } }
class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override _MyHomePageState createState() => _MyHomePageState(); }
class _MyHomePageState extends State
onvif.getDevices((device){
devices.add(device);
streamDevicesController.add(devices);
usernameController.add(TextEditingController());
passwordController.add(TextEditingController());
usernameFocus.add(FocusNode());
passwordFocus.add(FocusNode());
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: StreamBuilder(
stream: streamDevicesController.stream,
builder: (BuildContext context , AsyncSnapshot<List
],), );
});
},
),
);
} void _fieldFocusChange(BuildContext context, FocusNode currentFocus,FocusNode nextFocus) { currentFocus.unfocus(); FocusScope.of(context).requestFocus(nextFocus); } String showIP(OnvifDevice device){ return device.xAddr.split('/')[2]; } void connect(OnvifDevice onvifDev , String username , String password)async{
String uri = await onvif.getCameraUri(onvifDev, username, password);
Navigator.push(context,
MaterialPageRoute(
builder: (context) => VideoPlayer(uri , username , password),));
} }
ONVIF.dart file code as below: library onvif; import 'dart:async'; import 'package:flutter_app_onvifcamera/onvif/Model/OnvifDevice.dart'; import 'BLOC.dart'; import 'Model/NetworkProtocol.dart'; import 'Model/Probe.dart'; import 'Model/ProbeMatch.dart'; import 'Repository/ParseData.dart'; import 'Repository/ProcessResponse.dart'; import 'Repository/SendData.dart'; import 'Repository/Utils.dart'; import 'Repository/buildMessages.dart';
class ONVIF{
ONVIF();
void getDevices(Function(OnvifDevice)onDone) async {
List
Future
Future
}
Future<List<NetworkProtocol>> _getNetworkProtocols(OnvifDevice device , String username , String password)async{
String message = buildGetNetworkProtocolsMessage(device, username , password);
final info = await httpPost(device.xAddr, message);
return parseGetNetworkProtocols(info);
}
}
These are the files I wrote. I do not understand what you mean. Now you ran my example file and after giving the username and password to VLC, have a problem? Explain the problem clearly.
These are the files I wrote. I do not understand what you mean. Now you ran my example file and after giving the username and password to VLC, have a problem? Explain the problem clearly.
Yes, I ran your example, it discovers my CPPLUS camera, after gave username and password and click on connect button, it does not stream camera and giving 400 bad request error, as as given in issue description.
Please give the solution.
I am using the same example you have given, compiled in android studio and run on android tab. I am using CPPlus camera which is ONVIF supported and I have checked it with native android application. It works ok with native android application. Then why its giving error with flutter application? Please guide.
What was the Android app you checked? Please provide me with the link
I am using the same example you have given, compiled in android studio and run on android tab. I am using CPPlus camera which is ONVIF supported and I have checked it with native android application. It works ok with native android application. Then why its giving error with flutter application? Please guide.
What was the Android app you checked? Please provide me with the link
Onvifer app at play store
I use example the same problem @MostafaDadkhah
oh.I found why the error occurred,some device may not work,such as Network Video Recorder(NVR) may can discovered with onvif protocol,but it can't get stream uri with the Lib,and produce this error and exit the program. @MostafaDadkhah @anayajoshi
When I skip the NVR device then I got the uri
import 'package:onvif/Model/OnvifDevice.dart';
import 'package:onvif/onvif.dart';
void main(List<String> arguments) {
List<OnvifDevice> devices = [];
ONVIF onvif = ONVIF();
onvif.getDevices((device) async {
print(device.xAddr);
//skip the NVR by ip,
// NVR ip is 192.168.123.200
//ip Camera ip is 192.168.123.211
if (device.xAddr.contains("123.200")) {
return;
}
String uri = await onvif.getCameraUri(device, "admin", "");
print(uri);
devices.add(device);
});
}
output:
http://192.168.123.200/onvif/device_service
http://192.168.123.211:8899/onvif/device_service
rtsp://192.168.123.211:554/user=admin_password=tlJwpbo6_channel=1_stream=1.sdp?real_stream
@MostafaDadkhah @anayajoshi
then I use the url, all OK
And some other problem on Android platform,I will make a PR to fix the example Android may need and
android:usesCleartextTraffic="true"
for insecure Traffic(http)
E/flutter (24192): Receiver: "Http status error [400]" E/flutter (24192): Tried calling: source E/flutter (24192): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5) E/flutter (24192): #1 httpPost (package:flutter_app_onvifcamera/onvif/Repository/SendData.dart:27:22) E/flutter (24192):
E/flutter (24192): #2 ONVIF._updateCapabilities (package:flutter_app_onvifcamera/onvif/ONVIF.dart:42:33)
E/flutter (24192): #3 ONVIF.getCameraUri (package:flutter_app_onvifcamera/onvif/ONVIF.dart:56:22)
E/flutter (24192): #4 _MyHomePageState.connect (package:flutter_app_onvifcamera/main.dart:112:30)
E/flutter (24192): #5 _MyHomePageState.build... (package:flutter_app_onvifcamera/main.dart:92:23)
E/flutter (24192): #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:992:19)
E/flutter (24192): #7 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1098:38)
E/flutter (24192): #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
E/flutter (24192): #9 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:524:11)
E/flutter (24192): #10 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:284:5)
E/flutter (24192): #11 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:256:7)
E/flutter (24192): #12 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:158:27)
E/flutter (24192): #13 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:224:20)
E/flutter (24192): #14 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
E/flutter (24192): #15 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:158:7)