Write a mobile VR player that supports SMB (I): basic knowledge

There are several low-cost CardBoard VR plastic boxes in hand to experience VR content on mobile phones. Since I have several NAS, I urgently need a way to play the above content.

cause

Several VR boxes called xx Magic Mirror and xx VR were found in the corner of the box. They are all CardBoard type VR boxes. CardBoard is a low-cost VR solution. They use mobile phones to calculate and display content, and the human eye views the mobile phone screen through two Fresnel lenses on the helmet, so as to achieve VR perception.

According to the previous articles of this blog, this blog has multiple low-power PT attached NAS, which are attached as remote disks through Samba (SMB), which is very convenient for daily use. One day, one year, one month, this blog got 1TB+VR video resources by chance.

This blog wants to make use of these VR boxes, but after a round of searching, it can't find an Android player that supports both SMB and VR. At present, most player applications that support VR video (iQIYI VR, etc.) do not support SMB, while most video player applications that support SMB do not support VR video (eg: image anti distortion processing, etc.).

Therefore, in order to achieve this goal, I have to write one myself.

Terminology

1. Samba and SMB

SMB is a file sharing transfer protocol, which is supported by the Windows platform by default. Through this protocol, you can share files in computers under the same network, and perform operations such as adding, deleting, modifying, and querying.

Samba is a free software used to implement the SMB protocol on Linux. With this software, Windows computers can access the Linux SMB directory through the LAN to share resources. Windows Explorer has built-in support for SMB directories, so accessing shared content through SMB is much easier than FTP.

2. VR video

At present, VR video can be simply divided into two categories: panoramic video and stereoscopic video. The former can be divided into Cylindrical (very rare) 180 °/360 ° panorama Six sided panorama (rare, usually synthesized into 360 degree video), etc., while stereoscopic video can be divided into Up and down about Red blue Etc.

3. Distortion and anti distortion

VR lens will distort the image, which is an optical problem caused by the pursuit of short focus, small volume, and large field of view (FOV). See " Discussion on Basic Algorithms of VR Lens Anti distortion 'one article.

In order to make the image seen by the human eye a normal image, the player needs to reverse distort the image (most VR SDKs have achieved this), so that the image will display normally after lens distortion (can be understood as - 1+1=0).

Although most mobile phone players support decoding VR video, due to the lack of anti distortion processing, directly using CardBoard to watch will cause distortion, distortion, dislocation, etc.

Technical implementation

At present, three problems need to be solved:

  1. Android devices access smb content;
  2. Provide the smb content to the upper player application;
  3. The player shall apply decoding, anti distortion, and finally output the picture.

Problem 3 is the best solution. You can directly use the CardBoard SDK+player plug-in in Unity. So the difficulty is how to access the Smb content and provide it to Unity.

According to the research on the ES file browser and other software, it is found that their approach is to implement the smb to http conversion service on the Android side, and then provide the http link to the player for playing.

Therefore, to achieve my goal, first of all, we need to use Java code to implement smb to http services on the Android side, and then provide these data, methods, etc. to Unity C # for use. Their relationship is shown in the figure below:

Unity can interact with Java, so you can consider packaging Java code and interfaces into Jar packages to introduce Unity.

verification

It mainly verifies whether the Android side can access the SMB Server, so I introduced the smbj plug-in and wrote a simple Java code to verify the file browsing:

 SMBClient client = new SMBClient(); try (Connection connection = client.connect("192.168.3.102")) { System.out.println("=================="); AuthenticationContext ac = new AuthenticationContext("shares","shares".toCharArray(),"/"); Session session = connection.authenticate(ac); try(DiskShare share = (DiskShare) session.connectShare("d1_2")) { for (FileIdBothDirectoryInformation f : share.list("movies","*")){ //System.out.println("File:" + f.getFileName()); runOnUiThread(new Runnable() { @Override public void run() { test.setText(test.getText() + "\r\n" + f.getFileName()); } }); } } } catch (IOException e) { e.printStackTrace(); }

The following are the results of the operation:

other

This blog is a Unity script kid, not a professional Java Android developer. For some Java requirements with open source solutions, this blog will directly use these solutions after verifying the feasibility of the basic libraries used by the open source solutions, without spending time repeatedly building wheels.

This is not a commercial project, and it has nothing to do with my own work, so the relevant warehouse will be placed in Github organization in the exchange group of this blog—— Novice Biosphere Next. In addition, because it started out of interest, it is very likely to release pigeons halfway.

Zimiao haunting blog (azimiao. com) All rights reserved. Please note the link when reprinting: https://www.azimiao.com/8290.html
Welcome to the Zimiao haunting blog exchange group: three hundred and thirteen million seven hundred and thirty-two thousand

Comment

*

*