-----------------------------------------------------------------------------------------------
-- FRONT COVER PAGE --
-----------------------------------------------------------------------------------------------
[IMAGE PLACEHOLDER: University Logo, similar to source 1]
DR. C.V. RAMAN UNIVERSITY
KOTA, BILASPUR (C.G.)
INSTITUTE OF OPEN AND DISTANCE EDUCATION
A Project Report
On
CALL ROOM
For the award of the degree of
BACHELOR OF COMPUTER APPLICATION (BCA)
By
Rohit Bind
Registration No.: [YOUR REGISTRATION NUMBER]
Under the Guidance of
Mr. Kamaldeep Dwivedi
Session
[ACADEMIC SESSION, e.g., 2023-2024]
@[ACADEMIC YEAR, e.g., 2024] Rohit Bind All Rights Reserved.
-----------------------------------------------------------------------------------------------
-- INNER COVER PAGE (Optional, if your university requires it) --
-----------------------------------------------------------------------------------------------
CALL ROOM
A Project Report
Submitted to
DR. C.V. RAMAN UNIVERSITY
INSTITUTE OF OPEN AND DISTANCE EDUCATION
Kota, Bilaspur (C.G.)
For the award of the degree of
BACHELOR OF COMPUTER APPLICATION (BCA)
By
Rohit Bind
Registration No.: [YOUR REGISTRATION NUMBER]
Under the Guidance of
Mr. Kamaldeep Dwivedi
Session
[ACADEMIC SESSION, e.g., 2023-2024]
-----------------------------------------------------------------------------------------------
-- DECLARATION --
-----------------------------------------------------------------------------------------------
DECLARATION
I, the undersigned, solemnly declare that the Project Report entitled **"CALL ROOM"** is based on my own work carried out during the course of my study under the supervision of **Mr. Kamaldeep Dwivedi**. [cite: 3, 60]
I assert that the statements made and conclusions drawn are an outcome of my research work. [cite: 3, 61] I further certify that:
i. The work contained in the Project Report is original and has been done by me under the general supervision of my supervisor. [cite: 4, 62]
ii. The work has not been submitted to any other Institute for any other Degree/Diploma/Certificate in this University or any other University of India or abroad. [cite: 5, 63]
iii. I have followed the guidelines provided by the University in writing the Project Report. [cite: 6, 64]
iv. I have conformed to the norms and guidelines given in the concerned Ordinance of the University. [cite: 7, 65]
v. Whenever I have used materials (data, theoretical analysis, and text) from other sources, I have given due credit to them by citing them in the text of the Project Report and giving their details in the references. [cite: 8, 66]
vi. Whenever I have quoted written materials from other sources, I have put them under quotation marks and given due credit to the sources by citing them and giving required details in the references. [cite: 9, 67]
Date: [DATE]
Place: Kota, Bilaspur (C.G.)
(Signature)
**Rohit Bind**
Registration No.: [YOUR REGISTRATION NUMBER]
-----------------------------------------------------------------------------------------------
-- CERTIFICATE --
-----------------------------------------------------------------------------------------------
CERTIFICATE
This is to certify that the work incorporated in the Project Report entitled **"CALL ROOM"** is a record of own work carried out by **Rohit Bind**, Registration No.: **[YOUR REGISTRATION NUMBER]**, under my supervision for the award of the degree of **Bachelor of Computer Application (BCA)** of the Institute of Open and Distance Education, Dr. C.V. Raman University, Kota, Bilaspur (C.G.)-India. [cite: 11, 43, 69]
To the best of my knowledge and belief, the Project Report:
i. Embodies the work of the candidate himself. [cite: 12, 71]
ii. Has duly been completed. [cite: 12, 71]
iii. Is up to the desired standard both in respect of content and language for being referred to the examiners. [cite: 13, 72]
**Supervisor:**
(Signature)
**Mr. Kamaldeep Dwivedi**
[Supervisor's Designation, if known, e.g., Assistant Professor, Department of Computer Science]
(Signature of Academic Coordinator) [cite: 14] (Seal of IODE) [cite: 14]
[Name of Academic Coordinator]
Academic Coordinator, IODE
Dr. C.V. Raman University
-----------------------------------------------------------------------------------------------
-- ACKNOWLEDGEMENT --
-----------------------------------------------------------------------------------------------
ACKNOWLEDGEMENT
It is a matter of immense pleasure to express my overwhelming sense of gratitude and devotion to all those who have helped me in completing this project. [cite: 18, 49]
I would like to express my deepest appreciation and sincere thanks to my esteemed and learned guide, **Mr. Kamaldeep Dwivedi**, [Supervisor's Designation, if known], for his invaluable guidance, constant encouragement, and insightful suggestions throughout the development of this project report. His supervision has been instrumental in the successful completion of this work.
I am also thankful to the faculty members of the Institute of Open and Distance Education, Dr. C.V. Raman University, for their support and for providing a conducive learning environment.
Finally, I express my indebtedness to all who have directly or indirectly contributed to the successful completion of my project work, including my family and friends for their understanding and encouragement. [cite: 19, 53]
Date: [DATE]
(Signature)
**Rohit Bind**
Registration No.: [YOUR REGISTRATION NUMBER]
-----------------------------------------------------------------------------------------------
-- TABLE OF CONTENTS --
-----------------------------------------------------------------------------------------------
TABLE OF CONTENTS
CHAPTER NO. TITLE PAGE NO.
---------------------------------------------------------------------------
ABSTRACT vii
LIST OF FIGURES viii
1. INTRODUCTION 1
1.1 Project Aims and Objectives 1
1.2 Background of Project 2
1.3 Operation Environment 3
1.3.1 Hardware Requirements 3
1.3.2 Software Requirements (Development) 3
1.3.3 Software Requirements (Deployment) 4
2. SYSTEM ANALYSIS 5
2.1 Software Requirement Specification 5
2.1.1 Functional Requirements 5
2.1.2 Non-Functional Requirements 6
2.2 Existing System vs. Proposed System 7
2.2.1 Existing System (General) 7
2.2.2 Proposed System (Call Room) 8
2.3 Software Tools Used 8
3. SYSTEM DESIGN 10
3.1 System Architecture 10
3.2 Database Design 11
3.2.1 Table: room 11
3.3 Data Flow Diagrams (DFDs) 12
3.3.1 DFD Level 0 (Context Diagram) 12
3.3.2 DFD Level 1 (Detailed Diagram) 13
4. SYSTEM IMPLEMENTATION 15
4.1 Module Description 15
4.1.1 Frontend Modules 15
4.1.2 Backend Modules (PHP & Ratchet) 17
4.1.3 Database Module 18
4.1.4 Web Server Module (Nginx) 18
4.1.5 Containerization Modules (Docker) 19
4.2 Screen Shots 20
5. SYSTEM TESTING 24
5.1 Unit Testing 24
5.2 Integration Testing 25
5.3 Testing Strategy 26
6. CONCLUSION & FUTURE SCOPE 27
6.1 Conclusion 27
6.2 Future Scope 27
7. REFERENCES 29
(Note: Adjust page numbers once the document is finalized)
-----------------------------------------------------------------------------------------------
-- LIST OF FIGURES (Example, add more as you create actual figures) --
-----------------------------------------------------------------------------------------------
LIST OF FIGURES
FIGURE NO. TITLE PAGE NO.
---------------------------------------------------------------------------
3.1 Call Room System Architecture 10
3.2 E-R Diagram for `room` table 12
3.3 DFD Level 0 (Context Diagram) 13
3.4 DFD Level 1 (Detailed Diagram) 14
4.1 Home Page (Entering Room Name) 20
4.2 Call Page (Local Video, Waiting for Peer) 21
4.3 Call Page (Connected with Peer) 22
4.4 Call Ended Page 23
4.5 Database `room` table structure 23
(Note: Adjust page numbers once the document is finalized)
-----------------------------------------------------------------------------------------------
-- ABSTRACT --
-----------------------------------------------------------------------------------------------
ABSTRACT
The "Call Room" project is a lightweight, peer-to-peer video and audio calling application designed for simplicity and ease of use. Built using a modern web technology stack including PHP, JavaScript (WebRTC), Ratchet (for WebSockets), and MySQL, the application allows users to create or join communication rooms by specifying a room name. This facilitates direct video and audio communication between two participants within a room instance.
Key features of the "Call Room" application include its peer-to-peer architecture leveraging WebRTC for direct media streaming, room-based calling, dynamic pairing of users by the WebSocket server, and robust WebRTC negotiation logic (polite/impolite peers) to minimize connection failures. The system is designed to be lightweight and beginner-friendly, with detailed deployment instructions. Furthermore, the entire application is containerized using Docker and Docker Compose, ensuring easy setup and consistent operation across different environments. The backend uses MySQL for basic room and client management during the pairing process. The project aims to provide a straightforward and efficient solution for real-time video communication without the need for complex setups or third-party plugins.
-----------------------------------------------------------------------------------------------
-- CHAPTER 1: INTRODUCTION --
-----------------------------------------------------------------------------------------------
CHAPTER 1: INTRODUCTION
This chapter provides an overview of the "Call Room" project. It outlines the project's aims and objectives, discusses the background and motivation for its development, and details the operational environment including necessary hardware and software prerequisites.
**1.1 Project Aims and Objectives**
The primary aim of the "Call Room" project is to develop a simple and effective web-based application for real-time, two-party video and audio communication.
The specific objectives to achieve this aim are as follows:
* To design and implement a room-based system where users can create or join a communication session using a unique room name.
* To utilize WebRTC (Web Real-Time Communication) technology for establishing direct peer-to-peer media streams (video and audio) between users, minimizing latency and server load.
* To employ WebSockets (via Ratchet library in PHP) for real-time signaling between clients and the server, facilitating the WebRTC connection setup process, including offer/answer exchange and ICE candidate negotiation.
* To develop a dynamic pairing mechanism on the server-side that connects the first two users who join the same room.
* To implement "polite" and "impolite" peer logic for robust WebRTC negotiation to handle potential race conditions and ensure reliable connection establishment.
* To create a user-friendly interface using HTML, CSS, and JavaScript for easy interaction, allowing users to start and end calls seamlessly.
* To use a MySQL database for temporary storage of room and client information during the pairing process.
* To containerize the entire application (PHP backend, WebSocket server, Nginx web server, and MySQL database) using Docker and Docker Compose for simplified deployment, portability, and development setup.
* To provide a lightweight and easily understandable codebase, making it suitable as a learning resource for WebRTC and related technologies.
**1.2 Background of Project**
In an increasingly interconnected world, the demand for accessible and straightforward real-time communication tools is ever-present. While numerous sophisticated video conferencing solutions exist, they often come with complexities, dependencies on proprietary software or plugins, or significant server-side resource requirements for media relay. This project, "Call Room," was conceived to address the need for a simpler, more direct approach to two-party video calls.
The core motivations behind this project are:
* **Simplicity:** To create a video calling application with a minimal feature set, focusing on the essential functionality of connecting two users in a room.
* **Peer-to-Peer Communication:** To leverage WebRTC to establish direct P2P media connections between users. This reduces server overhead as media data does not need to be relayed through the server (except for initial signaling and NAT traversal assistance), potentially lowering latency and improving privacy.
* **Open Web Technologies:** To build the application using standard and open web technologies like HTML5, CSS3, JavaScript, PHP, and WebSockets, ensuring broad browser compatibility and avoiding the need for users to install additional software.
* **Learning and Demonstration:** To serve as a practical example of implementing a WebRTC-based video calling application, demonstrating the integration of frontend WebRTC APIs with a backend signaling server (PHP/Ratchet) and database (MySQL).
* **Ease of Deployment:** To use Docker containerization to package the application and its dependencies, making it easy for others to set up, run, and develop further.
The "Call Room" project provides a foundational platform for P2P video communication, highlighting how these technologies can be combined to create effective real-time interaction experiences.
**1.3 Operation Environment**
To successfully develop, deploy, and run the "Call Room" application, specific hardware and software environments are required.
**1.3.1 Hardware Requirements (Recommended Minimum):**
* **Processor:** Intel Core i3 or equivalent / AMD Ryzen 3 or equivalent.
* **Memory (RAM):** 4 GB RAM (8 GB recommended for smoother development, especially when running Docker).
* **Storage:**
* For Development: Approximately 1-2 GB free disk space (for Docker images, source code, dependencies).
* For Running Application: Approximately 500MB for containers and database.
* **Peripherals:**
* Webcam (for video input).
* Microphone (for audio input).
* Speakers/Headphones (for audio output).
* **Network:** A stable internet connection is required for downloading dependencies, Docker images, and for users to connect to each other (especially for NAT traversal).
**1.3.2 Software Requirements (For Development & Manual Setup):**
* **Operating System:** Windows, macOS, or Linux.
* **Web Browser:** A modern web browser with WebRTC support (e.g., Google Chrome, Mozilla Firefox, Safari, Microsoft Edge).
* **PHP:** Version 8.1 or newer (as specified in `code/dockerfile`), with `mysqli` extension.
* **Composer:** PHP dependency manager.
* **MySQL Server:** For database management.
* **Web Server (for manual setup):** Nginx, Apache, or PHP's built-in server for development.
* **Command Line Interface / Terminal:** For running commands.
* **Text Editor / IDE:** For code editing (e.g., VS Code, PhpStorm, Sublime Text).
* **Git:** For version control (optional, but recommended for managing code).
* **(Optional but Recommended for Development) Docker Desktop:** For building and running Docker containers locally. Includes Docker Engine and Docker Compose.
**1.3.3 Software Requirements (For Dockerized Deployment - Recommended):**
* **Operating System:** Any OS that can run Docker (Windows, macOS, Linux).
* **Docker Engine:** The core Docker platform.
* **Docker Compose:** Tool for defining and running multi-container Docker applications.
* **Web Browser:** A modern web browser with WebRTC support for accessing the application.
The Dockerized setup is recommended as it encapsulates all necessary software dependencies (PHP, Nginx, MySQL, Ratchet and its dependencies) within containers, simplifying the deployment process significantly.
-----------------------------------------------------------------------------------------------
-- CHAPTER 2: SYSTEM ANALYSIS --
-----------------------------------------------------------------------------------------------
CHAPTER 2: SYSTEM ANALYSIS
This chapter delves into the analysis of the "Call Room" system. It includes the Software Requirement Specification (SRS) detailing functional and non-functional requirements, a comparison between general existing systems and the proposed "Call Room" system, and a list of software tools and technologies utilized in the project.
**2.1 Software Requirement Specification (SRS)**
The Software Requirement Specification outlines what the "Call Room" application is expected to do.
**2.1.1 Functional Requirements:**
The system shall provide the following functionalities:
1. **Room Creation/Joining:**
* FR1.1: Users must be able to specify a room name on the home page (`index.html`).
* FR1.2: Upon submitting a room name, the user shall be redirected to the specific room page (`/room/index.php`).
2. **User Pairing:**
* FR2.1: The WebSocket server (`WsHandler.php`, `RoomHandler.php`) must establish a connection with clients joining a room.
* FR2.2: The `RoomHandler` shall check the MySQL `room` table if another user is already waiting in the same `room_id`.
* FR2.3: If a user is found waiting, the system shall "pair" the new user with the waiting user.
* FR2.4: The server shall send a `paired` message to both clients, indicating the `resourceId` of their peer.
* FR2.5: The first user to join the room (or the one designated by the server) shall be marked as the "polite" peer for WebRTC negotiation.
* FR2.6: If no user is found waiting, the current user's `client_id` (WebSocket `resourceId`) and `room_id` shall be added to the `room` table.
* FR2.7: The `RoomHandler` should remove the first user (who was waiting) from the `room` table once a pair is formed to allow new pairs for the same room name in the future (though the current implementation is for 2 participants at a time per instance).
3. **Media Stream Access:**
* FR3.1: The application (`stream.js`) must request access to the user's camera and microphone using `navigator.mediaDevices.getUserMedia`.
* FR3.2: The local video stream must be displayed in the `localVideo` HTML element on the room page.
4. **WebRTC Signaling and Connection:**
* FR4.1: Once paired, clients (`makeCall.js`) shall initiate the WebRTC peer connection process (`pc.js`).
* FR4.2: WebRTC signaling messages (SDP offers, SDP answers, ICE candidates) must be exchanged between peers via the WebSocket server.
* FR4.3: Signaling messages sent via WebSocket must include a `to` field specifying the `resourceId` of the recipient peer.
* FR4.4: The "polite" peer logic must handle offer collisions gracefully during negotiation.
* FR4.5: ICE (Interactive Connectivity Establishment) candidates shall be gathered and exchanged to facilitate NAT traversal.
* FR4.6: The system should use a STUN server (configurable in `pc.js`, e.g., `stun:stun.l.google.com:19302`) to discover public IP addresses and assist in NAT traversal.
5. **Peer-to-Peer Media Streaming:**
* FR5.1: Upon successful WebRTC signaling and connection establishment, a direct peer-to-peer media stream (video and audio) shall be established between the two clients.
* FR5.2: The remote user's video stream shall be displayed in the `remoteVideo` HTML element on the room page.
6. **Call Termination:**
* FR6.1: Users must be able to end the call by clicking an "End Call" button (which redirects to home) or by closing the browser tab/window.
* FR6.2: When a call is ended or the browser is closed (`beforeunload` event), a message (`endCall`) shall be sent to the peer via WebSocket to notify them.
* FR6.3: The `RTCPeerConnection` and WebSocket connection shall be closed on call termination.
* FR6.4: Users shall be redirected to a "Call Ended" page (`/call-ended/index.html`) if explicitly ended from the UI using this mechanism.
7. **Database Interaction:**
* FR7.1: The `Db.php` script must provide a function to establish a connection to the MySQL database.
* FR7.2: The `RoomHandler.php` script must interact with the `room` table to add users, find pairs, and remove users.
**2.1.2 Non-Functional Requirements:**
* **NFR1. Performance:**
* The system should establish P2P connections with minimal delay after pairing.
* Video and audio streaming should be real-time with low latency, primarily dependent on the network conditions of the peers.
* WebSocket signaling messages should be delivered promptly.
* **NFR2. Usability:**
* The user interface should be simple and intuitive, allowing users to easily enter a room name and join/start a call.
* Visual feedback should be provided (e.g., local video display, remote video display upon connection).
* **NFR3. Reliability:**
* The WebRTC negotiation process, including polite/impolite peer logic, should be robust to minimize connection failures.
* The WebSocket server should maintain stable connections during a call session.
* The database connection should be handled gracefully.
* **NFR4. Scalability (Limited by Design):**
* The current design is for two participants per room instance.
* The WebSocket server (Ratchet) should be capable of handling multiple concurrent rooms and connections, limited by server resources.
* The database is used for transient pairing data, so it's not a heavy transactional load system.
* **NFR5. Security:**
* WebRTC media streams are encrypted end-to-end by default (SRTP).
* Signaling messages via WebSocket are sent over WSS (WebSocket Secure) if the main site is on HTTPS. The provided Nginx configuration listens on HTTP (port 80), so signaling would be over WS unless HTTPS is configured. The `makeCall.js` checks `location.protocol` to use `ws` or `wss`.
* Database credentials should be securely managed (currently in `Db.php` and `docker-compose.dev.yml`).
* **NFR6. Maintainability:**
* The codebase is structured into frontend (HTML, CSS, JS) and backend (PHP) components.
* JavaScript code is modularized (e.g., `pc.js`, `stream.js`, `makeCall.js`).
* PHP code uses PSR-4 autoloading for namespaces (`App\\`).
* Configuration parameters (like STUN server, DB credentials) are identifiable.
* **NFR7. Portability & Deployability:**
* The application is containerized using Docker and Docker Compose, allowing it to run consistently across different environments that support Docker.
* Manual setup instructions are also provided for environments without Docker.
* **NFR8. Browser Compatibility:**
* The application should function correctly on modern web browsers that support WebRTC, `getUserMedia`, and ES6 JavaScript modules (e.g., latest versions of Chrome, Firefox, Edge, Safari).
**2.2 Existing System vs. Proposed System**
This section compares the general characteristics of typical existing video communication systems with the "Call Room" application.
**2.2.1 Existing System (General Characteristics):**
Many existing video communication solutions often exhibit one or more of the following characteristics:
* **Centralized Media Relaying:** Often route audio and video data through central servers (MCU/SFU), which can handle multi-party calls but may introduce latency and increase operational costs.
* **Proprietary Software/Plugins:** Some older or specialized systems require users to install browser plugins or dedicated desktop applications.
* **Complex Feature Sets:** May offer a wide array of features beyond simple video calling, such as screen sharing, recording, chat, user accounts, and extensive management tools, which can make them feel heavy for simple use cases.
* **Account Requirements:** Frequently require users to create accounts and log in before use.
* **Higher Resource Consumption:** Both client-side and server-side resource usage can be higher due to complex features or media processing.
* **Cost Factor:** Commercial solutions often involve subscription fees or licensing costs.
**2.2.2 Proposed System (Call Room):**
The "Call Room" application is designed with a different philosophy, emphasizing:
* **Peer-to-Peer Media:** Leverages WebRTC for direct P2P media streams between the two participants, reducing server load for media and potentially lowering latency. The server is only involved in signaling.
* **Browser-Based & Plugin-Free:** Works directly in modern web browsers supporting WebRTC without requiring any additional installations.
* **Lightweight & Focused:** Provides a core, simple two-party video calling functionality without an extensive list of peripheral features.
* **No Account System (Implicit):** Users join rooms by name without explicit account creation. User identification for pairing is via WebSocket connection resource IDs, and `localStorage` can be used for a username but it's not a formal account system.
* **Simplified Deployment:** Docker containerization makes it easy to deploy and run all components (web server, PHP application, WebSocket server, database).
* **Open Source Stack:** Built entirely using open-source technologies (PHP, JavaScript, WebRTC, Ratchet, MySQL, Nginx, Docker).
* **Educational Value:** The simpler codebase and architecture make it easier to understand the fundamentals of WebRTC and signaling.
* **Reusable Rooms:** The concept of rooms allows for easy ad-hoc call setup.
**2.3 Software Tools Used**
The development and operation of the "Call Room" project rely on the following software tools and technologies:
* **Frontend Development:**
* **HTML5:** For structuring the web pages (`index.html`, `room/index.php`, `call-ended/index.html`).
* **CSS3:** For styling the user interface (`assets/main.css`), featuring a custom retro theme.
* **JavaScript (ES6 Modules):** For client-side logic, DOM manipulation, and WebRTC implementation (`room/js/makeCall.js`, `room/js/pc.js`, `room/js/stream.js`).
* **WebRTC API:** Browser API for real-time peer-to-peer communication (video, audio).
* **Backend Development:**
* **PHP:** Server-side scripting language (Version 8.1.0 as per `code/dockerfile`) used for the WebSocket server logic.
* **Ratchet:** A PHP library for asynchronously serving WebSockets, used to build the signaling server (`ws/Ws.php`, `ws/WsHandler.php`). (Version ^0.4.4 as per `composer.json`)
* **Composer:** A dependency manager for PHP, used to manage Ratchet and other PHP libraries.
* **Database:**
* **MySQL:** Relational database management system used for storing temporary room and client information for pairing (`mysql/init.sql`, `ws/Db.php`). (Latest version used in `docker-compose.dev.yml`)
* **Web Server:**
* **Nginx:** High-performance web server used as a reverse proxy, for serving static files (HTML, CSS, JS) and PHP files via PHP-FPM (`nginx/default.conf`).
* **Containerization:**
* **Docker:** Platform for developing, shipping, and running applications in containers.
* **Docker Compose:** Tool for defining and running multi-container Docker applications (`docker-compose.dev.yml`, `code/dockerfile`, `nginx/dockerfile`).
* **Version Control:**
* **Git:** Distributed version control system (implied by project structure and README mentioning `git clone`).
* **Development Environment & Utilities:**
* **Web Browser Developer Tools:** (e.g., Chrome DevTools, Firefox Developer Tools) for debugging JavaScript, inspecting network requests, and viewing console logs.
* **Terminal/Command Line Interface:** For executing Docker commands, PHP scripts, etc.
* **Text Editor/IDE:** (e.g., VSCode, Sublime Text, PhpStorm) for writing and editing code.
-----------------------------------------------------------------------------------------------
-- CHAPTER 3: SYSTEM DESIGN --
-----------------------------------------------------------------------------------------------
CHAPTER 3: SYSTEM DESIGN
This chapter outlines the design of the "Call Room" application, covering its overall architecture, database design, and data flow. The design focuses on creating a simple yet effective peer-to-peer video communication system.
**3.1 System Architecture**
The "Call Room" application employs a client-server architecture for signaling and a peer-to-peer architecture for media streaming. The main components are:
1. **Client (Web Browser):**
* **User Interface (HTML, CSS, JavaScript):** Provides the visual elements for users to enter room names, view local and remote video, and end calls.
* **WebRTC Engine:** Built into the browser, responsible for capturing media (camera/microphone), encoding/decoding, and establishing direct P2P connections.
* **Signaling Logic (JavaScript - `makeCall.js`):** Communicates with the WebSocket server to exchange control messages (room joining, pairing info, SDP offers/answers, ICE candidates) necessary for setting up the WebRTC connection.
2. **Web Server (Nginx):**
* Serves static frontend files (HTML, CSS, JS).
* Passes PHP requests to the PHP-FPM process (though PHP is primarily used for the WebSocket server in this project, `room/index.php` is a PHP file that could have server-side logic).
* Acts as a reverse proxy for WebSocket connections, forwarding `/ws` requests to the Ratchet WebSocket server.
3. **Application Server Components:**
* **PHP-FPM:** Processes PHP files (though primarily the WebSocket server runs as a separate PHP CLI process).
* **WebSocket Server (PHP Ratchet - `Ws.php`, `WsHandler.php`, `RoomHandler.php`):**
* Manages WebSocket connections from clients.
* Handles client pairing logic by interacting with the MySQL database.
* Relays signaling messages (SDP, ICE candidates) between paired clients.
4. **Database Server (MySQL):**
* Stores temporary information about rooms and clients waiting to be paired. The `room` table facilitates the discovery of a peer in the same room.
**Interaction Flow:**
* A user accesses the application via Nginx.
* The frontend JavaScript establishes a WebSocket connection to the Ratchet server (proxied by Nginx).
* The `RoomHandler` on the WebSocket server uses MySQL to find a pair or register the user as waiting.
* Once paired, signaling messages are exchanged via WebSocket.
* WebRTC establishes a direct P2P media connection between the clients.
Figure 3.1: Call Room System Architecture
Figure 3.2: E-R Diagram for `room` table
Figure 3.3: DFD Level 0 (Context Diagram)
Figure 3.4: DFD Level 1 (Detailed Diagram)
IMAGE PLACEHOLDER
Please insert a screenshot of the Home Page here.
(Description: Shows the initial page where the user enters the "Room Name". This corresponds to code/index.html.)
Figure 4.1: Home Page (User entering room name)
IMAGE PLACEHOLDER
Please insert a screenshot of the Call Page when a user has just joined and is waiting.
(Description: Shows the call interface (`code/room/index.php`) with the local video feed visible, but the remote video area is likely empty or showing a waiting indicator, before a peer connects.)
Figure 4.2: Call Page (Local Video visible, Waiting for Peer)
IMAGE PLACEHOLDER
Please insert a screenshot of the Call Page when two users are connected.
(Description: Shows the call interface (`code/room/index.php`) with both the local video feed and the remote peer's video feed visible.)
Figure 4.3: Call Page (Connected with Peer, Local and Remote Video)
IMAGE PLACEHOLDER
Please insert a screenshot of the Call Ended Page.
(Description: Shows the page displayed after a call is terminated, code/call-ended/index.html.)
Figure 4.4: Call Ended Page
IMAGE PLACEHOLDER
Please insert a screenshot of the `room` table structure in MySQL.
(Description: Shows the columns and data types of the `room` table, possibly from a tool like phpMyAdmin, DBeaver, or MySQL Workbench after running `mysql/init.sql`.)
Figure 4.5: Database `room` table structure