90 lines
5.6 KiB
Markdown
90 lines
5.6 KiB
Markdown
|
|
# Requirements Document
|
|||
|
|
|
|||
|
|
## Introduction
|
|||
|
|
|
|||
|
|
本文档定义了一个基于 SRS(Simple Realtime Server)的个人直播系统的功能需求。该系统允许用户创建直播间、进行实时视频推流、观看直播内容,并提供基本的直播间管理功能。系统采用 SRS 作为核心流媒体服务器,支持 RTMP 推流和 HTTP-FLV/HLS 播放,具有高性能、低延迟的特点。
|
|||
|
|
|
|||
|
|
## Glossary
|
|||
|
|
|
|||
|
|
- **Live Streaming System(直播系统)**: 提供视频直播功能的完整系统,包含前端播放器、后端 API 服务和 SRS 流媒体服务
|
|||
|
|
- **SRS(Simple Realtime Server)**: 开源的高性能流媒体服务器,支持 RTMP、HLS、HTTP-FLV、WebRTC 等协议
|
|||
|
|
- **Streamer(主播)**: 创建直播间并推送视频流的用户
|
|||
|
|
- **Viewer(观众)**: 观看直播内容的用户
|
|||
|
|
- **Live Room(直播间)**: 主播进行直播的虚拟空间,包含标题、主播信息和直播状态
|
|||
|
|
- **Stream Key(推流密钥)**: 用于验证主播身份的唯一标识符
|
|||
|
|
- **RTMP(Real-Time Messaging Protocol)**: 用于主播推流的实时消息传输协议
|
|||
|
|
- **HTTP-FLV**: 基于 HTTP 的 FLV 流协议,延迟低于 HLS,适合实时直播
|
|||
|
|
- **HLS(HTTP Live Streaming)**: 基于 HTTP 的直播流协议,兼容性好但延迟较高
|
|||
|
|
- **SRS Callback**: SRS 的 HTTP 回调机制,用于通知业务服务器推流状态变化
|
|||
|
|
|
|||
|
|
## Requirements
|
|||
|
|
|
|||
|
|
### Requirement 1
|
|||
|
|
|
|||
|
|
**User Story:** As a streamer, I want to create a live room, so that I can start broadcasting my content to viewers.
|
|||
|
|
|
|||
|
|
#### Acceptance Criteria
|
|||
|
|
|
|||
|
|
1. WHEN a streamer submits a room creation request with title and streamer name, THE Live Streaming System SHALL create a new live room and return a unique stream key
|
|||
|
|
2. WHEN a live room is created, THE Live Streaming System SHALL initialize the room status as "offline"
|
|||
|
|
3. WHEN a streamer provides an empty title, THE Live Streaming System SHALL reject the creation request and return a validation error
|
|||
|
|
4. WHEN a live room is created, THE Live Streaming System SHALL store the room information including title, streamer name, stream key, and creation timestamp
|
|||
|
|
|
|||
|
|
### Requirement 2
|
|||
|
|
|
|||
|
|
**User Story:** As a streamer, I want to push my video stream to the server, so that viewers can watch my live content.
|
|||
|
|
|
|||
|
|
#### Acceptance Criteria
|
|||
|
|
|
|||
|
|
1. WHEN a streamer connects to the SRS RTMP endpoint with a valid stream key, THE SRS Server SHALL accept the connection and begin receiving the video stream
|
|||
|
|
2. WHEN SRS receives a publish event, THE SRS Server SHALL trigger an HTTP callback to notify the API service of the stream start
|
|||
|
|
3. WHEN the API service receives a publish callback, THE Live Streaming System SHALL update the corresponding room status to "live"
|
|||
|
|
4. WHEN SRS receives an unpublish event, THE SRS Server SHALL trigger an HTTP callback to notify the API service of the stream end
|
|||
|
|
5. WHEN the API service receives an unpublish callback, THE Live Streaming System SHALL update the room status to "offline"
|
|||
|
|
|
|||
|
|
### Requirement 3
|
|||
|
|
|
|||
|
|
**User Story:** As a viewer, I want to watch live streams, so that I can enjoy the content broadcasted by streamers.
|
|||
|
|
|
|||
|
|
#### Acceptance Criteria
|
|||
|
|
|
|||
|
|
1. WHEN a viewer requests to watch a live room, THE Live Streaming System SHALL provide both HTTP-FLV and HLS stream URLs for playback
|
|||
|
|
2. WHEN a viewer accesses an HTTP-FLV stream URL, THE Live Streaming System SHALL deliver the video with latency under 3 seconds
|
|||
|
|
3. WHEN a viewer accesses an HLS stream URL, THE Live Streaming System SHALL deliver the video with latency under 10 seconds
|
|||
|
|
4. WHEN a viewer attempts to watch an offline room, THE Live Streaming System SHALL display an appropriate offline message
|
|||
|
|
5. WHEN the stream quality changes, THE Live Streaming System SHALL continue playback without interruption
|
|||
|
|
|
|||
|
|
### Requirement 4
|
|||
|
|
|
|||
|
|
**User Story:** As a viewer, I want to browse available live rooms, so that I can discover content to watch.
|
|||
|
|
|
|||
|
|
#### Acceptance Criteria
|
|||
|
|
|
|||
|
|
1. WHEN a viewer requests the room list, THE Live Streaming System SHALL return all available rooms with their current status
|
|||
|
|
2. WHEN displaying the room list, THE Live Streaming System SHALL show room title, streamer name, and live status for each room
|
|||
|
|
3. WHEN a room's live status changes, THE Live Streaming System SHALL reflect the updated status within 5 seconds on subsequent requests
|
|||
|
|
4. WHEN no rooms exist, THE Live Streaming System SHALL return an empty list with appropriate messaging
|
|||
|
|
|
|||
|
|
### Requirement 5
|
|||
|
|
|
|||
|
|
**User Story:** As a system administrator, I want to deploy and configure SRS, so that the streaming service runs reliably.
|
|||
|
|
|
|||
|
|
#### Acceptance Criteria
|
|||
|
|
|
|||
|
|
1. WHEN deploying SRS, THE Live Streaming System SHALL use Docker for containerized deployment
|
|||
|
|
2. WHEN configuring SRS, THE Live Streaming System SHALL enable RTMP input on port 1935
|
|||
|
|
3. WHEN configuring SRS, THE Live Streaming System SHALL enable HTTP-FLV output on port 8080
|
|||
|
|
4. WHEN configuring SRS, THE Live Streaming System SHALL enable HLS output with 2-second segments
|
|||
|
|
5. WHEN configuring SRS, THE Live Streaming System SHALL set up HTTP callbacks for publish and unpublish events
|
|||
|
|
|
|||
|
|
### Requirement 6
|
|||
|
|
|
|||
|
|
**User Story:** As a user, I want a responsive web interface, so that I can access the live streaming platform from any device.
|
|||
|
|
|
|||
|
|
#### Acceptance Criteria
|
|||
|
|
|
|||
|
|
1. WHEN a user accesses the platform, THE Live Streaming System SHALL display a responsive interface that adapts to screen sizes from 320px to 1920px width
|
|||
|
|
2. WHEN a user interacts with the video player, THE Live Streaming System SHALL provide play, pause, and volume controls
|
|||
|
|
3. WHEN a user navigates between pages, THE Live Streaming System SHALL maintain smooth transitions without full page reloads
|
|||
|
|
4. WHEN the interface loads, THE Live Streaming System SHALL display the main content within 3 seconds on a standard broadband connection
|