mirror of
https://github.com/Monibuca/plugin-webrtc.git
synced 2025-10-05 06:46:57 +08:00
增加英文readme
This commit is contained in:
76
README.en.md
Normal file
76
README.en.md
Normal file
@@ -0,0 +1,76 @@
|
||||
_[简体中文](https://github.com/Monibuca/plugin-webrtc) | English_
|
||||
# WebRTC Plugin
|
||||
|
||||
This plugin provides the functionality to stream videos to Monibuca through a web page and to play streams from Monibuca using WebRTC technology. It follows the WHIP specification.
|
||||
|
||||
## Plugin URL
|
||||
|
||||
https://github.com/Monibuca/plugin-webrtc
|
||||
|
||||
## Plugin Import
|
||||
|
||||
```go
|
||||
import ( _ "m7s.live/plugin/webrtc/v4" )
|
||||
```
|
||||
|
||||
## Default Configuration
|
||||
|
||||
```yaml
|
||||
webrtc:
|
||||
iceservers: []
|
||||
publicip: [] # can be an array or a single string (automatically converted to an array)
|
||||
port: tcp:9000 # can be a range of ports like udp:8000-9000 or a single port like udp:9000
|
||||
pli: 2s # 2s
|
||||
```
|
||||
|
||||
### ICE Server Configuration Format
|
||||
|
||||
```yaml
|
||||
webrtc:
|
||||
iceservers:
|
||||
- urls:
|
||||
- stun:stun.l.google.com:19302
|
||||
- turn:turn.example.org
|
||||
username: user
|
||||
credential: pass
|
||||
```
|
||||
|
||||
### Configuration for Local Testing
|
||||
|
||||
If testing locally, no change in configuration is required. However, if you are accessing it remotely, then you need to configure the public IP.
|
||||
|
||||
## Basic Principle
|
||||
|
||||
The exchange of SDP messages between the browser and Monibuca takes place and RTP packets are read or sent to stream videos.
|
||||
|
||||
## API
|
||||
|
||||
### Play address
|
||||
`/webrtc/play/[streamPath]`
|
||||
|
||||
Body: `SDP`
|
||||
|
||||
Content-Type: `application/sdp`
|
||||
|
||||
Response Body: `SDP`
|
||||
|
||||
### Push address
|
||||
|
||||
`/webrtc/push/[streamPath]`
|
||||
|
||||
Body: `SDP`
|
||||
|
||||
Content-Type: `application/sdp`
|
||||
|
||||
Response Body: `SDP`
|
||||
|
||||
### Push Test Page
|
||||
|
||||
`/webrtc/test/publish`
|
||||
|
||||
## WHIP
|
||||
|
||||
WebRTC-HTTP ingestion protocol
|
||||
A specification for the exchange of SDP messages between WebRTC clients.
|
||||
|
||||
[WHIP ietf](https://datatracker.ietf.org/doc/html/draft-ietf-wish-whip-02)
|
@@ -1,3 +1,4 @@
|
||||
_[English](https://github.com/Monibuca/plugin-webrtc/blob/v4/README.en.md) | 简体中文_
|
||||
# WebRTC 插件
|
||||
|
||||
提供通过网页发布视频到monibuca,以及从monibuca拉流通过webrtc进行播放的功能,遵循WHIP规范
|
||||
|
@@ -1,10 +1,13 @@
|
||||
package webrtc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/pion/rtcp"
|
||||
. "github.com/pion/webrtc/v3"
|
||||
"go.uber.org/zap"
|
||||
. "m7s.live/engine/v4"
|
||||
"m7s.live/engine/v4/codec"
|
||||
"m7s.live/engine/v4/track"
|
||||
@@ -53,14 +56,14 @@ func (suber *WebRTCSubscriber) OnEvent(event any) {
|
||||
case *track.Video:
|
||||
switch v.CodecID {
|
||||
case codec.CodecID_H264:
|
||||
pli := "420028"
|
||||
// pli = fmt.Sprintf("%x", v.GetDecoderConfiguration().Raw[0][1:4])
|
||||
// if !strings.Contains(suber.SDP, pli) {
|
||||
// list := reg_level.FindAllStringSubmatch(suber.SDP, -1)
|
||||
// if len(list) > 0 {
|
||||
// pli = list[0][1]
|
||||
// }
|
||||
// }
|
||||
pli := fmt.Sprintf("%x", v.SPS[1:4])
|
||||
// pli := "42001f"
|
||||
if !strings.Contains(suber.SDP, pli) {
|
||||
list := reg_level.FindAllStringSubmatch(suber.SDP, -1)
|
||||
if len(list) > 0 {
|
||||
pli = list[0][1]
|
||||
}
|
||||
}
|
||||
suber.videoTrack, _ = NewTrackLocalStaticRTP(RTPCodecCapability{MimeType: MimeTypeH264, SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=" + pli}, v.Name, suber.Subscriber.Stream.Path)
|
||||
case codec.CodecID_H265:
|
||||
// suber.videoTrack, _ = NewTrackLocalStaticRTP(RTPCodecCapability{MimeType: MimeTypeH265, SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=" + pli}, "video", suber.Subscriber.Stream.Path)
|
||||
@@ -114,6 +117,7 @@ func (suber *WebRTCSubscriber) OnEvent(event any) {
|
||||
}
|
||||
case VideoRTP:
|
||||
if suber.videoTrack != nil {
|
||||
suber.Trace("video rtp", zap.Any("packet", v.Packet.Header))
|
||||
suber.videoTrack.WriteRTP(v.Packet)
|
||||
} else if suber.DC != nil {
|
||||
suber.sendAvByDatachannel(9, &suber.VideoReader)
|
||||
|
Reference in New Issue
Block a user