mirror of
https://github.com/lkmio/lkm.git
synced 2025-09-26 19:21:14 +08:00
feat: 支持国标倍速播放
This commit is contained in:
9
api.go
9
api.go
@@ -131,10 +131,11 @@ func startApiServer(addr string) {
|
|||||||
apiServer.router.HandleFunc("/api/v1/streams/statistics", nil) // 统计所有推拉流
|
apiServer.router.HandleFunc("/api/v1/streams/statistics", nil) // 统计所有推拉流
|
||||||
|
|
||||||
if stream.AppConfig.GB28181.Enable {
|
if stream.AppConfig.GB28181.Enable {
|
||||||
apiServer.router.HandleFunc("/ws/v1/gb28181/talk", apiServer.OnGBTalk) // 对讲的主讲人WebSocket连接
|
apiServer.router.HandleFunc("/ws/v1/gb28181/talk", apiServer.OnGBTalk) // 对讲的主讲人WebSocket连接
|
||||||
apiServer.router.HandleFunc("/api/v1/control/ws-talk/{device}/{channel}", apiServer.OnGBTalk) // 对讲的主讲人WebSocket连接
|
apiServer.router.HandleFunc("/api/v1/control/ws-talk/{device}/{channel}", apiServer.OnGBTalk) // 对讲的主讲人WebSocket连接
|
||||||
apiServer.router.HandleFunc("/api/v1/gb28181/source/create", withJsonParams(apiServer.OnGBOfferCreate, &SourceSDP{}))
|
apiServer.router.HandleFunc("/api/v1/gb28181/source/create", withJsonParams(apiServer.OnGBOfferCreate, &SourceSDP{})) // 创建国标源
|
||||||
apiServer.router.HandleFunc("/api/v1/gb28181/answer/set", withJsonParams(apiServer.OnGBSourceConnect, &SourceSDP{})) // 应答的sdp, 如果是active模式拉流, 设置对方的地址. 下载文件设置文件大小
|
apiServer.router.HandleFunc("/api/v1/gb28181/answer/set", withJsonParams(apiServer.OnGBSourceConnect, &SourceSDP{})) // 设置应答sdp, 如果是active模式拉流, 设置对方的地址. 下载文件设置文件大小
|
||||||
|
apiServer.router.HandleFunc("/api/v1/gb28181/speed/set", withJsonParams(apiServer.OnGBSpeedSet, &SourceSDP{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
apiServer.router.HandleFunc("/api/v1/gc/force", func(writer http.ResponseWriter, request *http.Request) {
|
apiServer.router.HandleFunc("/api/v1/gc/force", func(writer http.ResponseWriter, request *http.Request) {
|
||||||
|
33
api_gb.go
33
api_gb.go
@@ -24,20 +24,20 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SDP struct {
|
type SDP struct {
|
||||||
SessionName string `json:"session_name,omitempty"` // play/download/playback/talk/broadcast
|
SessionName string `json:"session_name,omitempty"` // play/download/playback/talk/broadcast
|
||||||
Addr string `json:"addr,omitempty"` // 连接地址
|
Addr string `json:"addr,omitempty"` // 连接地址
|
||||||
SSRC string `json:"ssrc,omitempty"`
|
SSRC string `json:"ssrc,omitempty"`
|
||||||
Setup string `json:"setup,omitempty"` // active/passive
|
Setup string `json:"setup,omitempty"` // active/passive
|
||||||
Transport string `json:"transport,omitempty"` // tcp/udp
|
Transport string `json:"transport,omitempty"` // tcp/udp
|
||||||
Speed int `json:"speed,omitempty"`
|
Speed float64 `json:"speed,omitempty"`
|
||||||
StartTime int `json:"start_time,omitempty"`
|
StartTime int `json:"start_time,omitempty"`
|
||||||
EndTime int `json:"end_time,omitempty"`
|
EndTime int `json:"end_time,omitempty"`
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DownloadInfo struct {
|
type DownloadInfo struct {
|
||||||
PlaybackDuration int // 回放/下载时长
|
PlaybackDuration int // 回放/下载时长
|
||||||
PlaybackSpeed int // 回放/下载速度
|
PlaybackSpeed float64 // 回放/下载速度
|
||||||
PlaybackFileURL string // 回放/下载文件URL
|
PlaybackFileURL string // 回放/下载文件URL
|
||||||
PlaybackStartTime string // 回放/下载开始时间
|
PlaybackStartTime string // 回放/下载开始时间
|
||||||
PlaybackEndTime string // 回放/下载结束时间
|
PlaybackEndTime string // 回放/下载结束时间
|
||||||
@@ -370,3 +370,16 @@ func (api *ApiServer) OnLiveGBSTalk(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
talkSource.Close()
|
talkSource.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *ApiServer) OnGBSpeedSet(v *SourceSDP, w http.ResponseWriter, r *http.Request) {
|
||||||
|
source := stream.SourceManager.Find(v.Source)
|
||||||
|
if source == nil {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
httpResponseError(w, "stream not found")
|
||||||
|
} else if stream.SourceType28181 != source.GetType() {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
httpResponseError(w, "stream type not support")
|
||||||
|
} else if gbSource := Source2GBSource(source); gbSource != nil {
|
||||||
|
gbSource.SetSpeed(v.Speed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -80,7 +80,7 @@ type GBSource interface {
|
|||||||
SetTransport(transport transport.Transport)
|
SetTransport(transport transport.Transport)
|
||||||
|
|
||||||
GetDuration() int
|
GetDuration() int
|
||||||
GetSpeed() int
|
GetSpeed() float64
|
||||||
GetSessionName() string
|
GetSessionName() string
|
||||||
GetStartTime() string
|
GetStartTime() string
|
||||||
GetEndTime() string
|
GetEndTime() string
|
||||||
@@ -88,7 +88,7 @@ type GBSource interface {
|
|||||||
GetPlaybackProgress() float64
|
GetPlaybackProgress() float64
|
||||||
|
|
||||||
SetDuration(duration int)
|
SetDuration(duration int)
|
||||||
SetSpeed(speed int)
|
SetSpeed(speed float64)
|
||||||
SetSessionName(sessionName string)
|
SetSessionName(sessionName string)
|
||||||
SetStartTime(startTime string)
|
SetStartTime(startTime string)
|
||||||
SetEndTime(endTime string)
|
SetEndTime(endTime string)
|
||||||
@@ -112,7 +112,7 @@ type BaseGBSource struct {
|
|||||||
|
|
||||||
sessionName string // play/playback/download...
|
sessionName string // play/playback/download...
|
||||||
duration int // 回放/下载时长, 单位秒
|
duration int // 回放/下载时长, 单位秒
|
||||||
speed int // 回放/下载速度
|
speed float64 // 回放/下载速度
|
||||||
startTime string // 回放/下载开始时间
|
startTime string // 回放/下载开始时间
|
||||||
endTime string // 回放/下载结束时间
|
endTime string // 回放/下载结束时间
|
||||||
fileSize int // 回放/下载文件大小
|
fileSize int // 回放/下载文件大小
|
||||||
@@ -345,7 +345,7 @@ func (source *BaseGBSource) GetDuration() int {
|
|||||||
return source.duration
|
return source.duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (source *BaseGBSource) GetSpeed() int {
|
func (source *BaseGBSource) GetSpeed() float64 {
|
||||||
return source.speed
|
return source.speed
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ func (source *BaseGBSource) SetDuration(duration int) {
|
|||||||
source.duration = duration
|
source.duration = duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (source *BaseGBSource) SetSpeed(speed int) {
|
func (source *BaseGBSource) SetSpeed(speed float64) {
|
||||||
source.speed = speed
|
source.speed = speed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user