ps

package module
v4.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 27 Imported by: 5

README

简介

ps 插件主要用于接收MpegPS流, 公安部制定的GBT 28181标准广泛应用于安防领域,这个标准规定了传输的视音频数据要封装成PS流格式。PS格式(原名叫MPEG-PS)。 该插件用于GB28181插件的流接收解析,为GB28181插件提供TCP、UDP链接的服务。

插件地址

https://github.com/Monibuca/plugin-ps

使用方法

插件引入

import (  
  _ "m7s.live/plugin/ps/v4" 
)

配置插件

默认配置
ps:
  http: # 格式参考全局配置
  publish: # 格式参考全局配置
  subscribe: # 格式参考全局配置
  relaymode: 1 # 0:纯转发 1:转协议,不转发 2:转发并且转协议
配置 ps 插件
  • 通用配置( 默认继承全局配置)

通用配置具体功能参考 m7s 配置

ps:
  http: # 格式参考全局配置
  publish: # 格式参考全局配置
  subscribe: # 格式参考全局配置
  • 基础配置
ps:
  relaymode: 1 # 0:纯转发 1:转协议,不转发 2:转发并且转协议

relaymode 根据使用需要进行配置

ps:
  relaymode: 0

以上配置后,为【纯转发】,当只需要获取ps流,不需要进行对PS流进行转协议时配置,m7s将不对流进行缓存、重排等一系列操作,因此延时更低。 应用场景举例: 1、只需要GB级联; 2、只需要拉取GB裸流; 需要注意: 因为没有对流进行转协议,所以其他播放流的组件将不能播放;

ps:
  relaymode: 1

以上配置后,为【转协议,不转发】,当不需要获取ps流,只需要播放流的时候配置,m7s将不对ps流进行保留。 需要注意: 因为m7s没有对PS流进行保留,API中对PS流的读取接收操作将不能正常使用。

ps:
  relaymode: 2

以上配置后,为【转发并且转协议】,m7s将保留PS流的同时对PS流进行协议解析,将占用更大的资源。 需要注意: 当急需要对PS流进行播放,同时有需要使用GB级联时,必须将配置设为【转发并且转协议】。

API

接收PS流

/ps/api/receive?streamPath=xxx&ssrc=xxx&port=xxx&reuse=1&dump=xxx 其中:

  • reuse代表是否端口复用,如果使用端口复用,请务必确定设备发送的ssrc和ssrc参数一致,否则会出现混流的情况
  • dump代表是否dump到文件,如果dump到文件,会在当前目录下生成一个以dump为名的文件夹,文件夹下面是以streamPath参数值为名的文件,文件内容从端口收到的数据[4byte 内容长度][2byte 相对时间][内容]

回放PS的dump文件

/ps/api/replay?streamPath=xxx&dump=xxx

  • dump 代表需要回放的文件,默认是dump/ps
  • streamPath 代表回放时生成的视频流的streamPath, 默认是replay/dump/ps (如果dump传了abc, 那么streamPath默认是replay/abc)

以ws协议读取PS流

ws://[host]/ps/[streamPath]

例如: ws://localhost:8080/ps/live/test

数据包含的是裸的PS数据,不包含rtp头

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PSPlugin = InstallPlugin(conf)

Functions

func Receive deprecated

func Receive(streamPath, dump, port string, ssrc uint32, reuse bool) (err error)

Deprecated: 请使用PSPublisher的Receive

Types

type MediaPort

type MediaPort struct {
	Protocol string
	Port     uint16
}

type PSConfig

type PSConfig struct {
	config.HTTP
	config.Publish
	config.Subscribe
	RelayMode int `desc:"转发模式" enum:"0:只转协议,1:只转发,2:转协议+转发"` // 转发模式,0:转协议+不转发,1:不转协议+转发,2:转协议+转发
	// contains filtered or unexported fields
}

func (*PSConfig) API_receive

func (c *PSConfig) API_receive(w http.ResponseWriter, r *http.Request)

收流

func (*PSConfig) API_replay

func (c *PSConfig) API_replay(w http.ResponseWriter, r *http.Request)

func (*PSConfig) OnEvent

func (c *PSConfig) OnEvent(event any)

func (*PSConfig) ServeHTTP added in v4.0.1

func (c *PSConfig) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*PSConfig) ServeTCP

func (c *PSConfig) ServeTCP(conn net.Conn)

func (*PSConfig) ServeUDP

func (c *PSConfig) ServeUDP(conn *net.UDPConn)

type PSPublisher

type PSPublisher struct {
	Publisher

	rtp.Packet     `json:"-" yaml:"-"`
	DisableReorder bool //是否禁用rtp重排序,TCP模式下应当禁用
	// mpegps.MpegPsStream `json:"-" yaml:"-"`
	// *mpegps.PSDemuxer `json:"-" yaml:"-"`
	mpegps.DecPSPackage `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

func (*PSPublisher) OnEvent

func (p *PSPublisher) OnEvent(event any)

func (*PSPublisher) OnFrame

func (p *PSPublisher) OnFrame(frame []byte, cid mpeg2.PS_STREAM_TYPE, pts uint64, dts uint64)

func (*PSPublisher) OnPacket

func (p *PSPublisher) OnPacket(pkg mpeg2.Display, decodeResult error)

func (*PSPublisher) PushPS

func (p *PSPublisher) PushPS(ps util.Buffer) (err error)

func (*PSPublisher) Receive added in v4.1.3

func (p *PSPublisher) Receive(streamPath, dump, port string, ssrc uint32, reuse bool) (err error)

func (*PSPublisher) ReceiveAudio

func (p *PSPublisher) ReceiveAudio(es mpegps.MpegPsEsStream)

func (*PSPublisher) ReceivePSM added in v4.0.1

func (p *PSPublisher) ReceivePSM(buf util.Buffer, hasAudio bool, hasVideo bool)

func (*PSPublisher) ReceiveVideo

func (p *PSPublisher) ReceiveVideo(es mpegps.MpegPsEsStream)

func (*PSPublisher) Replay

func (p *PSPublisher) Replay(f *os.File) (err error)

func (*PSPublisher) ServeTCP

func (p *PSPublisher) ServeTCP(conn net.Conn)

func (*PSPublisher) ServeUDP

func (p *PSPublisher) ServeUDP(conn *net.UDPConn)

type PSStream added in v4.1.0

type PSStream struct {
	Flag bool
	*PSPublisher
	net.Conn
}

type PSSubscriber added in v4.0.1

type PSSubscriber struct {
	Subscriber
}

func (*PSSubscriber) OnEvent added in v4.0.1

func (ps *PSSubscriber) OnEvent(event any)

type PSTrack added in v4.0.1

type PSTrack struct {
	track.RecycleData[*util.ListItem[util.Buffer]]
	PSM util.Buffer `json:"-" yaml:"-"`
}

func NewPSTrack added in v4.0.1

func NewPSTrack(s common.IStream) *PSTrack

func (*PSTrack) GetPSM added in v4.0.1

func (ps *PSTrack) GetPSM() (result net.Buffers)

type TCPRTP added in v4.1.0

type TCPRTP struct {
	net.Conn
}

func (*TCPRTP) Start added in v4.1.0

func (t *TCPRTP) Start(onRTP func(util.Buffer) error) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL