Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	www/apidoc/api_data.js
#	www/apidoc/api_data.json
#	www/apidoc/api_project.js
#	www/apidoc/api_project.json
#	www/css/index.24300558.css
#	www/index.html
  • Loading branch information
macbookpro committed Jan 6, 2019
2 parents 72bead0 + 9076981 commit 9810288
Show file tree
Hide file tree
Showing 15 changed files with 1,730 additions and 326 deletions.
15 changes: 13 additions & 2 deletions routers/streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package routers

import (
"fmt"
"github.com/EasyDarwin/EasyDarwin/models"
"github.com/penggy/EasyGoLib/db"
"log"
"net/http"
"strings"
"time"

"github.com/EasyDarwin/EasyDarwin/models"
"github.com/penggy/EasyGoLib/db"

"github.com/EasyDarwin/EasyDarwin/rtsp"
"github.com/gin-gonic/gin"
)
Expand All @@ -23,6 +24,7 @@ import (
* @apiName StreamStart
* @apiParam {String} url RTSP源地址
* @apiParam {String} [customPath] 转推时的推送PATH
* @apiParam {String=TCP,UDP} [transType=TCP] 拉流传输模式
* @apiParam {Number} [idleTimeout] 拉流时的超时时间
* @apiParam {Number} [heartbeatInterval] 拉流时的心跳间隔,毫秒为单位。如果心跳间隔不为0,那拉流时会向源地址以该间隔发送OPTION请求用来心跳保活
* @apiSuccess (200) {String} ID 拉流的ID。后续可以通过该ID来停止拉流
Expand All @@ -31,6 +33,7 @@ func (h *APIHandler) StreamStart(c *gin.Context) {
type Form struct {
URL string `form:"url" binding:"required"`
CustomPath string `form:"customPath"`
TransType string `form:"transType"`
IdleTimeout int `form:"idleTimeout"`
HeartbeatInterval int `form:"heartbeatInterval"`
}
Expand All @@ -53,6 +56,14 @@ func (h *APIHandler) StreamStart(c *gin.Context) {
form.CustomPath = "/" + form.CustomPath
}
client.CustomPath = form.CustomPath
switch strings.ToLower(form.TransType) {
case "udp":
client.TransType = rtsp.TRANS_TYPE_UDP
case "tcp":
fallthrough
default:
client.TransType = rtsp.TRANS_TYPE_TCP
}

pusher := rtsp.NewClientPusher(client)
if rtsp.GetServer().GetPusher(pusher.Path()) != nil {
Expand Down
Loading

0 comments on commit 9810288

Please sign in to comment.