Skip to content

calinvasileandrei/VrTripNative

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VR_TRIP: Distributed VR Video Player - Technical Documentation

1. Introduction

Purpose of the App

VR_TRIP is a distributed virtual reality video player that enables synchronized 360° video playback across multiple Android devices over local or remote networks. The application creates a shared immersive experience where one device acts as a master controller while multiple client devices follow in perfect synchronization.

Target Audience

  • Developers: Mobile app developers working with VR content, socket programming, and distributed systems
  • Technical Integrators: Teams implementing VR solutions for enterprise or educational environments
  • Content Creators: VR content producers looking to deliver synchronized group experiences
  • System Administrators: IT professionals deploying VR solutions in controlled environments
  • End Users: Tour guides, educators, and VR enthusiasts seeking collaborative viewing experiences

Use Cases

  • Educational Tours: Virtual museum visits, historical site explorations, and immersive learning experiences
  • Training Programs: Synchronized VR training sessions for multiple participants
  • Entertainment: Group VR movie watching and gaming experiences
  • Remote Collaboration: Distributed teams exploring 3D models and virtual environments
  • Medical Training: Synchronized medical procedure simulations and anatomy lessons
  • Real Estate: Virtual property tours for multiple potential buyers

2. Architecture Overview

High-Level System Design

VR_TRIP implements a client-server architecture using TCP socket connections for real-time communication and synchronization.

┌─────────────────┐         ┌─────────────────┐
│   Manager       │◄────────┤   Client 1      │
│   (Server)      │         │                 │
│   Port: 50000   │         └─────────────────┘
│                 │         ┌─────────────────┐
│                 │◄────────┤   Client 2      │
│                 │         │                 │
│                 │         └─────────────────┘
│                 │         ┌─────────────────┐
│                 │◄────────┤   Client N      │
└─────────────────┘         └─────────────────┘

Network Topology and Communication Protocols

  • Protocol: TCP sockets for reliable message delivery
  • Port: 50000 (configurable)
  • Message Format: JSON-based command structure
  • Discovery: Android Network Service Discovery (NSD) using "_vrmd360._tcp" service type
  • Fallback: Manual IP address entry for direct connections

Roles of Devices

Manager (Server) Device

  • Runs socket server on port 50000
  • Maintains client connection registry
  • Controls video playback state
  • Broadcasts synchronization commands
  • Manages video content selection
  • Handles timeline marker synchronization

Client Devices

  • Establishes TCP connection to manager
  • Receives and executes playback commands
  • Maintains synchronization with manager timeline
  • Automatically reconnects on connection loss
  • Reports connection status to manager

3. Core Features

VR Video Rendering Support

  • 360° Video Support: Full spherical video rendering using MD360Player4Android
  • Stereoscopic Support: Side-by-side and top-bottom 3D formats
  • Multiple Display Modes:
    • Touch navigation
    • Motion tracking for VR headsets
    • Cardboard-compatible rendering
  • Video Formats: MP4, WebM, and other ExoPlayer-supported formats
  • Resolution Support: Up to 4K 360° video content

Playback Synchronization Logic

  • Real-time Command Broadcasting: Instant propagation of play/pause/seek commands
  • Timeline Markers: JSON-based transcript system for guided synchronization points
  • Automatic Reconnection: Smart handling of temporary network disconnections
  • State Synchronization: New clients automatically sync to current playback state
  • Precision Control: Millisecond-level synchronization accuracy

Device Discovery and Pairing Mechanism

  • Network Service Discovery (NSD): Automatic discovery of manager devices on local network
  • Service Broadcasting: Manager devices announce availability using "_vrmd360._tcp" service type
  • Manual Connection: Direct IP address entry for remote connections
  • Device Naming: Configurable device names for easy identification
  • Connection Status: Real-time connection monitoring and status reporting

4. Technology Stack

Mobile Platforms Supported

  • Primary: Android (API 21+)
  • Future Roadmap: iOS compatibility planned

Frameworks and Libraries

  • VR Rendering: MD360Player4Android for 360° video processing
  • Media Playback: ExoPlayer for robust video handling
  • UI Framework: Native Android with Material Design components
  • Network Discovery: Android NSD (Network Service Discovery)
  • Cloud Integration: Google Drive API for content distribution
  • File Management: Android Storage Access Framework

Socket Library

  • Implementation: Native Java/Android socket programming
  • Protocol: TCP sockets for reliable communication
  • JSON Processing: Native Android JSON parsing
  • Threading: AsyncTask and Handler-based socket management

5. Setup and Installation

Prerequisites

  • Android Studio 4.0 or higher
  • Android SDK API 21 or higher
  • Google Services JSON configuration file
  • Android device with gyroscope (recommended for VR features)

Steps to Build and Run the App

  1. Clone Repository

    git clone [repository-url]
    cd VrMd360Player
  2. Google Services Setup

    • Place google-services.json in app/src/ directory
    • Ensure Google Drive API is enabled in Google Console
  3. Build Application

    ./gradlew assembleDebug
  4. Install on Devices

    adb install app/build/outputs/apk/debug/app-debug.apk

Environment Variables and Configuration

  • Socket Port: Configurable in app settings (default: 50000)
  • Device Name: User-configurable in settings
  • Content Directory: /Downloads/VR_TRIP/ for external content
  • Internal Storage: App-specific directory for imported videos

Required Permissions

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

6. API/Socket Events Documentation

Socket Event Structure

All socket communications use JSON format with the following structure:

{
  "action": "command_name",
  "payload": "optional_data"
}

Core Socket Events

Playback Control Events

// Play Command
{
  "action": "play",
  "payload": ""
}

// Pause Command
{
  "action": "pause",
  "payload": ""
}

// Seek Command
{
  "action": "seek",
  "payload": "12345"  // Position in milliseconds
}

// Video Selection
{
  "action": "load_video",
  "payload": "video_filename.mp4"
}

Connection Management Events

// Client Connection
{
  "action": "client_connect",
  "payload": "device_name"
}

// Client Disconnection
{
  "action": "client_disconnect",
  "payload": "device_name"
}

// Heartbeat
{
  "action": "ping",
  "payload": ""
}

Synchronization Events

// Timeline Sync
{
  "action": "sync_timeline",
  "payload": "enabled"  // "enabled" or "disabled"
}

// Position Update
{
  "action": "position_update",
  "payload": "12345"  // Current position in milliseconds
}

Error Handling Strategies

  • Connection Loss: Automatic reconnection with exponential backoff
  • Invalid Commands: Graceful error logging without app termination
  • Network Timeouts: 30-second timeout with retry mechanism
  • Malformed JSON: Error logging and command skipping
  • File Not Found: User notification and fallback to available content

7. UI/UX Overview

VR Player Interface

  • Immersive Design: Minimal UI overlay for maximum VR immersion
  • Auto-hide Controls: Playback controls disappear during viewing
  • Touch Activation: Tap screen to reveal control overlay
  • Spherical Navigation: 360° touch-based camera control
  • VR Mode Toggle: Switch between normal and cardboard viewing modes

Manager UI Components

  • Device Management Panel: Real-time display of connected clients
  • Video Library Browser: Grid view of available VR content
  • Playback Controls: Standard play/pause/seek controls with sync options
  • Timeline Management: Toggle for automatic pause at transcript markers
  • Connection Status: Visual indicators for network and client status

Client UI Components

  • Connection Screen: Manager discovery and manual connection options
  • Sync Indicator: Visual feedback for synchronization status
  • Minimal Player: Streamlined interface focused on content consumption
  • Status Overlay: Non-intrusive connection and sync status display

User Controls Available

Manager Controls

  • Video selection and playback control
  • Timeline scrubbing and seeking
  • Client device management
  • Sync mode toggle (timeline markers)
  • Connection monitoring

Client Controls

  • Manager selection and connection
  • VR viewing mode selection
  • Basic playback information display
  • Connection status monitoring

8. Limitations and Known Issues

Current Constraints

  • Platform Support: Android only (iOS planned for future release)
  • Network Dependency: Requires stable network connection for synchronization
  • Video Format Limitations: Limited to ExoPlayer-supported formats
  • Concurrent Client Limit: Practical limit of 10-15 simultaneous clients
  • File Size Restrictions: Large video files may impact sync performance

Performance Considerations

  • Network Bandwidth: 360° video requires significant bandwidth for streaming
  • Device Performance: VR rendering demands high-performance devices
  • Battery Consumption: Extended VR sessions drain battery quickly
  • Memory Usage: High-resolution 360° content requires substantial RAM

Planned Improvements and Roadmap

  • iOS Version: Native iOS client development
  • WebRTC Integration: Improved network performance and NAT traversal
  • Cloud Streaming: Direct cloud video streaming without local storage
  • Enhanced Sync Algorithms: Machine learning-based sync optimization
  • Multi-language Support: Internationalization for global deployment
  • Advanced Analytics: Usage tracking and performance monitoring

9. Testing and Debugging

Testing Synchronization and Playback

Automated Testing

# Unit Tests
./gradlew testDebugUnitTest

# Integration Tests
./gradlew connectedAndroidTest

Manual Testing Procedures

  1. Multi-device Setup: Test with 3+ devices in various network conditions
  2. Sync Accuracy Testing: Use stopwatch to verify millisecond-level sync
  3. Network Stress Testing: Simulate network interruptions and recovery
  4. Performance Testing: Monitor CPU/memory usage during VR playback

Simulating Network Delays

  • Android Emulator: Use network conditioning tools
  • Physical Testing: Test across different Wi-Fi networks and mobile data
  • Proxy Tools: Use Charles Proxy or similar for network simulation
  • Bandwidth Limiting: Test with throttled connections

Logging and Debugging Socket Communication

Enable Debug Logging

// In MainActivity or Application class
if (BuildConfig.DEBUG) {
    SocketManager.setDebugMode(true);
}

Log Categories

  • Socket Events: Connection, disconnection, and command transmission
  • Sync Events: Timeline synchronization and marker events
  • Performance Metrics: Latency measurements and frame rate monitoring
  • Error Tracking: Network errors, parsing failures, and recovery actions

Debug Tools

  • Android Studio Debugger: Real-time socket connection monitoring
  • Network Inspector: HTTP/Socket traffic analysis
  • Custom Debug Panel: In-app network statistics and connection status
  • Remote Logging: Centralized logging for multi-device debugging

Testing Commands

# ADB commands for testing
adb logcat | grep "VR_TRIP"  # View app-specific logs
adb shell dumpsys connectivity  # Network connectivity status
adb shell am start -n com.vrtrip/.MainActivity  # Launch app

10. License and Contribution Guidelines

Licensing Terms

This project is distributed under the [LICENSE_TYPE] license. See the LICENSE file for complete terms and conditions.

Key License Points

  • Commercial Use: [Specify if allowed]
  • Modification Rights: [Specify permissions]
  • Distribution Terms: [Specify requirements]
  • Attribution Requirements: [Specify if needed]

How to Contribute

Reporting Issues

  1. Search Existing Issues: Check GitHub issues before creating new ones
  2. Issue Template: Use provided templates for bug reports and feature requests
  3. Reproduction Steps: Include detailed steps to reproduce issues
  4. Environment Details: Specify device models, Android versions, and network conditions

Development Contributions

  1. Fork Repository: Create personal fork for development
  2. Feature Branches: Use descriptive branch names for new features
  3. Code Standards: Follow Android development best practices
  4. Testing Requirements: Include unit tests for new functionality
  5. Pull Request Process: Submit PR with detailed description and testing results

Code Style Guidelines

  • Java: Follow Google Java Style Guide
  • XML: Use consistent indentation and attribute ordering
  • Comments: Document complex socket communication logic
  • Naming: Use descriptive names for socket events and methods

Development Environment Setup

# Install development dependencies
./gradlew build

# Run code quality checks
./gradlew checkstyle
./gradlew findbugs

# Format code
./gradlew formatCode

Contact and Support

  • GitHub Issues: Primary support channel for bug reports and feature requests
  • Developer Email: [developer-email@domain.com]
  • Documentation Wiki: [link-to-wiki] for additional technical details
  • Community Forum: [link-to-forum] for user discussions and use cases

Quick Start Guide

For users wanting to get started quickly:

  1. Install the app on all devices (one manager, multiple clients)
  2. Configure device names in Settings
  3. Start Manager on the controlling device
  4. Connect Clients by discovering or entering manager IP
  5. Load Content using the File Manager
  6. Begin Playback and enjoy synchronized VR experiences

For detailed setup instructions, refer to Section 5: Setup and Installation.


Last Updated: [Current Date]
Version: [App Version]
Documentation Version: 1.0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages