scar-chat/README.md

10 KiB

SCAR Chat Application

A cross-platform GUI chat client and server with SSL/TLS encryption and live video streaming support, built in C++, Qt, and Java/Kotlin.

Features

Server (chat_server)

  • Listens on TCP port 42317 with TLS/SSL encryption
  • Multi-client support with broadcast messaging
  • Camera status tracking and relay for all connected clients
  • Uses OpenSSL for secure communication
  • Linux/cross-platform compatible

Qt Client (chat_client_qt)

  • Cross-platform GUI using Qt5/6 Widgets
  • TLS/SSL encrypted connection to server
  • Tabbed interface:
    • Chat Tab: Text-based messaging with customization
    • Video Feeds Tab: Live camera feeds from all connected users
  • Camera Controls:
    • Enable/disable camera toggle button
    • Camera selection dropdown
    • Live video feed display (framework for H.264 streaming)
    • Remote user video feed gallery
  • Customizable UI:
    • Background color selector for all windows
    • Chat text color customization
    • Transparency/opacity slider (0-100%)
  • Real-time message sending and receiving
  • Linux/cross-platform compatible

Windows Client (chat_client_win)

  • Native Win32 GUI client
  • Same UI features as Qt client
  • Windows-only build

Android Client

  • Full-featured native Android app (Android 7.0+)
  • Material Design UI with tabbed interface
  • Features:
    • Real-time TLS/SSL encrypted chat
    • Camera selection and enable/disable
    • Camera preview from device
    • Remote user status tracking
    • Customizable UI colors and transparency
  • Compatible with Android 7.0 (API 24) and above
  • Run on physical devices and emulators

Prerequisites

Linux / macOS

# Ubuntu/Debian
sudo apt-get install cmake qtbase5-dev libssl-dev libqt5multimedia5-dev build-essential

# macOS (Homebrew)
brew install cmake qt5 openssl

Windows

  • Visual Studio 2019+ or MinGW
  • CMake 3.16+
  • Qt5/6 SDK with Multimedia module
  • OpenSSL for Windows (vcpkg or prebuilt binaries)

Building

Linux / macOS

  1. Create and generate certificates:

    cd certs
    ./generate_certs.sh
    cd ..
    
  2. Build the project:

    mkdir build
    cd build
    cmake ..
    make
    
  3. Install (optional):

    make install
    

Windows

  • Visual Studio 2019+ or MinGW
  • CMake 3.16+
  • Qt5/6 SDK with Multimedia module
  • OpenSSL for Windows (vcpkg or prebuilt binaries)

Android

  • Android SDK 24+ (API level 24)
  • Android Studio 4.0+ or Gradle 8.1+
  • Java JDK 11+

Building

Linux / macOS

  1. Create and generate certificates:

    cd certs
    ./generate_certs.sh
    cd ..
    
  2. Build the project:

    mkdir build
    cd build
    cmake ..
    make
    
  3. Install (optional):

    make install
    

Windows

  1. Generate certificates (use OpenSSL for Windows or WSL):

    cd certs
    # On Windows, use Git Bash or WSL to run generate_certs.sh
    # Or generate manually using OpenSSL
    cd ..
    
  2. Build:

    mkdir build
    cd build
    cmake ..
    cmake --build . --config Release
    

Android

  1. Using Android Studio:

    • Open Android Studio
    • File → Open → Select android_client/ directory
    • Wait for Gradle sync
    • Build → Make Project
    • APK output: android_client/app/build/outputs/apk/debug/app-debug.apk
  2. Using Gradle (Command Line):

    cd android_client
    ./gradlew build
    # For installation on device/emulator
    ./gradlew installDebug
    

For detailed Android build instructions, see android_client/README.md

mkdir build
cd build
cmake -G "Visual Studio 16 2019" ..
cmake --build . --config Release

Running

Server

# Linux / macOS
./build/chat_server certs/server.crt certs/server.key

# Windows
.\build\Release\chat_server.exe certs\server.crt certs\server.key

The server will listen on localhost:42317 and relay:

  • Text chat messages
  • Camera status updates (enable/disable)
  • Video frame data (framework ready for H.264 streaming)

Qt Client

# Linux / macOS
./build/chat_client_qt

# Windows (if built on Windows)
.\build\Release\chat_client_qt.exe

Usage Steps:

  1. Enter server host/port (default: localhost:42317)
  2. Click "Connect" to establish TLS connection
  3. Switch to "Video Feeds" tab
  4. Select your camera from the dropdown
  5. Check "Enable Camera" to start video
  6. Switch to "Chat" tab to send messages

Android Client

  1. On Physical Device:

    cd android_client
    ./gradlew installDebug
    
    • Or open app manually after building
  2. On Emulator:

    • Start Android Virtual Device from Android Studio
    cd android_client
    ./gradlew installDebug
    

Usage Steps:

  1. Enter server host (IP address or hostname)

  2. Enter server port (default: 42317)

  3. Tap "Connect" to establish TLS connection

  4. Go to "Video" tab

  5. Select camera from dropdown

  6. Check "Enable Camera" to start camera

  7. Go to "Chat" tab to send/receive messages

  8. Check "Enable Camera" to broadcast your video status

  9. See all connected users' camera status in the feed gallery

  10. Use "Chat" tab for text messaging with customization options

Windows Client

# Windows only
.\build\Release\chat_client_win.exe

Customization Features

Chat Tab

Background Color

  • Click "BG Color" button to select background color for all windows
  • Color choice is applied immediately

Text Color

  • Click "Text Color" button to select chat text color
  • Updates chat display in real-time

Transparency

  • Use the transparency slider (0-100%) to adjust window opacity
  • 0% = fully transparent, 100% = fully opaque

Video Feeds Tab

Camera Enable/Disable

  • Toggle "Enable Camera" checkbox to start/stop your camera
  • Status is broadcast to all connected users
  • Green border indicates active camera, gray indicates disabled

Camera Selection

  • Choose from available cameras in your system
  • Supports multiple camera inputs

Video Feed Display

  • Your Camera Feed: Shows your active camera stream (640x480)
  • Connected Users: Grid display of all users' video feeds (320x240 each)
  • Status Indicators: Shows "Online" or "Offline" for each user's camera

Video Streaming Architecture

The application includes a framework for live video streaming:

  1. Camera Capture: Qt5 Multimedia module handles camera access
  2. Protocol: Camera status (enable/disable) sent over TLS
  3. Future Expansion:
    • Binary video frame encoding (H.264/VP9)
    • Real-time frame transmission over TLS socket
    • Hardware-accelerated decoding on client side
    • Bandwidth optimization with adaptive bitrate streaming

Current Implementation:

  • Camera detection and selection
  • Enable/disable controls
  • Status synchronization across clients
  • Full H.264 video encoding/decoding (requires additional codec libraries)

SSL/TLS Certificates

Generate Self-Signed Certificates

For development and testing:

cd certs

# Generate private key
openssl genrsa -out server.key 2048

# Generate certificate (valid for 365 days)
openssl req -new -x509 -key server.key -out server.crt -days 365 \
  -subj "/C=US/ST=State/L=City/O=SCAR/CN=localhost"

cd ..

Note: For production, use certificates signed by a trusted Certificate Authority (CA).

Ignoring Self-Signed Certificates

The Qt client is configured to ignore self-signed certificate errors during development:

socket->ignoreSslErrors();

For production, implement proper certificate validation.

Project Structure

scar-chat/
├── CMakeLists.txt          # Top-level CMake configuration
├── README.md               # This file
├── certs/                  # SSL certificates directory
│   └── generate_certs.sh   # Certificate generation script
├── src/
│   ├── server/
│   │   └── server.cpp      # TLS server with camera status relay
│   ├── qt_client/
│   │   └── main.cpp        # Qt GUI client with video streaming
│   └── windows_client/
│       └── main_win.cpp    # Win32 GUI client (Windows-only)
└── build/                  # Build output directory (created after cmake)
    ├── chat_server         # Linux server binary
    └── chat_client_qt      # Linux client binary (179 KB with video support)

Troubleshooting

"Connection refused" error

  • Ensure server is running on the same host/port
  • Check firewall settings on port 42317

SSL/TLS errors

  • Verify certificates exist in certs/ directory
  • Regenerate certificates if expired or corrupted
  • Ensure certificate and key files are readable

Qt not found during CMake

# Set Qt path explicitly
cmake -DQt5_DIR=/path/to/Qt5/lib/cmake/Qt5 ..

OpenSSL not found during CMake

# Set OpenSSL path explicitly (macOS example)
cmake -DOPENSSL_DIR=/usr/local/opt/openssl ..

Development Notes

  • C++17 standard is required
  • Qt5/6 for cross-platform GUI
  • OpenSSL 1.1+ for TLS/SSL
  • Threading used for non-blocking socket operations
  • Message protocol: simple newline-delimited UTF-8 text

Security Considerations

  • Uses TLS 1.2+ for encrypted communication
  • ⚠️ Development mode: ignores self-signed certificate errors
  • ⚠️ No user authentication implemented
  • ⚠️ No message encryption at application level (relies on TLS)

For production use, implement:

  • Proper certificate validation
  • User authentication and authorization
  • Message signing/verification
  • Rate limiting and DoS protection
  • Video frame encryption (end-to-end)

Future Enhancements

Video Streaming

  • H.264/VP9 video codec integration
  • Adaptive bitrate streaming based on network conditions
  • Hardware-accelerated encoding/decoding (NVIDIA NVENC, Intel QuickSync)
  • STUN/TURN for P2P connections (bypass server for bandwidth efficiency)
  • Screen sharing mode
  • Picture-in-picture for local + remote feeds

Chat Features

  • Message history persistence (database backend)
  • User authentication with username/password
  • Emoji and rich text support
  • File transfer with progress bar
  • Message reactions and threading

UI/UX

  • Dark mode / light mode themes
  • Resizable video feed windows
  • Drag-and-drop window layout
  • Audio chat (VoIP) integration
  • Settings/preferences dialog

License

This project is provided as-is for educational and development purposes.