mirror of
				https://github.com/Monibuca/plugin-rtsp.git
				synced 2025-11-01 03:12:45 +08:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | f9f5966750 | ||
|   | 7ff13d89ce | 
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | |||||||
|  | .vscode | ||||||
|  | node_modules | ||||||
							
								
								
									
										96
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										96
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,81 +1,29 @@ | |||||||
| # RTSP插件 | # Monibuca 的RTSP 插件 | ||||||
| rtsp插件提供rtsp协议的推拉流能力,以及向远程服务器推拉rtsp协议的能力。 |  | ||||||
| ## 插件地址 |  | ||||||
|  |  | ||||||
| https://github.com/Monibuca/plugin-rtsp | 主要功能是提供RTSP的端口监听接受RTSP推流,以及对RTSP地址进行拉流转发 | ||||||
|  |  | ||||||
| ## 插件引入 | ## 插件名称 | ||||||
| ```go |  | ||||||
| import ( |  | ||||||
|     _ "m7s.live/plugin/rtsp/v4" |  | ||||||
| ) |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ## 推拉地址形式 |  | ||||||
| ``` |  | ||||||
| rtsp://localhost/live/test |  | ||||||
| ``` |  | ||||||
| - `localhost`是m7s的服务器域名或者IP地址,默认端口`554`可以不写,否则需要写 |  | ||||||
| - `live`代表`appName` |  | ||||||
| - `test`代表`streamName` |  | ||||||
| - m7s中`live/test`将作为`streamPath`为流的唯一标识 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 例如通过ffmpeg向m7s进行推流 |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| ffmpeg -i [视频源] -c:v h264 -f rtsp rtsp://localhost/live/test |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| 会在m7s内部形成一个名为live/test的流 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 如果m7s中已经存在live/test流的话就可以用rtsp协议进行播放 |  | ||||||
| ```bash |  | ||||||
| ffplay rtsp://localhost/live/test |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
|  | RTSP | ||||||
|  |  | ||||||
| ## 配置 | ## 配置 | ||||||
|  | ```toml | ||||||
| ```yaml | [RTSP] | ||||||
| rtsp: | ListenAddr  = ":554" | ||||||
|     publish: | BufferLength  = 2048 | ||||||
|         pubaudio: true | AutoPull     = false | ||||||
|         pubvideo: true | RemoteAddr   = "rtsp://localhost/${streamPath}" | ||||||
|         kickexist: false | [[RTSP.AutoPullList]] | ||||||
|         publishtimeout: 10 | URL = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=1&subtype=1" | ||||||
|         waitclosetimeout: 0 | StreamPath = "live/rtsp" | ||||||
|     subscribe: |  | ||||||
|         subaudio: true |  | ||||||
|         subvideo: true |  | ||||||
|         iframeonly: false |  | ||||||
|         waittimeout: 10 |  | ||||||
|     pull: |  | ||||||
|         repull: 0 |  | ||||||
|         pullonstart: {} |  | ||||||
|         pullonsub: {} |  | ||||||
|     push: |  | ||||||
|         repush: 0 |  | ||||||
|         pushlist: {} |  | ||||||
|     listenaddr: :554 |  | ||||||
|     udpaddr: :8000 |  | ||||||
|     rtcpaddr: :8001 |  | ||||||
|     readbuffersize: 2048 |  | ||||||
|     pullprotocol: 'auto' |  | ||||||
| ``` | ``` | ||||||
| :::tip 配置覆盖 | - ListenAddr 是监听端口,可以将rtsp流推到Monibuca中 | ||||||
| publish | - BufferLength是指解析拉取的rtp包的缓冲大小 | ||||||
| subscribe | - AutoPull是指当有用户订阅一个新流的时候自动向远程拉流转发 | ||||||
| 两项中未配置部分将使用全局配置 | - RemoteAddr 指远程拉流地址,其中${streamPath}是占位符,实际使用流路径替换。 | ||||||
| ::: | - AutoPullList 是一个数组,如果配置了该数组,则会在程序启动时自动启动拉流,StreamPath一定要是唯一的,不能重复 | ||||||
| ## API |  | ||||||
|  |  | ||||||
| ### `rtsp/api/list` | ## 使用方法(拉流转发) | ||||||
| 获取所有rtsp流 | ```go | ||||||
|  | new(RTSP).PullStream("live/user1","rtsp://xxx.xxx.xxx.xxx/live/user1")  | ||||||
| ### `rtsp/api/pull?target=[RTSP地址]&streamPath=[流标识]` | ``` | ||||||
| 从远程拉取rtsp到m7s中 |  | ||||||
|  |  | ||||||
| ### `rtsp/api/push?target=[RTSP地址]&streamPath=[流标识]` |  | ||||||
| 将本地的流推送到远端 |  | ||||||
							
								
								
									
										626
									
								
								client.go
									
									
									
									
									
								
							
							
						
						
									
										626
									
								
								client.go
									
									
									
									
									
								
							| @@ -1,147 +1,563 @@ | |||||||
| package rtsp | package rtsp | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"github.com/aler9/gortsplib" | 	"bufio" | ||||||
| 	"github.com/aler9/gortsplib/pkg/url" | 	"bytes" | ||||||
| 	"go.uber.org/zap" | 	"crypto/md5" | ||||||
| 	"m7s.live/engine/v4" | 	"encoding/base64" | ||||||
|  | 	"encoding/binary" | ||||||
|  | 	"errors" | ||||||
|  | 	"fmt" | ||||||
|  | 	"io" | ||||||
|  | 	"net" | ||||||
|  | 	"net/url" | ||||||
|  | 	"regexp" | ||||||
|  | 	"strconv" | ||||||
|  | 	"strings" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	. "github.com/Monibuca/engine/v2" | ||||||
|  | 	. "github.com/Monibuca/plugin-rtp" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type RTSPPuller struct { | // PullStream 从外部拉流 | ||||||
| 	RTSPPublisher | func (rtsp *RTSP) PullStream(streamPath string, rtspUrl string) (err error) { | ||||||
| 	engine.Puller | 	if result := rtsp.Publish(streamPath); result { | ||||||
| 	*gortsplib.Client `json:"-"` | 		rtsp.Stream.Type = "RTSP" | ||||||
| 	gortsplib.Transport | 		rtsp.RTSPInfo.StreamInfo = &rtsp.Stream.StreamInfo | ||||||
|  | 		rtsp.TransType = TRANS_TYPE_TCP | ||||||
|  | 		rtsp.vRTPChannel = 0 | ||||||
|  | 		rtsp.vRTPControlChannel = 1 | ||||||
|  | 		rtsp.aRTPChannel = 2 | ||||||
|  | 		rtsp.aRTPControlChannel = 3 | ||||||
|  | 		rtsp.URL = rtspUrl | ||||||
|  | 		rtsp.UDPServer = &UDPServer{Session: rtsp} | ||||||
|  | 		if err = rtsp.requestStream(); err != nil { | ||||||
|  | 			Println(err) | ||||||
|  | 			rtsp.Close() | ||||||
|  | 			return | ||||||
| 		} | 		} | ||||||
|  | 		go rtsp.startStream() | ||||||
|  | 		collection.Store(streamPath, rtsp) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	return errors.New("publish badname") | ||||||
|  | } | ||||||
|  | func DigestAuth(authLine string, method string, URL string) (string, error) { | ||||||
|  | 	l, err := url.Parse(URL) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return "", fmt.Errorf("Url parse error:%v,%v", URL, err) | ||||||
|  | 	} | ||||||
|  | 	realm := "" | ||||||
|  | 	nonce := "" | ||||||
|  | 	realmRex := regexp.MustCompile(`realm="(.*?)"`) | ||||||
|  | 	result1 := realmRex.FindStringSubmatch(authLine) | ||||||
|  |  | ||||||
| func (p *RTSPPuller) Connect() error { | 	nonceRex := regexp.MustCompile(`nonce="(.*?)"`) | ||||||
| 	switch rtspConfig.PullProtocol { | 	result2 := nonceRex.FindStringSubmatch(authLine) | ||||||
| 	case "tcp", "TCP": |  | ||||||
| 		p.Transport = gortsplib.TransportTCP | 	if len(result1) == 2 { | ||||||
| 	case "udp", "UDP": | 		realm = result1[1] | ||||||
| 		p.Transport = gortsplib.TransportUDP |  | ||||||
| 	default: |  | ||||||
| 		if p.Transport == gortsplib.TransportTCP { |  | ||||||
| 			p.Transport = gortsplib.TransportUDP |  | ||||||
| 	} else { | 	} else { | ||||||
| 			p.Transport = gortsplib.TransportTCP | 		return "", fmt.Errorf("auth error : no realm found") | ||||||
|  | 	} | ||||||
|  | 	if len(result2) == 2 { | ||||||
|  | 		nonce = result2[1] | ||||||
|  | 	} else { | ||||||
|  | 		return "", fmt.Errorf("auth error : no nonce found") | ||||||
|  | 	} | ||||||
|  | 	// response= md5(md5(username:realm:password):nonce:md5(public_method:url)); | ||||||
|  | 	username := l.User.Username() | ||||||
|  | 	password, _ := l.User.Password() | ||||||
|  | 	l.User = nil | ||||||
|  | 	if l.Port() == "" { | ||||||
|  | 		l.Host = fmt.Sprintf("%s:%s", l.Host, "554") | ||||||
|  | 	} | ||||||
|  | 	md5UserRealmPwd := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s:%s:%s", username, realm, password)))) | ||||||
|  | 	md5MethodURL := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s:%s", method, l.String())))) | ||||||
|  |  | ||||||
|  | 	response := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s:%s:%s", md5UserRealmPwd, nonce, md5MethodURL)))) | ||||||
|  | 	Authorization := fmt.Sprintf("Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\"", username, realm, nonce, l.String(), response) | ||||||
|  | 	return Authorization, nil | ||||||
|  | } | ||||||
|  | // auth Basic验证 | ||||||
|  | func BasicAuth(authLine string, method string, URL string) (string, error) { | ||||||
|  | 	l, err := url.Parse(URL) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return "", fmt.Errorf("Url parse error:%v,%v", URL, err) | ||||||
|  | 	} | ||||||
|  | 	username := l.User.Username() | ||||||
|  | 	password, _ := l.User.Password() | ||||||
|  | 	userAndpass := []byte(username + ":" + password) | ||||||
|  | 	Authorization := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString(userAndpass)) | ||||||
|  | 	return Authorization, nil | ||||||
|  | } | ||||||
|  | func (client *RTSP) checkAuth(method string, resp *Response) (string, error) { | ||||||
|  | 	if resp.StatusCode == 401 { | ||||||
|  | 		// need auth. | ||||||
|  | 		AuthHeaders := resp.Header["WWW-Authenticate"] | ||||||
|  | 		auths, ok := AuthHeaders.([]string) | ||||||
|  | 		if ok { | ||||||
|  | 			for _, authLine := range auths { | ||||||
|  | 				if strings.IndexAny(authLine, "Digest") == 0 { | ||||||
|  | 					// 					realm="HipcamRealServer", | ||||||
|  | 					// nonce="3b27a446bfa49b0c48c3edb83139543d" | ||||||
|  | 					client.authLine = authLine | ||||||
|  | 					return DigestAuth(authLine, method, client.URL) | ||||||
|  | 				} else if strings.IndexAny(authLine, "Basic") == 0 { | ||||||
|  | 					return BasicAuth(authLine, method, client.URL) | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 	p.Client = &gortsplib.Client{ | 			return "", fmt.Errorf("auth error") | ||||||
| 		OnPacketRTP: func(ctx *gortsplib.ClientOnPacketRTPCtx) { | 		} else { | ||||||
| 			if p.RTSPPublisher.Tracks[ctx.TrackID] != nil { | 			authLine, _ := AuthHeaders.(string) | ||||||
| 				p.RTSPPublisher.Tracks[ctx.TrackID].WriteRTPPack(ctx.Packet) | 			if strings.IndexAny(authLine, "Digest") == 0 { | ||||||
|  | 				client.authLine = authLine | ||||||
|  | 				return DigestAuth(authLine, method, client.URL) | ||||||
|  | 			} else if strings.IndexAny(authLine, "Basic") == 0 { | ||||||
|  | 				return BasicAuth(authLine, method, client.URL) | ||||||
| 			} | 			} | ||||||
| 		}, |  | ||||||
| 		ReadBufferCount: rtspConfig.ReadBufferSize, |  | ||||||
| 		Transport:       &p.Transport, |  | ||||||
| 		} | 		} | ||||||
| 	// parse URL | 	} | ||||||
| 	u, err := url.Parse(p.RemoteURL) | 	return "", nil | ||||||
|  | } | ||||||
|  | func (client *RTSP) requestStream() (err error) { | ||||||
|  | 	timeout := time.Duration(5) * time.Second | ||||||
|  | 	l, err := url.Parse(client.URL) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	// connect to the server | 	if strings.ToLower(l.Scheme) != "rtsp" { | ||||||
| 	if err = p.Client.Start(u.Scheme, u.Host); err != nil { | 		err = fmt.Errorf("RTSP url is invalid") | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	if strings.ToLower(l.Hostname()) == "" { | ||||||
|  | 		err = fmt.Errorf("RTSP url is invalid") | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	port := l.Port() | ||||||
|  | 	if len(port) == 0 { | ||||||
|  | 		port = "554" | ||||||
|  | 	} | ||||||
|  | 	conn, err := net.DialTimeout("tcp", l.Hostname()+":"+port, timeout) | ||||||
|  | 	if err != nil { | ||||||
|  | 		// handle error | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	networkBuffer := 204800 | ||||||
|  |  | ||||||
|  | 	timeoutConn := RichConn{ | ||||||
|  | 		conn, | ||||||
|  | 		timeout, | ||||||
|  | 	} | ||||||
|  | 	client.Conn = &timeoutConn | ||||||
|  | 	client.connRW = bufio.NewReadWriter(bufio.NewReaderSize(&timeoutConn, networkBuffer), bufio.NewWriterSize(&timeoutConn, networkBuffer)) | ||||||
|  |  | ||||||
|  | 	headers := make(map[string]string) | ||||||
|  | 	//headers["Require"] = "implicit-play" | ||||||
|  | 	// An OPTIONS request returns the request types the server will accept. | ||||||
|  | 	resp, err := client.Request("OPTIONS", headers) | ||||||
|  | 	if err != nil { | ||||||
|  | 		if resp != nil { | ||||||
|  | 			Authorization, _ := client.checkAuth("OPTIONS", resp) | ||||||
|  | 			if len(Authorization) > 0 { | ||||||
|  | 				headers := make(map[string]string) | ||||||
|  | 				headers["Require"] = "implicit-play" | ||||||
|  | 				headers["Authorization"] = Authorization | ||||||
|  | 				// An OPTIONS request returns the request types the server will accept. | ||||||
|  | 				resp, err = client.Request("OPTIONS", headers) | ||||||
|  | 			} | ||||||
|  | 			if err != nil { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  | 			return err | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// A DESCRIBE request includes an RTSP URL (rtsp://...), and the type of reply data that can be handled. This reply includes the presentation description, | ||||||
|  | 	// typically in Session Description Protocol (SDP) format. Among other things, the presentation description lists the media streams controlled with the aggregate URL. | ||||||
|  | 	// In the typical case, there is one media stream each for audio and video. | ||||||
|  | 	headers = make(map[string]string) | ||||||
|  | 	headers["Accept"] = "application/sdp" | ||||||
|  | 	resp, err = client.Request("DESCRIBE", headers) | ||||||
|  | 	if err != nil { | ||||||
|  | 		if resp != nil { | ||||||
|  | 			authorization, _ := client.checkAuth("DESCRIBE", resp) | ||||||
|  | 			if len(authorization) > 0 { | ||||||
|  | 				headers := make(map[string]string) | ||||||
|  | 				headers["Authorization"] = authorization | ||||||
|  | 				headers["Accept"] = "application/sdp" | ||||||
|  | 				resp, err = client.Request("DESCRIBE", headers) | ||||||
|  | 			} | ||||||
|  | 			if err != nil { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  | 			return err | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	client.SDPRaw = resp.Body | ||||||
|  | 	client.SDPMap = ParseSDP(client.SDPRaw) | ||||||
|  | 	client.VSdp, client.HasVideo = client.SDPMap["video"] | ||||||
|  | 	client.ASdp, client.HasAudio = client.SDPMap["audio"] | ||||||
|  | 	session := "" | ||||||
|  | 	otherChannel := 4 | ||||||
|  | 	for t, sdpInfo := range client.SDPMap { | ||||||
|  | 		headers = make(map[string]string) | ||||||
|  | 		if session != "" { | ||||||
|  | 			headers["Session"] = session | ||||||
|  | 		} | ||||||
|  | 		var _url = sdpInfo.Control | ||||||
|  | 		if !strings.HasPrefix(strings.ToLower(sdpInfo.Control), "rtsp://") { | ||||||
|  | 			_url = strings.TrimRight(client.URL, "/") + "/" + strings.TrimLeft(sdpInfo.Control, "/") | ||||||
|  | 		} | ||||||
|  | 		switch t { | ||||||
|  | 		case "video": | ||||||
|  | 			if len(sdpInfo.SpropParameterSets) > 1 { | ||||||
|  | 				client.WriteSPS(sdpInfo.SpropParameterSets[0]) | ||||||
|  | 				client.WritePPS(sdpInfo.SpropParameterSets[1]) | ||||||
|  | 			} | ||||||
|  | 			if client.TransType == TRANS_TYPE_TCP { | ||||||
|  | 				headers["Transport"] = fmt.Sprintf("RTP/AVP/TCP;unicast;interleaved=%d-%d", client.vRTPChannel, client.vRTPControlChannel) | ||||||
|  | 			} else { | ||||||
|  | 				//RTP/AVP;unicast;client_port=64864-64865 | ||||||
|  | 				if err = client.UDPServer.SetupVideo(); err != nil { | ||||||
|  | 					Printf("Setup video err.%v", err) | ||||||
|  | 					return err | ||||||
|  | 				} | ||||||
|  | 				headers["Transport"] = fmt.Sprintf("RTP/AVP/UDP;unicast;client_port=%d-%d", client.UDPServer.VPort, client.UDPServer.VControlPort) | ||||||
|  | 				client.Conn.timeout = 0 //	UDP ignore timeout | ||||||
|  | 			} | ||||||
|  | 		case "audio": | ||||||
|  | 			if len(sdpInfo.Config) > 0 { | ||||||
|  | 				client.WriteASC(sdpInfo.Config) | ||||||
|  | 			}else{ | ||||||
|  | 				client.setAudioFormat() | ||||||
|  | 			} | ||||||
|  | 			if client.TransType == TRANS_TYPE_TCP { | ||||||
|  | 				headers["Transport"] = fmt.Sprintf("RTP/AVP/TCP;unicast;interleaved=%d-%d", client.aRTPChannel, client.aRTPControlChannel) | ||||||
|  | 			} else { | ||||||
|  | 				if err = client.UDPServer.SetupAudio(); err != nil { | ||||||
|  | 					Printf("Setup audio err.%v", err) | ||||||
|  | 					return err | ||||||
|  | 				} | ||||||
|  | 				headers["Transport"] = fmt.Sprintf("RTP/AVP/UDP;unicast;client_port=%d-%d", client.UDPServer.APort, client.UDPServer.AControlPort) | ||||||
|  | 				client.Conn.timeout = 0 //	UDP ignore timeout | ||||||
|  | 			} | ||||||
|  | 		default: | ||||||
|  | 			if client.TransType == TRANS_TYPE_TCP { | ||||||
|  | 				headers["Transport"] = fmt.Sprintf("RTP/AVP/TCP;unicast;interleaved=%d-%d", otherChannel, otherChannel+1) | ||||||
|  | 				otherChannel += 2 | ||||||
|  | 			} else { | ||||||
|  | 				//TODO: UDP support | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		if resp, err = client.RequestWithPath("SETUP", _url, headers, true); err != nil { | ||||||
|  | 			return err | ||||||
|  | 		} | ||||||
|  | 		session, _ = resp.Header["Session"].(string) | ||||||
|  | 		session = strings.Split(session, ";")[0] | ||||||
|  | 	} | ||||||
|  | 	headers = make(map[string]string) | ||||||
|  | 	if session != "" { | ||||||
|  | 		headers["Session"] = session | ||||||
|  | 		client.Session = session | ||||||
|  | 	} | ||||||
|  | 	resp, err = client.Request("PLAY", headers) | ||||||
|  | 	return err | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (client *RTSP) startStream() { | ||||||
|  | 	startTime := time.Now() | ||||||
|  | 	//loggerTime := time.Now().Add(-10 * time.Second) | ||||||
|  | 	defer func() { | ||||||
|  | 		if client.Err() == nil && config.Reconnect { | ||||||
|  | 			Printf("reconnecting:%s", client.URL) | ||||||
|  | 			client.RTSPClientInfo = RTSPClientInfo{} | ||||||
|  | 			if err := client.requestStream(); err != nil { | ||||||
|  | 				t := time.NewTicker(time.Second * 5) | ||||||
|  | 				for { | ||||||
|  | 					Printf("reconnecting:%s in 5 seconds", client.URL) | ||||||
|  | 					select { | ||||||
|  | 					case <-client.Done(): | ||||||
|  | 						client.Stop() | ||||||
|  | 						return | ||||||
|  | 					case <-t.C: | ||||||
|  | 						if err = client.requestStream(); err == nil { | ||||||
|  | 							go client.startStream() | ||||||
|  | 							return | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} else { | ||||||
|  | 				go client.startStream() | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  | 			client.Stop() | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  | 	for client.Err() == nil { | ||||||
|  | 		if time.Since(startTime) > time.Minute { | ||||||
|  | 			startTime = time.Now() | ||||||
|  | 			headers := make(map[string]string) | ||||||
|  | 			headers["Require"] = "implicit-play" | ||||||
|  | 			// An OPTIONS request returns the request types the server will accept. | ||||||
|  | 			if err := client.RequestNoResp("GET_PARAMETER", headers); err != nil { | ||||||
|  | 				// ignore... | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		b, err := client.connRW.ReadByte() | ||||||
|  | 		if err != nil { | ||||||
|  | 			Printf("client.connRW.ReadByte err:%v", err) | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 		switch b { | ||||||
|  | 		case 0x24: // rtp | ||||||
|  | 			header := make([]byte, 4) | ||||||
|  | 			header[0] = b | ||||||
|  | 			_, err := io.ReadFull(client.connRW, header[1:]) | ||||||
|  | 			if err != nil { | ||||||
|  | 				Printf("io.ReadFull err:%v", err) | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 			channel := int(header[1]) | ||||||
|  | 			length := binary.BigEndian.Uint16(header[2:]) | ||||||
|  | 			content := make([]byte, length) | ||||||
|  | 			_, err = io.ReadFull(client.connRW, content) | ||||||
|  | 			if err != nil { | ||||||
|  | 				Printf("io.ReadFull err:%v", err) | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 			var pack *RTPPack | ||||||
|  |  | ||||||
|  | 			switch channel { | ||||||
|  | 			case client.aRTPChannel: | ||||||
|  | 				pack = &RTPPack{ | ||||||
|  | 					Type: RTP_TYPE_AUDIO, | ||||||
|  | 				} | ||||||
|  | 			case client.aRTPControlChannel: | ||||||
|  | 				pack = &RTPPack{ | ||||||
|  | 					Type: RTP_TYPE_AUDIOCONTROL, | ||||||
|  | 				} | ||||||
|  | 			case client.vRTPChannel: | ||||||
|  | 				pack = &RTPPack{ | ||||||
|  | 					Type: RTP_TYPE_VIDEO, | ||||||
|  | 				} | ||||||
|  | 			case client.vRTPControlChannel: | ||||||
|  | 				pack = &RTPPack{ | ||||||
|  | 					Type: RTP_TYPE_VIDEOCONTROL, | ||||||
|  | 				} | ||||||
|  | 			default: | ||||||
|  | 				Printf("unknow rtp pack type, channel:%v", channel) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 			pack.Unmarshal(content) | ||||||
|  | 			//if client.debugLogEnable { | ||||||
|  | 			//	rtp := ParseRTP(pack.Buffer) | ||||||
|  | 			//	if rtp != nil { | ||||||
|  | 			//		rtpSN := uint16(rtp.SequenceNumber) | ||||||
|  | 			//		if client.lastRtpSN != 0 && client.lastRtpSN+1 != rtpSN { | ||||||
|  | 			//			Printf("%s, %d packets lost, current SN=%d, last SN=%d\n", client.String(), rtpSN-client.lastRtpSN, rtpSN, client.lastRtpSN) | ||||||
|  | 			//		} | ||||||
|  | 			//		client.lastRtpSN = rtpSN | ||||||
|  | 			//	} | ||||||
|  | 			// | ||||||
|  | 			//	elapsed := time.Now().Sub(loggerTime) | ||||||
|  | 			//	if elapsed >= 30*time.Second { | ||||||
|  | 			//		Printf("%v read rtp frame.", client) | ||||||
|  | 			//		loggerTime = time.Now() | ||||||
|  | 			//	} | ||||||
|  | 			//} | ||||||
|  |  | ||||||
|  | 			client.InBytes += int(length + 4) | ||||||
|  | 			client.PushPack(pack) | ||||||
|  |  | ||||||
|  | 		default: // rtsp | ||||||
|  | 			builder := bytes.Buffer{} | ||||||
|  | 			builder.WriteByte(b) | ||||||
|  | 			contentLen := 0 | ||||||
|  | 			for client.Err() == nil { | ||||||
|  | 				line, prefix, err := client.connRW.ReadLine() | ||||||
|  | 				if err != nil { | ||||||
|  | 					Printf("client.connRW.ReadLine err:%v", err) | ||||||
|  | 					return | ||||||
|  | 				} | ||||||
|  | 				if len(line) == 0 { | ||||||
|  | 					if contentLen != 0 { | ||||||
|  | 						content := make([]byte, contentLen) | ||||||
|  | 						_, err = io.ReadFull(client.connRW, content) | ||||||
|  | 						if err != nil { | ||||||
|  | 							err = fmt.Errorf("Read content err.ContentLength:%d", contentLen) | ||||||
|  | 							return | ||||||
|  | 						} | ||||||
|  | 						builder.Write(content) | ||||||
|  | 					} | ||||||
|  | 					Printf("<<<[IN]\n%s", builder.String()) | ||||||
|  | 					break | ||||||
|  | 				} | ||||||
|  | 				s := string(line) | ||||||
|  | 				builder.Write(line) | ||||||
|  | 				if !prefix { | ||||||
|  | 					builder.WriteString("\r\n") | ||||||
|  | 				} | ||||||
|  |  | ||||||
|  | 				if strings.Index(s, "Content-Length:") == 0 { | ||||||
|  | 					splits := strings.Split(s, ":") | ||||||
|  | 					contentLen, err = strconv.Atoi(strings.TrimSpace(splits[1])) | ||||||
|  | 					if err != nil { | ||||||
|  | 						Printf("strconv.Atoi err:%v, str:%v", err, splits[1]) | ||||||
|  | 						return | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (client *RTSP) Request(method string, headers map[string]string) (*Response, error) { | ||||||
|  | 	l, err := url.Parse(client.URL) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, fmt.Errorf("Url parse error:%v", err) | ||||||
|  | 	} | ||||||
|  | 	l.User = nil | ||||||
|  | 	return client.RequestWithPath(method, l.String(), headers, true) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (client *RTSP) RequestNoResp(method string, headers map[string]string) (err error) { | ||||||
|  | 	l, err := url.Parse(client.URL) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return fmt.Errorf("Url parse error:%v", err) | ||||||
|  | 	} | ||||||
|  | 	l.User = nil | ||||||
|  | 	if _, err = client.RequestWithPath(method, l.String(), headers, false); err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	p.SetIO(p.Client) |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func (p *RTSPPuller) Pull() (err error) { | func (client *RTSP) RequestWithPath(method string, path string, headers map[string]string, needResp bool) (resp *Response, err error) { | ||||||
| 	u, _ := url.Parse(p.RemoteURL) | 	headers["User-Agent"] = client.Agent | ||||||
| 	if _, err = p.Options(u); err != nil { | 	if len(headers["Authorization"]) == 0 { | ||||||
| 		p.Error("Options", zap.Error(err)) | 		if len(client.authLine) != 0 { | ||||||
| 		return | 			Authorization, _ := DigestAuth(client.authLine, method, client.URL) | ||||||
|  | 			if len(Authorization) > 0 { | ||||||
|  | 				headers["Authorization"] = Authorization | ||||||
| 			} | 			} | ||||||
| 	// find published tracks | 		} | ||||||
| 	tracks, baseURL, _, err := p.Describe(u) | 	} | ||||||
|  | 	if len(client.Session) > 0 { | ||||||
|  | 		headers["Session"] = client.Session | ||||||
|  | 	} | ||||||
|  | 	client.Seq++ | ||||||
|  | 	cseq := client.Seq | ||||||
|  | 	builder := bytes.Buffer{} | ||||||
|  | 	builder.WriteString(fmt.Sprintf("%s %s RTSP/1.0\r\n", method, path)) | ||||||
|  | 	builder.WriteString(fmt.Sprintf("CSeq: %d\r\n", cseq)) | ||||||
|  | 	for k, v := range headers { | ||||||
|  | 		builder.WriteString(fmt.Sprintf("%s: %s\r\n", k, v)) | ||||||
|  | 	} | ||||||
|  | 	builder.WriteString(fmt.Sprintf("\r\n")) | ||||||
|  | 	s := builder.String() | ||||||
|  | 	Printf("[OUT]>>>\n%s", s) | ||||||
|  | 	_, err = client.connRW.WriteString(s) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		p.Error("Describe", zap.Error(err)) |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
| 	p.tracks = tracks |  | ||||||
| 	p.SetTracks() |  | ||||||
| 	if err = p.SetupAndPlay(tracks, baseURL); err != nil { |  | ||||||
| 		p.Error("SetupAndPlay", zap.Error(err)) |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
| 	p.Wait() |  | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | 	client.connRW.Flush() | ||||||
|  |  | ||||||
| type RTSPPusher struct { | 	if !needResp { | ||||||
| 	RTSPSubscriber | 		return nil, nil | ||||||
| 	engine.Pusher |  | ||||||
| 	*gortsplib.Client |  | ||||||
| 	gortsplib.Transport |  | ||||||
| 	} | 	} | ||||||
|  | 	lineCount := 0 | ||||||
|  | 	statusCode := 200 | ||||||
|  | 	status := "" | ||||||
|  | 	sid := "" | ||||||
|  | 	contentLen := 0 | ||||||
|  | 	respHeader := make(map[string]interface{}) | ||||||
|  | 	var line []byte | ||||||
|  | 	builder.Reset() | ||||||
|  | 	for { | ||||||
|  | 		isPrefix := false | ||||||
|  | 		if line, isPrefix, err = client.connRW.ReadLine(); err != nil { | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 		s := string(line) | ||||||
|  | 		builder.Write(line) | ||||||
|  | 		if !isPrefix { | ||||||
|  | 			builder.WriteString("\r\n") | ||||||
|  | 		} | ||||||
|  | 		if len(line) == 0 { | ||||||
|  | 			body := "" | ||||||
|  | 			if contentLen > 0 { | ||||||
|  | 				content := make([]byte, contentLen) | ||||||
|  | 				_, err = io.ReadFull(client.connRW, content) | ||||||
|  | 				if err != nil { | ||||||
|  | 					err = fmt.Errorf("Read content err.ContentLength:%d", contentLen) | ||||||
|  | 					return | ||||||
|  | 				} | ||||||
|  | 				body = string(content) | ||||||
|  | 				builder.Write(content) | ||||||
|  | 			} | ||||||
|  | 			resp = NewResponse(statusCode, status, strconv.Itoa(cseq), sid, body) | ||||||
|  | 			resp.Header = respHeader | ||||||
|  | 			Printf("<<<[IN]\n%s", builder.String()) | ||||||
|  |  | ||||||
| func (p *RTSPPusher) OnEvent(event any) { | 			if !(statusCode >= 200 && statusCode <= 300) { | ||||||
| 	switch v := event.(type) { | 				err = fmt.Errorf("Response StatusCode is :%d", statusCode) | ||||||
| 	case engine.VideoRTP: | 				return | ||||||
| 		p.Client.WritePacketRTP(p.videoTrackId, &v.Packet) |  | ||||||
| 	case engine.AudioRTP: |  | ||||||
| 		p.Client.WritePacketRTP(p.audioTrackId, &v.Packet) |  | ||||||
| 	default: |  | ||||||
| 		p.RTSPSubscriber.OnEvent(event) |  | ||||||
| 			} | 			} | ||||||
|  | 			return | ||||||
| 		} | 		} | ||||||
| func (p *RTSPPusher) Connect() error { | 		if lineCount == 0 { | ||||||
| 	if p.Transport == gortsplib.TransportTCP { | 			splits := strings.Split(s, " ") | ||||||
| 		p.Transport = gortsplib.TransportUDP | 			if len(splits) < 3 { | ||||||
|  | 				err = fmt.Errorf("StatusCode Line error:%s", s) | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 			statusCode, err = strconv.Atoi(splits[1]) | ||||||
|  | 			if err != nil { | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 			status = splits[2] | ||||||
|  | 		} | ||||||
|  | 		lineCount++ | ||||||
|  | 		splits := strings.Split(s, ":") | ||||||
|  | 		if len(splits) == 2 { | ||||||
|  | 			if val, ok := respHeader[splits[0]]; ok { | ||||||
|  | 				if slice, ok2 := val.([]string); ok2 { | ||||||
|  | 					slice = append(slice, strings.TrimSpace(splits[1])) | ||||||
|  | 					respHeader[splits[0]] = slice | ||||||
| 				} else { | 				} else { | ||||||
| 		p.Transport = gortsplib.TransportTCP | 					str, _ := val.(string) | ||||||
|  | 					slice := []string{str, strings.TrimSpace(splits[1])} | ||||||
|  | 					respHeader[splits[0]] = slice | ||||||
| 				} | 				} | ||||||
| 	p.Client = &gortsplib.Client{ | 			} else { | ||||||
| 		ReadBufferCount: rtspConfig.ReadBufferSize, | 				respHeader[splits[0]] = strings.TrimSpace(splits[1]) | ||||||
| 		Transport:       &p.Transport, |  | ||||||
| 			} | 			} | ||||||
| 	// parse URL |  | ||||||
| 	u, err := url.Parse(p.RemoteURL) |  | ||||||
| 	if err != nil { |  | ||||||
| 		p.Error("url.Parse", zap.Error(err)) |  | ||||||
| 		return err |  | ||||||
| 		} | 		} | ||||||
| 	// connect to the server | 		if strings.Index(s, "Session:") == 0 { | ||||||
| 	if err = p.Client.Start(u.Scheme, u.Host); err != nil { | 			splits := strings.Split(s, ":") | ||||||
| 		p.Error("Client.Start", zap.Error(err)) | 			sid = strings.TrimSpace(splits[1]) | ||||||
| 		return err |  | ||||||
| 		} | 		} | ||||||
| 	p.SetIO(p.Client) | 		//if strings.Index(s, "CSeq:") == 0 { | ||||||
| 	_, err = p.Client.Options(u) | 		//	splits := strings.Split(s, ":") | ||||||
| 	return err | 		//	cseq, err = strconv.Atoi(strings.TrimSpace(splits[1])) | ||||||
| } | 		//	if err != nil { | ||||||
| func (p *RTSPPusher) Push() (err error) { | 		//		err = fmt.Errorf("Atoi CSeq err. line:%s", s) | ||||||
| 	var u *url.URL | 		//		return | ||||||
| 	u, err = url.Parse(p.RemoteURL) |  | ||||||
| 	defer func() { |  | ||||||
| 		if err != nil { |  | ||||||
| 			p.Close() |  | ||||||
| 		} |  | ||||||
| 	}() |  | ||||||
| 	// startTime := time.Now() |  | ||||||
| 	// for len(p.tracks) < 2 { |  | ||||||
| 	// 	if time.Sleep(time.Second); time.Since(startTime) > time.Second*10 { |  | ||||||
| 	// 		return fmt.Errorf("timeout") |  | ||||||
| 		//	} | 		//	} | ||||||
| 		//} | 		//} | ||||||
| 	if _, err = p.Announce(u, p.tracks); err != nil { | 		if strings.Index(s, "Content-Length:") == 0 { | ||||||
| 		p.Error("Announce", zap.Error(err)) | 			splits := strings.Split(s, ":") | ||||||
| 		return | 			contentLen, err = strconv.Atoi(strings.TrimSpace(splits[1])) | ||||||
| 	} |  | ||||||
| 	for _, track := range p.tracks { |  | ||||||
| 		_, err = p.Setup(track, u, 0, 0) |  | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 			p.Error("Setup", zap.Error(err)) |  | ||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	if _, err = p.Record(); err != nil { |  | ||||||
| 		p.Error("Record", zap.Error(err)) | 	} | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
| 	p.PlayRTP() |  | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										51
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								go.mod
									
									
									
									
									
								
							| @@ -1,47 +1,14 @@ | |||||||
| module m7s.live/plugin/rtsp/v4 | module github.com/Monibuca/plugin-rtsp | ||||||
|  |  | ||||||
| go 1.18 | go 1.16 | ||||||
|  |  | ||||||
| require ( | require ( | ||||||
| 	github.com/aler9/gortsplib v0.0.0-20221115222755-87d5a512b129 | 	github.com/Monibuca/engine/v2 v2.4.0 | ||||||
| 	go.uber.org/zap v1.23.0 | 	github.com/Monibuca/plugin-rtp v1.0.0 | ||||||
| 	m7s.live/engine/v4 v4.9.5 |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| require ( |  | ||||||
| 	github.com/cnotch/ipchub v1.1.0 // indirect |  | ||||||
| 	github.com/go-ole/go-ole v1.2.6 // indirect |  | ||||||
| 	github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect |  | ||||||
| 	github.com/golang/mock v1.6.0 // indirect |  | ||||||
| 	github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect |  | ||||||
| 	github.com/google/uuid v1.3.0 // indirect |  | ||||||
| 	github.com/kr/text v0.2.0 // indirect |  | ||||||
| 	github.com/logrusorgru/aurora v2.0.3+incompatible // indirect | 	github.com/logrusorgru/aurora v2.0.3+incompatible // indirect | ||||||
| 	github.com/lucas-clemente/quic-go v0.31.0 // indirect | 	github.com/mattn/go-colorable v0.1.7 // indirect | ||||||
| 	github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect | 	github.com/pion/rtp v1.6.0 // indirect | ||||||
| 	github.com/marten-seemann/qtls-go1-18 v0.1.3 // indirect | 	github.com/shirou/gopsutil v2.20.7+incompatible // indirect | ||||||
| 	github.com/marten-seemann/qtls-go1-19 v0.1.1 // indirect | 	github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf | ||||||
| 	github.com/onsi/ginkgo/v2 v2.2.0 // indirect | 	golang.org/x/sys v0.0.0-20200828161417-c663848e9a16 // indirect | ||||||
| 	github.com/pion/randutil v0.1.0 // indirect |  | ||||||
| 	github.com/pion/rtcp v1.2.10 // indirect |  | ||||||
| 	github.com/pion/rtp v1.7.13 // indirect |  | ||||||
| 	github.com/pion/sdp/v3 v3.0.6 // indirect |  | ||||||
| 	github.com/pion/webrtc/v3 v3.1.49 // indirect |  | ||||||
| 	github.com/pkg/errors v0.9.1 // indirect |  | ||||||
| 	github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect |  | ||||||
| 	github.com/q191201771/naza v0.30.8 // indirect |  | ||||||
| 	github.com/shirou/gopsutil/v3 v3.22.10 // indirect |  | ||||||
| 	github.com/tklauser/go-sysconf v0.3.11 // indirect |  | ||||||
| 	github.com/tklauser/numcpus v0.6.0 // indirect |  | ||||||
| 	github.com/yusufpapurcu/wmi v1.2.2 // indirect |  | ||||||
| 	go.uber.org/atomic v1.10.0 // indirect |  | ||||||
| 	go.uber.org/multierr v1.8.0 // indirect |  | ||||||
| 	golang.org/x/crypto v0.3.0 // indirect |  | ||||||
| 	golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 // indirect |  | ||||||
| 	golang.org/x/mod v0.7.0 // indirect |  | ||||||
| 	golang.org/x/net v0.2.0 // indirect |  | ||||||
| 	golang.org/x/sync v0.1.0 // indirect |  | ||||||
| 	golang.org/x/sys v0.2.0 // indirect |  | ||||||
| 	golang.org/x/tools v0.3.0 // indirect |  | ||||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect |  | ||||||
| ) | ) | ||||||
|   | |||||||
							
								
								
									
										275
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										275
									
								
								go.sum
									
									
									
									
									
								
							| @@ -1,245 +1,52 @@ | |||||||
|  | github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= | ||||||
| github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | ||||||
| github.com/aler9/gortsplib v0.0.0-20221115222755-87d5a512b129 h1:CG96FPsxizdlpsRIsjU2xQR6G3QC0sPK+f+AeVEr0Tg= | github.com/Monibuca/engine/v2 v2.2.0/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc= | ||||||
| github.com/aler9/gortsplib v0.0.0-20221115222755-87d5a512b129/go.mod h1:BOWNZ/QBkY/eVcRqUzJbPFEsRJshwxaxBT01K260Jeo= | github.com/Monibuca/engine/v2 v2.4.0 h1:aa647MW5ToMdVQlB4nehfc3Vcos6752aLYRAkRnMLqo= | ||||||
| github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= | github.com/Monibuca/engine/v2 v2.4.0/go.mod h1:LBuAJFcTtUjVsGKWcUKQpIftRECf7Ii9DfuGWHL3Ngg= | ||||||
| github.com/cnotch/apirouter v0.0.0-20200731232942-89e243a791f3/go.mod h1:5deJPLON/x/s2dLOQfuKS0lenhOIT4xX0pvtN/OEIuY= | github.com/Monibuca/plugin-rtp v1.0.0 h1:yksNsIIGxoKX8UZirkAUK+mGZ/XoEeS2vqbIqtqXyCg= | ||||||
| github.com/cnotch/ipchub v1.1.0 h1:hH0lh2mU3AZXPiqMwA0pdtqrwo7PFIMRGush9OobMUs= | github.com/Monibuca/plugin-rtp v1.0.0/go.mod h1:0xkNm23a/BjVnEMz1zXyOqfEjoVmGe3PJqPNF1KyFGc= | ||||||
| github.com/cnotch/ipchub v1.1.0/go.mod h1:2PbeBs2q2VxxTVCn1eYCDwpAWuVXbq1+N0FU7GimOH4= | github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= | ||||||
| github.com/cnotch/loader v0.0.0-20200405015128-d9d964d09439/go.mod h1:oWpDagHB6p+Kqqq7RoRZKyC4XAXft50hR8pbTxdbYYs= | github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= | ||||||
| github.com/cnotch/queue v0.0.0-20200326024423-6e88bdbf2ad4/go.mod h1:zOssjAlNusOxvtaqT+EMA+Iyi8rrtKr4/XfzN1Fgoeg= | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||||||
| github.com/cnotch/queue v0.0.0-20201224060551-4191569ce8f6/go.mod h1:zOssjAlNusOxvtaqT+EMA+Iyi8rrtKr4/XfzN1Fgoeg= |  | ||||||
| github.com/cnotch/scheduler v0.0.0-20200522024700-1d2da93eefc5/go.mod h1:F4GE3SZkJZ8an1Y0ZCqvSM3jeozNuKzoC67erG1PhIo= |  | ||||||
| github.com/cnotch/xlog v0.0.0-20201208005456-cfda439cd3a0/go.mod h1:RW9oHsR79ffl3sR3yMGgxYupMn2btzdtJUwoxFPUE5E= |  | ||||||
| github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= |  | ||||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | github.com/funny/slab v0.0.0-20180511031532-b1fad5e5d478 h1:Db9StoJ6RZN3YttC0Pm0I4Y5izITRYch3RMbT59BYN0= | ||||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | github.com/funny/slab v0.0.0-20180511031532-b1fad5e5d478/go.mod h1:0j1+svBH8ABEIPdUP0AIg4qedsybnXGJBakCEw8cfoo= | ||||||
| github.com/emitter-io/address v1.0.0/go.mod h1:GfZb5+S/o8694B1GMGK2imUYQyn2skszMvGNA5D84Ug= | github.com/funny/utest v0.0.0-20161029064919-43870a374500 h1:Z0r1CZnoIWFB/Uiwh1BU5FYmuFe6L5NPi6XWQEmsTRg= | ||||||
| github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= | github.com/funny/utest v0.0.0-20161029064919-43870a374500/go.mod h1:mUn39tBov9jKnTWV1RlOYoNzxdBFHiSzXWdY1FoNGGg= | ||||||
| github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= | github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= | ||||||
| github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= | github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= | ||||||
| github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= | github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= | ||||||
| github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= |  | ||||||
| github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= |  | ||||||
| github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= |  | ||||||
| github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= |  | ||||||
| github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= |  | ||||||
| github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= |  | ||||||
| github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= |  | ||||||
| github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= |  | ||||||
| github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= |  | ||||||
| github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= |  | ||||||
| github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= |  | ||||||
| github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= |  | ||||||
| github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= |  | ||||||
| github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= |  | ||||||
| github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= |  | ||||||
| github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= |  | ||||||
| github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |  | ||||||
| github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |  | ||||||
| github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= |  | ||||||
| github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= |  | ||||||
| github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= |  | ||||||
| github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= |  | ||||||
| github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= |  | ||||||
| github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |  | ||||||
| github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= |  | ||||||
| github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= |  | ||||||
| github.com/kelindar/process v0.0.0-20170730150328-69a29e249ec3/go.mod h1:+lTCLnZFXOkqwD8sLPl6u4erAc0cP8wFegQHfipz7KE= |  | ||||||
| github.com/kelindar/rate v1.0.0/go.mod h1:AjT4G+hTItNwt30lucEGZIz8y7Uk5zPho6vurIZ+1Es= |  | ||||||
| github.com/kelindar/tcp v1.0.0/go.mod h1:JB5hj1cshLU60XrLij2BBxW3JQ4hOye8vqbyvuKb52k= |  | ||||||
| github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= |  | ||||||
| github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= |  | ||||||
| github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= |  | ||||||
| github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= |  | ||||||
| github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= |  | ||||||
| github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= |  | ||||||
| github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= | github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= | ||||||
| github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= | github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= | ||||||
| github.com/lucas-clemente/quic-go v0.31.0 h1:MfNp3fk0wjWRajw6quMFA3ap1AVtlU+2mtwmbVogB2M= | github.com/mask-pp/rtp-ps v1.0.0 h1:JFxuJL9N+gD1ldgJlAy3b7rYfY8wAVHi9ODNmdP4+EE= | ||||||
| github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= | github.com/mask-pp/rtp-ps v1.0.0/go.mod h1:jCxsZ2G7z/jX+aqFypEWMePnhNrfnUiXUEKm6Xp0vgU= | ||||||
| github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY= | github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | ||||||
| github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= | github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= | ||||||
| github.com/marten-seemann/qtls-go1-18 v0.1.3 h1:R4H2Ks8P6pAtUagjFty2p7BVHn3XiwDAl7TTQf5h7TI= | github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | ||||||
| github.com/marten-seemann/qtls-go1-18 v0.1.3/go.mod h1:mJttiymBAByA49mhlNZZGrH5u1uXYZJ+RW28Py7f4m4= | github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= | ||||||
| github.com/marten-seemann/qtls-go1-19 v0.1.1 h1:mnbxeq3oEyQxQXwI4ReCgW9DPoPR94sNlqWoDZnjRIE= | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= | ||||||
| github.com/marten-seemann/qtls-go1-19 v0.1.1/go.mod h1:5HTDWtVudo/WFsHKRNuOhWlbdjrfs5JHrYb0wIJqGpI= | github.com/pion/randutil v0.0.0 h1:aLWLVhTG2jzoD25F0OlW6nXvXrjoGwiXq2Sz7j7NzL0= | ||||||
| github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= | github.com/pion/randutil v0.0.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= | ||||||
| github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= | github.com/pion/rtp v1.5.4/go.mod h1:bg60AL5GotNOlYZsqycbhDtEV3TkfbpXG0KBiUq29Mg= | ||||||
| github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= | github.com/pion/rtp v1.6.0 h1:4Ssnl/T5W2LzxHj9ssYpGVEQh3YYhQFNVmSWO88MMwk= | ||||||
| github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= | github.com/pion/rtp v1.6.0/go.mod h1:QgfogHsMBVE/RFNno467U/KBqfUywEH+HK+0rtnwsdI= | ||||||
| github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= |  | ||||||
| github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= |  | ||||||
| github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= |  | ||||||
| github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI= |  | ||||||
| github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= |  | ||||||
| github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= |  | ||||||
| github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= |  | ||||||
| github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= |  | ||||||
| github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= |  | ||||||
| github.com/pion/datachannel v1.5.2/go.mod h1:FTGQWaHrdCwIJ1rw6xBIfZVkslikjShim5yr05XFuCQ= |  | ||||||
| github.com/pion/dtls/v2 v2.1.5/go.mod h1:BqCE7xPZbPSubGasRoDFJeTsyJtdD1FanJYL0JGheqY= |  | ||||||
| github.com/pion/interceptor v0.1.11/go.mod h1:tbtKjZY14awXd7Bq0mmWvgtHB5MDaRN7HV3OZ/uy7s8= |  | ||||||
| github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= |  | ||||||
| github.com/pion/mdns v0.0.5/go.mod h1:UgssrvdD3mxpi8tMxAXbsppL3vJ4Jipw1mTCW+al01g= |  | ||||||
| github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= |  | ||||||
| github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= |  | ||||||
| github.com/pion/rtcp v1.2.9/go.mod h1:qVPhiCzAm4D/rxb6XzKeyZiQK69yJpbUDJSF7TgrqNo= |  | ||||||
| github.com/pion/rtcp v1.2.10 h1:nkr3uj+8Sp97zyItdN60tE/S6vk4al5CPRR6Gejsdjc= |  | ||||||
| github.com/pion/rtcp v1.2.10/go.mod h1:ztfEwXZNLGyF1oQDttz/ZKIBaeeg/oWbRYqzBM9TL1I= |  | ||||||
| github.com/pion/rtp v1.6.2/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= |  | ||||||
| github.com/pion/rtp v1.7.13 h1:qcHwlmtiI50t1XivvoawdCGTP4Uiypzfrsap+bijcoA= |  | ||||||
| github.com/pion/rtp v1.7.13/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= |  | ||||||
| github.com/pion/sctp v1.8.0/go.mod h1:xFe9cLMZ5Vj6eOzpyiKjT9SwGM4KpK/8Jbw5//jc+0s= |  | ||||||
| github.com/pion/sdp/v3 v3.0.6 h1:WuDLhtuFUUVpTfus9ILC4HRyHsW6TdugjEX/QY9OiUw= |  | ||||||
| github.com/pion/sdp/v3 v3.0.6/go.mod h1:iiFWFpQO8Fy3S5ldclBkpXqmWy02ns78NOKoLLL0YQw= |  | ||||||
| github.com/pion/srtp/v2 v2.0.10/go.mod h1:XEeSWaK9PfuMs7zxXyiN252AHPbH12NX5q/CFDWtUuA= |  | ||||||
| github.com/pion/stun v0.3.5/go.mod h1:gDMim+47EeEtfWogA37n6qXZS88L5V6LqFcf+DZA2UA= |  | ||||||
| github.com/pion/transport v0.12.2/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q= |  | ||||||
| github.com/pion/transport v0.12.3/go.mod h1:OViWW9SP2peE/HbwBvARicmAVnesphkNkCVZIWJ6q9A= |  | ||||||
| github.com/pion/transport v0.13.0/go.mod h1:yxm9uXpK9bpBBWkITk13cLo1y5/ur5VQpG22ny6EP7g= |  | ||||||
| github.com/pion/transport v0.13.1/go.mod h1:EBxbqzyv+ZrmDb82XswEE0BjfQFtuw1Nu6sjnjWCsGg= |  | ||||||
| github.com/pion/turn/v2 v2.0.8/go.mod h1:+y7xl719J8bAEVpSXBXvTxStjJv3hbz9YFflvkpcGPw= |  | ||||||
| github.com/pion/udp v0.1.1/go.mod h1:6AFo+CMdKQm7UiA0eUPA8/eVCTx8jBIITLZHc9DWX5M= |  | ||||||
| github.com/pion/webrtc/v3 v3.1.49 h1:rbsNGxK9jMYts+xE6zYAJMUQHnGwmk/JYze8yttW+to= |  | ||||||
| github.com/pixelbender/go-sdp v1.1.0/go.mod h1:6IBlz9+BrUHoFTea7gcp4S54khtOhjCW/nVDLhmZBAs= |  | ||||||
| github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||||||
|  | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||||
| github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= | github.com/shirou/gopsutil v2.20.1+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= | ||||||
| github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c h1:NRoLoZvkBTKvR5gQLgA3e0hqjkY9u1wm+iOL45VN/qI= | github.com/shirou/gopsutil v2.20.7+incompatible h1:Ymv4OD12d6zm+2yONe39VSmp2XooJe8za7ngOLW/o/w= | ||||||
| github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= | github.com/shirou/gopsutil v2.20.7+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= | ||||||
| github.com/q191201771/naza v0.30.8 h1:Lhh29o65C4PmTDj2l+eKfsw9dddpgWZk4bFICtcnSaA= |  | ||||||
| github.com/q191201771/naza v0.30.8/go.mod h1:n+dpJjQSh90PxBwxBNuifOwQttywvSIN5TkWSSYCeBk= |  | ||||||
| github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= |  | ||||||
| github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= |  | ||||||
| github.com/shirou/gopsutil/v3 v3.22.10 h1:4KMHdfBRYXGF9skjDWiL4RA2N+E8dRdodU/bOZpPoVg= |  | ||||||
| github.com/shirou/gopsutil/v3 v3.22.10/go.mod h1:QNza6r4YQoydyCfo6rH0blGfKahgibh4dQmV5xdFkQk= |  | ||||||
| github.com/sqs/goreturns v0.0.0-20181028201513-538ac6014518/go.mod h1:CKI4AZ4XmGV240rTHfO0hfE83S6/a3/Q1siZJ/vXf7A= |  | ||||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||||
| github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= | ||||||
| github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= |  | ||||||
| github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= |  | ||||||
| github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||||||
| github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf h1:Z2X3Os7oRzpdJ75iPqWZc0HeJWFYNCvKsfpQwFpRNTA= | ||||||
| github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf/go.mod h1:M8agBzgqHIhgj7wEn9/0hJUZcrvt9VY+Ln+S1I5Mha0= | ||||||
| github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||||
| github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||||
| github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= | golang.org/x/sys v0.0.0-20200828161417-c663848e9a16 h1:54u1berWyLujz9htI1BHtZpcCEYaYNUSDFLXMNDd7To= | ||||||
| github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= | golang.org/x/sys v0.0.0-20200828161417-c663848e9a16/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||||
| github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||||
| github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= |  | ||||||
| github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI= |  | ||||||
| github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= |  | ||||||
| github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms= |  | ||||||
| github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= |  | ||||||
| github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |  | ||||||
| github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= |  | ||||||
| github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= |  | ||||||
| github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= |  | ||||||
| go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= |  | ||||||
| go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= |  | ||||||
| go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= |  | ||||||
| go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= |  | ||||||
| go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= |  | ||||||
| go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= |  | ||||||
| go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= |  | ||||||
| go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= |  | ||||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |  | ||||||
| golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= |  | ||||||
| golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= |  | ||||||
| golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= |  | ||||||
| golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= |  | ||||||
| golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A= |  | ||||||
| golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7Gny4PBWYYK3zskGpx4= |  | ||||||
| golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= |  | ||||||
| golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= |  | ||||||
| golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= |  | ||||||
| golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |  | ||||||
| golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |  | ||||||
| golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |  | ||||||
| golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= |  | ||||||
| golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= |  | ||||||
| golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= |  | ||||||
| golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |  | ||||||
| golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= |  | ||||||
| golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= |  | ||||||
| golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |  | ||||||
| golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= |  | ||||||
| golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= |  | ||||||
| golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= |  | ||||||
| golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= |  | ||||||
| golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= |  | ||||||
| golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |  | ||||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |  | ||||||
| golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |  | ||||||
| golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |  | ||||||
| golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= |  | ||||||
| golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |  | ||||||
| golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |  | ||||||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |  | ||||||
| golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |  | ||||||
| golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |  | ||||||
| golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |  | ||||||
| golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |  | ||||||
| golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |  | ||||||
| golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |  | ||||||
| golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |  | ||||||
| golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |  | ||||||
| golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= |  | ||||||
| golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |  | ||||||
| golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= |  | ||||||
| golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= |  | ||||||
| golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= |  | ||||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |  | ||||||
| golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |  | ||||||
| golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |  | ||||||
| golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= |  | ||||||
| golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= |  | ||||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |  | ||||||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= |  | ||||||
| golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= |  | ||||||
| golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= |  | ||||||
| golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM= |  | ||||||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |  | ||||||
| golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |  | ||||||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |  | ||||||
| golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |  | ||||||
| google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= |  | ||||||
| google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= |  | ||||||
| google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= |  | ||||||
| google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= |  | ||||||
| google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= |  | ||||||
| google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= |  | ||||||
| google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= |  | ||||||
| google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= |  | ||||||
| google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= |  | ||||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||||
| gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||||||
| gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |  | ||||||
| gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= |  | ||||||
| gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= |  | ||||||
| gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= |  | ||||||
| gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |  | ||||||
| gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||||
| gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |  | ||||||
| gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |  | ||||||
| gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= |  | ||||||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |  | ||||||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |  | ||||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |  | ||||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |  | ||||||
| m7s.live/engine/v4 v4.9.5 h1:xTZYokxH/kNOqrGzQlkOQIsElbkb8VsfwlktjjOXZ08= |  | ||||||
| m7s.live/engine/v4 v4.9.5/go.mod h1:OgI9lOQ1bE64s9rApdGGop1MBAJIpc/V2MJ190d9ig4= |  | ||||||
|   | |||||||
							
								
								
									
										282
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										282
									
								
								main.go
									
									
									
									
									
								
							| @@ -1,111 +1,217 @@ | |||||||
| package rtsp | package rtsp | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"bufio" | ||||||
|  | 	"embed" | ||||||
|  | 	"fmt" | ||||||
|  | 	"log" | ||||||
|  | 	"net" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"strconv" | 	"strings" | ||||||
| 	"sync" | 	"sync" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/aler9/gortsplib" | 	. "github.com/Monibuca/engine/v2" | ||||||
| 	"go.uber.org/zap" | 	"github.com/Monibuca/engine/v2/util" | ||||||
| 	. "m7s.live/engine/v4" | 	. "github.com/Monibuca/plugin-rtp" | ||||||
| 	"m7s.live/engine/v4/config" | 	"github.com/teris-io/shortid" | ||||||
| 	"m7s.live/engine/v4/util" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type RTSPConfig struct { | //go:embed ui/* | ||||||
| 	config.Publish | //go:embed README.md | ||||||
| 	config.Subscribe | var ui embed.FS | ||||||
| 	config.Pull | var collection sync.Map | ||||||
| 	config.Push | var config = struct { | ||||||
| 	ListenAddr   string | 	ListenAddr   string | ||||||
| 	UDPAddr        string | 	AutoPull     bool | ||||||
| 	RTCPAddr       string | 	RemoteAddr   string | ||||||
| 	ReadBufferSize int | 	Timeout      int | ||||||
| 	PullProtocol   string //tcp、udp、 auto(default) | 	Reconnect    bool | ||||||
| 	sync.Map | 	AutoPullList []*struct { | ||||||
|  | 		URL        string | ||||||
|  | 		StreamPath string | ||||||
| 	} | 	} | ||||||
|  | }{":554", false, "rtsp://localhost/${streamPath}", 0, false, nil} | ||||||
|  |  | ||||||
| func (conf *RTSPConfig) OnEvent(event any) { | func init() { | ||||||
| 	switch v := event.(type) { | 	InstallPlugin(&PluginConfig{ | ||||||
| 	case FirstConfig: | 		Name:   "RTSP", | ||||||
| 		s := &gortsplib.Server{ | 		Type:   PLUGIN_PUBLISHER | PLUGIN_HOOK, | ||||||
| 			Handler:           conf, | 		Config: &config, | ||||||
| 			RTSPAddress:       conf.ListenAddr, | 		Run:    runPlugin, | ||||||
| 			UDPRTPAddress:     conf.UDPAddr, | 		HotConfig: map[string]func(interface{}){ | ||||||
| 			UDPRTCPAddress:    conf.RTCPAddr, | 			"AutoPull": func(value interface{}) { | ||||||
| 			MulticastIPRange:  "224.1.0.0/16", | 				config.AutoPull = value.(bool) | ||||||
| 			MulticastRTPPort:  8002, | 			}, | ||||||
| 			MulticastRTCPPort: 8003, | 		}, | ||||||
|  | 		UIFile: &ui, | ||||||
|  | 	}) | ||||||
| } | } | ||||||
| 		if err := s.Start(); err != nil { | func runPlugin() { | ||||||
| 			RTSPPlugin.Error("server start", zap.Error(err)) | 	OnSubscribeHooks.AddHook(func(s *Subscriber) { | ||||||
| 			v["enable"] = false | 		if config.AutoPull && s.Publisher == nil { | ||||||
|  | 			new(RTSP).PullStream(s.StreamPath, strings.Replace(config.RemoteAddr, "${streamPath}", s.StreamPath, -1)) | ||||||
| 		} | 		} | ||||||
| 		for streamPath, url := range conf.PullOnStart { | 	}) | ||||||
| 			if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil { | 	http.HandleFunc("/rtsp/list", func(w http.ResponseWriter, r *http.Request) { | ||||||
| 				RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err)) | 		sse := util.NewSSE(w, r.Context()) | ||||||
|  | 		var err error | ||||||
|  | 		for tick := time.NewTicker(time.Second); err == nil; <-tick.C { | ||||||
|  | 			var info []*RTSPInfo | ||||||
|  | 			collection.Range(func(key, value interface{}) bool { | ||||||
|  | 				rtsp := value.(*RTSP) | ||||||
|  | 				pinfo := &rtsp.RTSPInfo | ||||||
|  | 				info = append(info, pinfo) | ||||||
|  | 				return true | ||||||
|  | 			}) | ||||||
|  | 			err = sse.WriteJSON(info) | ||||||
| 		} | 		} | ||||||
| 		} | 	}) | ||||||
| 	case SEpublish: | 	http.HandleFunc("/rtsp/pull", func(w http.ResponseWriter, r *http.Request) { | ||||||
| 		for streamPath, url := range conf.PushList { | 		w.Header().Set("Access-Control-Allow-Origin", "*") | ||||||
| 			if streamPath == v.Stream.Path { | 		targetURL := r.URL.Query().Get("target") | ||||||
| 				if err := RTSPPlugin.Push(streamPath, url, new(RTSPPusher), false); err != nil { | 		streamPath := r.URL.Query().Get("streamPath") | ||||||
| 					RTSPPlugin.Error("push", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err)) | 		if err := new(RTSP).PullStream(streamPath, targetURL); err == nil { | ||||||
| 				} | 			w.Write([]byte(`{"code":0}`)) | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	case *Stream: //按需拉流 |  | ||||||
| 		for streamPath, url := range conf.PullOnSub { |  | ||||||
| 			if streamPath == v.Path { |  | ||||||
| 				if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil { |  | ||||||
| 					RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err)) |  | ||||||
| 				} |  | ||||||
| 				break |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| var rtspConfig = &RTSPConfig{ |  | ||||||
| 	ListenAddr:     ":554", |  | ||||||
| 	UDPAddr:        ":8000", |  | ||||||
| 	RTCPAddr:       ":8001", |  | ||||||
| 	ReadBufferSize: 2048, |  | ||||||
| } |  | ||||||
| var RTSPPlugin = InstallPlugin(rtspConfig) |  | ||||||
|  |  | ||||||
| func filterStreams() (ss []*Stream) { |  | ||||||
| 	Streams.RLock() |  | ||||||
| 	defer Streams.RUnlock() |  | ||||||
| 	for _, s := range Streams.Map { |  | ||||||
| 		switch s.Publisher.(type) { |  | ||||||
| 		case *RTSPPublisher, *RTSPPuller: |  | ||||||
| 			ss = append(ss, s) |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	return |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (*RTSPConfig) API_list(w http.ResponseWriter, r *http.Request) { |  | ||||||
| 	util.ReturnJson(filterStreams, time.Second, w, r) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (*RTSPConfig) API_Pull(rw http.ResponseWriter, r *http.Request) { |  | ||||||
| 	save, _ := strconv.Atoi(r.URL.Query().Get("save")) |  | ||||||
| 	err := RTSPPlugin.Pull(r.URL.Query().Get("streamPath"), r.URL.Query().Get("target"), new(RTSPPuller), save) |  | ||||||
| 	if err != nil { |  | ||||||
| 		http.Error(rw, err.Error(), http.StatusBadRequest) |  | ||||||
| 		} else { | 		} else { | ||||||
| 		rw.Write([]byte("ok")) | 			w.Write([]byte(fmt.Sprintf(`{"code":1,"msg":"%s"}`, err.Error()))) | ||||||
|  | 		} | ||||||
|  | 	}) | ||||||
|  | 	if len(config.AutoPullList) > 0 { | ||||||
|  | 		for _, info := range config.AutoPullList { | ||||||
|  | 			if err := new(RTSP).PullStream(info.StreamPath, info.URL); err != nil { | ||||||
|  | 				Println(err) | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	if config.ListenAddr != "" { | ||||||
|  | 		log.Fatal(ListenRtsp(config.ListenAddr)) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func (*RTSPConfig) API_Push(rw http.ResponseWriter, r *http.Request) { | func ListenRtsp(addr string) error { | ||||||
| 	err := RTSPPlugin.Push(r.URL.Query().Get("streamPath"), r.URL.Query().Get("target"), new(RTSPPusher), r.URL.Query().Has("save")) | 	defer log.Println("rtsp server start!") | ||||||
|  | 	listener, err := net.Listen("tcp", addr) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		http.Error(rw, err.Error(), http.StatusBadRequest) | 		return err | ||||||
|  | 	} | ||||||
|  | 	var tempDelay time.Duration | ||||||
|  | 	networkBuffer := 204800 | ||||||
|  | 	timeoutMillis := config.Timeout | ||||||
|  | 	for { | ||||||
|  | 		conn, err := listener.Accept() | ||||||
|  | 		conn.(*net.TCPConn).SetNoDelay(false) | ||||||
|  | 		if err != nil { | ||||||
|  | 			if ne, ok := err.(net.Error); ok && ne.Temporary() { | ||||||
|  | 				if tempDelay == 0 { | ||||||
|  | 					tempDelay = 5 * time.Millisecond | ||||||
| 				} else { | 				} else { | ||||||
| 		rw.Write([]byte("ok")) | 					tempDelay *= 2 | ||||||
|  | 				} | ||||||
|  | 				if max := 1 * time.Second; tempDelay > max { | ||||||
|  | 					tempDelay = max | ||||||
|  | 				} | ||||||
|  | 				fmt.Printf("rtsp: Accept error: %v; retrying in %v", err, tempDelay) | ||||||
|  | 				time.Sleep(tempDelay) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 			return err | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		tempDelay = 0 | ||||||
|  | 		timeoutTCPConn := &RichConn{conn, time.Duration(timeoutMillis) * time.Millisecond} | ||||||
|  | 		go (&RTSP{ | ||||||
|  | 			ID:                 shortid.MustGenerate(), | ||||||
|  | 			Conn:               timeoutTCPConn, | ||||||
|  | 			connRW:             bufio.NewReadWriter(bufio.NewReaderSize(timeoutTCPConn, networkBuffer), bufio.NewWriterSize(timeoutTCPConn, networkBuffer)), | ||||||
|  | 			Timeout:            config.Timeout, | ||||||
|  | 			vRTPChannel:        -1, | ||||||
|  | 			vRTPControlChannel: -1, | ||||||
|  | 			aRTPChannel:        -1, | ||||||
|  | 			aRTPControlChannel: -1, | ||||||
|  | 		}).AcceptPush() | ||||||
|  | 	} | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type RTSP struct { | ||||||
|  | 	RTP | ||||||
|  | 	RTSPInfo | ||||||
|  | 	RTSPClientInfo | ||||||
|  | 	ID        string | ||||||
|  | 	Conn      *RichConn | ||||||
|  | 	connRW    *bufio.ReadWriter | ||||||
|  | 	connWLock sync.RWMutex | ||||||
|  | 	Type      SessionType | ||||||
|  | 	TransType TransType | ||||||
|  |  | ||||||
|  | 	SDPMap   map[string]*SDPInfo | ||||||
|  | 	nonce    string | ||||||
|  | 	closeOld bool | ||||||
|  | 	ASdp     *SDPInfo | ||||||
|  | 	VSdp     *SDPInfo | ||||||
|  | 	aacsent  bool | ||||||
|  | 	Timeout  int | ||||||
|  | 	//tcp channels | ||||||
|  | 	aRTPChannel        int | ||||||
|  | 	aRTPControlChannel int | ||||||
|  | 	vRTPChannel        int | ||||||
|  | 	vRTPControlChannel int | ||||||
|  | 	UDPServer          *UDPServer | ||||||
|  | 	UDPClient          *UDPClient | ||||||
|  | 	Auth               func(string) string | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (rtsp *RTSP) setAudioFormat() { | ||||||
|  | 	switch rtsp.ASdp.Codec { | ||||||
|  | 	case "aac": | ||||||
|  | 		rtsp.AudioInfo.SoundFormat = 10 | ||||||
|  | 	case "pcma": | ||||||
|  | 		rtsp.AudioInfo.SoundFormat = 7 | ||||||
|  | 		rtsp.AudioInfo.SoundRate = rtsp.ASdp.TimeScale | ||||||
|  | 		rtsp.AudioInfo.SoundSize = 16 | ||||||
|  | 	case "pcmu": | ||||||
|  | 		rtsp.AudioInfo.SoundFormat = 8 | ||||||
|  | 		rtsp.AudioInfo.SoundRate = rtsp.ASdp.TimeScale | ||||||
|  | 		rtsp.AudioInfo.SoundSize = 16 | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | type RTSPClientInfo struct { | ||||||
|  | 	Agent    string | ||||||
|  | 	Session  string | ||||||
|  | 	authLine string | ||||||
|  | 	Seq      int | ||||||
|  | } | ||||||
|  | type RTSPInfo struct { | ||||||
|  | 	URL        string | ||||||
|  | 	SDPRaw     string | ||||||
|  | 	InBytes    int | ||||||
|  | 	OutBytes   int | ||||||
|  | 	StreamInfo *StreamInfo | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type RichConn struct { | ||||||
|  | 	net.Conn | ||||||
|  | 	timeout time.Duration | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (conn *RichConn) Read(b []byte) (n int, err error) { | ||||||
|  | 	if conn.timeout > 0 { | ||||||
|  | 		conn.Conn.SetReadDeadline(time.Now().Add(conn.timeout)) | ||||||
|  | 	} else { | ||||||
|  | 		var t time.Time | ||||||
|  | 		conn.Conn.SetReadDeadline(t) | ||||||
|  | 	} | ||||||
|  | 	return conn.Conn.Read(b) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (conn *RichConn) Write(b []byte) (n int, err error) { | ||||||
|  | 	if conn.timeout > 0 { | ||||||
|  | 		conn.Conn.SetWriteDeadline(time.Now().Add(conn.timeout)) | ||||||
|  | 	} else { | ||||||
|  | 		var t time.Time | ||||||
|  | 		conn.Conn.SetWriteDeadline(t) | ||||||
|  | 	} | ||||||
|  | 	return conn.Conn.Write(b) | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										137
									
								
								publisher.go
									
									
									
									
									
								
							
							
						
						
									
										137
									
								
								publisher.go
									
									
									
									
									
								
							| @@ -1,137 +0,0 @@ | |||||||
| package rtsp |  | ||||||
|  |  | ||||||
| import ( |  | ||||||
| 	"encoding/base64" |  | ||||||
| 	"encoding/hex" |  | ||||||
| 	"errors" |  | ||||||
| 	"fmt" |  | ||||||
| 	"strconv" |  | ||||||
| 	"strings" |  | ||||||
|  |  | ||||||
| 	"github.com/aler9/gortsplib" |  | ||||||
| 	. "m7s.live/engine/v4" |  | ||||||
| 	"m7s.live/engine/v4/common" |  | ||||||
| 	. "m7s.live/engine/v4/track" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| type RTSPPublisher struct { |  | ||||||
| 	Publisher |  | ||||||
| 	Tracks []common.AVTrack `json:"-"` |  | ||||||
| 	RTSPIO |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (p *RTSPPublisher) SetTracks() error { |  | ||||||
| 	p.Tracks = make([]common.AVTrack, len(p.tracks)) |  | ||||||
| 	for trackId, track := range p.tracks { |  | ||||||
| 		md := track.MediaDescription() |  | ||||||
| 		v, ok := md.Attribute("rtpmap") |  | ||||||
| 		if !ok { |  | ||||||
| 			return errors.New("rtpmap attribute not found") |  | ||||||
| 		} |  | ||||||
| 		v = strings.TrimSpace(v) |  | ||||||
| 		vals := strings.Split(v, " ") |  | ||||||
| 		if len(vals) != 2 { |  | ||||||
| 			continue |  | ||||||
| 		} |  | ||||||
| 		fmtp := make(map[string]string) |  | ||||||
| 		if v, ok = md.Attribute("fmtp"); ok { |  | ||||||
| 			if tmp := strings.SplitN(v, " ", 2); len(tmp) == 2 { |  | ||||||
| 				for _, kv := range strings.Split(tmp[1], ";") { |  | ||||||
| 					kv = strings.Trim(kv, " ") |  | ||||||
|  |  | ||||||
| 					if len(kv) == 0 { |  | ||||||
| 						continue |  | ||||||
| 					} |  | ||||||
| 					tmp := strings.SplitN(kv, "=", 2) |  | ||||||
| 					if len(tmp) == 2 { |  | ||||||
| 						fmtp[strings.TrimSpace(tmp[0])] = tmp[1] |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		timeScale := 0 |  | ||||||
| 		keyval := strings.Split(vals[1], "/") |  | ||||||
| 		if i, err := strconv.Atoi(keyval[1]); err == nil { |  | ||||||
| 			timeScale = i |  | ||||||
| 		} |  | ||||||
| 		if len(keyval) >= 2 { |  | ||||||
| 			switch strings.ToLower(keyval[0]) { |  | ||||||
| 			case "h264": |  | ||||||
| 				vt := NewH264(p.Stream) |  | ||||||
| 				if payloadType, err := strconv.Atoi(vals[0]); err == nil { |  | ||||||
| 					vt.DecoderConfiguration.PayloadType = byte(payloadType) |  | ||||||
| 				} |  | ||||||
| 				p.Tracks[trackId] = vt |  | ||||||
| 				t := track.(*gortsplib.TrackH264) |  | ||||||
| 				if len(t.SPS) > 0 { |  | ||||||
| 					vt.WriteSlice(common.NALUSlice{t.SPS}) |  | ||||||
| 				} |  | ||||||
| 				if len(t.PPS) > 0 { |  | ||||||
| 					vt.WriteSlice(common.NALUSlice{t.PPS}) |  | ||||||
| 				} |  | ||||||
| 			case "h265", "hevc": |  | ||||||
| 				vt := NewH265(p.Stream) |  | ||||||
| 				if payloadType, err := strconv.Atoi(vals[0]); err == nil { |  | ||||||
| 					vt.DecoderConfiguration.PayloadType = byte(payloadType) |  | ||||||
| 				} |  | ||||||
| 				p.Tracks[trackId] = vt |  | ||||||
| 				if v, ok := fmtp["sprop-vps"]; ok { |  | ||||||
| 					vps, _ := base64.StdEncoding.DecodeString(v) |  | ||||||
| 					vt.WriteSlice(common.NALUSlice{vps}) |  | ||||||
| 				} |  | ||||||
| 				if v, ok := fmtp["sprop-sps"]; ok { |  | ||||||
| 					sps, _ := base64.StdEncoding.DecodeString(v) |  | ||||||
| 					vt.WriteSlice(common.NALUSlice{sps}) |  | ||||||
| 				} |  | ||||||
| 				if v, ok := fmtp["sprop-pps"]; ok { |  | ||||||
| 					pps, _ := base64.StdEncoding.DecodeString(v) |  | ||||||
| 					vt.WriteSlice(common.NALUSlice{pps}) |  | ||||||
| 				} |  | ||||||
| 			case "pcma": |  | ||||||
| 				at := NewG711(p.Stream, true) |  | ||||||
| 				if payloadType, err := strconv.Atoi(vals[0]); err == nil { |  | ||||||
| 					at.DecoderConfiguration.PayloadType = byte(payloadType) |  | ||||||
| 				} |  | ||||||
| 				p.Tracks[trackId] = at |  | ||||||
| 				at.SampleRate = uint32(timeScale) |  | ||||||
| 				if len(keyval) >= 3 { |  | ||||||
| 					x, _ := strconv.Atoi(keyval[2]) |  | ||||||
| 					at.Channels = byte(x) |  | ||||||
| 				} else { |  | ||||||
| 					at.Channels = 1 |  | ||||||
| 				} |  | ||||||
| 				at.AVCCHead = []byte{(byte(at.CodecID) << 4) | (1 << 1)} |  | ||||||
| 			case "pcmu": |  | ||||||
| 				at := NewG711(p.Stream, false) |  | ||||||
| 				if payloadType, err := strconv.Atoi(vals[0]); err == nil { |  | ||||||
| 					at.DecoderConfiguration.PayloadType = byte(payloadType) |  | ||||||
| 				} |  | ||||||
| 				p.Tracks[trackId] = at |  | ||||||
| 				at.SampleRate = uint32(timeScale) |  | ||||||
| 				if len(keyval) >= 3 { |  | ||||||
| 					x, _ := strconv.Atoi(keyval[2]) |  | ||||||
| 					at.Channels = byte(x) |  | ||||||
| 				} else { |  | ||||||
| 					at.Channels = 1 |  | ||||||
| 				} |  | ||||||
| 				at.AVCCHead = []byte{(byte(at.CodecID) << 4) | (1 << 1)} |  | ||||||
| 			case "mpeg4-generic": |  | ||||||
| 				at := NewAAC(p.Stream) |  | ||||||
| 				if payloadType, err := strconv.Atoi(vals[0]); err == nil { |  | ||||||
| 					at.DecoderConfiguration.PayloadType = byte(payloadType) |  | ||||||
| 				} |  | ||||||
| 				p.Tracks[trackId] = at |  | ||||||
| 				if config, ok := fmtp["config"]; ok { |  | ||||||
| 					asc, _ := hex.DecodeString(config) |  | ||||||
| 					// 复用AVCC写入逻辑,解析出AAC的配置信息 |  | ||||||
| 					at.WriteAVCC(0, append([]byte{0xAF, 0}, asc...)) |  | ||||||
| 				} else { |  | ||||||
| 					RTSPPlugin.Warn("aac no config") |  | ||||||
| 				} |  | ||||||
| 			default: |  | ||||||
| 				return fmt.Errorf("unsupport codec:%s", keyval[0]) |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	return nil |  | ||||||
| } |  | ||||||
							
								
								
									
										100
									
								
								request.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								request.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,100 @@ | |||||||
|  | package rtsp | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"log" | ||||||
|  | 	"regexp" | ||||||
|  | 	"strconv" | ||||||
|  | 	"strings" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | const ( | ||||||
|  | 	RTSP_VERSION = "RTSP/1.0" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | const ( | ||||||
|  | 	// Client to server for presentation and stream objects; recommended | ||||||
|  | 	DESCRIBE = "DESCRIBE" | ||||||
|  | 	// Bidirectional for client and stream objects; optional | ||||||
|  | 	ANNOUNCE = "ANNOUNCE" | ||||||
|  | 	// Bidirectional for client and stream objects; optional | ||||||
|  | 	GET_PARAMETER = "GET_PARAMETER" | ||||||
|  | 	// Bidirectional for client and stream objects; required for Client to server, optional for server to client | ||||||
|  | 	OPTIONS = "OPTIONS" | ||||||
|  | 	// Client to server for presentation and stream objects; recommended | ||||||
|  | 	PAUSE = "PAUSE" | ||||||
|  | 	// Client to server for presentation and stream objects; required | ||||||
|  | 	PLAY = "PLAY" | ||||||
|  | 	// Client to server for presentation and stream objects; optional | ||||||
|  | 	RECORD = "RECORD" | ||||||
|  | 	// Server to client for presentation and stream objects; optional | ||||||
|  | 	REDIRECT = "REDIRECT" | ||||||
|  | 	// Client to server for stream objects; required | ||||||
|  | 	SETUP = "SETUP" | ||||||
|  | 	// Bidirectional for presentation and stream objects; optional | ||||||
|  | 	SET_PARAMETER = "SET_PARAMETER" | ||||||
|  | 	// Client to server for presentation and stream objects; required | ||||||
|  | 	TEARDOWN = "TEARDOWN" | ||||||
|  | 	DATA     = "DATA" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type Request struct { | ||||||
|  | 	Method  string | ||||||
|  | 	URL     string | ||||||
|  | 	Version string | ||||||
|  | 	Header  map[string]string | ||||||
|  | 	Content string | ||||||
|  | 	Body    string | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func NewRequest(content string) *Request { | ||||||
|  | 	lines := strings.Split(strings.TrimSpace(content), "\r\n") | ||||||
|  | 	if len(lines) == 0 { | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  | 	items := regexp.MustCompile("\\s+").Split(strings.TrimSpace(lines[0]), -1) | ||||||
|  | 	if len(items) < 3 { | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  | 	if !strings.HasPrefix(items[2], "RTSP") { | ||||||
|  | 		log.Printf("invalid rtsp request, line[0] %s", lines[0]) | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  | 	header := make(map[string]string) | ||||||
|  | 	for i := 1; i < len(lines); i++ { | ||||||
|  | 		line := strings.TrimSpace(lines[i]) | ||||||
|  | 		headerItems := regexp.MustCompile(":\\s+").Split(line, 2) | ||||||
|  | 		if len(headerItems) < 2 { | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
|  | 		header[headerItems[0]] = headerItems[1] | ||||||
|  | 	} | ||||||
|  | 	return &Request{ | ||||||
|  | 		Method:  items[0], | ||||||
|  | 		URL:     items[1], | ||||||
|  | 		Version: items[2], | ||||||
|  | 		Header:  header, | ||||||
|  | 		Content: content, | ||||||
|  | 		Body:    "", | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (r *Request) String() string { | ||||||
|  | 	str := fmt.Sprintf("%s %s %s\r\n", r.Method, r.URL, r.Version) | ||||||
|  | 	for key, value := range r.Header { | ||||||
|  | 		str += fmt.Sprintf("%s: %s\r\n", key, value) | ||||||
|  | 	} | ||||||
|  | 	str += "\r\n" | ||||||
|  | 	str += r.Body | ||||||
|  | 	return str | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (r *Request) GetContentLength() int { | ||||||
|  | 	v, err := strconv.ParseInt(r.Header["Content-Length"], 10, 64) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return 0 | ||||||
|  | 	} else { | ||||||
|  | 		return int(v) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										51
									
								
								response.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								response.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | |||||||
|  | package rtsp | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"strconv" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type Response struct { | ||||||
|  | 	Version    string | ||||||
|  | 	StatusCode int | ||||||
|  | 	Status     string | ||||||
|  | 	Header     map[string]interface{} | ||||||
|  | 	Body       string | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func NewResponse(statusCode int, status, cSeq, sid, body string) *Response { | ||||||
|  | 	res := &Response{ | ||||||
|  | 		Version:    RTSP_VERSION, | ||||||
|  | 		StatusCode: statusCode, | ||||||
|  | 		Status:     status, | ||||||
|  | 		Header:     map[string]interface{}{"CSeq": cSeq, "Session": sid}, | ||||||
|  | 		Body:       body, | ||||||
|  | 	} | ||||||
|  | 	len := len(body) | ||||||
|  | 	if len > 0 { | ||||||
|  | 		res.Header["Content-Length"] = strconv.Itoa(len) | ||||||
|  | 	} else { | ||||||
|  | 		delete(res.Header, "Content-Length") | ||||||
|  | 	} | ||||||
|  | 	return res | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (r *Response) String() string { | ||||||
|  | 	str := fmt.Sprintf("%s %d %s\r\n", r.Version, r.StatusCode, r.Status) | ||||||
|  | 	for key, value := range r.Header { | ||||||
|  | 		str += fmt.Sprintf("%s: %s\r\n", key, value) | ||||||
|  | 	} | ||||||
|  | 	str += "\r\n" | ||||||
|  | 	str += r.Body | ||||||
|  | 	return str | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (r *Response) SetBody(body string) { | ||||||
|  | 	len := len(body) | ||||||
|  | 	r.Body = body | ||||||
|  | 	if len > 0 { | ||||||
|  | 		r.Header["Content-Length"] = strconv.Itoa(len) | ||||||
|  | 	} else { | ||||||
|  | 		delete(r.Header, "Content-Length") | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										68
									
								
								rtp-parser.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								rtp-parser.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | |||||||
|  | package rtsp | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"encoding/binary" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | const ( | ||||||
|  | 	RTP_FIXED_HEADER_LENGTH = 12 | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type RTPInfo struct { | ||||||
|  | 	Version        int | ||||||
|  | 	Padding        bool | ||||||
|  | 	Extension      bool | ||||||
|  | 	CSRCCnt        int | ||||||
|  | 	Marker         bool | ||||||
|  | 	PayloadType    int | ||||||
|  | 	SequenceNumber int | ||||||
|  | 	Timestamp      int | ||||||
|  | 	SSRC           int | ||||||
|  | 	Payload        []byte | ||||||
|  | 	PayloadOffset  int | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func ParseRTP(rtpBytes []byte) *RTPInfo { | ||||||
|  | 	if len(rtpBytes) < RTP_FIXED_HEADER_LENGTH { | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  | 	firstByte := rtpBytes[0] | ||||||
|  | 	secondByte := rtpBytes[1] | ||||||
|  | 	info := &RTPInfo{ | ||||||
|  | 		Version:   int(firstByte >> 6), | ||||||
|  | 		Padding:   (firstByte>>5)&1 == 1, | ||||||
|  | 		Extension: (firstByte>>4)&1 == 1, | ||||||
|  | 		CSRCCnt:   int(firstByte & 0x0f), | ||||||
|  |  | ||||||
|  | 		Marker:         secondByte>>7 == 1, | ||||||
|  | 		PayloadType:    int(secondByte & 0x7f), | ||||||
|  | 		SequenceNumber: int(binary.BigEndian.Uint16(rtpBytes[2:])), | ||||||
|  | 		Timestamp:      int(binary.BigEndian.Uint32(rtpBytes[4:])), | ||||||
|  | 		SSRC:           int(binary.BigEndian.Uint32(rtpBytes[8:])), | ||||||
|  | 	} | ||||||
|  | 	offset := RTP_FIXED_HEADER_LENGTH | ||||||
|  | 	end := len(rtpBytes) | ||||||
|  | 	if end-offset >= 4*info.CSRCCnt { | ||||||
|  | 		offset += 4 * info.CSRCCnt | ||||||
|  | 	} | ||||||
|  | 	if info.Extension && end-offset >= 4 { | ||||||
|  | 		extLen := 4 * int(binary.BigEndian.Uint16(rtpBytes[offset+2:])) | ||||||
|  | 		offset += 4 | ||||||
|  | 		if end-offset >= extLen { | ||||||
|  | 			offset += extLen | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	if info.Padding && end-offset > 0 { | ||||||
|  | 		paddingLen := int(rtpBytes[end-1]) | ||||||
|  | 		if end-offset >= paddingLen { | ||||||
|  | 			end -= paddingLen | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	info.Payload = rtpBytes[offset:end] | ||||||
|  | 	info.PayloadOffset = offset | ||||||
|  | 	if end-offset < 1 { | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return info | ||||||
|  | } | ||||||
							
								
								
									
										105
									
								
								sdp-parser.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								sdp-parser.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,105 @@ | |||||||
|  | package rtsp | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"encoding/base64" | ||||||
|  | 	"encoding/hex" | ||||||
|  | 	"strconv" | ||||||
|  | 	"strings" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SDPInfo struct { | ||||||
|  | 	AVType             string | ||||||
|  | 	Codec              string | ||||||
|  | 	TimeScale          int | ||||||
|  | 	Control            string | ||||||
|  | 	Rtpmap             int | ||||||
|  | 	Config             []byte | ||||||
|  | 	SpropParameterSets [][]byte | ||||||
|  | 	PayloadType        int | ||||||
|  | 	SizeLength         int | ||||||
|  | 	IndexLength        int | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func ParseSDP(sdpRaw string) map[string]*SDPInfo { | ||||||
|  | 	sdpMap := make(map[string]*SDPInfo) | ||||||
|  | 	var info *SDPInfo | ||||||
|  | 	for _, line := range strings.Split(sdpRaw, "\n") { | ||||||
|  | 		line = strings.TrimSpace(line) | ||||||
|  | 		typeval := strings.SplitN(line, "=", 2) | ||||||
|  | 		if len(typeval) == 2 { | ||||||
|  | 			fields := strings.SplitN(typeval[1], " ", 2) | ||||||
|  | 			switch typeval[0] { | ||||||
|  | 			case "m": | ||||||
|  | 				if len(fields) > 0 { | ||||||
|  | 					info = &SDPInfo{AVType: fields[0]} | ||||||
|  | 					sdpMap[info.AVType] = info | ||||||
|  | 					mfields := strings.Split(fields[1], " ") | ||||||
|  | 					if len(mfields) >= 3 { | ||||||
|  | 						info.PayloadType, _ = strconv.Atoi(mfields[2]) | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			case "a": | ||||||
|  | 				if info != nil { | ||||||
|  | 					for _, field := range fields { | ||||||
|  | 						keyval := strings.SplitN(field, ":", 2) | ||||||
|  | 						if len(keyval) >= 2 { | ||||||
|  | 							key := keyval[0] | ||||||
|  | 							val := keyval[1] | ||||||
|  | 							switch key { | ||||||
|  | 							case "control": | ||||||
|  | 								info.Control = val | ||||||
|  | 							case "rtpmap": | ||||||
|  | 								info.Rtpmap, _ = strconv.Atoi(val) | ||||||
|  | 							} | ||||||
|  | 						} | ||||||
|  | 						keyval = strings.Split(field, "/") | ||||||
|  | 						if len(keyval) >= 2 { | ||||||
|  | 							key := keyval[0] | ||||||
|  | 							switch key { | ||||||
|  | 							case "PCMA": | ||||||
|  | 								info.Codec = "pcma" | ||||||
|  | 							case "PCMU": | ||||||
|  | 								info.Codec = "pcmu" | ||||||
|  | 							case "MPEG4-GENERIC": | ||||||
|  | 								info.Codec = "aac" | ||||||
|  | 							case "H264": | ||||||
|  | 								info.Codec = "h264" | ||||||
|  | 							case "H265": | ||||||
|  | 								info.Codec = "h265" | ||||||
|  | 							} | ||||||
|  | 							if i, err := strconv.Atoi(keyval[1]); err == nil { | ||||||
|  | 								info.TimeScale = i | ||||||
|  | 							} | ||||||
|  | 						} | ||||||
|  | 						keyval = strings.Split(field, ";") | ||||||
|  | 						if len(keyval) > 1 { | ||||||
|  | 							for _, field := range keyval { | ||||||
|  | 								keyval := strings.SplitN(field, "=", 2) | ||||||
|  | 								if len(keyval) == 2 { | ||||||
|  | 									key := strings.TrimSpace(keyval[0]) | ||||||
|  | 									val := keyval[1] | ||||||
|  | 									switch key { | ||||||
|  | 									case "config": | ||||||
|  | 										info.Config, _ = hex.DecodeString(val) | ||||||
|  | 									case "sizelength": | ||||||
|  | 										info.SizeLength, _ = strconv.Atoi(val) | ||||||
|  | 									case "indexlength": | ||||||
|  | 										info.IndexLength, _ = strconv.Atoi(val) | ||||||
|  | 									case "sprop-parameter-sets": | ||||||
|  | 										fields := strings.Split(val, ",") | ||||||
|  | 										for _, field := range fields { | ||||||
|  | 											val, _ := base64.StdEncoding.DecodeString(field) | ||||||
|  | 											info.SpropParameterSets = append(info.SpropParameterSets, val) | ||||||
|  | 										} | ||||||
|  | 									} | ||||||
|  | 								} | ||||||
|  | 							} | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  |  | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return sdpMap | ||||||
|  | } | ||||||
							
								
								
									
										125
									
								
								server.go
									
									
									
									
									
								
							
							
						
						
									
										125
									
								
								server.go
									
									
									
									
									
								
							| @@ -1,125 +0,0 @@ | |||||||
| package rtsp |  | ||||||
|  |  | ||||||
| import ( |  | ||||||
| 	"github.com/aler9/gortsplib" |  | ||||||
| 	"github.com/aler9/gortsplib/pkg/base" |  | ||||||
| 	. "m7s.live/engine/v4" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| type RTSPIO struct { |  | ||||||
| 	tracks       gortsplib.Tracks |  | ||||||
| 	stream       *gortsplib.ServerStream |  | ||||||
| 	audioTrackId int |  | ||||||
| 	videoTrackId int |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (conf *RTSPConfig) OnConnOpen(ctx *gortsplib.ServerHandlerOnConnOpenCtx) { |  | ||||||
| 	RTSPPlugin.Debug("conn opened") |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (conf *RTSPConfig) OnConnClose(ctx *gortsplib.ServerHandlerOnConnCloseCtx) { |  | ||||||
| 	RTSPPlugin.Debug("conn closed") |  | ||||||
| 	if p, ok := conf.LoadAndDelete(ctx.Conn); ok { |  | ||||||
| 		p.(IIO).Stop() |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (conf *RTSPConfig) OnSessionOpen(ctx *gortsplib.ServerHandlerOnSessionOpenCtx) { |  | ||||||
| 	RTSPPlugin.Debug("session opened") |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (conf *RTSPConfig) OnSessionClose(ctx *gortsplib.ServerHandlerOnSessionCloseCtx) { |  | ||||||
| 	RTSPPlugin.Debug("session closed") |  | ||||||
| 	if p, ok := conf.LoadAndDelete(ctx.Session); ok { |  | ||||||
| 		p.(IIO).Stop() |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // called after receiving a DESCRIBE request. |  | ||||||
| func (conf *RTSPConfig) OnDescribe(ctx *gortsplib.ServerHandlerOnDescribeCtx) (*base.Response, *gortsplib.ServerStream, error) { |  | ||||||
| 	RTSPPlugin.Debug("describe request") |  | ||||||
| 	var suber RTSPSubscriber |  | ||||||
| 	suber.SetIO(ctx.Conn.NetConn()) |  | ||||||
| 	streamPath := ctx.Path |  | ||||||
| 	if ctx.Query != "" { |  | ||||||
| 		streamPath = streamPath + "?" + ctx.Query |  | ||||||
| 	} |  | ||||||
| 	if err := RTSPPlugin.Subscribe(streamPath, &suber); err == nil { |  | ||||||
| 		RTSPPlugin.Debug("describe replay ok") |  | ||||||
| 		conf.Store(ctx.Conn, &suber) |  | ||||||
| 		return &base.Response{ |  | ||||||
| 			StatusCode: base.StatusOK, |  | ||||||
| 		}, suber.stream, nil |  | ||||||
| 	} else { |  | ||||||
| 		return &base.Response{ |  | ||||||
| 			StatusCode: base.StatusNotFound, |  | ||||||
| 		}, suber.stream, nil |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (conf *RTSPConfig) OnSetup(ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) { |  | ||||||
| 	var resp base.Response |  | ||||||
| 	resp.StatusCode = base.StatusOK |  | ||||||
| 	if p, ok := conf.Load(ctx.Conn); ok { |  | ||||||
| 		switch v := p.(type) { |  | ||||||
| 		case *RTSPSubscriber: |  | ||||||
| 			return &resp, v.stream, nil |  | ||||||
| 		case *RTSPPublisher: |  | ||||||
| 			return &resp, v.stream, nil |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	resp.StatusCode = base.StatusNotFound |  | ||||||
| 	return &resp, nil, nil |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (conf *RTSPConfig) OnPlay(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) { |  | ||||||
| 	var resp base.Response |  | ||||||
| 	resp.StatusCode = base.StatusNotFound |  | ||||||
| 	if p, ok := conf.Load(ctx.Conn); ok { |  | ||||||
| 		switch v := p.(type) { |  | ||||||
| 		case *RTSPSubscriber: |  | ||||||
| 			resp.StatusCode = base.StatusOK |  | ||||||
| 			go func() { |  | ||||||
| 				v.PlayRTP() |  | ||||||
| 				ctx.Session.Close() |  | ||||||
| 			}() |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	return &resp, nil |  | ||||||
| } |  | ||||||
| func (conf *RTSPConfig) OnRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*base.Response, error) { |  | ||||||
| 	return &base.Response{ |  | ||||||
| 		StatusCode: base.StatusOK, |  | ||||||
| 	}, nil |  | ||||||
| } |  | ||||||
| func (conf *RTSPConfig) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (*base.Response, error) { |  | ||||||
| 	p := &RTSPPublisher{} |  | ||||||
| 	p.SetIO(ctx.Conn.NetConn()) |  | ||||||
| 	if err := RTSPPlugin.Publish(ctx.Path, p); err == nil { |  | ||||||
| 		p.tracks = ctx.Tracks |  | ||||||
| 		p.stream = gortsplib.NewServerStream(ctx.Tracks) |  | ||||||
| 		if err = p.SetTracks(); err != nil { |  | ||||||
| 			return nil, err |  | ||||||
| 		} |  | ||||||
| 		conf.Store(ctx.Conn, p) |  | ||||||
| 		conf.Store(ctx.Session, p) |  | ||||||
| 	} else { |  | ||||||
| 		return &base.Response{ |  | ||||||
| 			StatusCode: base.StatusBadRequest, |  | ||||||
| 		}, nil |  | ||||||
| 	} |  | ||||||
| 	return &base.Response{ |  | ||||||
| 		StatusCode: base.StatusOK, |  | ||||||
| 	}, nil |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (conf *RTSPConfig) OnPacketRTP(ctx *gortsplib.ServerHandlerOnPacketRTPCtx) { |  | ||||||
| 	if p, ok := conf.Load(ctx.Session); ok { |  | ||||||
| 		switch v := p.(type) { |  | ||||||
| 		case *RTSPPublisher: |  | ||||||
| 			if v.Tracks[ctx.TrackID] != nil { |  | ||||||
| 				v.Tracks[ctx.TrackID].WriteRTPPack(ctx.Packet) |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
							
								
								
									
										604
									
								
								session.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										604
									
								
								session.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,604 @@ | |||||||
|  | package rtsp | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"bytes" | ||||||
|  | 	"crypto/md5" | ||||||
|  | 	"encoding/binary" | ||||||
|  | 	"fmt" | ||||||
|  | 	"io" | ||||||
|  | 	"net/url" | ||||||
|  | 	"regexp" | ||||||
|  | 	"strconv" | ||||||
|  | 	"strings" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	. "github.com/Monibuca/engine/v2" | ||||||
|  | 	. "github.com/Monibuca/plugin-rtp" | ||||||
|  | 	"github.com/teris-io/shortid" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type SessionType int | ||||||
|  |  | ||||||
|  | const ( | ||||||
|  | 	SESSION_TYPE_PUSHER SessionType = iota | ||||||
|  | 	SESSEION_TYPE_PLAYER | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func (st SessionType) String() string { | ||||||
|  | 	switch st { | ||||||
|  | 	case SESSION_TYPE_PUSHER: | ||||||
|  | 		return "pusher" | ||||||
|  | 	case SESSEION_TYPE_PLAYER: | ||||||
|  | 		return "player" | ||||||
|  | 	} | ||||||
|  | 	return "unknow" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type TransType int | ||||||
|  |  | ||||||
|  | const ( | ||||||
|  | 	TRANS_TYPE_TCP TransType = iota | ||||||
|  | 	TRANS_TYPE_UDP | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func (tt TransType) String() string { | ||||||
|  | 	switch tt { | ||||||
|  | 	case TRANS_TYPE_TCP: | ||||||
|  | 		return "TCP" | ||||||
|  | 	case TRANS_TYPE_UDP: | ||||||
|  | 		return "UDP" | ||||||
|  | 	} | ||||||
|  | 	return "unknow" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | const UDP_BUF_SIZE = 1048576 | ||||||
|  |  | ||||||
|  | func (session *RTSP) SessionString() string { | ||||||
|  | 	return fmt.Sprintf("session[%v][%v][%s][%s][%s]", session.Type, session.TransType, session.StreamPath, session.ID, session.Conn.RemoteAddr().String()) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (session *RTSP) Stop() { | ||||||
|  | 	if session.Conn != nil { | ||||||
|  | 		session.connRW.Flush() | ||||||
|  | 		session.Conn.Close() | ||||||
|  | 		session.Conn = nil | ||||||
|  | 	} | ||||||
|  | 	if session.UDPClient != nil { | ||||||
|  | 		session.UDPClient.Stop() | ||||||
|  | 		session.UDPClient = nil | ||||||
|  | 	} | ||||||
|  | 	if session.UDPServer != nil { | ||||||
|  | 		session.UDPServer.Stop() | ||||||
|  | 		session.UDPServer = nil | ||||||
|  | 	} | ||||||
|  | 	if session.Running() { | ||||||
|  | 		session.Cancel() | ||||||
|  | 	} | ||||||
|  | 	if session.Stream != nil { | ||||||
|  | 		collection.Delete(session.StreamPath) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // AcceptPush 接受推流 | ||||||
|  | func (session *RTSP) AcceptPush() { | ||||||
|  | 	defer session.Stop() | ||||||
|  | 	buf2 := make([]byte, 2) | ||||||
|  | 	timer := time.Unix(0, 0) | ||||||
|  | 	for { | ||||||
|  | 		buf1, err := session.connRW.ReadByte() | ||||||
|  | 		if err != nil { | ||||||
|  | 			Println(err) | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 		if buf1 == 0x24 { //rtp data | ||||||
|  | 			if buf1, err = session.connRW.ReadByte(); err != nil { | ||||||
|  | 				Println(err) | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 			if _, err := io.ReadFull(session.connRW, buf2); err != nil { | ||||||
|  | 				Println(err) | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 			channel := int(buf1) | ||||||
|  | 			rtpLen := int(binary.BigEndian.Uint16(buf2)) | ||||||
|  | 			pack := new(RTPPack) | ||||||
|  | 			rtpBytes := make([]byte, rtpLen) | ||||||
|  | 			if _, err := io.ReadFull(session.connRW, rtpBytes); err != nil { | ||||||
|  | 				Println(err) | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 			if err = pack.Unmarshal(rtpBytes); err != nil { | ||||||
|  | 				Println(err) | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 			switch channel { | ||||||
|  | 			case session.aRTPChannel: | ||||||
|  | 				pack.Type = RTP_TYPE_AUDIO | ||||||
|  | 				elapsed := time.Now().Sub(timer) | ||||||
|  | 				if elapsed >= 30*time.Second { | ||||||
|  | 					Println("Recv an audio RTP package") | ||||||
|  | 					timer = time.Now() | ||||||
|  | 				} | ||||||
|  | 			case session.aRTPControlChannel: | ||||||
|  | 				pack.Type = RTP_TYPE_AUDIOCONTROL | ||||||
|  | 			case session.vRTPChannel: | ||||||
|  | 				pack.Type = RTP_TYPE_VIDEO | ||||||
|  | 				elapsed := time.Now().Sub(timer) | ||||||
|  | 				if elapsed >= 30*time.Second { | ||||||
|  | 					Println("Recv an video RTP package") | ||||||
|  | 					timer = time.Now() | ||||||
|  | 				} | ||||||
|  | 			case session.vRTPControlChannel: | ||||||
|  | 				pack.Type = RTP_TYPE_VIDEOCONTROL | ||||||
|  | 			default: | ||||||
|  | 				Printf("unknow rtp pack type, %v", pack.Type) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 			session.InBytes += rtpLen + 4 | ||||||
|  | 			session.PushPack(pack) | ||||||
|  | 		} else { // rtsp cmd | ||||||
|  | 			reqBuf := bytes.NewBuffer(nil) | ||||||
|  | 			reqBuf.WriteByte(buf1) | ||||||
|  | 			for { | ||||||
|  | 				if line, isPrefix, err := session.connRW.ReadLine(); err != nil { | ||||||
|  | 					Println(err) | ||||||
|  | 					return | ||||||
|  | 				} else { | ||||||
|  | 					reqBuf.Write(line) | ||||||
|  | 					if !isPrefix { | ||||||
|  | 						reqBuf.WriteString("\r\n") | ||||||
|  | 					} | ||||||
|  | 					if len(line) == 0 { | ||||||
|  | 						req := NewRequest(reqBuf.String()) | ||||||
|  | 						if req == nil { | ||||||
|  | 							break | ||||||
|  | 						} | ||||||
|  | 						session.InBytes += reqBuf.Len() | ||||||
|  | 						contentLen := req.GetContentLength() | ||||||
|  | 						session.InBytes += contentLen | ||||||
|  | 						if contentLen > 0 { | ||||||
|  | 							bodyBuf := make([]byte, contentLen) | ||||||
|  | 							if n, err := io.ReadFull(session.connRW, bodyBuf); err != nil { | ||||||
|  | 								Println(err) | ||||||
|  | 								return | ||||||
|  | 							} else if n != contentLen { | ||||||
|  | 								Printf("read rtsp request body failed, expect size[%d], got size[%d]", contentLen, n) | ||||||
|  | 								return | ||||||
|  | 							} | ||||||
|  | 							req.Body = string(bodyBuf) | ||||||
|  | 						} | ||||||
|  | 						session.handleRequest(req) | ||||||
|  | 						break | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (session *RTSP) CheckAuth(authLine string, method string) error { | ||||||
|  | 	realmRex := regexp.MustCompile(`realm="(.*?)"`) | ||||||
|  | 	nonceRex := regexp.MustCompile(`nonce="(.*?)"`) | ||||||
|  | 	usernameRex := regexp.MustCompile(`username="(.*?)"`) | ||||||
|  | 	responseRex := regexp.MustCompile(`response="(.*?)"`) | ||||||
|  | 	uriRex := regexp.MustCompile(`uri="(.*?)"`) | ||||||
|  |  | ||||||
|  | 	realm := "" | ||||||
|  | 	nonce := "" | ||||||
|  | 	username := "" | ||||||
|  | 	response := "" | ||||||
|  | 	uri := "" | ||||||
|  | 	result1 := realmRex.FindStringSubmatch(authLine) | ||||||
|  | 	if len(result1) == 2 { | ||||||
|  | 		realm = result1[1] | ||||||
|  | 	} else { | ||||||
|  | 		return fmt.Errorf("CheckAuth error : no realm found") | ||||||
|  | 	} | ||||||
|  | 	result1 = nonceRex.FindStringSubmatch(authLine) | ||||||
|  | 	if len(result1) == 2 { | ||||||
|  | 		nonce = result1[1] | ||||||
|  | 	} else { | ||||||
|  | 		return fmt.Errorf("CheckAuth error : no nonce found") | ||||||
|  | 	} | ||||||
|  | 	if session.nonce != nonce { | ||||||
|  | 		return fmt.Errorf("CheckAuth error : sessionNonce not same as nonce") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	result1 = usernameRex.FindStringSubmatch(authLine) | ||||||
|  | 	if len(result1) == 2 { | ||||||
|  | 		username = result1[1] | ||||||
|  | 	} else { | ||||||
|  | 		return fmt.Errorf("CheckAuth error : username not found") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	result1 = responseRex.FindStringSubmatch(authLine) | ||||||
|  | 	if len(result1) == 2 { | ||||||
|  | 		response = result1[1] | ||||||
|  | 	} else { | ||||||
|  | 		return fmt.Errorf("CheckAuth error : response not found") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	result1 = uriRex.FindStringSubmatch(authLine) | ||||||
|  | 	if len(result1) == 2 { | ||||||
|  | 		uri = result1[1] | ||||||
|  | 	} else { | ||||||
|  | 		return fmt.Errorf("CheckAuth error : uri not found") | ||||||
|  | 	} | ||||||
|  | 	// var user models.User | ||||||
|  | 	// err := db.SQLite.Where("Username = ?", username).First(&user).Error | ||||||
|  | 	// if err != nil { | ||||||
|  | 	// 	return fmt.Errorf("CheckAuth error : user not exists") | ||||||
|  | 	// } | ||||||
|  | 	md5UserRealmPwd := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s:%s:%s", username, realm, session.Auth(username))))) | ||||||
|  | 	md5MethodURL := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s:%s", method, uri)))) | ||||||
|  | 	myResponse := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s:%s:%s", md5UserRealmPwd, nonce, md5MethodURL)))) | ||||||
|  | 	if myResponse != response { | ||||||
|  | 		return fmt.Errorf("CheckAuth error : response not equal") | ||||||
|  | 	} | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (session *RTSP) handleRequest(req *Request) { | ||||||
|  | 	//if session.Timeout > 0 { | ||||||
|  | 	//	session.Conn.SetDeadline(time.Now().Add(time.Duration(session.Timeout) * time.Second)) | ||||||
|  | 	//} | ||||||
|  | 	Printf("<<<\n%s", req) | ||||||
|  | 	res := NewResponse(200, "OK", req.Header["CSeq"], session.ID, "") | ||||||
|  | 	defer func() { | ||||||
|  | 		if p := recover(); p != nil { | ||||||
|  | 			Printf("handleRequest err ocurs:%v", p) | ||||||
|  | 			res.StatusCode = 500 | ||||||
|  | 			res.Status = fmt.Sprintf("Inner Server Error, %v", p) | ||||||
|  | 		} | ||||||
|  | 		Printf(">>>\n%s", res) | ||||||
|  | 		outBytes := []byte(res.String()) | ||||||
|  | 		session.connWLock.Lock() | ||||||
|  | 		session.connRW.Write(outBytes) | ||||||
|  | 		session.connRW.Flush() | ||||||
|  | 		session.connWLock.Unlock() | ||||||
|  | 		session.OutBytes += len(outBytes) | ||||||
|  | 		switch req.Method { | ||||||
|  | 		case "PLAY", "RECORD": | ||||||
|  | 			switch session.Type { | ||||||
|  | 			case SESSEION_TYPE_PLAYER: | ||||||
|  | 				// if session.Pusher.HasPlayer(session.Player) { | ||||||
|  | 				// 	session.Player.Pause(false) | ||||||
|  | 				// } else { | ||||||
|  | 				// 	session.Pusher.AddPlayer(session.Player) | ||||||
|  | 				// } | ||||||
|  | 			} | ||||||
|  | 		case "TEARDOWN": | ||||||
|  | 			{ | ||||||
|  | 				session.Stop() | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		if res.StatusCode != 200 && res.StatusCode != 401 { | ||||||
|  | 			Printf("Response request error[%d]. stop session.", res.StatusCode) | ||||||
|  | 			session.Stop() | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  | 	if req.Method != "OPTIONS" { | ||||||
|  | 		if session.Auth != nil { | ||||||
|  | 			authLine := req.Header["Authorization"] | ||||||
|  | 			authFailed := true | ||||||
|  | 			if authLine != "" { | ||||||
|  | 				err := session.CheckAuth(authLine, req.Method) | ||||||
|  | 				if err == nil { | ||||||
|  | 					authFailed = false | ||||||
|  | 				} else { | ||||||
|  | 					Printf("%v", err) | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			if authFailed { | ||||||
|  | 				res.StatusCode = 401 | ||||||
|  | 				res.Status = "Unauthorized" | ||||||
|  | 				nonce := fmt.Sprintf("%x", md5.Sum([]byte(shortid.MustGenerate()))) | ||||||
|  | 				session.nonce = nonce | ||||||
|  | 				res.Header["WWW-Authenticate"] = fmt.Sprintf(`Digest realm="EasyDarwin", nonce="%s", algorithm="MD5"`, nonce) | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	switch req.Method { | ||||||
|  | 	case "OPTIONS": | ||||||
|  | 		res.Header["Public"] = "DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, OPTIONS, ANNOUNCE, RECORD" | ||||||
|  | 	case "ANNOUNCE": | ||||||
|  | 		session.Type = SESSION_TYPE_PUSHER | ||||||
|  | 		session.URL = req.URL | ||||||
|  |  | ||||||
|  | 		url, err := url.Parse(req.URL) | ||||||
|  | 		if err != nil { | ||||||
|  | 			res.StatusCode = 500 | ||||||
|  | 			res.Status = "Invalid URL" | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 		streamPath := strings.TrimPrefix(url.Path, "/") | ||||||
|  |  | ||||||
|  | 		session.SDPRaw = req.Body | ||||||
|  | 		session.SDPMap = ParseSDP(req.Body) | ||||||
|  | 		if session.Publish(streamPath) { | ||||||
|  | 			if session.ASdp, session.HasAudio = session.SDPMap["audio"]; session.HasAudio { | ||||||
|  | 				if len(session.ASdp.Control) > 0 { | ||||||
|  | 					session.WriteASC(session.ASdp.Config) | ||||||
|  | 				} else { | ||||||
|  | 					session.setAudioFormat() | ||||||
|  | 				} | ||||||
|  | 				Printf("audio codec[%s]\n", session.ASdp.Codec) | ||||||
|  | 			} | ||||||
|  | 			if session.VSdp, session.HasVideo = session.SDPMap["video"]; session.HasVideo { | ||||||
|  | 				if len(session.VSdp.SpropParameterSets) > 1 { | ||||||
|  | 					session.WriteSPS(session.VSdp.SpropParameterSets[0]) | ||||||
|  | 					session.WritePPS(session.VSdp.SpropParameterSets[1]) | ||||||
|  | 				} | ||||||
|  | 				Printf("video codec[%s]\n", session.VSdp.Codec) | ||||||
|  | 			} | ||||||
|  | 			session.Stream.Type = "RTSP" | ||||||
|  | 			session.RTSPInfo.StreamInfo = &session.Stream.StreamInfo | ||||||
|  | 			collection.Store(streamPath, session) | ||||||
|  | 		} | ||||||
|  | 	case "DESCRIBE": | ||||||
|  | 		session.Type = SESSEION_TYPE_PLAYER | ||||||
|  | 		session.URL = req.URL | ||||||
|  | 		url, err := url.Parse(req.URL) | ||||||
|  | 		if err != nil { | ||||||
|  | 			res.StatusCode = 500 | ||||||
|  | 			res.Status = "Invalid URL" | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 		streamPath := url.Path | ||||||
|  | 		stream := FindStream(streamPath) | ||||||
|  | 		if stream == nil { | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 		// | ||||||
|  | 		//res.SetBody(session.SDPRaw) | ||||||
|  | 	case "SETUP": | ||||||
|  | 		ts := req.Header["Transport"] | ||||||
|  | 		// control字段可能是`stream=1`字样,也可能是rtsp://...字样。即control可能是url的path,也可能是整个url | ||||||
|  | 		// 例1: | ||||||
|  | 		// a=control:streamid=1 | ||||||
|  | 		// 例2: | ||||||
|  | 		// a=control:rtsp://192.168.1.64/trackID=1 | ||||||
|  | 		// 例3: | ||||||
|  | 		// a=control:?ctype=video | ||||||
|  | 		setupUrl, err := url.Parse(req.URL) | ||||||
|  | 		if err != nil { | ||||||
|  | 			res.StatusCode = 500 | ||||||
|  | 			res.Status = "Invalid URL" | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 		if setupUrl.Port() == "" { | ||||||
|  | 			setupUrl.Host = fmt.Sprintf("%s:554", setupUrl.Host) | ||||||
|  | 		} | ||||||
|  | 		setupPath := setupUrl.String() | ||||||
|  |  | ||||||
|  | 		// error status. SETUP without ANNOUNCE or DESCRIBE. | ||||||
|  | 		//if session.Pusher == nil { | ||||||
|  | 		//	res.StatusCode = 500 | ||||||
|  | 		//	res.Status = "Error Status" | ||||||
|  | 		//	return | ||||||
|  | 		//} | ||||||
|  | 		var vPath, aPath string | ||||||
|  | 		if session.HasVideo { | ||||||
|  | 			if strings.Index(strings.ToLower(session.VSdp.Control), "rtsp://") == 0 { | ||||||
|  | 				vControlUrl, err := url.Parse(session.VSdp.Control) | ||||||
|  | 				if err != nil { | ||||||
|  | 					res.StatusCode = 500 | ||||||
|  | 					res.Status = "Invalid VControl" | ||||||
|  | 					return | ||||||
|  | 				} | ||||||
|  | 				if vControlUrl.Port() == "" { | ||||||
|  | 					vControlUrl.Host = fmt.Sprintf("%s:554", vControlUrl.Host) | ||||||
|  | 				} | ||||||
|  | 				vPath = vControlUrl.String() | ||||||
|  | 			} else { | ||||||
|  | 				vPath = session.VSdp.Control | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		if session.HasAudio { | ||||||
|  | 			if strings.Index(strings.ToLower(session.ASdp.Control), "rtsp://") == 0 { | ||||||
|  | 				aControlUrl, err := url.Parse(session.ASdp.Control) | ||||||
|  | 				if err != nil { | ||||||
|  | 					res.StatusCode = 500 | ||||||
|  | 					res.Status = "Invalid AControl" | ||||||
|  | 					return | ||||||
|  | 				} | ||||||
|  | 				if aControlUrl.Port() == "" { | ||||||
|  | 					aControlUrl.Host = fmt.Sprintf("%s:554", aControlUrl.Host) | ||||||
|  | 				} | ||||||
|  | 				aPath = aControlUrl.String() | ||||||
|  | 			} else { | ||||||
|  | 				aPath = session.ASdp.Control | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		mtcp := regexp.MustCompile("interleaved=(\\d+)(-(\\d+))?") | ||||||
|  | 		mudp := regexp.MustCompile("client_port=(\\d+)(-(\\d+))?") | ||||||
|  |  | ||||||
|  | 		if tcpMatchs := mtcp.FindStringSubmatch(ts); tcpMatchs != nil { | ||||||
|  | 			session.TransType = TRANS_TYPE_TCP | ||||||
|  | 			if setupPath == aPath || aPath != "" && strings.LastIndex(setupPath, aPath) == len(setupPath)-len(aPath) { | ||||||
|  | 				session.aRTPChannel, _ = strconv.Atoi(tcpMatchs[1]) | ||||||
|  | 				session.aRTPControlChannel, _ = strconv.Atoi(tcpMatchs[3]) | ||||||
|  | 			} else if setupPath == vPath || vPath != "" && strings.LastIndex(setupPath, vPath) == len(setupPath)-len(vPath) { | ||||||
|  | 				session.vRTPChannel, _ = strconv.Atoi(tcpMatchs[1]) | ||||||
|  | 				session.vRTPControlChannel, _ = strconv.Atoi(tcpMatchs[3]) | ||||||
|  | 			} else { | ||||||
|  | 				res.StatusCode = 500 | ||||||
|  | 				res.Status = fmt.Sprintf("SETUP [TCP] got UnKown control:%s", setupPath) | ||||||
|  | 				Printf("SETUP [TCP] got UnKown control:%s", setupPath) | ||||||
|  | 			} | ||||||
|  | 			Printf("Parse SETUP req.TRANSPORT:TCP.Session.Type:%d,control:%s, AControl:%s,VControl:%s", session.Type, setupPath, aPath, vPath) | ||||||
|  | 		} else if udpMatchs := mudp.FindStringSubmatch(ts); udpMatchs != nil { | ||||||
|  | 			session.TransType = TRANS_TYPE_UDP | ||||||
|  | 			// no need for tcp timeout. | ||||||
|  | 			session.Conn.timeout = 0 | ||||||
|  | 			if session.Type == SESSEION_TYPE_PLAYER && session.UDPClient == nil { | ||||||
|  | 				session.UDPClient = &UDPClient{} | ||||||
|  | 			} | ||||||
|  | 			if session.Type == SESSION_TYPE_PUSHER && session.UDPServer == nil { | ||||||
|  | 				session.UDPServer = &UDPServer{ | ||||||
|  | 					Session: session, | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			Printf("Parse SETUP req.TRANSPORT:UDP.Session.Type:%d,control:%s, AControl:%s,VControl:%s", session.Type, setupPath, aPath, vPath) | ||||||
|  | 			if setupPath == aPath || aPath != "" && strings.LastIndex(setupPath, aPath) == len(setupPath)-len(aPath) { | ||||||
|  | 				if session.Type == SESSEION_TYPE_PLAYER { | ||||||
|  | 					session.UDPClient.APort, _ = strconv.Atoi(udpMatchs[1]) | ||||||
|  | 					session.UDPClient.AControlPort, _ = strconv.Atoi(udpMatchs[3]) | ||||||
|  | 					if err := session.UDPClient.SetupAudio(); err != nil { | ||||||
|  | 						res.StatusCode = 500 | ||||||
|  | 						res.Status = fmt.Sprintf("udp client setup audio error, %v", err) | ||||||
|  | 						return | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 				if session.Type == SESSION_TYPE_PUSHER { | ||||||
|  | 					if err := session.UDPServer.SetupAudio(); err != nil { | ||||||
|  | 						res.StatusCode = 500 | ||||||
|  | 						res.Status = fmt.Sprintf("udp server setup audio error, %v", err) | ||||||
|  | 						return | ||||||
|  | 					} | ||||||
|  | 					tss := strings.Split(ts, ";") | ||||||
|  | 					idx := -1 | ||||||
|  | 					for i, val := range tss { | ||||||
|  | 						if val == udpMatchs[0] { | ||||||
|  | 							idx = i | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 					tail := append([]string{}, tss[idx+1:]...) | ||||||
|  | 					tss = append(tss[:idx+1], fmt.Sprintf("server_port=%d-%d", session.UDPServer.APort, session.UDPServer.AControlPort)) | ||||||
|  | 					tss = append(tss, tail...) | ||||||
|  | 					ts = strings.Join(tss, ";") | ||||||
|  | 				} | ||||||
|  | 			} else if setupPath == vPath || vPath != "" && strings.LastIndex(setupPath, vPath) == len(setupPath)-len(vPath) { | ||||||
|  | 				if session.Type == SESSEION_TYPE_PLAYER { | ||||||
|  | 					session.UDPClient.VPort, _ = strconv.Atoi(udpMatchs[1]) | ||||||
|  | 					session.UDPClient.VControlPort, _ = strconv.Atoi(udpMatchs[3]) | ||||||
|  | 					if err := session.UDPClient.SetupVideo(); err != nil { | ||||||
|  | 						res.StatusCode = 500 | ||||||
|  | 						res.Status = fmt.Sprintf("udp client setup video error, %v", err) | ||||||
|  | 						return | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  |  | ||||||
|  | 				if session.Type == SESSION_TYPE_PUSHER { | ||||||
|  | 					if err := session.UDPServer.SetupVideo(); err != nil { | ||||||
|  | 						res.StatusCode = 500 | ||||||
|  | 						res.Status = fmt.Sprintf("udp server setup video error, %v", err) | ||||||
|  | 						return | ||||||
|  | 					} | ||||||
|  | 					tss := strings.Split(ts, ";") | ||||||
|  | 					idx := -1 | ||||||
|  | 					for i, val := range tss { | ||||||
|  | 						if val == udpMatchs[0] { | ||||||
|  | 							idx = i | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 					tail := append([]string{}, tss[idx+1:]...) | ||||||
|  | 					tss = append(tss[:idx+1], fmt.Sprintf("server_port=%d-%d", session.UDPServer.VPort, session.UDPServer.VControlPort)) | ||||||
|  | 					tss = append(tss, tail...) | ||||||
|  | 					ts = strings.Join(tss, ";") | ||||||
|  | 				} | ||||||
|  | 			} else { | ||||||
|  | 				Printf("SETUP [UDP] got UnKown control:%s", setupPath) | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		res.Header["Transport"] = ts | ||||||
|  | 	case "PLAY": | ||||||
|  | 		// error status. PLAY without ANNOUNCE or DESCRIBE. | ||||||
|  | 		// if session.Pusher == nil { | ||||||
|  | 		// 	res.StatusCode = 500 | ||||||
|  | 		// 	res.Status = "Error Status" | ||||||
|  | 		// 	return | ||||||
|  | 		// } | ||||||
|  | 		res.Header["Range"] = req.Header["Range"] | ||||||
|  | 	case "RECORD": | ||||||
|  | 		// error status. RECORD without ANNOUNCE or DESCRIBE. | ||||||
|  | 		// if session.Pusher == nil { | ||||||
|  | 		// 	res.StatusCode = 500 | ||||||
|  | 		// 	res.Status = "Error Status" | ||||||
|  | 		// 	return | ||||||
|  | 		// } | ||||||
|  | 	case "PAUSE": | ||||||
|  | 		// if session.Player == nil { | ||||||
|  | 		// 	res.StatusCode = 500 | ||||||
|  | 		// 	res.Status = "Error Status" | ||||||
|  | 		// 	return | ||||||
|  | 		// } | ||||||
|  | 		// session.Player.Pause(true) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (session *RTSP) SendRTP(pack *RTPPack) (err error) { | ||||||
|  | 	if pack == nil { | ||||||
|  | 		err = fmt.Errorf("player send rtp got nil pack") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if session.TransType == TRANS_TYPE_UDP { | ||||||
|  | 		if session.UDPClient == nil { | ||||||
|  | 			err = fmt.Errorf("player use udp transport but udp client not found") | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 		err = session.UDPClient.SendRTP(pack) | ||||||
|  | 		session.OutBytes += len(pack.Raw) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	switch pack.Type { | ||||||
|  | 	case RTP_TYPE_AUDIO: | ||||||
|  | 		bufChannel := make([]byte, 2) | ||||||
|  | 		bufChannel[0] = 0x24 | ||||||
|  | 		bufChannel[1] = byte(session.aRTPChannel) | ||||||
|  | 		session.connWLock.Lock() | ||||||
|  | 		session.connRW.Write(bufChannel) | ||||||
|  | 		bufLen := make([]byte, 2) | ||||||
|  | 		binary.BigEndian.PutUint16(bufLen, uint16(len(pack.Raw))) | ||||||
|  | 		session.connRW.Write(bufLen) | ||||||
|  | 		session.connRW.Write(pack.Raw) | ||||||
|  | 		session.connRW.Flush() | ||||||
|  | 		session.connWLock.Unlock() | ||||||
|  | 		session.OutBytes += len(pack.Raw) + 4 | ||||||
|  | 	case RTP_TYPE_AUDIOCONTROL: | ||||||
|  | 		bufChannel := make([]byte, 2) | ||||||
|  | 		bufChannel[0] = 0x24 | ||||||
|  | 		bufChannel[1] = byte(session.aRTPControlChannel) | ||||||
|  | 		session.connWLock.Lock() | ||||||
|  | 		session.connRW.Write(bufChannel) | ||||||
|  | 		bufLen := make([]byte, 2) | ||||||
|  | 		binary.BigEndian.PutUint16(bufLen, uint16(len(pack.Raw))) | ||||||
|  | 		session.connRW.Write(bufLen) | ||||||
|  | 		session.connRW.Write(pack.Raw) | ||||||
|  | 		session.connRW.Flush() | ||||||
|  | 		session.connWLock.Unlock() | ||||||
|  | 		session.OutBytes += len(pack.Raw) + 4 | ||||||
|  | 	case RTP_TYPE_VIDEO: | ||||||
|  | 		bufChannel := make([]byte, 2) | ||||||
|  | 		bufChannel[0] = 0x24 | ||||||
|  | 		bufChannel[1] = byte(session.vRTPChannel) | ||||||
|  | 		session.connWLock.Lock() | ||||||
|  | 		session.connRW.Write(bufChannel) | ||||||
|  | 		bufLen := make([]byte, 2) | ||||||
|  | 		binary.BigEndian.PutUint16(bufLen, uint16(len(pack.Raw))) | ||||||
|  | 		session.connRW.Write(bufLen) | ||||||
|  | 		session.connRW.Write(pack.Raw) | ||||||
|  | 		session.connRW.Flush() | ||||||
|  | 		session.connWLock.Unlock() | ||||||
|  | 		session.OutBytes += len(pack.Raw) + 4 | ||||||
|  | 	case RTP_TYPE_VIDEOCONTROL: | ||||||
|  | 		bufChannel := make([]byte, 2) | ||||||
|  | 		bufChannel[0] = 0x24 | ||||||
|  | 		bufChannel[1] = byte(session.vRTPControlChannel) | ||||||
|  | 		session.connWLock.Lock() | ||||||
|  | 		session.connRW.Write(bufChannel) | ||||||
|  | 		bufLen := make([]byte, 2) | ||||||
|  | 		binary.BigEndian.PutUint16(bufLen, uint16(len(pack.Raw))) | ||||||
|  | 		session.connRW.Write(bufLen) | ||||||
|  | 		session.connRW.Write(pack.Raw) | ||||||
|  | 		session.connRW.Flush() | ||||||
|  | 		session.connWLock.Unlock() | ||||||
|  | 		session.OutBytes += len(pack.Raw) + 4 | ||||||
|  | 	default: | ||||||
|  | 		err = fmt.Errorf("session tcp send rtp got unkown pack type[%v]", pack.Type) | ||||||
|  | 	} | ||||||
|  | 	return | ||||||
|  | } | ||||||
| @@ -1,68 +0,0 @@ | |||||||
| package rtsp |  | ||||||
|  |  | ||||||
| import ( |  | ||||||
| 	"github.com/aler9/gortsplib" |  | ||||||
| 	"github.com/aler9/gortsplib/pkg/mpeg4audio" |  | ||||||
| 	. "m7s.live/engine/v4" |  | ||||||
| 	"m7s.live/engine/v4/codec" |  | ||||||
| 	"m7s.live/engine/v4/track" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| type RTSPSubscriber struct { |  | ||||||
| 	Subscriber |  | ||||||
| 	RTSPIO |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (s *RTSPSubscriber) OnEvent(event any) { |  | ||||||
| 	switch v := event.(type) { |  | ||||||
| 	case *track.Video: |  | ||||||
| 		if s.Video.Track != nil { |  | ||||||
| 			return |  | ||||||
| 		} |  | ||||||
| 		switch v.CodecID { |  | ||||||
| 		case codec.CodecID_H264: |  | ||||||
| 			extra := v.DecoderConfiguration.Raw |  | ||||||
| 			vtrack := &gortsplib.TrackH264{ |  | ||||||
| 				PayloadType: v.DecoderConfiguration.PayloadType, SPS: extra[0], PPS: extra[1], |  | ||||||
| 			} |  | ||||||
| 			s.videoTrackId = len(s.tracks) |  | ||||||
| 			s.tracks = append(s.tracks, vtrack) |  | ||||||
| 		case codec.CodecID_H265: |  | ||||||
| 			vtrack := &gortsplib.TrackH265{ |  | ||||||
| 				PayloadType: v.DecoderConfiguration.PayloadType, VPS: v.DecoderConfiguration.Raw[0], SPS: v.DecoderConfiguration.Raw[1], PPS: v.DecoderConfiguration.Raw[2], |  | ||||||
| 			} |  | ||||||
| 			s.videoTrackId = len(s.tracks) |  | ||||||
| 			s.tracks = append(s.tracks, vtrack) |  | ||||||
| 		} |  | ||||||
| 		s.AddTrack(v) |  | ||||||
| 	case *track.Audio: |  | ||||||
| 		if s.Audio.Track != nil { |  | ||||||
| 			return |  | ||||||
| 		} |  | ||||||
| 		switch v.CodecID { |  | ||||||
| 		case codec.CodecID_AAC: |  | ||||||
| 			var mpegConf mpeg4audio.Config |  | ||||||
| 			mpegConf.Unmarshal(v.DecoderConfiguration.Raw) |  | ||||||
| 			atrack := &gortsplib.TrackMPEG4Audio{ |  | ||||||
| 				PayloadType: v.DecoderConfiguration.PayloadType, Config: &mpegConf, SizeLength: 13, IndexLength: 3, IndexDeltaLength: 3, |  | ||||||
| 			} |  | ||||||
| 			s.audioTrackId = len(s.tracks) |  | ||||||
| 			s.tracks = append(s.tracks, atrack) |  | ||||||
| 		case codec.CodecID_PCMA: |  | ||||||
| 			s.audioTrackId = len(s.tracks) |  | ||||||
| 			s.tracks = append(s.tracks, &gortsplib.TrackPCMA{}) |  | ||||||
| 		case codec.CodecID_PCMU: |  | ||||||
| 			s.audioTrackId = len(s.tracks) |  | ||||||
| 			s.tracks = append(s.tracks, &gortsplib.TrackPCMU{}) |  | ||||||
| 		} |  | ||||||
| 		s.AddTrack(v) |  | ||||||
| 	case ISubscriber: |  | ||||||
| 		s.stream = gortsplib.NewServerStream(s.tracks) |  | ||||||
| 	case VideoRTP: |  | ||||||
| 		s.stream.WritePacketRTP(s.videoTrackId, &v.Packet) |  | ||||||
| 	case AudioRTP: |  | ||||||
| 		s.stream.WritePacketRTP(s.audioTrackId, &v.Packet) |  | ||||||
| 	default: |  | ||||||
| 		s.Subscriber.OnEvent(event) |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
							
								
								
									
										161
									
								
								udp-client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										161
									
								
								udp-client.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,161 @@ | |||||||
|  | package rtsp | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	. "github.com/Monibuca/engine/v2" | ||||||
|  | 	. "github.com/Monibuca/plugin-rtp" | ||||||
|  | 	"net" | ||||||
|  | 	"strings" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type UDPClient struct { | ||||||
|  | 	APort        int | ||||||
|  | 	AConn        *net.UDPConn | ||||||
|  | 	AControlPort int | ||||||
|  | 	AControlConn *net.UDPConn | ||||||
|  | 	VPort        int | ||||||
|  | 	VConn        *net.UDPConn | ||||||
|  | 	VControlPort int | ||||||
|  | 	VControlConn *net.UDPConn | ||||||
|  |  | ||||||
|  | 	Stoped bool | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (s *UDPClient) Stop() { | ||||||
|  | 	if s.Stoped { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	s.Stoped = true | ||||||
|  | 	if s.AConn != nil { | ||||||
|  | 		s.AConn.Close() | ||||||
|  | 		s.AConn = nil | ||||||
|  | 	} | ||||||
|  | 	if s.AControlConn != nil { | ||||||
|  | 		s.AControlConn.Close() | ||||||
|  | 		s.AControlConn = nil | ||||||
|  | 	} | ||||||
|  | 	if s.VConn != nil { | ||||||
|  | 		s.VConn.Close() | ||||||
|  | 		s.VConn = nil | ||||||
|  | 	} | ||||||
|  | 	if s.VControlConn != nil { | ||||||
|  | 		s.VControlConn.Close() | ||||||
|  | 		s.VControlConn = nil | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (c *UDPClient) SetupAudio() (err error) { | ||||||
|  | 	defer func() { | ||||||
|  | 		if err != nil { | ||||||
|  | 			Println(err) | ||||||
|  | 			c.Stop() | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  | 	host := c.AConn.RemoteAddr().String() | ||||||
|  | 	host = host[:strings.LastIndex(host, ":")] | ||||||
|  | 	addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", host, c.APort)) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	c.AConn, err = net.DialUDP("udp", nil, addr) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	networkBuffer := 1048576 | ||||||
|  | 	if err := c.AConn.SetReadBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp client audio conn set read buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	if err := c.AConn.SetWriteBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp client audio conn set write buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	addr, err = net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", host, c.AControlPort)) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	c.AControlConn, err = net.DialUDP("udp", nil, addr) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if err := c.AControlConn.SetReadBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp client audio control conn set read buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	if err := c.AControlConn.SetWriteBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp client audio control conn set write buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (c *UDPClient) SetupVideo() (err error) { | ||||||
|  | 	defer func() { | ||||||
|  | 		if err != nil { | ||||||
|  | 			Println(err) | ||||||
|  | 			c.Stop() | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  | 	host := c.VConn.RemoteAddr().String() | ||||||
|  | 	host = host[:strings.LastIndex(host, ":")] | ||||||
|  | 	addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", host, c.VPort)) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	c.VConn, err = net.DialUDP("udp", nil, addr) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	networkBuffer := 1048576 | ||||||
|  | 	if err := c.VConn.SetReadBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp client video conn set read buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	if err := c.VConn.SetWriteBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp client video conn set write buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	addr, err = net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", host, c.VControlPort)) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	c.VControlConn, err = net.DialUDP("udp", nil, addr) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if err := c.VControlConn.SetReadBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp client video control conn set read buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	if err := c.VControlConn.SetWriteBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp client video control conn set write buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (c *UDPClient) SendRTP(pack *RTPPack) (err error) { | ||||||
|  | 	if pack == nil { | ||||||
|  | 		err = fmt.Errorf("udp client send rtp got nil pack") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	var conn *net.UDPConn | ||||||
|  | 	switch pack.Type { | ||||||
|  | 	case RTP_TYPE_AUDIO: | ||||||
|  | 		conn = c.AConn | ||||||
|  | 	case RTP_TYPE_AUDIOCONTROL: | ||||||
|  | 		conn = c.AControlConn | ||||||
|  | 	case RTP_TYPE_VIDEO: | ||||||
|  | 		conn = c.VConn | ||||||
|  | 	case RTP_TYPE_VIDEOCONTROL: | ||||||
|  | 		conn = c.VControlConn | ||||||
|  | 	default: | ||||||
|  | 		err = fmt.Errorf("udp client send rtp got unkown pack type[%v]", pack.Type) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if conn == nil { | ||||||
|  | 		err = fmt.Errorf("udp client send rtp pack type[%v] failed, conn not found", pack.Type) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if _, err = conn.Write(pack.Raw); err != nil { | ||||||
|  | 		err = fmt.Errorf("udp client write bytes error, %v", err) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// Printf("udp client write [%d/%d]", n, pack.Buffer.Len()) | ||||||
|  | 	return | ||||||
|  | } | ||||||
							
								
								
									
										235
									
								
								udp-server.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										235
									
								
								udp-server.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,235 @@ | |||||||
|  | package rtsp | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"net" | ||||||
|  | 	"strconv" | ||||||
|  | 	"strings" | ||||||
|  | 	"sync" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	. "github.com/Monibuca/engine/v2" | ||||||
|  | 	. "github.com/Monibuca/plugin-rtp" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type UDPServer struct { | ||||||
|  | 	Session *RTSP | ||||||
|  | 	UDPClient | ||||||
|  | 	sync.Mutex | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (s *UDPServer) AddInputBytes(bytes int) { | ||||||
|  | 	if s.Session != nil { | ||||||
|  | 		s.Session.InBytes += bytes | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	panic(fmt.Errorf("session and RTSPClient both nil")) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (s *UDPServer) HandleRTP(pack *RTPPack) { | ||||||
|  | 	s.Lock() | ||||||
|  | 	defer s.Unlock() | ||||||
|  | 	if s.Session != nil { | ||||||
|  | 		s.Session.PushPack(pack) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (s *UDPServer) Stop() { | ||||||
|  | 	if s.Stoped { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	s.Stoped = true | ||||||
|  | 	if s.AConn != nil { | ||||||
|  | 		s.AConn.Close() | ||||||
|  | 		s.AConn = nil | ||||||
|  | 	} | ||||||
|  | 	if s.AControlConn != nil { | ||||||
|  | 		s.AControlConn.Close() | ||||||
|  | 		s.AControlConn = nil | ||||||
|  | 	} | ||||||
|  | 	if s.VConn != nil { | ||||||
|  | 		s.VConn.Close() | ||||||
|  | 		s.VConn = nil | ||||||
|  | 	} | ||||||
|  | 	if s.VControlConn != nil { | ||||||
|  | 		s.VControlConn.Close() | ||||||
|  | 		s.VControlConn = nil | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (s *UDPServer) SetupAudio() (err error) { | ||||||
|  | 	addr, err := net.ResolveUDPAddr("udp", ":0") | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	s.AConn, err = net.ListenUDP("udp", addr) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	networkBuffer := 1048576 | ||||||
|  | 	if err := s.AConn.SetReadBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp server audio conn set read buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	if err := s.AConn.SetWriteBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp server audio conn set write buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	la := s.AConn.LocalAddr().String() | ||||||
|  | 	strPort := la[strings.LastIndex(la, ":")+1:] | ||||||
|  | 	s.APort, err = strconv.Atoi(strPort) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	go func() { | ||||||
|  | 		bufUDP := make([]byte, UDP_BUF_SIZE) | ||||||
|  | 		Printf("udp server start listen audio port[%d]", s.APort) | ||||||
|  | 		defer Printf("udp server stop listen audio port[%d]", s.APort) | ||||||
|  | 		timer := time.Unix(0, 0) | ||||||
|  | 		for !s.Stoped { | ||||||
|  | 			if n, _, err := s.AConn.ReadFromUDP(bufUDP); err == nil { | ||||||
|  | 				elapsed := time.Now().Sub(timer) | ||||||
|  | 				if elapsed >= 30*time.Second { | ||||||
|  | 					Printf("Package recv from AConn.len:%d\n", n) | ||||||
|  | 					timer = time.Now() | ||||||
|  | 				} | ||||||
|  | 				s.AddInputBytes(n) | ||||||
|  | 				pack := &RTPPack{ | ||||||
|  | 					Type: RTP_TYPE_AUDIO, | ||||||
|  | 				} | ||||||
|  | 				pack.Unmarshal(bufUDP[:n]) | ||||||
|  | 				s.HandleRTP(pack) | ||||||
|  | 			} else { | ||||||
|  | 				Println("udp server read audio pack error", err) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  | 	addr, err = net.ResolveUDPAddr("udp", ":0") | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	s.AControlConn, err = net.ListenUDP("udp", addr) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if err := s.AControlConn.SetReadBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp server audio control conn set read buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	if err := s.AControlConn.SetWriteBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp server audio control conn set write buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	la = s.AControlConn.LocalAddr().String() | ||||||
|  | 	strPort = la[strings.LastIndex(la, ":")+1:] | ||||||
|  | 	s.AControlPort, err = strconv.Atoi(strPort) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	go func() { | ||||||
|  | 		bufUDP := make([]byte, UDP_BUF_SIZE) | ||||||
|  | 		Printf("udp server start listen audio control port[%d]", s.AControlPort) | ||||||
|  | 		defer Printf("udp server stop listen audio control port[%d]", s.AControlPort) | ||||||
|  | 		for !s.Stoped { | ||||||
|  | 			if n, _, err := s.AControlConn.ReadFromUDP(bufUDP); err == nil { | ||||||
|  | 				//Printf("Package recv from AControlConn.len:%d\n", n) | ||||||
|  | 				s.AddInputBytes(n) | ||||||
|  | 				pack := &RTPPack{ | ||||||
|  | 					Type: RTP_TYPE_AUDIOCONTROL, | ||||||
|  | 				} | ||||||
|  | 				pack.Unmarshal(bufUDP[:n]) | ||||||
|  | 				s.HandleRTP(pack) | ||||||
|  | 			} else { | ||||||
|  | 				Println("udp server read audio control pack error", err) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (s *UDPServer) SetupVideo() (err error) { | ||||||
|  | 	addr, err := net.ResolveUDPAddr("udp", ":0") | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	s.VConn, err = net.ListenUDP("udp", addr) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	networkBuffer := 1048576 | ||||||
|  | 	if err := s.VConn.SetReadBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp server video conn set read buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	if err := s.VConn.SetWriteBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp server video conn set write buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	la := s.VConn.LocalAddr().String() | ||||||
|  | 	strPort := la[strings.LastIndex(la, ":")+1:] | ||||||
|  | 	s.VPort, err = strconv.Atoi(strPort) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	go func() { | ||||||
|  | 		bufUDP := make([]byte, UDP_BUF_SIZE) | ||||||
|  | 		Printf("udp server start listen video port[%d]", s.VPort) | ||||||
|  | 		defer Printf("udp server stop listen video port[%d]", s.VPort) | ||||||
|  | 		timer := time.Unix(0, 0) | ||||||
|  | 		for !s.Stoped { | ||||||
|  | 			if n, _, err := s.VConn.ReadFromUDP(bufUDP); err == nil { | ||||||
|  | 				elapsed := time.Now().Sub(timer) | ||||||
|  | 				if elapsed >= 30*time.Second { | ||||||
|  | 					Printf("Package recv from VConn.len:%d\n", n) | ||||||
|  | 					timer = time.Now() | ||||||
|  | 				} | ||||||
|  | 				s.AddInputBytes(n) | ||||||
|  | 				pack := &RTPPack{ | ||||||
|  | 					Type: RTP_TYPE_VIDEO, | ||||||
|  | 				} | ||||||
|  | 				pack.Unmarshal(bufUDP[:n]) | ||||||
|  | 				s.HandleRTP(pack) | ||||||
|  | 			} else { | ||||||
|  | 				Println("udp server read video pack error", err) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	addr, err = net.ResolveUDPAddr("udp", ":0") | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	s.VControlConn, err = net.ListenUDP("udp", addr) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if err := s.VControlConn.SetReadBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp server video control conn set read buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	if err := s.VControlConn.SetWriteBuffer(networkBuffer); err != nil { | ||||||
|  | 		Printf("udp server video control conn set write buffer error, %v", err) | ||||||
|  | 	} | ||||||
|  | 	la = s.VControlConn.LocalAddr().String() | ||||||
|  | 	strPort = la[strings.LastIndex(la, ":")+1:] | ||||||
|  | 	s.VControlPort, err = strconv.Atoi(strPort) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	go func() { | ||||||
|  | 		bufUDP := make([]byte, UDP_BUF_SIZE) | ||||||
|  | 		Printf("udp server start listen video control port[%d]", s.VControlPort) | ||||||
|  | 		defer Printf("udp server stop listen video control port[%d]", s.VControlPort) | ||||||
|  | 		for !s.Stoped { | ||||||
|  | 			if n, _, err := s.VControlConn.ReadFromUDP(bufUDP); err == nil { | ||||||
|  | 				//Printf("Package recv from VControlConn.len:%d\n", n) | ||||||
|  | 				s.AddInputBytes(n) | ||||||
|  | 				pack := &RTPPack{ | ||||||
|  | 					Type: RTP_TYPE_VIDEOCONTROL, | ||||||
|  | 				} | ||||||
|  | 				pack.Unmarshal(bufUDP[:n]) | ||||||
|  | 				s.HandleRTP(pack) | ||||||
|  | 			} else { | ||||||
|  | 				Println("udp server read video control pack error", err) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  | 	return | ||||||
|  | } | ||||||
							
								
								
									
										19
									
								
								ui/dist/demo.html
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								ui/dist/demo.html
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | <meta charset="utf-8"> | ||||||
|  | <title>plugin-rtsp demo</title> | ||||||
|  | <script src="https://unpkg.com/vue"></script> | ||||||
|  | <script src="./plugin-rtsp.umd.js"></script> | ||||||
|  |  | ||||||
|  | <link rel="stylesheet" href="./plugin-rtsp.css"> | ||||||
|  |  | ||||||
|  |  | ||||||
|  | <div id="app"> | ||||||
|  |   <demo></demo> | ||||||
|  | </div> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | new Vue({ | ||||||
|  |   components: { | ||||||
|  |     demo: plugin-rtsp | ||||||
|  |   } | ||||||
|  | }).$mount('#app') | ||||||
|  | </script> | ||||||
							
								
								
									
										437
									
								
								ui/dist/plugin-rtsp.common.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										437
									
								
								ui/dist/plugin-rtsp.common.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,437 @@ | |||||||
|  | module.exports = | ||||||
|  | /******/ (function(modules) { // webpackBootstrap | ||||||
|  | /******/ 	// The module cache | ||||||
|  | /******/ 	var installedModules = {}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// The require function | ||||||
|  | /******/ 	function __webpack_require__(moduleId) { | ||||||
|  | /******/ | ||||||
|  | /******/ 		// Check if module is in cache | ||||||
|  | /******/ 		if(installedModules[moduleId]) { | ||||||
|  | /******/ 			return installedModules[moduleId].exports; | ||||||
|  | /******/ 		} | ||||||
|  | /******/ 		// Create a new module (and put it into the cache) | ||||||
|  | /******/ 		var module = installedModules[moduleId] = { | ||||||
|  | /******/ 			i: moduleId, | ||||||
|  | /******/ 			l: false, | ||||||
|  | /******/ 			exports: {} | ||||||
|  | /******/ 		}; | ||||||
|  | /******/ | ||||||
|  | /******/ 		// Execute the module function | ||||||
|  | /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||||||
|  | /******/ | ||||||
|  | /******/ 		// Flag the module as loaded | ||||||
|  | /******/ 		module.l = true; | ||||||
|  | /******/ | ||||||
|  | /******/ 		// Return the exports of the module | ||||||
|  | /******/ 		return module.exports; | ||||||
|  | /******/ 	} | ||||||
|  | /******/ | ||||||
|  | /******/ | ||||||
|  | /******/ 	// expose the modules object (__webpack_modules__) | ||||||
|  | /******/ 	__webpack_require__.m = modules; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// expose the module cache | ||||||
|  | /******/ 	__webpack_require__.c = installedModules; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// define getter function for harmony exports | ||||||
|  | /******/ 	__webpack_require__.d = function(exports, name, getter) { | ||||||
|  | /******/ 		if(!__webpack_require__.o(exports, name)) { | ||||||
|  | /******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||||||
|  | /******/ 		} | ||||||
|  | /******/ 	}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// define __esModule on exports | ||||||
|  | /******/ 	__webpack_require__.r = function(exports) { | ||||||
|  | /******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||||||
|  | /******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||||||
|  | /******/ 		} | ||||||
|  | /******/ 		Object.defineProperty(exports, '__esModule', { value: true }); | ||||||
|  | /******/ 	}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// create a fake namespace object | ||||||
|  | /******/ 	// mode & 1: value is a module id, require it | ||||||
|  | /******/ 	// mode & 2: merge all properties of value into the ns | ||||||
|  | /******/ 	// mode & 4: return value when already ns object | ||||||
|  | /******/ 	// mode & 8|1: behave like require | ||||||
|  | /******/ 	__webpack_require__.t = function(value, mode) { | ||||||
|  | /******/ 		if(mode & 1) value = __webpack_require__(value); | ||||||
|  | /******/ 		if(mode & 8) return value; | ||||||
|  | /******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||||||
|  | /******/ 		var ns = Object.create(null); | ||||||
|  | /******/ 		__webpack_require__.r(ns); | ||||||
|  | /******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||||||
|  | /******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||||||
|  | /******/ 		return ns; | ||||||
|  | /******/ 	}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// getDefaultExport function for compatibility with non-harmony modules | ||||||
|  | /******/ 	__webpack_require__.n = function(module) { | ||||||
|  | /******/ 		var getter = module && module.__esModule ? | ||||||
|  | /******/ 			function getDefault() { return module['default']; } : | ||||||
|  | /******/ 			function getModuleExports() { return module; }; | ||||||
|  | /******/ 		__webpack_require__.d(getter, 'a', getter); | ||||||
|  | /******/ 		return getter; | ||||||
|  | /******/ 	}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// Object.prototype.hasOwnProperty.call | ||||||
|  | /******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// __webpack_public_path__ | ||||||
|  | /******/ 	__webpack_require__.p = ""; | ||||||
|  | /******/ | ||||||
|  | /******/ | ||||||
|  | /******/ 	// Load entry module and return exports | ||||||
|  | /******/ 	return __webpack_require__(__webpack_require__.s = "fb15"); | ||||||
|  | /******/ }) | ||||||
|  | /************************************************************************/ | ||||||
|  | /******/ ({ | ||||||
|  |  | ||||||
|  | /***/ "034f": | ||||||
|  | /***/ (function(module, __webpack_exports__, __webpack_require__) { | ||||||
|  |  | ||||||
|  | "use strict"; | ||||||
|  | /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("85ec"); | ||||||
|  | /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__); | ||||||
|  | /* unused harmony reexport * */ | ||||||
|  |  /* unused harmony default export */ var _unused_webpack_default_export = (_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default.a);  | ||||||
|  |  | ||||||
|  | /***/ }), | ||||||
|  |  | ||||||
|  | /***/ "85ec": | ||||||
|  | /***/ (function(module, exports, __webpack_require__) { | ||||||
|  |  | ||||||
|  | // extracted by mini-css-extract-plugin | ||||||
|  |  | ||||||
|  | /***/ }), | ||||||
|  |  | ||||||
|  | /***/ "f6fd": | ||||||
|  | /***/ (function(module, exports) { | ||||||
|  |  | ||||||
|  | // document.currentScript polyfill by Adam Miller | ||||||
|  |  | ||||||
|  | // MIT license | ||||||
|  |  | ||||||
|  | (function(document){ | ||||||
|  |   var currentScript = "currentScript", | ||||||
|  |       scripts = document.getElementsByTagName('script'); // Live NodeList collection | ||||||
|  |  | ||||||
|  |   // If browser needs currentScript polyfill, add get currentScript() to the document object | ||||||
|  |   if (!(currentScript in document)) { | ||||||
|  |     Object.defineProperty(document, currentScript, { | ||||||
|  |       get: function(){ | ||||||
|  |  | ||||||
|  |         // IE 6-10 supports script readyState | ||||||
|  |         // IE 10+ support stack trace | ||||||
|  |         try { throw new Error(); } | ||||||
|  |         catch (err) { | ||||||
|  |  | ||||||
|  |           // Find the second match for the "at" string to get file src url from stack. | ||||||
|  |           // Specifically works with the format of stack traces in IE. | ||||||
|  |           var i, res = ((/.*at [^\(]*\((.*):.+:.+\)$/ig).exec(err.stack) || [false])[1]; | ||||||
|  |  | ||||||
|  |           // For all scripts on the page, if src matches or if ready state is interactive, return the script tag | ||||||
|  |           for(i in scripts){ | ||||||
|  |             if(scripts[i].src == res || scripts[i].readyState == "interactive"){ | ||||||
|  |               return scripts[i]; | ||||||
|  |             } | ||||||
|  |           } | ||||||
|  |  | ||||||
|  |           // If no match, return null | ||||||
|  |           return null; | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  | })(document); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /***/ }), | ||||||
|  |  | ||||||
|  | /***/ "fb15": | ||||||
|  | /***/ (function(module, __webpack_exports__, __webpack_require__) { | ||||||
|  |  | ||||||
|  | "use strict"; | ||||||
|  | // ESM COMPAT FLAG | ||||||
|  | __webpack_require__.r(__webpack_exports__); | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js | ||||||
|  | // This file is imported into lib/wc client bundles. | ||||||
|  |  | ||||||
|  | if (typeof window !== 'undefined') { | ||||||
|  |   if (true) { | ||||||
|  |     __webpack_require__("f6fd") | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   var i | ||||||
|  |   if ((i = window.document.currentScript) && (i = i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))) { | ||||||
|  |     __webpack_require__.p = i[1] // eslint-disable-line | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Indicate to webpack that this file can be concatenated | ||||||
|  | /* harmony default export */ var setPublicPath = (null); | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"29918b3a-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=de44c72c& | ||||||
|  | var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('mu-data-table',{attrs:{"data":_vm.Streams,"columns":_vm.columns},scopedSlots:_vm._u([{key:"default",fn:function(ref){ | ||||||
|  | var item = ref.row; | ||||||
|  | return [_c('td',[_vm._v(_vm._s(item.StreamInfo.StreamPath))]),_c('td',[_c('StartTime',{attrs:{"value":item.StreamInfo.StartTime}})],1),_c('td',[_vm._v(_vm._s(_vm.unitFormat(item.InBytes)))]),_c('td',[_vm._v(_vm._s(_vm.unitFormat(item.OutBytes)))]),_c('td',[_c('mu-button',{attrs:{"flat":""},on:{"click":function($event){return _vm.showHeader(item)}}},[_vm._v("头信息")]),_c('mu-button',{attrs:{"flat":""},on:{"click":function($event){return _vm.stop(item)}}},[_vm._v("中止")])],1)]}}])}),_c('mu-dialog',{attrs:{"title":"拉流转发","width":"360","open":_vm.openPull},on:{"update:open":function($event){_vm.openPull=$event}}},[_c('mu-text-field',{attrs:{"label":"rtsp url","label-float":"","help-text":"Please enter URL of rtsp..."},model:{value:(_vm.remoteAddr),callback:function ($$v) {_vm.remoteAddr=$$v},expression:"remoteAddr"}}),_c('mu-text-field',{attrs:{"label":"streamPath","label-float":"","help-text":"Please enter streamPath to publish."},model:{value:(_vm.streamPath),callback:function ($$v) {_vm.streamPath=$$v},expression:"streamPath"}}),_c('mu-button',{attrs:{"slot":"actions","flat":"","color":"primary"},on:{"click":_vm.addPull},slot:"actions"},[_vm._v("确定")])],1)],1)} | ||||||
|  | var staticRenderFns = [] | ||||||
|  |  | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=de44c72c& | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js& | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  |  | ||||||
|  | let listES = null; | ||||||
|  | /* harmony default export */ var Appvue_type_script_lang_js_ = ({ | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       currentStream: null, | ||||||
|  |       Streams: null, | ||||||
|  |       remoteAddr: "", | ||||||
|  |       streamPath: "", | ||||||
|  |       openPull: false, | ||||||
|  |       columns: [ | ||||||
|  |         "StreamPath", | ||||||
|  |         "开始时间", | ||||||
|  |         "总接收", | ||||||
|  |         "总发送", | ||||||
|  |         "操作" | ||||||
|  |       ].map(title => ({ title })) | ||||||
|  |     }; | ||||||
|  |   }, | ||||||
|  |  | ||||||
|  |   methods: { | ||||||
|  |     fetchlist() { | ||||||
|  |       listES = new EventSource(this.apiHost + "/rtsp/list"); | ||||||
|  |       listES.onmessage = evt => { | ||||||
|  |         if (!evt.data) return; | ||||||
|  |         this.Streams = JSON.parse(evt.data) || []; | ||||||
|  |         this.Streams.sort((a, b) => | ||||||
|  |           a.StreamInfo.StreamPath > b.StreamInfo.StreamPath ? 1 : -1 | ||||||
|  |         ); | ||||||
|  |       }; | ||||||
|  |     }, | ||||||
|  |     showHeader(item) { | ||||||
|  |       this.$Modal.info({ | ||||||
|  |         title: "RTSP SDPRaw", | ||||||
|  |         width: "1000px", | ||||||
|  |         scrollable: true, | ||||||
|  |         content: item.SDPRaw | ||||||
|  |       }); | ||||||
|  |     }, | ||||||
|  |     addPull() { | ||||||
|  |       this.openPull = false; | ||||||
|  |       this.ajax | ||||||
|  |         .getJSON(this.apiHost + "/rtsp/pull", { | ||||||
|  |           target: this.remoteAddr, | ||||||
|  |           streamPath: this.streamPath | ||||||
|  |         }) | ||||||
|  |         .then(x => { | ||||||
|  |           if (x.code == 0) { | ||||||
|  |             this.$toast.success("已启动拉流"); | ||||||
|  |           } else { | ||||||
|  |             this.$toast.error(x.msg); | ||||||
|  |           } | ||||||
|  |         }); | ||||||
|  |     }, | ||||||
|  |     stop(item) { | ||||||
|  |       this.ajax | ||||||
|  |         .get(this.apiHost + "/api/stop", { | ||||||
|  |           stream: item.StreamInfo.StreamPath | ||||||
|  |         }) | ||||||
|  |         .then(x => { | ||||||
|  |           if (x == "success") { | ||||||
|  |             this.$toast.success("已停止拉流"); | ||||||
|  |           } else { | ||||||
|  |             this.$toast.error(x.msg); | ||||||
|  |           } | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   mounted() { | ||||||
|  |     this.fetchlist(); | ||||||
|  |     let _this = this; | ||||||
|  |     this.$parent.titleOps = [ | ||||||
|  |       { | ||||||
|  |         template: '<m-button @click="onClick">拉流转发</m-button>', | ||||||
|  |         methods: { | ||||||
|  |           onClick() { | ||||||
|  |             _this.openPull = true; | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     ]; | ||||||
|  |   }, | ||||||
|  |   destroyed() { | ||||||
|  |     listES.close(); | ||||||
|  |   } | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./src/App.vue?vue&type=script&lang=js& | ||||||
|  |  /* harmony default export */ var src_Appvue_type_script_lang_js_ = (Appvue_type_script_lang_js_);  | ||||||
|  | // EXTERNAL MODULE: ./src/App.vue?vue&type=style&index=0&lang=css& | ||||||
|  | var Appvue_type_style_index_0_lang_css_ = __webpack_require__("034f"); | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js | ||||||
|  | /* globals __VUE_SSR_CONTEXT__ */ | ||||||
|  |  | ||||||
|  | // IMPORTANT: Do NOT use ES2015 features in this file (except for modules). | ||||||
|  | // This module is a runtime utility for cleaner component module output and will | ||||||
|  | // be included in the final webpack user bundle. | ||||||
|  |  | ||||||
|  | function normalizeComponent ( | ||||||
|  |   scriptExports, | ||||||
|  |   render, | ||||||
|  |   staticRenderFns, | ||||||
|  |   functionalTemplate, | ||||||
|  |   injectStyles, | ||||||
|  |   scopeId, | ||||||
|  |   moduleIdentifier, /* server only */ | ||||||
|  |   shadowMode /* vue-cli only */ | ||||||
|  | ) { | ||||||
|  |   // Vue.extend constructor export interop | ||||||
|  |   var options = typeof scriptExports === 'function' | ||||||
|  |     ? scriptExports.options | ||||||
|  |     : scriptExports | ||||||
|  |  | ||||||
|  |   // render functions | ||||||
|  |   if (render) { | ||||||
|  |     options.render = render | ||||||
|  |     options.staticRenderFns = staticRenderFns | ||||||
|  |     options._compiled = true | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // functional template | ||||||
|  |   if (functionalTemplate) { | ||||||
|  |     options.functional = true | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // scopedId | ||||||
|  |   if (scopeId) { | ||||||
|  |     options._scopeId = 'data-v-' + scopeId | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   var hook | ||||||
|  |   if (moduleIdentifier) { // server build | ||||||
|  |     hook = function (context) { | ||||||
|  |       // 2.3 injection | ||||||
|  |       context = | ||||||
|  |         context || // cached call | ||||||
|  |         (this.$vnode && this.$vnode.ssrContext) || // stateful | ||||||
|  |         (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional | ||||||
|  |       // 2.2 with runInNewContext: true | ||||||
|  |       if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { | ||||||
|  |         context = __VUE_SSR_CONTEXT__ | ||||||
|  |       } | ||||||
|  |       // inject component styles | ||||||
|  |       if (injectStyles) { | ||||||
|  |         injectStyles.call(this, context) | ||||||
|  |       } | ||||||
|  |       // register component module identifier for async chunk inferrence | ||||||
|  |       if (context && context._registeredComponents) { | ||||||
|  |         context._registeredComponents.add(moduleIdentifier) | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |     // used by ssr in case component is cached and beforeCreate | ||||||
|  |     // never gets called | ||||||
|  |     options._ssrRegister = hook | ||||||
|  |   } else if (injectStyles) { | ||||||
|  |     hook = shadowMode | ||||||
|  |       ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) } | ||||||
|  |       : injectStyles | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   if (hook) { | ||||||
|  |     if (options.functional) { | ||||||
|  |       // for template-only hot-reload because in that case the render fn doesn't | ||||||
|  |       // go through the normalizer | ||||||
|  |       options._injectStyles = hook | ||||||
|  |       // register for functional component in vue file | ||||||
|  |       var originalRender = options.render | ||||||
|  |       options.render = function renderWithStyleInjection (h, context) { | ||||||
|  |         hook.call(context) | ||||||
|  |         return originalRender(h, context) | ||||||
|  |       } | ||||||
|  |     } else { | ||||||
|  |       // inject component registration as beforeCreate hook | ||||||
|  |       var existing = options.beforeCreate | ||||||
|  |       options.beforeCreate = existing | ||||||
|  |         ? [].concat(existing, hook) | ||||||
|  |         : [hook] | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   return { | ||||||
|  |     exports: scriptExports, | ||||||
|  |     options: options | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./src/App.vue | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /* normalize component */ | ||||||
|  |  | ||||||
|  | var component = normalizeComponent( | ||||||
|  |   src_Appvue_type_script_lang_js_, | ||||||
|  |   render, | ||||||
|  |   staticRenderFns, | ||||||
|  |   false, | ||||||
|  |   null, | ||||||
|  |   null, | ||||||
|  |   null | ||||||
|  |    | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | /* harmony default export */ var App = (component.exports); | ||||||
|  | // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /* harmony default export */ var entry_lib = __webpack_exports__["default"] = (App); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /***/ }) | ||||||
|  |  | ||||||
|  | /******/ })["default"]; | ||||||
|  | //# sourceMappingURL=plugin-rtsp.common.js.map | ||||||
							
								
								
									
										1
									
								
								ui/dist/plugin-rtsp.common.js.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								ui/dist/plugin-rtsp.common.js.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										1
									
								
								ui/dist/plugin-rtsp.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								ui/dist/plugin-rtsp.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | .empty{color:#eb5e46;width:100%;min-height:500px;display:flex;justify-content:center;align-items:center}.layout{padding-bottom:30px;display:flex;flex-wrap:wrap}.ts-info{width:300px}.hls-info{width:350px;display:flex;flex-direction:column} | ||||||
							
								
								
									
										447
									
								
								ui/dist/plugin-rtsp.umd.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										447
									
								
								ui/dist/plugin-rtsp.umd.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,447 @@ | |||||||
|  | (function webpackUniversalModuleDefinition(root, factory) { | ||||||
|  | 	if(typeof exports === 'object' && typeof module === 'object') | ||||||
|  | 		module.exports = factory(); | ||||||
|  | 	else if(typeof define === 'function' && define.amd) | ||||||
|  | 		define([], factory); | ||||||
|  | 	else if(typeof exports === 'object') | ||||||
|  | 		exports["plugin-rtsp"] = factory(); | ||||||
|  | 	else | ||||||
|  | 		root["plugin-rtsp"] = factory(); | ||||||
|  | })((typeof self !== 'undefined' ? self : this), function() { | ||||||
|  | return /******/ (function(modules) { // webpackBootstrap | ||||||
|  | /******/ 	// The module cache | ||||||
|  | /******/ 	var installedModules = {}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// The require function | ||||||
|  | /******/ 	function __webpack_require__(moduleId) { | ||||||
|  | /******/ | ||||||
|  | /******/ 		// Check if module is in cache | ||||||
|  | /******/ 		if(installedModules[moduleId]) { | ||||||
|  | /******/ 			return installedModules[moduleId].exports; | ||||||
|  | /******/ 		} | ||||||
|  | /******/ 		// Create a new module (and put it into the cache) | ||||||
|  | /******/ 		var module = installedModules[moduleId] = { | ||||||
|  | /******/ 			i: moduleId, | ||||||
|  | /******/ 			l: false, | ||||||
|  | /******/ 			exports: {} | ||||||
|  | /******/ 		}; | ||||||
|  | /******/ | ||||||
|  | /******/ 		// Execute the module function | ||||||
|  | /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||||||
|  | /******/ | ||||||
|  | /******/ 		// Flag the module as loaded | ||||||
|  | /******/ 		module.l = true; | ||||||
|  | /******/ | ||||||
|  | /******/ 		// Return the exports of the module | ||||||
|  | /******/ 		return module.exports; | ||||||
|  | /******/ 	} | ||||||
|  | /******/ | ||||||
|  | /******/ | ||||||
|  | /******/ 	// expose the modules object (__webpack_modules__) | ||||||
|  | /******/ 	__webpack_require__.m = modules; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// expose the module cache | ||||||
|  | /******/ 	__webpack_require__.c = installedModules; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// define getter function for harmony exports | ||||||
|  | /******/ 	__webpack_require__.d = function(exports, name, getter) { | ||||||
|  | /******/ 		if(!__webpack_require__.o(exports, name)) { | ||||||
|  | /******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||||||
|  | /******/ 		} | ||||||
|  | /******/ 	}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// define __esModule on exports | ||||||
|  | /******/ 	__webpack_require__.r = function(exports) { | ||||||
|  | /******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||||||
|  | /******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||||||
|  | /******/ 		} | ||||||
|  | /******/ 		Object.defineProperty(exports, '__esModule', { value: true }); | ||||||
|  | /******/ 	}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// create a fake namespace object | ||||||
|  | /******/ 	// mode & 1: value is a module id, require it | ||||||
|  | /******/ 	// mode & 2: merge all properties of value into the ns | ||||||
|  | /******/ 	// mode & 4: return value when already ns object | ||||||
|  | /******/ 	// mode & 8|1: behave like require | ||||||
|  | /******/ 	__webpack_require__.t = function(value, mode) { | ||||||
|  | /******/ 		if(mode & 1) value = __webpack_require__(value); | ||||||
|  | /******/ 		if(mode & 8) return value; | ||||||
|  | /******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||||||
|  | /******/ 		var ns = Object.create(null); | ||||||
|  | /******/ 		__webpack_require__.r(ns); | ||||||
|  | /******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||||||
|  | /******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||||||
|  | /******/ 		return ns; | ||||||
|  | /******/ 	}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// getDefaultExport function for compatibility with non-harmony modules | ||||||
|  | /******/ 	__webpack_require__.n = function(module) { | ||||||
|  | /******/ 		var getter = module && module.__esModule ? | ||||||
|  | /******/ 			function getDefault() { return module['default']; } : | ||||||
|  | /******/ 			function getModuleExports() { return module; }; | ||||||
|  | /******/ 		__webpack_require__.d(getter, 'a', getter); | ||||||
|  | /******/ 		return getter; | ||||||
|  | /******/ 	}; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// Object.prototype.hasOwnProperty.call | ||||||
|  | /******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||||||
|  | /******/ | ||||||
|  | /******/ 	// __webpack_public_path__ | ||||||
|  | /******/ 	__webpack_require__.p = ""; | ||||||
|  | /******/ | ||||||
|  | /******/ | ||||||
|  | /******/ 	// Load entry module and return exports | ||||||
|  | /******/ 	return __webpack_require__(__webpack_require__.s = "fb15"); | ||||||
|  | /******/ }) | ||||||
|  | /************************************************************************/ | ||||||
|  | /******/ ({ | ||||||
|  |  | ||||||
|  | /***/ "034f": | ||||||
|  | /***/ (function(module, __webpack_exports__, __webpack_require__) { | ||||||
|  |  | ||||||
|  | "use strict"; | ||||||
|  | /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("85ec"); | ||||||
|  | /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__); | ||||||
|  | /* unused harmony reexport * */ | ||||||
|  |  /* unused harmony default export */ var _unused_webpack_default_export = (_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default.a);  | ||||||
|  |  | ||||||
|  | /***/ }), | ||||||
|  |  | ||||||
|  | /***/ "85ec": | ||||||
|  | /***/ (function(module, exports, __webpack_require__) { | ||||||
|  |  | ||||||
|  | // extracted by mini-css-extract-plugin | ||||||
|  |  | ||||||
|  | /***/ }), | ||||||
|  |  | ||||||
|  | /***/ "f6fd": | ||||||
|  | /***/ (function(module, exports) { | ||||||
|  |  | ||||||
|  | // document.currentScript polyfill by Adam Miller | ||||||
|  |  | ||||||
|  | // MIT license | ||||||
|  |  | ||||||
|  | (function(document){ | ||||||
|  |   var currentScript = "currentScript", | ||||||
|  |       scripts = document.getElementsByTagName('script'); // Live NodeList collection | ||||||
|  |  | ||||||
|  |   // If browser needs currentScript polyfill, add get currentScript() to the document object | ||||||
|  |   if (!(currentScript in document)) { | ||||||
|  |     Object.defineProperty(document, currentScript, { | ||||||
|  |       get: function(){ | ||||||
|  |  | ||||||
|  |         // IE 6-10 supports script readyState | ||||||
|  |         // IE 10+ support stack trace | ||||||
|  |         try { throw new Error(); } | ||||||
|  |         catch (err) { | ||||||
|  |  | ||||||
|  |           // Find the second match for the "at" string to get file src url from stack. | ||||||
|  |           // Specifically works with the format of stack traces in IE. | ||||||
|  |           var i, res = ((/.*at [^\(]*\((.*):.+:.+\)$/ig).exec(err.stack) || [false])[1]; | ||||||
|  |  | ||||||
|  |           // For all scripts on the page, if src matches or if ready state is interactive, return the script tag | ||||||
|  |           for(i in scripts){ | ||||||
|  |             if(scripts[i].src == res || scripts[i].readyState == "interactive"){ | ||||||
|  |               return scripts[i]; | ||||||
|  |             } | ||||||
|  |           } | ||||||
|  |  | ||||||
|  |           // If no match, return null | ||||||
|  |           return null; | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  | })(document); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /***/ }), | ||||||
|  |  | ||||||
|  | /***/ "fb15": | ||||||
|  | /***/ (function(module, __webpack_exports__, __webpack_require__) { | ||||||
|  |  | ||||||
|  | "use strict"; | ||||||
|  | // ESM COMPAT FLAG | ||||||
|  | __webpack_require__.r(__webpack_exports__); | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js | ||||||
|  | // This file is imported into lib/wc client bundles. | ||||||
|  |  | ||||||
|  | if (typeof window !== 'undefined') { | ||||||
|  |   if (true) { | ||||||
|  |     __webpack_require__("f6fd") | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   var i | ||||||
|  |   if ((i = window.document.currentScript) && (i = i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))) { | ||||||
|  |     __webpack_require__.p = i[1] // eslint-disable-line | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Indicate to webpack that this file can be concatenated | ||||||
|  | /* harmony default export */ var setPublicPath = (null); | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"29918b3a-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=de44c72c& | ||||||
|  | var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('mu-data-table',{attrs:{"data":_vm.Streams,"columns":_vm.columns},scopedSlots:_vm._u([{key:"default",fn:function(ref){ | ||||||
|  | var item = ref.row; | ||||||
|  | return [_c('td',[_vm._v(_vm._s(item.StreamInfo.StreamPath))]),_c('td',[_c('StartTime',{attrs:{"value":item.StreamInfo.StartTime}})],1),_c('td',[_vm._v(_vm._s(_vm.unitFormat(item.InBytes)))]),_c('td',[_vm._v(_vm._s(_vm.unitFormat(item.OutBytes)))]),_c('td',[_c('mu-button',{attrs:{"flat":""},on:{"click":function($event){return _vm.showHeader(item)}}},[_vm._v("头信息")]),_c('mu-button',{attrs:{"flat":""},on:{"click":function($event){return _vm.stop(item)}}},[_vm._v("中止")])],1)]}}])}),_c('mu-dialog',{attrs:{"title":"拉流转发","width":"360","open":_vm.openPull},on:{"update:open":function($event){_vm.openPull=$event}}},[_c('mu-text-field',{attrs:{"label":"rtsp url","label-float":"","help-text":"Please enter URL of rtsp..."},model:{value:(_vm.remoteAddr),callback:function ($$v) {_vm.remoteAddr=$$v},expression:"remoteAddr"}}),_c('mu-text-field',{attrs:{"label":"streamPath","label-float":"","help-text":"Please enter streamPath to publish."},model:{value:(_vm.streamPath),callback:function ($$v) {_vm.streamPath=$$v},expression:"streamPath"}}),_c('mu-button',{attrs:{"slot":"actions","flat":"","color":"primary"},on:{"click":_vm.addPull},slot:"actions"},[_vm._v("确定")])],1)],1)} | ||||||
|  | var staticRenderFns = [] | ||||||
|  |  | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=de44c72c& | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js& | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  | // | ||||||
|  |  | ||||||
|  | let listES = null; | ||||||
|  | /* harmony default export */ var Appvue_type_script_lang_js_ = ({ | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       currentStream: null, | ||||||
|  |       Streams: null, | ||||||
|  |       remoteAddr: "", | ||||||
|  |       streamPath: "", | ||||||
|  |       openPull: false, | ||||||
|  |       columns: [ | ||||||
|  |         "StreamPath", | ||||||
|  |         "开始时间", | ||||||
|  |         "总接收", | ||||||
|  |         "总发送", | ||||||
|  |         "操作" | ||||||
|  |       ].map(title => ({ title })) | ||||||
|  |     }; | ||||||
|  |   }, | ||||||
|  |  | ||||||
|  |   methods: { | ||||||
|  |     fetchlist() { | ||||||
|  |       listES = new EventSource(this.apiHost + "/rtsp/list"); | ||||||
|  |       listES.onmessage = evt => { | ||||||
|  |         if (!evt.data) return; | ||||||
|  |         this.Streams = JSON.parse(evt.data) || []; | ||||||
|  |         this.Streams.sort((a, b) => | ||||||
|  |           a.StreamInfo.StreamPath > b.StreamInfo.StreamPath ? 1 : -1 | ||||||
|  |         ); | ||||||
|  |       }; | ||||||
|  |     }, | ||||||
|  |     showHeader(item) { | ||||||
|  |       this.$Modal.info({ | ||||||
|  |         title: "RTSP SDPRaw", | ||||||
|  |         width: "1000px", | ||||||
|  |         scrollable: true, | ||||||
|  |         content: item.SDPRaw | ||||||
|  |       }); | ||||||
|  |     }, | ||||||
|  |     addPull() { | ||||||
|  |       this.openPull = false; | ||||||
|  |       this.ajax | ||||||
|  |         .getJSON(this.apiHost + "/rtsp/pull", { | ||||||
|  |           target: this.remoteAddr, | ||||||
|  |           streamPath: this.streamPath | ||||||
|  |         }) | ||||||
|  |         .then(x => { | ||||||
|  |           if (x.code == 0) { | ||||||
|  |             this.$toast.success("已启动拉流"); | ||||||
|  |           } else { | ||||||
|  |             this.$toast.error(x.msg); | ||||||
|  |           } | ||||||
|  |         }); | ||||||
|  |     }, | ||||||
|  |     stop(item) { | ||||||
|  |       this.ajax | ||||||
|  |         .get(this.apiHost + "/api/stop", { | ||||||
|  |           stream: item.StreamInfo.StreamPath | ||||||
|  |         }) | ||||||
|  |         .then(x => { | ||||||
|  |           if (x == "success") { | ||||||
|  |             this.$toast.success("已停止拉流"); | ||||||
|  |           } else { | ||||||
|  |             this.$toast.error(x.msg); | ||||||
|  |           } | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   mounted() { | ||||||
|  |     this.fetchlist(); | ||||||
|  |     let _this = this; | ||||||
|  |     this.$parent.titleOps = [ | ||||||
|  |       { | ||||||
|  |         template: '<m-button @click="onClick">拉流转发</m-button>', | ||||||
|  |         methods: { | ||||||
|  |           onClick() { | ||||||
|  |             _this.openPull = true; | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     ]; | ||||||
|  |   }, | ||||||
|  |   destroyed() { | ||||||
|  |     listES.close(); | ||||||
|  |   } | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./src/App.vue?vue&type=script&lang=js& | ||||||
|  |  /* harmony default export */ var src_Appvue_type_script_lang_js_ = (Appvue_type_script_lang_js_);  | ||||||
|  | // EXTERNAL MODULE: ./src/App.vue?vue&type=style&index=0&lang=css& | ||||||
|  | var Appvue_type_style_index_0_lang_css_ = __webpack_require__("034f"); | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js | ||||||
|  | /* globals __VUE_SSR_CONTEXT__ */ | ||||||
|  |  | ||||||
|  | // IMPORTANT: Do NOT use ES2015 features in this file (except for modules). | ||||||
|  | // This module is a runtime utility for cleaner component module output and will | ||||||
|  | // be included in the final webpack user bundle. | ||||||
|  |  | ||||||
|  | function normalizeComponent ( | ||||||
|  |   scriptExports, | ||||||
|  |   render, | ||||||
|  |   staticRenderFns, | ||||||
|  |   functionalTemplate, | ||||||
|  |   injectStyles, | ||||||
|  |   scopeId, | ||||||
|  |   moduleIdentifier, /* server only */ | ||||||
|  |   shadowMode /* vue-cli only */ | ||||||
|  | ) { | ||||||
|  |   // Vue.extend constructor export interop | ||||||
|  |   var options = typeof scriptExports === 'function' | ||||||
|  |     ? scriptExports.options | ||||||
|  |     : scriptExports | ||||||
|  |  | ||||||
|  |   // render functions | ||||||
|  |   if (render) { | ||||||
|  |     options.render = render | ||||||
|  |     options.staticRenderFns = staticRenderFns | ||||||
|  |     options._compiled = true | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // functional template | ||||||
|  |   if (functionalTemplate) { | ||||||
|  |     options.functional = true | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // scopedId | ||||||
|  |   if (scopeId) { | ||||||
|  |     options._scopeId = 'data-v-' + scopeId | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   var hook | ||||||
|  |   if (moduleIdentifier) { // server build | ||||||
|  |     hook = function (context) { | ||||||
|  |       // 2.3 injection | ||||||
|  |       context = | ||||||
|  |         context || // cached call | ||||||
|  |         (this.$vnode && this.$vnode.ssrContext) || // stateful | ||||||
|  |         (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional | ||||||
|  |       // 2.2 with runInNewContext: true | ||||||
|  |       if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { | ||||||
|  |         context = __VUE_SSR_CONTEXT__ | ||||||
|  |       } | ||||||
|  |       // inject component styles | ||||||
|  |       if (injectStyles) { | ||||||
|  |         injectStyles.call(this, context) | ||||||
|  |       } | ||||||
|  |       // register component module identifier for async chunk inferrence | ||||||
|  |       if (context && context._registeredComponents) { | ||||||
|  |         context._registeredComponents.add(moduleIdentifier) | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |     // used by ssr in case component is cached and beforeCreate | ||||||
|  |     // never gets called | ||||||
|  |     options._ssrRegister = hook | ||||||
|  |   } else if (injectStyles) { | ||||||
|  |     hook = shadowMode | ||||||
|  |       ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) } | ||||||
|  |       : injectStyles | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   if (hook) { | ||||||
|  |     if (options.functional) { | ||||||
|  |       // for template-only hot-reload because in that case the render fn doesn't | ||||||
|  |       // go through the normalizer | ||||||
|  |       options._injectStyles = hook | ||||||
|  |       // register for functional component in vue file | ||||||
|  |       var originalRender = options.render | ||||||
|  |       options.render = function renderWithStyleInjection (h, context) { | ||||||
|  |         hook.call(context) | ||||||
|  |         return originalRender(h, context) | ||||||
|  |       } | ||||||
|  |     } else { | ||||||
|  |       // inject component registration as beforeCreate hook | ||||||
|  |       var existing = options.beforeCreate | ||||||
|  |       options.beforeCreate = existing | ||||||
|  |         ? [].concat(existing, hook) | ||||||
|  |         : [hook] | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   return { | ||||||
|  |     exports: scriptExports, | ||||||
|  |     options: options | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // CONCATENATED MODULE: ./src/App.vue | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /* normalize component */ | ||||||
|  |  | ||||||
|  | var component = normalizeComponent( | ||||||
|  |   src_Appvue_type_script_lang_js_, | ||||||
|  |   render, | ||||||
|  |   staticRenderFns, | ||||||
|  |   false, | ||||||
|  |   null, | ||||||
|  |   null, | ||||||
|  |   null | ||||||
|  |    | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | /* harmony default export */ var App = (component.exports); | ||||||
|  | // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /* harmony default export */ var entry_lib = __webpack_exports__["default"] = (App); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /***/ }) | ||||||
|  |  | ||||||
|  | /******/ })["default"]; | ||||||
|  | }); | ||||||
|  | //# sourceMappingURL=plugin-rtsp.umd.js.map | ||||||
							
								
								
									
										1
									
								
								ui/dist/plugin-rtsp.umd.js.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								ui/dist/plugin-rtsp.umd.js.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								ui/dist/plugin-rtsp.umd.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								ui/dist/plugin-rtsp.umd.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | |||||||
|  | (function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["plugin-rtsp"]=e():t["plugin-rtsp"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s="fb15")}({"034f":function(t,e,r){"use strict";var n=r("85ec"),o=r.n(n);o.a},"85ec":function(t,e,r){},f6fd:function(t,e){(function(t){var e="currentScript",r=t.getElementsByTagName("script");e in t||Object.defineProperty(t,e,{get:function(){try{throw new Error}catch(n){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(n.stack)||[!1])[1];for(t in r)if(r[t].src==e||"interactive"==r[t].readyState)return r[t];return null}}})})(document)},fb15:function(t,e,r){"use strict";var n;(r.r(e),"undefined"!==typeof window)&&(r("f6fd"),(n=window.document.currentScript)&&(n=n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(r.p=n[1]));var o=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",[r("mu-data-table",{attrs:{data:t.Streams,columns:t.columns},scopedSlots:t._u([{key:"default",fn:function(e){var n=e.row;return[r("td",[t._v(t._s(n.StreamInfo.StreamPath))]),r("td",[r("StartTime",{attrs:{value:n.StreamInfo.StartTime}})],1),r("td",[t._v(t._s(t.unitFormat(n.InBytes)))]),r("td",[t._v(t._s(t.unitFormat(n.OutBytes)))]),r("td",[r("mu-button",{attrs:{flat:""},on:{click:function(e){return t.showHeader(n)}}},[t._v("头信息")]),r("mu-button",{attrs:{flat:""},on:{click:function(e){return t.stop(n)}}},[t._v("中止")])],1)]}}])}),r("mu-dialog",{attrs:{title:"拉流转发",width:"360",open:t.openPull},on:{"update:open":function(e){t.openPull=e}}},[r("mu-text-field",{attrs:{label:"rtsp url","label-float":"","help-text":"Please enter URL of rtsp..."},model:{value:t.remoteAddr,callback:function(e){t.remoteAddr=e},expression:"remoteAddr"}}),r("mu-text-field",{attrs:{label:"streamPath","label-float":"","help-text":"Please enter streamPath to publish."},model:{value:t.streamPath,callback:function(e){t.streamPath=e},expression:"streamPath"}}),r("mu-button",{attrs:{slot:"actions",flat:"",color:"primary"},on:{click:t.addPull},slot:"actions"},[t._v("确定")])],1)],1)},a=[];let s=null;var i={data(){return{currentStream:null,Streams:null,remoteAddr:"",streamPath:"",openPull:!1,columns:["StreamPath","开始时间","总接收","总发送","操作"].map(t=>({title:t}))}},methods:{fetchlist(){s=new EventSource(this.apiHost+"/rtsp/list"),s.onmessage=t=>{t.data&&(this.Streams=JSON.parse(t.data)||[],this.Streams.sort((t,e)=>t.StreamInfo.StreamPath>e.StreamInfo.StreamPath?1:-1))}},showHeader(t){this.$Modal.info({title:"RTSP SDPRaw",width:"1000px",scrollable:!0,content:t.SDPRaw})},addPull(){this.openPull=!1,this.ajax.getJSON(this.apiHost+"/rtsp/pull",{target:this.remoteAddr,streamPath:this.streamPath}).then(t=>{0==t.code?this.$toast.success("已启动拉流"):this.$toast.error(t.msg)})},stop(t){this.ajax.get(this.apiHost+"/api/stop",{stream:t.StreamInfo.StreamPath}).then(t=>{"success"==t?this.$toast.success("已停止拉流"):this.$toast.error(t.msg)})}},mounted(){this.fetchlist();let t=this;this.$parent.titleOps=[{template:'<m-button @click="onClick">拉流转发</m-button>',methods:{onClick(){t.openPull=!0}}}]},destroyed(){s.close()}},l=i;r("034f");function u(t,e,r,n,o,a,s,i){var l,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=r,u._compiled=!0),n&&(u.functional=!0),a&&(u._scopeId="data-v-"+a),s?(l=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},u._ssrRegister=l):o&&(l=i?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(u.functional){u._injectStyles=l;var c=u.render;u.render=function(t,e){return l.call(e),c(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,l):[l]}return{exports:t,options:u}}var c=u(l,o,a,!1,null,null,null),f=c.exports;e["default"]=f}})["default"]})); | ||||||
|  | //# sourceMappingURL=plugin-rtsp.umd.min.js.map | ||||||
							
								
								
									
										1
									
								
								ui/dist/plugin-rtsp.umd.min.js.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								ui/dist/plugin-rtsp.umd.min.js.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										9560
									
								
								ui/package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										9560
									
								
								ui/package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										15
									
								
								ui/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								ui/package.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | { | ||||||
|  |   "name": "dashboard", | ||||||
|  |   "version": "1.0.0", | ||||||
|  |   "description": "dashboard of rtsp plugin for monibuca", | ||||||
|  |   "main": "index.js", | ||||||
|  |   "scripts": { | ||||||
|  |     "build": "vue-cli-service build --target lib --name plugin-rtsp" | ||||||
|  |   }, | ||||||
|  |   "author": "dexter", | ||||||
|  |   "license": "ISC", | ||||||
|  |   "devDependencies": { | ||||||
|  |     "@vue/cli-service": "^4.2.3", | ||||||
|  |     "vue-template-compiler": "^2.6.11" | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										147
									
								
								ui/src/App.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								ui/src/App.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,147 @@ | |||||||
|  | <template> | ||||||
|  |   <div> | ||||||
|  |     <mu-data-table :data="Streams" :columns="columns"> | ||||||
|  |       <template #default="{row:item}"> | ||||||
|  |         <td>{{item.StreamInfo.StreamPath}}</td> | ||||||
|  |         <td> | ||||||
|  |           <StartTime :value="item.StreamInfo.StartTime"></StartTime> | ||||||
|  |         </td> | ||||||
|  |         <td>{{unitFormat(item.InBytes)}}</td> | ||||||
|  |         <td>{{unitFormat(item.OutBytes)}}</td> | ||||||
|  |         <td> | ||||||
|  |           <mu-button flat @click="showHeader(item)">头信息</mu-button> | ||||||
|  |           <mu-button flat @click="stop(item)">中止</mu-button> | ||||||
|  |         </td> | ||||||
|  |       </template> | ||||||
|  |     </mu-data-table> | ||||||
|  |     <mu-dialog title="拉流转发" width="360" :open.sync="openPull"> | ||||||
|  |       <mu-text-field | ||||||
|  |         v-model="remoteAddr" | ||||||
|  |         label="rtsp url" | ||||||
|  |         label-float | ||||||
|  |         help-text="Please enter URL of rtsp..." | ||||||
|  |       ></mu-text-field> | ||||||
|  |       <mu-text-field | ||||||
|  |         v-model="streamPath" | ||||||
|  |         label="streamPath" | ||||||
|  |         label-float | ||||||
|  |         help-text="Please enter streamPath to publish." | ||||||
|  |       ></mu-text-field> | ||||||
|  |       <mu-button slot="actions" flat color="primary" @click="addPull">确定</mu-button> | ||||||
|  |     </mu-dialog> | ||||||
|  |   </div> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | let listES = null; | ||||||
|  | export default { | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       currentStream: null, | ||||||
|  |       Streams: null, | ||||||
|  |       remoteAddr: "", | ||||||
|  |       streamPath: "", | ||||||
|  |       openPull: false, | ||||||
|  |       columns: [ | ||||||
|  |         "StreamPath", | ||||||
|  |         "开始时间", | ||||||
|  |         "总接收", | ||||||
|  |         "总发送", | ||||||
|  |         "操作" | ||||||
|  |       ].map(title => ({ title })) | ||||||
|  |     }; | ||||||
|  |   }, | ||||||
|  |  | ||||||
|  |   methods: { | ||||||
|  |     fetchlist() { | ||||||
|  |       listES = new EventSource(this.apiHost + "/rtsp/list"); | ||||||
|  |       listES.onmessage = evt => { | ||||||
|  |         if (!evt.data) return; | ||||||
|  |         this.Streams = JSON.parse(evt.data) || []; | ||||||
|  |         this.Streams.sort((a, b) => | ||||||
|  |           a.StreamInfo.StreamPath > b.StreamInfo.StreamPath ? 1 : -1 | ||||||
|  |         ); | ||||||
|  |       }; | ||||||
|  |     }, | ||||||
|  |     showHeader(item) { | ||||||
|  |       this.$Modal.info({ | ||||||
|  |         title: "RTSP SDPRaw", | ||||||
|  |         width: "1000px", | ||||||
|  |         scrollable: true, | ||||||
|  |         content: item.SDPRaw | ||||||
|  |       }); | ||||||
|  |     }, | ||||||
|  |     addPull() { | ||||||
|  |       this.openPull = false; | ||||||
|  |       this.ajax | ||||||
|  |         .getJSON(this.apiHost + "/rtsp/pull", { | ||||||
|  |           target: this.remoteAddr, | ||||||
|  |           streamPath: this.streamPath | ||||||
|  |         }) | ||||||
|  |         .then(x => { | ||||||
|  |           if (x.code == 0) { | ||||||
|  |             this.$toast.success("已启动拉流"); | ||||||
|  |           } else { | ||||||
|  |             this.$toast.error(x.msg); | ||||||
|  |           } | ||||||
|  |         }); | ||||||
|  |     }, | ||||||
|  |     stop(item) { | ||||||
|  |       this.ajax | ||||||
|  |         .get(this.apiHost + "/api/stop", { | ||||||
|  |           stream: item.StreamInfo.StreamPath | ||||||
|  |         }) | ||||||
|  |         .then(x => { | ||||||
|  |           if (x == "success") { | ||||||
|  |             this.$toast.success("已停止拉流"); | ||||||
|  |           } else { | ||||||
|  |             this.$toast.error(x.msg); | ||||||
|  |           } | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   mounted() { | ||||||
|  |     this.fetchlist(); | ||||||
|  |     let _this = this; | ||||||
|  |     this.$parent.titleOps = [ | ||||||
|  |       { | ||||||
|  |         template: '<m-button @click="onClick">拉流转发</m-button>', | ||||||
|  |         methods: { | ||||||
|  |           onClick() { | ||||||
|  |             _this.openPull = true; | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     ]; | ||||||
|  |   }, | ||||||
|  |   destroyed() { | ||||||
|  |     listES.close(); | ||||||
|  |   } | ||||||
|  | }; | ||||||
|  | </script> | ||||||
|  |  | ||||||
|  | <style> | ||||||
|  | .empty { | ||||||
|  |   color: #eb5e46; | ||||||
|  |   width: 100%; | ||||||
|  |   min-height: 500px; | ||||||
|  |   display: flex; | ||||||
|  |   justify-content: center; | ||||||
|  |   align-items: center; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .layout { | ||||||
|  |   padding-bottom: 30px; | ||||||
|  |   display: flex; | ||||||
|  |   flex-wrap: wrap; | ||||||
|  | } | ||||||
|  | .ts-info { | ||||||
|  |   width: 300px; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .hls-info { | ||||||
|  |   width: 350px; | ||||||
|  |   display: flex; | ||||||
|  |   flex-direction: column; | ||||||
|  | } | ||||||
|  | </style> | ||||||
		Reference in New Issue
	
	Block a user