不能从IP凸轮收到RTSP实时流 [英] Can't receive RTSP live stream from an IP cam

查看:508
本文介绍了不能从IP凸轮收到RTSP实时流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从使用RTSP一个IP摄像头接收实时流,我得到的无法播放此视频,然后下面的异常:

I want to receive live streaming from an IP camera using RTSP, I'm getting 'Can't play this video', and the following Exception:

07-16 14:06:26.945: D/MediaPlayer(19411): setDataSource IOException happend : 
07-16 14:06:26.945: D/MediaPlayer(19411): java.io.FileNotFoundException: No content provider: rtsp://192.168.30.108:554
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1052)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:907)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:834)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.media.MediaPlayer.setDataSource(MediaPlayer.java:973)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.widget.VideoView.openVideo(VideoView.java:337)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.widget.VideoView.setVideoURI(VideoView.java:247)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.widget.VideoView.setVideoURI(VideoView.java:237)
07-16 14:06:26.945: D/MediaPlayer(19411):   at com.example.video_rtsp.MainActivity$2.run(MainActivity.java:59)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.os.Handler.handleCallback(Handler.java:733)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.os.Handler.dispatchMessage(Handler.java:95)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.os.Looper.loop(Looper.java:157)
07-16 14:06:26.945: D/MediaPlayer(19411):   at android.app.ActivityThread.main(ActivityThread.java:5293)
07-16 14:06:26.945: D/MediaPlayer(19411):   at java.lang.reflect.Method.invokeNative(Native Method)
07-16 14:06:26.945: D/MediaPlayer(19411):   at java.lang.reflect.Method.invoke(Method.java:515)
07-16 14:06:26.945: D/MediaPlayer(19411):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
07-16 14:06:26.945: D/MediaPlayer(19411):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
07-16 14:06:26.945: D/MediaPlayer(19411):   at dalvik.system.NativeStart.main(Native Method)
07-16 14:06:26.945: D/MediaPlayer(19411): Couldn't open file on client side, trying server side
07-16 14:06:26.955: V/MediaPlayer(19411): setVideoSurfaceTexture
07-16 14:06:26.955: V/MediaPlayer-JNI(19411): setAudioStreamType: 3
07-16 14:06:26.955: V/MediaPlayer(19411): MediaPlayer::setAudioStreamType
07-16 14:06:26.955: V/MediaPlayer(19411): setVideoSurfaceTexture
07-16 14:06:26.955: V/MediaPlayer(19411): prepareAsync
07-16 14:06:26.965: D/ProgressBar(19411): setProgressDrawable drawableHeight = 48
07-16 14:06:26.985: D/AbsSeekBar(19411): AbsSeekBar Constructor: misSeebarAnimationAvailable = true

我使用的方式如下:

I'm using the following way:

VideoView videoView = (VideoView) ((Activity) ctx).findViewById(R.id.videoView);

//add controls to a MediaPlayer like play, pause.
MediaController mc = new MediaController(ctx);
videoView.setMediaController(mc);

//Set the path of Video or URI
videoView.setVideoURI(Uri.parse("rtsp://192.168.30.108:554"));

//Set the focus
videoView.requestFocus();

不能说我敢肯定,这是一个问题,但我认为这是因为这台相机软件需要身份验证,但如果是这样,我不知道如何提供验证它。

使用MediaPlayer的用的setDataSource后,我得到了以下异常:

After using MediaPlayer with setDataSource, I'm getting the following Exception:

07-21 12:04:11.677: W/System.err(17714): java.io.IOException: Prepare failed.: status=0x1
07-21 12:04:11.677: W/System.err(17714):    at android.media.MediaPlayer.prepare(Native Method)

我不知道如果这涉及到一个错误的方式在设置页眉或不:

I'm not sure if that related to a wrong way in setting the headers or not :

Uri uri = Uri.parse("rtsp://192.168.30.108:554");
Map<String , String> headres = new HashMap<String, String>();
headres.put("Authorization", "Basic ce0ca0f0864513c28c7be98f0f929be7b1f5db79"); //Also tried it without "Basic"
headres.put("encryption", "Default");
headres.put("mac", "9002A9D89200");
headres.put("random", "1715377261");
headres.put("realm", "Login to 90:02:a9:d8:92:00");

mediaPlayer.setDataSource(getApplicationContext(), uri, headres);

这是使用Firebug登录过程头和JSON数据的截图:

and this is a screenshots of login process headers and json data using firebug:

推荐答案

如果身份验证机制 HTTP基本身份验证,然后可能有办法设置所需的HTTP标头:在<一个href=\"http://developer.android.com/reference/android/media/MediaPlayer.html#setDataSource%28android.content.Context,%20android.net.Uri,%20java.util.Map%3Cjava.lang.String,%20java.lang.String%3E%29\"相对=nofollow> MediaPlayer的类有一个方法的setDataSource 地图参数头文件:

If the authentication mechanism is HTTP basic authentication then there might be way to set the required HTTP header: the MediaPlayer class has a method setDataSource taking a Map parameter for headers:

公共无效的setDataSource(上下文的背景下,开放的URI,地图&LT;字符串,字符串&GT;头)

您必须设置授权头:

授权:基本_credentials _

_credentials _ 的RFC2045-MIME Base64编码的用户​​名:密码字符串

这篇关于不能从IP凸轮收到RTSP实时流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆