mirror of
https://github.com/Monibuca/plugin-webrtc.git
synced 2025-10-04 22:42:44 +08:00
转码需求
This commit is contained in:
17
main.go
17
main.go
@@ -3,9 +3,6 @@ package webrtc
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pion/interceptor"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/rtp/codecs"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"regexp"
|
||||
@@ -14,6 +11,10 @@ import (
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/pion/interceptor"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/rtp/codecs"
|
||||
|
||||
"github.com/Monibuca/engine/v3"
|
||||
"github.com/Monibuca/plugin-webrtc/v3/webrtc"
|
||||
|
||||
@@ -83,7 +84,7 @@ func (wl *WaitList) Get(k string) *WebRTC {
|
||||
return wl.m[k]
|
||||
}
|
||||
func init() {
|
||||
pc:= engine.PluginConfig{
|
||||
pc := engine.PluginConfig{
|
||||
Config: &config,
|
||||
Name: "WebRTC",
|
||||
}
|
||||
@@ -329,6 +330,13 @@ func run() {
|
||||
}
|
||||
}()
|
||||
}
|
||||
if at == nil {
|
||||
engine.TriggerHook(engine.HOOK_REQUEST_TRANSAUDIO, &engine.TransCodeReq{
|
||||
Subscriber: &sub,
|
||||
RequestCodec: "pcma",
|
||||
})
|
||||
at = sub.WaitAudioTrack("pcma")
|
||||
}
|
||||
if at != nil {
|
||||
var audioTrack *TrackLocalStaticSample
|
||||
audioMimeType := MimeTypePCMA
|
||||
@@ -353,7 +361,6 @@ func run() {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if bytes, err := rtc.GetAnswer(); err == nil {
|
||||
w.Write(bytes)
|
||||
rtc.OnConnectionStateChange(func(pcs PeerConnectionState) {
|
||||
|
Reference in New Issue
Block a user