简体   繁体   English

在Xamarin Android设备(4.4+)上播放H264视频/音频流(来自现有RTP会话)

[英]Play H264 Video/Audio Stream (from existing RTP session) on Xamarin Android device (4.4+)

I am developing an App on Xamarin right now for Android, alter IOS. 我现在正在Xamarin上为Android开发一个应用程序,更改IOS。 I have started a SIP session as a Client successfully and got a SDP. 我已经作为客户端成功启动了SIP会话并获得了SDP。

With the session description I start my RTPClient (I am using Managed Media Aggregation ( https://net7mma.codeplex.com/ ) also successfully it seems. 通过会话描述,我似乎也成功启动了RTPClient(我正在使用托管媒体聚合( https://net7mma.codeplex.com/ ))。

I get an URI ending with a Media Port. 我得到一个以Media Port结尾的URI。

I have tried different ways to Play back that stream: 我尝试了不同的方法来播放该流:

Android.Widget.VideoView: Android.Widget.VideoView:

videoview.SetVideoURI(Android.Net.Uri.Parse(fullPath));
videoview.Start();

says in a popup box "Cannot Playback Video" or something like this just in german in my case. 在弹出式窗口中说“无法播放视频”或类似的内容,在我看来是德语。

So I tried an Android.Media.MediaPlayer: 所以我尝试了一个Android.Media.MediaPlayer:

player.Reset();
player.SetDataSource(fullPath);
player.Prepare();

runs into an exception and 遇到一个异常,

player.PrepareAsync();

seems to run nowhere. 似乎无处可去。

Should These work somehow and am I just doing wrong? 这些应该以某种方式工作,我只是做错了吗?

Or must I give it more info like it is H.264 decoded, has 640x480 Pixels and more stuff I know exactly from my SDP media description? 还是我必须提供更多信息,例如H.264解码,640x480像素以及我从SDP媒体描述中确切知道的更多内容?

I have taken a look into that MediaFormat and MediaCodec classes from Android but still do not know how to use them exactly for my case (RTP Connection with known Media description). 我已经研究了Android中的MediaFormat和MediaCodec类,但仍然不知道如何在我的情况下准确使用它们(带有已知媒体描述的RTP连接)。

Thanks a lot and have a nice Weekend! 非常感谢,周末愉快!

Eric 埃里克

You should use an external component like the Google ExoPlayer to media with encoding. 您应该将外部组件(例如Google ExoPlayer)用于编码媒体。 There is a Nuget package available for this: https://github.com/martijn00/ExoPlayerXamarin 有一个可用的Nuget软件包: https//github.com/martijn00/ExoPlayerXamarin

That's my project... (net7mma) eg I am the Author... 那是我的项目...(net7mma)例如我是作者...

You can use either the Rtsp or Rtp client quite easily and I have verified such in Android recently. 您可以很容易地使用Rtsp或Rtp客户端,我最近在Android中对此进行了验证。

If you have specific questions make a thread in the project's home page and I will address it. 如果您有特定的问题,请在项目的主页中创建一个线程,我将予以解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM