mirror of
https://github.com/cnotch/ipchub.git
synced 2025-09-26 19:41:18 +08:00
add log
This commit is contained in:
@@ -51,7 +51,7 @@ func (c *httpFlvConsumer) Close() (err error) {
|
||||
// ConsumeByHTTP 处理 http 方式访问流媒体
|
||||
func ConsumeByHTTP(logger *xlog.Logger, path string, addr string, w http.ResponseWriter) {
|
||||
logger = logger.With(xlog.Fields(
|
||||
xlog.F("path", path),
|
||||
xlog.F("path", path),xlog.F("ext", "flv"),
|
||||
xlog.F("addr", addr)))
|
||||
|
||||
stream := media.GetOrCreate(path)
|
||||
|
@@ -53,7 +53,7 @@ func (c *wsFlvConsumer) Type() string {
|
||||
// ConsumeByWebsocket 处理 websocket 方式访问流媒体
|
||||
func ConsumeByWebsocket(logger *xlog.Logger, path string, addr string, conn websocket.Conn) {
|
||||
logger = logger.With(xlog.Fields(
|
||||
xlog.F("path", path),
|
||||
xlog.F("path", path),xlog.F("ext", "flv"),
|
||||
xlog.F("addr", addr)))
|
||||
|
||||
stream := media.GetOrCreate(path)
|
||||
|
@@ -18,6 +18,12 @@ import (
|
||||
|
||||
// GetM3u8 .
|
||||
func GetM3u8(logger *xlog.Logger, path string, token string, addr string, w http.ResponseWriter) {
|
||||
logger = logger.With(xlog.Fields(
|
||||
xlog.F("path", path), xlog.F("ext", "m3u8"),
|
||||
xlog.F("addr", addr)))
|
||||
|
||||
logger.Info("http-hls: access playlist")
|
||||
|
||||
// 需要手动启动,如果需要转换或拉流,很耗时
|
||||
var c media.Hlsable
|
||||
s := media.GetOrCreate(path)
|
||||
@@ -64,6 +70,12 @@ func GetM3u8(logger *xlog.Logger, path string, token string, addr string, w http
|
||||
|
||||
// GetTS .
|
||||
func GetTS(logger *xlog.Logger, path string, addr string, w http.ResponseWriter) {
|
||||
logger = logger.With(xlog.Fields(
|
||||
xlog.F("path", path), xlog.F("ext", "ts"),
|
||||
xlog.F("addr", addr)))
|
||||
|
||||
logger.Info("http-hls: access segment file")
|
||||
|
||||
i := strings.LastIndex(path, "/")
|
||||
if i < 0 {
|
||||
logger.Errorf("http-hls: path illegal `%s`", path)
|
||||
|
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/cnotch/ipchub/provider/auth"
|
||||
"github.com/cnotch/ipchub/service/flv"
|
||||
"github.com/cnotch/ipchub/service/hls"
|
||||
"github.com/cnotch/xlog"
|
||||
|
||||
"github.com/cnotch/apirouter"
|
||||
"github.com/cnotch/ipchub/utils/scan"
|
||||
@@ -53,9 +52,6 @@ func (s *Service) onWebSocketRequest(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Service) onStreamsRequest(w http.ResponseWriter, r *http.Request) {
|
||||
// 获取文件后缀和流路径
|
||||
streamPath, ext := extractStreamPathAndExt(r.URL.Path)
|
||||
s.logger.Info("http access stream media.",
|
||||
xlog.F("path", streamPath),
|
||||
xlog.F("ext", ext))
|
||||
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
switch ext {
|
||||
|
Reference in New Issue
Block a user