Browse Source

remove workaround for creating keys

pull/83/head
DKing 6 years ago
parent
commit
7dca40f9e6
  1. 10
      configure/channel.go
  2. 4
      protocol/httpopera/http_opera.go
  3. 1
      protocol/rtmp/rtmp.go

10
configure/channel.go

@ -2,16 +2,18 @@ package configure
import ( import (
"encoding/json" "encoding/json"
"flag"
"io/ioutil" "io/ioutil"
"log" "log"
"math/rand" "math/rand"
"sync" "sync"
"time" "time"
) )
var (
roomKeySaveFile = flag.String("keyFile", "room_keys.json", "path to save room keys")
)
const roomKeySaveFile = "room_keys.json" var RoomKeys = LoadRoomKey(*roomKeySaveFile)
var RoomKeys = LoadRoomKey(roomKeySaveFile)
var roomUpdated = false var roomUpdated = false
@ -21,7 +23,7 @@ func init() {
for { for {
time.Sleep(15 * time.Second) time.Sleep(15 * time.Second)
if roomUpdated { if roomUpdated {
RoomKeys.Save(roomKeySaveFile) RoomKeys.Save(*roomKeySaveFile)
roomUpdated = false roomUpdated = false
} }
} }

4
protocol/httpopera/http_opera.go

@ -89,7 +89,7 @@ func (s *Server) Serve(l net.Listener) error {
type stream struct { type stream struct {
Key string `json:"key"` Key string `json:"key"`
Url string `json:"url"` Url string `json:"url"`
StreamId uint32 `json:"stream_id"` StreamId uint32 `json:"-"` // hide
VideoTotalBytes uint64 `json:"video_total_bytes"` VideoTotalBytes uint64 `json:"video_total_bytes"`
VideoSpeed uint64 `json:"video_speed"` VideoSpeed uint64 `json:"video_speed"`
AudioTotalBytes uint64 `json:"audio_total_bytes"` AudioTotalBytes uint64 `json:"audio_total_bytes"`
@ -98,7 +98,7 @@ type stream struct {
type streams struct { type streams struct {
Publishers []stream `json:"publishers"` Publishers []stream `json:"publishers"`
Players []stream `json:"players"` Players []stream `json:"-"` // hide
} }
//http://127.0.0.1:8090/stat/livestat //http://127.0.0.1:8090/stat/livestat

1
protocol/rtmp/rtmp.go

@ -146,7 +146,6 @@ func (s *Server) handleConn(conn *core.Conn) error {
flvWriter := new(flv.FlvDvr) flvWriter := new(flv.FlvDvr)
s.handler.HandleWriter(flvWriter.GetWriter(reader.Info())) s.handler.HandleWriter(flvWriter.GetWriter(reader.Info()))
} else { } else {
configure.RoomKeys.GetKey(name) // set new key if this channel not exists
writer := NewVirWriter(connServer) writer := NewVirWriter(connServer)
log.Printf("new player: %+v", writer.Info()) log.Printf("new player: %+v", writer.Info())
s.handler.HandleWriter(writer) s.handler.HandleWriter(writer)

Loading…
Cancel
Save