2025-12-04 19:46:54 -07:00
|
|
|
# SCAR Chat Application
|
|
|
|
|
|
2025-12-04 21:22:58 -07:00
|
|
|
A cross-platform GUI chat client and server with SSL/TLS encryption and **live video streaming support**, built in C++, Qt, and Java/Kotlin.
|
2025-12-04 19:46:54 -07:00
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
|
|
### Server (`chat_server`)
|
|
|
|
|
- Listens on TCP port **42317** with TLS/SSL encryption
|
|
|
|
|
- Multi-client support with broadcast messaging
|
2025-12-04 21:22:58 -07:00
|
|
|
- Camera status tracking and relay for all connected clients
|
2025-12-04 19:46:54 -07:00
|
|
|
- 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
|
2025-12-04 21:22:58 -07:00
|
|
|
- **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
|
2025-12-04 19:46:54 -07:00
|
|
|
- **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
|
|
|
|
|
|
2025-12-04 21:22:58 -07:00
|
|
|
### 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
|
|
|
|
|
|
2025-12-04 19:46:54 -07:00
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
|
|
### Linux / macOS
|
|
|
|
|
```bash
|
|
|
|
|
# Ubuntu/Debian
|
2025-12-04 21:22:58 -07:00
|
|
|
sudo apt-get install cmake qtbase5-dev libssl-dev libqt5multimedia5-dev build-essential
|
2025-12-04 19:46:54 -07:00
|
|
|
|
|
|
|
|
# macOS (Homebrew)
|
|
|
|
|
brew install cmake qt5 openssl
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Windows
|
|
|
|
|
- Visual Studio 2019+ or MinGW
|
|
|
|
|
- CMake 3.16+
|
2025-12-04 21:22:58 -07:00
|
|
|
- Qt5/6 SDK with Multimedia module
|
|
|
|
|
- OpenSSL for Windows (vcpkg or prebuilt binaries)
|
|
|
|
|
|
|
|
|
|
## Building
|
|
|
|
|
|
|
|
|
|
### Linux / macOS
|
|
|
|
|
|
|
|
|
|
1. **Create and generate certificates:**
|
|
|
|
|
```bash
|
|
|
|
|
cd certs
|
|
|
|
|
./generate_certs.sh
|
|
|
|
|
cd ..
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. **Build the project:**
|
|
|
|
|
```bash
|
|
|
|
|
mkdir build
|
|
|
|
|
cd build
|
|
|
|
|
cmake ..
|
|
|
|
|
make
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3. **Install (optional):**
|
|
|
|
|
```bash
|
|
|
|
|
make install
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Windows
|
|
|
|
|
- Visual Studio 2019+ or MinGW
|
|
|
|
|
- CMake 3.16+
|
|
|
|
|
- Qt5/6 SDK with Multimedia module
|
2025-12-04 19:46:54 -07:00
|
|
|
- OpenSSL for Windows (vcpkg or prebuilt binaries)
|
|
|
|
|
|
2025-12-04 21:22:58 -07:00
|
|
|
### Android
|
|
|
|
|
- Android SDK 24+ (API level 24)
|
|
|
|
|
- Android Studio 4.0+ or Gradle 8.1+
|
|
|
|
|
- Java JDK 11+
|
|
|
|
|
|
2025-12-04 19:46:54 -07:00
|
|
|
## Building
|
|
|
|
|
|
|
|
|
|
### Linux / macOS
|
|
|
|
|
|
|
|
|
|
1. **Create and generate certificates:**
|
|
|
|
|
```bash
|
|
|
|
|
cd certs
|
|
|
|
|
./generate_certs.sh
|
|
|
|
|
cd ..
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. **Build the project:**
|
|
|
|
|
```bash
|
|
|
|
|
mkdir build
|
|
|
|
|
cd build
|
|
|
|
|
cmake ..
|
|
|
|
|
make
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3. **Install (optional):**
|
|
|
|
|
```bash
|
|
|
|
|
make install
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Windows
|
|
|
|
|
|
|
|
|
|
1. **Generate certificates** (use OpenSSL for Windows or WSL):
|
|
|
|
|
```bash
|
|
|
|
|
cd certs
|
|
|
|
|
# On Windows, use Git Bash or WSL to run generate_certs.sh
|
|
|
|
|
# Or generate manually using OpenSSL
|
|
|
|
|
cd ..
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. **Build:**
|
2025-12-04 21:22:58 -07:00
|
|
|
```bash
|
|
|
|
|
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):**
|
|
|
|
|
```bash
|
|
|
|
|
cd android_client
|
|
|
|
|
./gradlew build
|
|
|
|
|
# For installation on device/emulator
|
|
|
|
|
./gradlew installDebug
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
For detailed Android build instructions, see `android_client/README.md`
|
|
|
|
|
|
2025-12-04 19:46:54 -07:00
|
|
|
```bash
|
|
|
|
|
mkdir build
|
|
|
|
|
cd build
|
|
|
|
|
cmake -G "Visual Studio 16 2019" ..
|
|
|
|
|
cmake --build . --config Release
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Running
|
|
|
|
|
|
|
|
|
|
### Server
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Linux / macOS
|
|
|
|
|
./build/chat_server certs/server.crt certs/server.key
|
|
|
|
|
|
|
|
|
|
# Windows
|
|
|
|
|
.\build\Release\chat_server.exe certs\server.crt certs\server.key
|
|
|
|
|
```
|
|
|
|
|
|
2025-12-04 21:22:58 -07:00
|
|
|
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)
|
2025-12-04 19:46:54 -07:00
|
|
|
|
|
|
|
|
### Qt Client
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Linux / macOS
|
|
|
|
|
./build/chat_client_qt
|
|
|
|
|
|
|
|
|
|
# Windows (if built on Windows)
|
|
|
|
|
.\build\Release\chat_client_qt.exe
|
|
|
|
|
```
|
|
|
|
|
|
2025-12-04 21:22:58 -07:00
|
|
|
**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:**
|
|
|
|
|
```bash
|
|
|
|
|
cd android_client
|
|
|
|
|
./gradlew installDebug
|
|
|
|
|
```
|
|
|
|
|
- Or open app manually after building
|
|
|
|
|
|
|
|
|
|
2. **On Emulator:**
|
|
|
|
|
- Start Android Virtual Device from Android Studio
|
|
|
|
|
```bash
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
5. Check "Enable Camera" to broadcast your video status
|
|
|
|
|
6. See all connected users' camera status in the feed gallery
|
|
|
|
|
7. Use "Chat" tab for text messaging with customization options
|
2025-12-04 19:46:54 -07:00
|
|
|
|
|
|
|
|
### Windows Client
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Windows only
|
|
|
|
|
.\build\Release\chat_client_win.exe
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Customization Features
|
|
|
|
|
|
2025-12-04 21:22:58 -07:00
|
|
|
### Chat Tab
|
|
|
|
|
**Background Color**
|
2025-12-04 19:46:54 -07:00
|
|
|
- Click "BG Color" button to select background color for all windows
|
|
|
|
|
- Color choice is applied immediately
|
|
|
|
|
|
2025-12-04 21:22:58 -07:00
|
|
|
**Text Color**
|
2025-12-04 19:46:54 -07:00
|
|
|
- Click "Text Color" button to select chat text color
|
|
|
|
|
- Updates chat display in real-time
|
|
|
|
|
|
2025-12-04 21:22:58 -07:00
|
|
|
**Transparency**
|
2025-12-04 19:46:54 -07:00
|
|
|
- Use the transparency slider (0-100%) to adjust window opacity
|
|
|
|
|
- 0% = fully transparent, 100% = fully opaque
|
|
|
|
|
|
2025-12-04 21:22:58 -07:00
|
|
|
### 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)
|
|
|
|
|
|
2025-12-04 19:46:54 -07:00
|
|
|
## SSL/TLS Certificates
|
|
|
|
|
|
|
|
|
|
### Generate Self-Signed Certificates
|
|
|
|
|
|
|
|
|
|
For development and testing:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
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:
|
|
|
|
|
```cpp
|
|
|
|
|
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/
|
2025-12-04 21:22:58 -07:00
|
|
|
│ │ └── server.cpp # TLS server with camera status relay
|
2025-12-04 19:46:54 -07:00
|
|
|
│ ├── qt_client/
|
2025-12-04 21:22:58 -07:00
|
|
|
│ │ └── main.cpp # Qt GUI client with video streaming
|
2025-12-04 19:46:54 -07:00
|
|
|
│ └── windows_client/
|
2025-12-04 21:22:58 -07:00
|
|
|
│ └── main_win.cpp # Win32 GUI client (Windows-only)
|
2025-12-04 19:46:54 -07:00
|
|
|
└── build/ # Build output directory (created after cmake)
|
2025-12-04 21:22:58 -07:00
|
|
|
├── chat_server # Linux server binary
|
|
|
|
|
└── chat_client_qt # Linux client binary (179 KB with video support)
|
2025-12-04 19:46:54 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 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
|
|
|
|
|
```bash
|
|
|
|
|
# Set Qt path explicitly
|
|
|
|
|
cmake -DQt5_DIR=/path/to/Qt5/lib/cmake/Qt5 ..
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### OpenSSL not found during CMake
|
|
|
|
|
```bash
|
|
|
|
|
# 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
|
2025-12-04 21:22:58 -07:00
|
|
|
- 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
|
2025-12-04 19:46:54 -07:00
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
This project is provided as-is for educational and development purposes.
|