Total rework RTMP client

This commit is contained in:
Alexey Khit
2023-08-14 06:11:21 +03:00
parent 0b6fda2af5
commit 19c61e20c0
9 changed files with 507 additions and 216 deletions

View File

@@ -1,13 +1,15 @@
package rtmp
import (
"io"
"net/http"
"github.com/AlexxIT/go2rtc/internal/api"
"github.com/AlexxIT/go2rtc/internal/streams"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/flv"
"github.com/AlexxIT/go2rtc/pkg/rtmp"
"github.com/rs/zerolog/log"
"io"
"net/http"
)
func Init() {
@@ -17,14 +19,14 @@ func Init() {
}
func streamsHandle(url string) (core.Producer, error) {
conn := rtmp.NewClient(url)
if err := conn.Dial(); err != nil {
client, err := rtmp.Dial(url)
if err != nil {
return nil, err
}
if err := conn.Describe(); err != nil {
if err = client.Describe(); err != nil {
return nil, err
}
return conn, nil
return client, nil
}
func apiHandle(w http.ResponseWriter, r *http.Request) {
@@ -40,8 +42,7 @@ func apiHandle(w http.ResponseWriter, r *http.Request) {
return
}
res := &http.Response{Body: r.Body, Request: r}
client, err := rtmp.Accept(res)
client, err := flv.NewClient(r.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return