显示在Android现场UDP或RTP流(多播) [英] Displaying live UDP or RTP stream (multicast) on Android

查看:458
本文介绍了显示在Android现场UDP或RTP流(多播)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的Andr​​oid开发,因为几个星期,我需要编写一个应用程序,可以显示用户的实时流在多播UDP或RDP。流位于一个地址,如RTP://230.0.0.11:1234,并且由WIFI由于这种模块发射: <一href="http://www.ikusi.es/public/ctrl_public_prod.php?accion=verProducto&id_familia=34&id_gama=186&id_producto=351" rel="nofollow">http://www.ikusi.es/public/ctrl_public_prod.php?accion=verProducto&id_familia=34&id_gama=186&id_producto=351

I am new to Android development since a few weeks, and I need to write an app that can display the user a live stream multicasted in UDP or RDP. The stream is located at an address such as "rtp://230.0.0.11:1234", and is emitted by WIFI thanks to this module : http://www.ikusi.es/public/ctrl_public_prod.php?accion=verProducto&id_familia=34&id_gama=186&id_producto=351

我已经试图从玩家阅读(Daroon球员,从PlayStore),和它的工作很好,所以我认为我的foolowing问题不是由于广播。

I already tried to read it from a player (Daroon player, from PlayStore), and it worked well, so I assume that my foolowing problem is not due to the broadcast.

我看到,有可能以显示视频内容给用户通过不同的方式:

I saw that it is possible to display video content to the user by different ways :

  • 使用新的意向与ACTION_VIEW,和Android选择一个应用程序,可以查看的内容;

  • Using a new Intent with an ACTION_VIEW, and Android selects an app that can view the content;

使用的MediaPlayer类和VideoView。

Using the MediaPlayer class and VideoView.

我有两个问题,让我们先从最重要的:   - 对于以上这两种解决方案,有一个问题:我读了无处不在的MediaPlayer只支持HTTP / S和RTSP协议,是这样吗?而对于这里的行动的观点是什么,我尝试过:

I have two issues, let us start with the most important : - For both solution above, there is an issue : I read everywhere that MediaPlayer only support http/s and rtsp protocols, is that right? And for the action view here is what I tried before :

    Uri streamURL = Uri.parse("rtp://230.0.0.11:1234");
    Intent streamIntent = new Intent(Intent.ACTION_VIEW);
    streamIntent.setData(streamURL);
//  streamIntent.setDataAndType(streamURL,"video/*");   
    startActivity(streamIntent);

下面是LogCat中:

Here is the LogCat :

07-11 00:25:58.119: D/AndroidRuntime(2659): Shutting down VM
07-11 00:25:58.119: W/dalvikvm(2659): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-11 00:25:58.129: E/AndroidRuntime(2659): FATAL EXCEPTION: main
07-11 00:25:58.129: E/AndroidRuntime(2659): java.lang.IllegalStateException: Could not execute method of the activity
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.view.View$1.onClick(View.java:2144)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.view.View.performClick(View.java:2485)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.view.View$PerformClick.run(View.java:9080)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.os.Handler.handleCallback(Handler.java:587)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.os.Looper.loop(Looper.java:123)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.app.ActivityThread.main(ActivityThread.java:3683)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at java.lang.reflect.Method.invokeNative(Native Method)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at java.lang.reflect.Method.invoke(Method.java:507)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at dalvik.system.NativeStart.main(Native Method)
07-11 00:25:58.129: E/AndroidRuntime(2659): Caused by: java.lang.reflect.InvocationTargetException
07-11 00:25:58.129: E/AndroidRuntime(2659):     at java.lang.reflect.Method.invokeNative(Native Method)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at java.lang.reflect.Method.invoke(Method.java:507)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.view.View$1.onClick(View.java:2139)
07-11 00:25:58.129: E/AndroidRuntime(2659):     ... 11 more
07-11 00:25:58.129: E/AndroidRuntime(2659): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=rtp://230.0.0.11:1234 }
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.app.Activity.startActivityForResult(Activity.java:2827)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at android.app.Activity.startActivity(Activity.java:2933)
07-11 00:25:58.129: E/AndroidRuntime(2659):     at fr.infosat.tvreplay.MainActivity.listStream(MainActivity.java:35)
07-11 00:25:58.129: E/AndroidRuntime(2659):     ... 14 more
07-11 00:26:00.079: I/Process(2659): Sending signal. PID: 2659 SIG: 9

我的理解是错误的InvocationTargetException,通常是由于在类名的错误,不能直接在这里解决了,因为我不调用任何类startActivity。不过,我觉得我的语法是不正确的,也许是方法不正确的使用。当然,如果我去掉了setDataAndType线,它显示了同样的错误。

My understanding is that the error InvocationTargetException, usually due to error on class names, cannot be resolved directly here, since I don't call any class in startActivity. However I think my syntax is not correct, maybe the method is not the right one to use. Of course if I uncomment the setDataAndType line, it displays the same error.

我注意到,当我启动我的隐含意图的错误来了。

I noticed the error come when I launch my implicit intent.

  • 在我的第二个问题是,Daroon播放效果很好对我的机顶盒,我可以看到我在电视上我流。但是,当我尝试从Eclipse的模拟器启动它,它不玩了,即使我可以从VLC播放...是模拟器强大到足以阅读这些类型的流?

我希望你对如何解决一些线索! :)

I hope that you have some clues on how to solve that! :)

推荐答案

首先,你得到的异常,因为没有应用程序安装在设备上,它可以处理这样的 RTP:// URL。

First, you get the exception because there is no app installed on your device which can handle such an rtp:// url.

您可能需要在开始之前检查的目的:<一href="http://developer.android.com/reference/android/content/pm/PackageManager.html#queryIntentActivities%28android.content.Intent,%20int%29"相对=nofollow> queryIntentActivities(..)

You may want to check the intent before you start it: queryIntentActivities(..)

二,我觉得模拟器是pretty的缓慢相比,任何可用的真实的设备,你可能不希望使用模拟器来测试A / V流。

Second, I think emulator is pretty slow compared to any available real device, you may not want to use emulator to test A/V streaming.

这篇关于显示在Android现场UDP或RTP流(多播)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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