Stream key not involved until publish stage, just check if proper command and app
This commit is contained in:
parent
3d7e00169b
commit
ca36226491
2 changed files with 18 additions and 38 deletions
|
@ -2,30 +2,31 @@ package amf
|
|||
|
||||
import "errors"
|
||||
|
||||
func (amf_obj_root AMFObj) ProcessConnect() (string, error) {
|
||||
err := errors.New("Bad AMF connect command")
|
||||
func (amf_obj_root AMFObj) ProcessConnect() (err error) {
|
||||
err = errors.New("Bad AMF connect command")
|
||||
if _, ok := amf_obj_root[0]; !ok {
|
||||
return "", err
|
||||
return
|
||||
} else if command_string, ok := amf_obj_root[0].(string); !ok || command_string != "connect" {
|
||||
return "", err
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok := amf_obj_root[1]; !ok {
|
||||
return "", err
|
||||
return
|
||||
} else if transac_id_float, ok := amf_obj_root[1].(float64); !ok || transac_id_float != 1.0 {
|
||||
return "", err
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok := amf_obj_root[2]; !ok {
|
||||
return "", err
|
||||
return
|
||||
} else if _, ok := amf_obj_root[2].(AMFObj); !ok {
|
||||
return "", err
|
||||
} else if _, ok := amf_obj_root[2].(AMFObj)["tcUrl"]; !ok {
|
||||
return "", err
|
||||
} else if tcUrl, ok := amf_obj_root[2].(AMFObj)["tcUrl"].(string); ok {
|
||||
return tcUrl, nil
|
||||
} else {
|
||||
return "", err
|
||||
return
|
||||
} else if _, ok := amf_obj_root[2].(AMFObj)["app"]; !ok {
|
||||
return
|
||||
} else if _, ok := amf_obj_root[2].(AMFObj)["app"].(string); !ok {
|
||||
return
|
||||
} else if amf_obj_root[2].(AMFObj)["app"].(string) != "live" {
|
||||
return
|
||||
}
|
||||
|
||||
err = nil
|
||||
return
|
||||
}
|
||||
|
|
|
@ -4,10 +4,6 @@ import (
|
|||
"net"
|
||||
"encoding/binary"
|
||||
"stream_server/rtmp/amf"
|
||||
"errors"
|
||||
"strings"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type ChunkWrapper struct {
|
||||
|
@ -70,27 +66,10 @@ func (chnk_wrp_ptr *ChunkWrapper) ReadConnectCommand() (error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tcUrl, err := amf_obj.ProcessConnect()
|
||||
err = amf_obj.ProcessConnect()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if chnk_wrp_ptr.params.stream_key, err = check_stream_key(tcUrl); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func check_stream_key(tcUrl string) (string, error) {
|
||||
err := errors.New("bad stream key")
|
||||
tcUrl_split := strings.Split(tcUrl, "/")
|
||||
if len(tcUrl_split) != 5 {
|
||||
return "", err
|
||||
}
|
||||
base_dir, _ := os.UserHomeDir()
|
||||
stream_dir := base_dir + "/live/" + tcUrl_split[4]
|
||||
fileinfo, err := os.Stat(stream_dir)
|
||||
if err == nil && fileinfo.IsDir() {
|
||||
return tcUrl_split[4], nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue