Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
493 views
in Technique[技术] by (71.8m points)

android - 将UDP数据包流入设备的最佳方法是什么?(What is the best way to stream UDP packets INTO the device?)

I'm looking for the most efficient way to stream a video in Android coming from a flow of UDP packets from an external device.

(我正在寻找一种最有效的方式来在Android中流式传输来自外部设备的UDP数据包中的视频。)

Currently, when each packet received, i'm manually stripping the data from the packet to comprise the h264 frame (a few packets comprise a single frame), I then adding the new frame to a queue;

(当前,当接收到每个数据包时,我正在手动从数据包中剥离数据以组成h264帧(一些数据包包含一个帧),然后将新帧添加到队列中。)

a circular buffer.

(循环缓冲区。)

To turn the data into visual, I've created a parent view which holds a TextureView.

(为了将数据变成可视的,我创建了一个包含TextureView的父视图。)

This Texture view, whenever ready to be called again, reads the latest frame from the queue and render it on screen.

(每当准备再次调用该Texture视图时,都会从队列中读取最新的帧并将其呈现在屏幕上。)

Now, everything works but the memory consumption is pretty big (around 50%-65%) which heat up the device quite a bit.

(现在,一切正常,但是内存消耗非常大(大约50%-65%),这会使设备发热很多。)

I've searched around the web for an answer cause doing all of this manually myself is probably not efficient, and found this: Exoplayer to play live video chunks received as byte arrays one after another maintaining continuity but couldn't understand how to create and implement the custom DataSource in the ExoPlayer.

(我在网上搜索了一个答案,原因是我自己手动执行所有操作可能效率不高,并且发现了这一点: Exoplayer播放以字节数组形式接收的实时视频块,一个接一个地保持连续性,但不知道如何创建和在ExoPlayer中实现自定义数据源。)

Plus, I'm not sure if the ExoPlayer can produce video from h264 frames.

(另外,我不确定ExoPlayer是否可以从h264帧生成视频。)

I also found this: repo on github but haven't manage to work it out (my external device is not an Android and the payload of the packets is not something that I can change).

(我也发现了这一点: 在github上进行了回购,但还没有解决(我的外部设备不是Android,并且数据包的有效负载不是我可以更改的东西)。)

Thanks!

(谢谢!)

  ask by Oz Shabat translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...