rtsp

package module
v3.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: MIT Imports: 21 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

RTSP插件

插件地址

github.com/Monibuca/plugin-rtsp

插件引入

import (
    _ "github.com/Monibuca/plugin-rtsp"
)

默认插件配置

[RTSP]
# 端口接收推流
ListenAddr = ":554"
Reconnect = true
[RTSP.AutoPullList]
"live/rtsp1" = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=1&subtype=1"
"live/rtsp2" = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=2&subtype=1"
  • ListenAddr是监听的地址
  • Reconnect 是否自动重连
  • RTSP.AutoPullList 可以配置多项,用于自动拉流,key是streamPath,value是远程rtsp地址
特殊功能

当自动拉流列表中当的streamPath为sub/xxx 这种形式的话,在gb28181的分屏显示时会优先采用rtsp流,已实现分屏观看子码流效果

插件功能

接收RTSP协议的推流

例如通过ffmpeg向m7s进行推流

ffmpeg -i **** rtsp://localhost/live/test

会在m7s内部形成一个名为live/test的流

从远程拉取rtsp到m7s中

可调用接口 /api/rtsp/pull?target=[RTSP地址]&streamPath=[流标识]

使用编程方式拉流

new(RTSPClient).PullStream("live/user1","rtsp://xxx.xxx.xxx.xxx/live/user1") 
罗列所有的rtsp协议的流

可调用接口 /api/rtsp/list

从m7s中拉取rtsp协议流

直接通过协议rtsp://xxx.xxx.xxx.xxx/live/user1 即可播放

h265 编码拉流尚未实现,敬请期待

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenRtsp

func ListenRtsp(addr string) error

func NewG711Track

func NewG711Track(payloadType uint8, law string) *gortsplib.Track
	return &gortsplib.Track{
		Media: &psdp.MediaDescription{
			MediaName: psdp.MediaName{
				Media:   "audio",
				Protos:  []string{"RTP", "AVP"},
				Formats: []string{typ},
			},
			Attributes: []psdp.Attribute{
				{
					Key: "rtpmap",
					Value: typ + " mpeg4-generic/" + strconv.FormatInt(int64(conf.SampleRate), 10) +
						"/" + strconv.FormatInt(int64(conf.ChannelCount), 10),
				},
				{
					Key: "fmtp",
					Value: typ + " profile-level-id=1; " +
						"mode=AAC-hbr; " +
						"sizelength=6; " +
						"indexlength=2; " +
						"indexdeltalength=2; " +
						"config=" + hex.EncodeToString(mpegConf),
				},
			},
		},
	}, nil
}

func NewH265Track

func NewH265Track(payloadType uint8, sprop [][]byte) *gortsplib.Track

Types

type AACPayloader

type AACPayloader struct{}

AACayloader payloads AAC packets

func (*AACPayloader) Payload

func (p *AACPayloader) Payload(mtu uint16, payload []byte) [][]byte

Payload fragments an AAC packet across one or more byte arrays

type H265Payloader

type H265Payloader struct{}

func (*H265Payloader) Payload

func (p *H265Payloader) Payload(mtu uint16, payload []byte) [][]byte

type RTSPClient

type RTSPClient struct {
	RTSPublisher
	Transport         gortsplib.Transport
	*gortsplib.Client `json:"-"`
}

func (*RTSPClient) PullStream

func (rtsp *RTSPClient) PullStream(streamPath string, rtspUrl string) (err error)

PullStream 从外部拉流

func (*RTSPClient) PushStream

func (rtsp *RTSPClient) PushStream(streamPath string, rtspUrl string) (err error)

type RTSPServer

type RTSPServer struct {
	sync.Map
}

接收RTSP推流:OnConnOpen->OnAnnounce->OnSetup->OnSessionOpen 接收RTSP拉流:OnConnOpen->OnDescribe->OnSetup->OnSessionOpen

func (*RTSPServer) OnAnnounce

called after receiving an ANNOUNCE request.

func (*RTSPServer) OnConnClose

func (sh *RTSPServer) OnConnClose(ctx *gortsplib.ServerHandlerOnConnCloseCtx)

called after a connection is closed.

func (*RTSPServer) OnConnOpen

func (sh *RTSPServer) OnConnOpen(ctx *gortsplib.ServerHandlerOnConnOpenCtx)

called after a connection is opened.

func (*RTSPServer) OnDescribe

called after receiving a DESCRIBE request.

func (*RTSPServer) OnPacketRTP

func (sh *RTSPServer) OnPacketRTP(ctx *gortsplib.ServerHandlerOnPacketRTPCtx)

called after receiving a frame.

func (*RTSPServer) OnPlay

called after receiving a PLAY request.

func (*RTSPServer) OnRecord

called after receiving a RECORD request.

func (*RTSPServer) OnSessionClose

func (sh *RTSPServer) OnSessionClose(ctx *gortsplib.ServerHandlerOnSessionCloseCtx)

called after a session is closed.

func (*RTSPServer) OnSessionOpen

func (sh *RTSPServer) OnSessionOpen(ctx *gortsplib.ServerHandlerOnSessionOpenCtx)

called after a session is opened.

func (*RTSPServer) OnSetup

called after receiving a SETUP request.

type RTSPSubscriber

type RTSPSubscriber struct {
	engine.Subscriber
	// contains filtered or unexported fields
}

type RTSPublisher

type RTSPublisher struct {
	*Stream `json:"-"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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