read and write publishing, check stream key validity (if dir exists)
This commit is contained in:
parent
f6e23abbaf
commit
579bf2e195
1 changed files with 25 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
||||||
package rtmp
|
package rtmp
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
func NegotiateConnect(chnk_wrp_ptr *ChunkWrapper) (bool) {
|
func NegotiateConnect(chnk_wrp_ptr *ChunkWrapper) (bool) {
|
||||||
if err := chnk_wrp_ptr.ReadPeerChunkSize(); err != nil {
|
if err := chnk_wrp_ptr.ReadPeerChunkSize(); err != nil {
|
||||||
|
@ -37,7 +40,28 @@ func CreateStream(chnk_wrp_ptr *ChunkWrapper) (bool) {
|
||||||
if err := chnk_wrp_ptr.WriteCreateStreamResponse(); err != nil {
|
if err := chnk_wrp_ptr.WriteCreateStreamResponse(); err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func PublishAsKey(chnk_wrp_ptr *ChunkWrapper) (bool) {
|
||||||
|
if err := chnk_wrp_ptr.ReadPublish(); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !check_stream_key(chnk_wrp_ptr.params.stream_key) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if err := chnk_wrp_ptr.WritePublishResponse(); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
p, _ := chnk_wrp_ptr.ReadChunk()
|
p, _ := chnk_wrp_ptr.ReadChunk()
|
||||||
fmt.Println(p)
|
fmt.Println(p)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func check_stream_key(stream_key string) (bool) {
|
||||||
|
base_dir, _ := os.UserHomeDir()
|
||||||
|
if fileinfo, err := os.Stat(base_dir + "/live/" + stream_key); err == nil && fileinfo.IsDir() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue