且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用套接字fd流从手机实时视频电话

更新时间:2023-11-18 17:13:22

我发现了一个开源项目实现了我的努力。它通过IP相机处理元数据的视频。虽然它不直接发送视频到电话,它广播视频关于各种设备上观看。 /:源$ C ​​$ C可在下列项目的网页。 HTTP发现/$c$c.google.com/p/ipcamera-for-android/

I found an open source project for implementing what I was trying. It processes the video with metadata through an IP camera. Although it does not send video directly to a phone, it does broadcast video for various devices to watch. The source code can be found at the following project page http://code.google.com/p/ipcamera-for-android/.

使用Android 4.4系统还有另一种方式来播放实时MJPEG流。正在播放的流应该由其他设备端口在UDP上播出。比方说,我们有一个流正在播出192.168.0.101:8080。我们可以通过将web视图到我们的布局播放流。然后,在我们的活动,我们做到以下几点:

With Android 4.4 there is another way to play a live MJPEG stream. The stream you are playing should be broadcast by the other device on a port over UDP. Let's say we have a stream being broadcast on 192.168.0.101:8080. We can play the stream by adding a WebView to our layout. Then in our activity we do the following:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mjpeg_activity);
    // Grab instance of WebView
    WebView webView = (WebView)findViewById(R.id.webViewStream);
    // Set page content for webview
    webView.loadData("<html><head><meta name='viewport' content='target-densitydpi=device-dpi,initial-scale=1,minimum-scale=1,user-scalable=yes'/></head><body><center><img src=\"http://192.168.0.101:8080/\" alt=\"Stream\" align=\"middle\"></center></body></html>", "text/html", null);
    webView.getSettings().setBuiltInZoomControls(true);
}

在内容,我们告诉网页使用设备的DPI。为了支持双指缩放对我添加了以下初始规模= 1,最低规模为1,用户可扩展的网页用户= YES。最初的图像是它的原始尺寸,并且不能得到小。现在,用户可以扩展到放大图像和缩小到它的原始尺寸。卸下最小刻度将带给用户完全控制变焦,但可能会导致使图像这么小,你不能找到它。

In the content we tell the webpage to use the device's dpi. To support the user to pinch zoom on the webpage I have added the following initial-scale=1,minimum-scale=1,user-scalable=yes. Initially the image is it's original size and cannot get smaller. The user can now scale to zoom into the image and out to it's original size. Removing the minimum scale will give the user complete control over zoom, but can result in making the image so small you can't find it.