mirror of
https://github.com/cnotch/ipchub.git
synced 2025-09-26 19:41:18 +08:00
update readme and move addr
This commit is contained in:
35
README.md
35
README.md
@@ -1,2 +1,35 @@
|
|||||||
# ipchub
|
# ipchub
|
||||||
一个小而美的流媒体服务器
|
一个小而美的流媒体服务器,即拷即用。
|
||||||
|
|
||||||
|
偶尔和前同事聊天,说到一些小的监控项目需要把IP摄像头集中管理,并提供html播放能力。闲来无事就试着开发一个打发时间,也作为学习 go 语言的一个实践。
|
||||||
|
|
||||||
|
在此之前没有流媒体经验,没有go语言项目开发经验。看了一些文档,参考了一些开源项目,主要包括:
|
||||||
|
+ [emitter](https://github.com/emitter-io/emitter) 学习多协议共享端口等网络编程技能
|
||||||
|
+ [EasyDarwin](https://github.com/EasyDarwin/EasyDarwin) 为加深对rtsp协议的理解
|
||||||
|
+ [seal](https://github.com/calabashdad/seal.git) rtmp/flv 相关协议学习及 hls 相关处理
|
||||||
|
|
||||||
|
## 做什么
|
||||||
|
摄像头集中、多级路由及h5播放
|
||||||
|
|
||||||
|
功能:
|
||||||
|
+ 流媒体源支持
|
||||||
|
+ RTSP拉流
|
||||||
|
+ RTSP推流
|
||||||
|
+ 流媒体消费支持
|
||||||
|
+ RTSP流
|
||||||
|
+ RTSP WEBSOCKET 代理
|
||||||
|
+ HTTP-FLV
|
||||||
|
+ WEBSOCKET-FLV
|
||||||
|
+ HTTP-HLS
|
||||||
|
+ 流媒体多级路由
|
||||||
|
+ 用户流媒体推拉权限管理
|
||||||
|
+ 业务系统集成API
|
||||||
|
|
||||||
|
## 不做什么
|
||||||
|
+ 不存储
|
||||||
|
+ 不转码
|
||||||
|
|
||||||
|
## 文档
|
||||||
|
+ [Quick Start](/docs/quickstart.md)
|
||||||
|
+ [Restful Api](/docs/apis.md)
|
||||||
|
+ [Server Config](/docs/config.md)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package utils
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@@ -11,7 +11,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/cnotch/ipchub/media"
|
"github.com/cnotch/ipchub/media"
|
||||||
"github.com/cnotch/ipchub/utils"
|
"github.com/cnotch/ipchub/network"
|
||||||
"github.com/cnotch/xlog"
|
"github.com/cnotch/xlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ func (proxy *multicastProxy) TTL() int {
|
|||||||
|
|
||||||
func (proxy *multicastProxy) SourceIP() string {
|
func (proxy *multicastProxy) SourceIP() string {
|
||||||
if len(proxy.sourceIP) == 0 {
|
if len(proxy.sourceIP) == 0 {
|
||||||
addrs := utils.GetLocalIP()
|
addrs := network.GetLocalIP()
|
||||||
if len(addrs) == 0 {
|
if len(addrs) == 0 {
|
||||||
proxy.sourceIP = "Unknown"
|
proxy.sourceIP = "Unknown"
|
||||||
} else {
|
} else {
|
||||||
|
@@ -18,6 +18,7 @@ import (
|
|||||||
|
|
||||||
"github.com/cnotch/ipchub/config"
|
"github.com/cnotch/ipchub/config"
|
||||||
"github.com/cnotch/ipchub/media"
|
"github.com/cnotch/ipchub/media"
|
||||||
|
"github.com/cnotch/ipchub/network"
|
||||||
"github.com/cnotch/ipchub/network/socket/buffered"
|
"github.com/cnotch/ipchub/network/socket/buffered"
|
||||||
"github.com/cnotch/ipchub/network/websocket"
|
"github.com/cnotch/ipchub/network/websocket"
|
||||||
"github.com/cnotch/ipchub/provider/auth"
|
"github.com/cnotch/ipchub/provider/auth"
|
||||||
@@ -113,7 +114,7 @@ func newSession(svr *Server, conn net.Conn) *Session {
|
|||||||
|
|
||||||
ipaddr, _ := address.Parse(conn.RemoteAddr().String(), 80)
|
ipaddr, _ := address.Parse(conn.RemoteAddr().String(), 80)
|
||||||
// 如果是本机IP,不验证;以便ffmpeg本机rtsp->rtmp
|
// 如果是本机IP,不验证;以便ffmpeg本机rtsp->rtmp
|
||||||
if utils.IsLocalhostIP(ipaddr.IP) {
|
if network.IsLocalhostIP(ipaddr.IP) {
|
||||||
session.authMode = auth.NoneAuth
|
session.authMode = auth.NoneAuth
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +440,7 @@ func (s *Session) onPlay(resp *Response, req *Request) (err error) {
|
|||||||
return s.response(resp)
|
return s.response(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
stream := media.GetOrCreate( s.path)
|
stream := media.GetOrCreate(s.path)
|
||||||
if stream == nil {
|
if stream == nil {
|
||||||
resp.StatusCode = StatusNotFound
|
resp.StatusCode = StatusNotFound
|
||||||
return s.response(resp)
|
return s.response(resp)
|
||||||
|
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/cnotch/ipchub/config"
|
"github.com/cnotch/ipchub/config"
|
||||||
"github.com/cnotch/ipchub/media"
|
"github.com/cnotch/ipchub/media"
|
||||||
|
"github.com/cnotch/ipchub/network"
|
||||||
"github.com/cnotch/ipchub/utils"
|
"github.com/cnotch/ipchub/utils"
|
||||||
"github.com/cnotch/xlog"
|
"github.com/cnotch/xlog"
|
||||||
)
|
)
|
||||||
@@ -255,7 +256,7 @@ func (s *Session) asUDPConsumer(stream *media.Stream, resp *Response) (err error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建udp连接
|
// 创建udp连接
|
||||||
err = c.prepareUDP(utils.GetIP(s.conn.RemoteAddr()), s.transport.ClientPorts)
|
err = c.prepareUDP(network.GetIP(s.conn.RemoteAddr()), s.transport.ClientPorts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp.StatusCode = StatusInternalServerError
|
resp.StatusCode = StatusInternalServerError
|
||||||
err = s.response(resp)
|
err = s.response(resp)
|
||||||
|
Reference in New Issue
Block a user