mirror of
				https://github.com/Monibuca/plugin-rtsp.git
				synced 2025-10-31 19:03:05 +08:00 
			
		
		
		
	Compare commits
	
		
			34 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | a331359e97 | ||
|   | bbd668796e | ||
|   | 107b4e8941 | ||
|   | ac8aa96350 | ||
|   | f267b1ca52 | ||
|   | 229370c083 | ||
|   | bb1e8ba1d8 | ||
|   | 8cf3e0c0fc | ||
|   | 1ecb45d904 | ||
|   | 3ea5bb7f27 | ||
|   | 9aec4ec4be | ||
|   | da2fc9d462 | ||
|   | f68a3ee14b | ||
|   | a2f5cb87b1 | ||
|   | 5cdbc220de | ||
|   | f0a00f3db9 | ||
|   | fd8ebcd87c | ||
|   | cc731a25f0 | ||
|   | ba9f39853f | ||
|   | 0c8bd62e81 | ||
|   | dfe462a7d1 | ||
|   | cc7b899922 | ||
|   | b0c3cdb21a | ||
|   | d08230bf0c | ||
|   | 8a7fdedc0f | ||
|   | b7d59b0198 | ||
|   | dc65348ccb | ||
|   | 7fa6d0dcce | ||
|   | 0689154012 | ||
|   | 2e39eabcba | ||
|   | a9cb4cd853 | ||
|   | 7e61ba71f7 | ||
|   | d6384dcbd5 | ||
|   | 2159a6fd9b | 
							
								
								
									
										67
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,26 +1,63 @@ | ||||
| # Monibuca 的RTSP 插件 | ||||
| # RTSP插件 | ||||
|  | ||||
| 主要功能是提供RTSP的端口监听接受RTSP推流,以及对RTSP地址进行拉流转发 | ||||
| ## 插件地址 | ||||
|  | ||||
| ## 插件名称 | ||||
| github.com/Monibuca/plugin-rtsp | ||||
|  | ||||
| RTSP | ||||
| ## 插件引入 | ||||
| ```go | ||||
| import ( | ||||
|     _ "github.com/Monibuca/plugin-rtsp" | ||||
| ) | ||||
| ``` | ||||
|  | ||||
| ## 默认插件配置 | ||||
|  | ||||
| ## 配置 | ||||
| ```toml | ||||
| [RTSP] | ||||
| ListenAddr  = ":554" | ||||
| BufferLength  = 2048 | ||||
| AutoPull     = false | ||||
| RemoteAddr   = "rtsp://localhost/${streamPath}" | ||||
| # 端口接收推流 | ||||
| ListenAddr = ":554" | ||||
| Reconnect = true | ||||
| [RTSP.AutoPullList] | ||||
| "live/rtsp1" = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=1&subtype=1" | ||||
| "live/rtsp2" = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=2&subtype=1" | ||||
| ``` | ||||
| - ListenAddr 是监听端口,可以将rtsp流推到Monibuca中 | ||||
| - BufferLength是指解析拉取的rtp包的缓冲大小 | ||||
| - AutoPull是指当有用户订阅一个新流的时候自动向远程拉流转发 | ||||
| - RemoteAddr 指远程拉流地址,其中${streamPath}是占位符,实际使用流路径替换。 | ||||
|  | ||||
| - `ListenAddr`是监听的地址 | ||||
| - `Reconnect` 是否自动重连 | ||||
| - `RTSP.AutoPullList` 可以配置多项,用于自动拉流,key是streamPath,value是远程rtsp地址 | ||||
|  | ||||
| ## 使用方法(拉流转发) | ||||
| ### 特殊功能 | ||||
|  | ||||
| 当自动拉流列表中当的streamPath为sub/xxx 这种形式的话,在gb28181的分屏显示时会优先采用rtsp流,已实现分屏观看子码流效果 | ||||
| ## 插件功能 | ||||
|  | ||||
| ### 接收RTSP协议的推流 | ||||
|  | ||||
| 例如通过ffmpeg向m7s进行推流 | ||||
|  | ||||
| ```bash | ||||
| ffmpeg -i **** rtsp://localhost/live/test | ||||
| ``` | ||||
|  | ||||
| 会在m7s内部形成一个名为live/test的流 | ||||
|  | ||||
| ### 从远程拉取rtsp到m7s中 | ||||
|  | ||||
| 可调用接口 | ||||
| `/api/rtsp/pull?target=[RTSP地址]&streamPath=[流标识]` | ||||
|  | ||||
| ## 使用编程方式拉流 | ||||
| ```go | ||||
| new(RTSP).PullStream("live/user1","rtsp://xxx.xxx.xxx.xxx/live/user1")  | ||||
| ``` | ||||
| ``` | ||||
|  | ||||
| ### 罗列所有的rtsp协议的流 | ||||
|  | ||||
| 可调用接口 | ||||
| `/api/rtsp/list` | ||||
|  | ||||
| ### 从m7s中拉取rtsp协议流 | ||||
|  | ||||
| 直接通过协议rtsp://xxx.xxx.xxx.xxx/live/user1 即可播放 | ||||
| > h265和aac 编码拉流尚未实现,敬请期待 | ||||
|   | ||||
							
								
								
									
										116
									
								
								client.go
									
									
									
									
									
								
							
							
						
						
									
										116
									
								
								client.go
									
									
									
									
									
								
							| @@ -16,15 +16,18 @@ import ( | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	. "github.com/Monibuca/engine/v2" | ||||
| 	. "github.com/Monibuca/plugin-rtp" | ||||
| 	. "github.com/Monibuca/engine/v3" | ||||
| 	. "github.com/Monibuca/utils/v3" | ||||
| ) | ||||
|  | ||||
| // PullStream 从外部拉流 | ||||
| func (rtsp *RTSP) PullStream(streamPath string, rtspUrl string) (err error) { | ||||
| 	if result := rtsp.Publish(streamPath); result { | ||||
| 		rtsp.Stream.Type = "RTSP" | ||||
| 		rtsp.RTSPInfo.StreamInfo = &rtsp.Stream.StreamInfo | ||||
| 	rtsp.Stream = &Stream{ | ||||
| 		StreamPath: streamPath, | ||||
| 		Type:       "RTSP Pull", | ||||
| 		ExtraProp:  rtsp, | ||||
| 	} | ||||
| 	if result := rtsp.Publish(); result { | ||||
| 		rtsp.TransType = TRANS_TYPE_TCP | ||||
| 		rtsp.vRTPChannel = 0 | ||||
| 		rtsp.vRTPControlChannel = 1 | ||||
| @@ -32,13 +35,26 @@ func (rtsp *RTSP) PullStream(streamPath string, rtspUrl string) (err error) { | ||||
| 		rtsp.aRTPControlChannel = 3 | ||||
| 		rtsp.URL = rtspUrl | ||||
| 		rtsp.UDPServer = &UDPServer{Session: rtsp} | ||||
| 		if err = rtsp.requestStream(); err != nil { | ||||
| 			Println(err) | ||||
| 			rtsp.Close() | ||||
| 			return | ||||
| 		if config.Reconnect { | ||||
| 			go func() { | ||||
| 				for rtsp.Err() == nil { | ||||
| 					rtsp.RTSPClientInfo = RTSPClientInfo{} | ||||
| 					Printf("reconnecting:%s in 5 seconds", rtspUrl) | ||||
| 					time.Sleep(time.Second * 5) | ||||
| 					rtsp.startStream() | ||||
| 				} | ||||
| 				rtsp.Stop() | ||||
| 				if rtsp.IsTimeout { | ||||
| 					go rtsp.PullStream(streamPath, rtspUrl) | ||||
| 				} | ||||
| 			}() | ||||
| 		} else { | ||||
| 			rtsp.RTSPClientInfo = RTSPClientInfo{} | ||||
| 			go func() { | ||||
| 				rtsp.startStream() | ||||
| 				rtsp.Stop() | ||||
| 			}() | ||||
| 		} | ||||
| 		go rtsp.startStream() | ||||
| 		collection.Store(streamPath, rtsp) | ||||
| 		return | ||||
| 	} | ||||
| 	return errors.New("publish badname") | ||||
| @@ -80,6 +96,7 @@ func DigestAuth(authLine string, method string, URL string) (string, error) { | ||||
| 	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) | ||||
| @@ -154,7 +171,7 @@ func (client *RTSP) requestStream() (err error) { | ||||
| 	client.Conn = &timeoutConn | ||||
| 	client.connRW = bufio.NewReadWriter(bufio.NewReaderSize(&timeoutConn, networkBuffer), bufio.NewWriterSize(&timeoutConn, networkBuffer)) | ||||
|  | ||||
| 	headers := make(map[string]string) | ||||
| 	headers := map[string]string{} | ||||
| 	//headers["Require"] = "implicit-play" | ||||
| 	// An OPTIONS request returns the request types the server will accept. | ||||
| 	resp, err := client.Request("OPTIONS", headers) | ||||
| @@ -215,10 +232,7 @@ func (client *RTSP) requestStream() (err error) { | ||||
| 		} | ||||
| 		switch t { | ||||
| 		case "video": | ||||
| 			if len(sdpInfo.SpropParameterSets) > 1 { | ||||
| 				client.WriteSPS(sdpInfo.SpropParameterSets[0]) | ||||
| 				client.WritePPS(sdpInfo.SpropParameterSets[1]) | ||||
| 			} | ||||
| 			client.setVideoTrack() | ||||
| 			if client.TransType == TRANS_TYPE_TCP { | ||||
| 				headers["Transport"] = fmt.Sprintf("RTP/AVP/TCP;unicast;interleaved=%d-%d", client.vRTPChannel, client.vRTPControlChannel) | ||||
| 			} else { | ||||
| @@ -231,11 +245,7 @@ func (client *RTSP) requestStream() (err error) { | ||||
| 				client.Conn.timeout = 0 //	UDP ignore timeout | ||||
| 			} | ||||
| 		case "audio": | ||||
| 			if len(sdpInfo.Config) > 0 { | ||||
| 				client.WriteASC(sdpInfo.Config) | ||||
| 			}else{ | ||||
| 				client.setAudioFormat() | ||||
| 			} | ||||
| 			client.setAudioTrack() | ||||
| 			if client.TransType == TRANS_TYPE_TCP { | ||||
| 				headers["Transport"] = fmt.Sprintf("RTP/AVP/TCP;unicast;interleaved=%d-%d", client.aRTPChannel, client.aRTPControlChannel) | ||||
| 			} else { | ||||
| @@ -270,34 +280,15 @@ func (client *RTSP) requestStream() (err error) { | ||||
| } | ||||
|  | ||||
| func (client *RTSP) startStream() { | ||||
| 	if client.Err() != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	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() | ||||
| 		} | ||||
| 	}() | ||||
| 	if err := client.requestStream(); err != nil { | ||||
| 		Printf("rtsp requestStream err:%v", err) | ||||
| 		return | ||||
| 	} | ||||
| 	for client.Err() == nil { | ||||
| 		if time.Since(startTime) > time.Minute { | ||||
| 			startTime = time.Now() | ||||
| @@ -314,46 +305,40 @@ func (client *RTSP) startStream() { | ||||
| 			return | ||||
| 		} | ||||
| 		switch b { | ||||
| 		case 0x24: // rtp | ||||
| 			header := make([]byte, 4) | ||||
| 			header[0] = b | ||||
| 			_, err := io.ReadFull(client.connRW, header[1:]) | ||||
| 		case '$': // rtp | ||||
| 			header := make([]byte, 3) | ||||
| 			_, err := io.ReadFull(client.connRW, header) | ||||
| 			if err != nil { | ||||
| 				Printf("io.ReadFull err:%v", err) | ||||
| 				return | ||||
| 			} | ||||
| 			channel := int(header[1]) | ||||
| 			length := binary.BigEndian.Uint16(header[2:]) | ||||
| 			channel := int(header[0]) | ||||
| 			length := binary.BigEndian.Uint16(header[1:]) | ||||
| 			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, | ||||
| 				if client.RtpAudio != nil { | ||||
| 					client.RtpAudio.Push(content) | ||||
| 				} | ||||
| 			case client.aRTPControlChannel: | ||||
| 				pack = &RTPPack{ | ||||
| 					Type: RTP_TYPE_AUDIOCONTROL, | ||||
| 				} | ||||
|  | ||||
| 			case client.vRTPChannel: | ||||
| 				pack = &RTPPack{ | ||||
| 					Type: RTP_TYPE_VIDEO, | ||||
| 				if client.RtpVideo != nil { | ||||
| 					client.RtpVideo.Push(content) | ||||
| 				} | ||||
| 			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 { | ||||
| @@ -372,7 +357,6 @@ func (client *RTSP) startStream() { | ||||
| 			//} | ||||
|  | ||||
| 			client.InBytes += int(length + 4) | ||||
| 			client.PushPack(pack) | ||||
|  | ||||
| 		default: // rtsp | ||||
| 			builder := bytes.Buffer{} | ||||
|   | ||||
							
								
								
									
										17
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								go.mod
									
									
									
									
									
								
							| @@ -1,14 +1,11 @@ | ||||
| module github.com/Monibuca/plugin-rtsp | ||||
| module github.com/Monibuca/plugin-rtsp/v3 | ||||
|  | ||||
| go 1.13 | ||||
| go 1.16 | ||||
|  | ||||
| require ( | ||||
| 	github.com/Monibuca/engine/v2 v2.2.0 | ||||
| 	github.com/Monibuca/plugin-rtp v1.0.0 | ||||
| 	github.com/logrusorgru/aurora v2.0.3+incompatible // indirect | ||||
| 	github.com/mattn/go-colorable v0.1.7 // indirect | ||||
| 	github.com/pion/rtp v1.6.0 // indirect | ||||
| 	github.com/shirou/gopsutil v2.20.7+incompatible // indirect | ||||
| 	github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf | ||||
| 	golang.org/x/sys v0.0.0-20200828161417-c663848e9a16 // indirect | ||||
| 	github.com/Monibuca/engine/v3 v3.3.7 | ||||
| 	github.com/Monibuca/utils/v3 v3.0.2 | ||||
| 	github.com/pion/rtp v1.7.2 | ||||
| 	github.com/teris-io/shortid v0.0.0-20201117134242-e59966efd125 | ||||
| 	golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect | ||||
| ) | ||||
|   | ||||
							
								
								
									
										106
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										106
									
								
								go.sum
									
									
									
									
									
								
							| @@ -1,63 +1,87 @@ | ||||
| github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= | ||||
| github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | ||||
| github.com/Monibuca/engine/v2 v2.1.0 h1:pHeDCEFDusKFsZLpconYj8U5LCaWApnjd+yQRHYgQsQ= | ||||
| github.com/Monibuca/engine/v2 v2.1.0/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc= | ||||
| github.com/Monibuca/engine/v2 v2.1.2 h1:7dUrHJAPEtvGFOO4GsKGjfMCmcbMrtLyYQ7WoK5EpG0= | ||||
| github.com/Monibuca/engine/v2 v2.1.2/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc= | ||||
| github.com/Monibuca/engine/v2 v2.1.9 h1:IulMIeP24qv8xWaI+tcg233Y7w3mCaLXxt4iQaVpT7s= | ||||
| github.com/Monibuca/engine/v2 v2.1.9/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc= | ||||
| github.com/Monibuca/engine/v2 v2.2.0 h1:A4SyWwzVLegd8Oa6LfSW3LpNfBmWq+MHJJLO55gvaYI= | ||||
| github.com/Monibuca/engine/v2 v2.2.0/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc= | ||||
| github.com/Monibuca/plugin-rtp v0.0.0-20200531014802-504413c0dfcb h1:CnmoQ8XsWxs/6mulbQfTGUa8cPr6c/3bkkTsNozRBwE= | ||||
| github.com/Monibuca/plugin-rtp v0.0.0-20200531014802-504413c0dfcb/go.mod h1:8HxBilkF835Lepe/DLUCjaw1mRiu3MxTDsG7g9UcfZA= | ||||
| github.com/Monibuca/plugin-rtp v1.0.0/go.mod h1:0xkNm23a/BjVnEMz1zXyOqfEjoVmGe3PJqPNF1KyFGc= | ||||
| github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= | ||||
| github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= | ||||
| github.com/Monibuca/engine/v3 v3.3.0 h1:7zwYsLEHdeVZy6+JjVlaDhl/asr0HG6jirBL4uynj0s= | ||||
| github.com/Monibuca/engine/v3 v3.3.0/go.mod h1:odyqD/VTQDN4qgzajsgn7kW7MWDIzTHt+j+BcI8i+4g= | ||||
| github.com/Monibuca/engine/v3 v3.3.7 h1:EB77gSzvu4ThRWcWBWPmqWcCmMqC4B21/sUQmf/i2XU= | ||||
| github.com/Monibuca/engine/v3 v3.3.7/go.mod h1:odyqD/VTQDN4qgzajsgn7kW7MWDIzTHt+j+BcI8i+4g= | ||||
| github.com/Monibuca/utils/v3 v3.0.1/go.mod h1:RpNS95gapWs6gimwh8Xn2x72FN5tO7Powabj7dTFyvE= | ||||
| github.com/Monibuca/utils/v3 v3.0.2 h1:n2vr67DHanav8wBC9IENk8xrKzeGJnBsxYUu69s8TrQ= | ||||
| github.com/Monibuca/utils/v3 v3.0.2/go.mod h1:RpNS95gapWs6gimwh8Xn2x72FN5tO7Powabj7dTFyvE= | ||||
| github.com/cnotch/apirouter v0.0.0-20200731232942-89e243a791f3/go.mod h1:5deJPLON/x/s2dLOQfuKS0lenhOIT4xX0pvtN/OEIuY= | ||||
| github.com/cnotch/ipchub v1.1.0 h1:hH0lh2mU3AZXPiqMwA0pdtqrwo7PFIMRGush9OobMUs= | ||||
| github.com/cnotch/ipchub v1.1.0/go.mod h1:2PbeBs2q2VxxTVCn1eYCDwpAWuVXbq1+N0FU7GimOH4= | ||||
| github.com/cnotch/loader v0.0.0-20200405015128-d9d964d09439/go.mod h1:oWpDagHB6p+Kqqq7RoRZKyC4XAXft50hR8pbTxdbYYs= | ||||
| github.com/cnotch/queue v0.0.0-20200326024423-6e88bdbf2ad4/go.mod h1:zOssjAlNusOxvtaqT+EMA+Iyi8rrtKr4/XfzN1Fgoeg= | ||||
| 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/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/emitter-io/address v1.0.0/go.mod h1:GfZb5+S/o8694B1GMGK2imUYQyn2skszMvGNA5D84Ug= | ||||
| github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= | ||||
| github.com/funny/slab v0.0.0-20180511031532-b1fad5e5d478 h1:Db9StoJ6RZN3YttC0Pm0I4Y5izITRYch3RMbT59BYN0= | ||||
| github.com/funny/slab v0.0.0-20180511031532-b1fad5e5d478/go.mod h1:0j1+svBH8ABEIPdUP0AIg4qedsybnXGJBakCEw8cfoo= | ||||
| github.com/funny/utest v0.0.0-20161029064919-43870a374500 h1:Z0r1CZnoIWFB/Uiwh1BU5FYmuFe6L5NPi6XWQEmsTRg= | ||||
| github.com/funny/utest v0.0.0-20161029064919-43870a374500/go.mod h1:mUn39tBov9jKnTWV1RlOYoNzxdBFHiSzXWdY1FoNGGg= | ||||
| github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= | ||||
| github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= | ||||
| github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRnB5PcgP0RXtQvnMSgIF14M7CBd2shtXs= | ||||
| github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= | ||||
| github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||||
| 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/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= | ||||
| github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= | ||||
| github.com/mask-pp/rtp-ps v1.0.0/go.mod h1:jCxsZ2G7z/jX+aqFypEWMePnhNrfnUiXUEKm6Xp0vgU= | ||||
| github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= | ||||
| github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | ||||
| github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= | ||||
| github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | ||||
| github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= | ||||
| github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | ||||
| github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= | ||||
| github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= | ||||
| github.com/pion/randutil v0.0.0 h1:aLWLVhTG2jzoD25F0OlW6nXvXrjoGwiXq2Sz7j7NzL0= | ||||
| github.com/pion/randutil v0.0.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= | ||||
| github.com/pion/rtp v1.5.4 h1:PuNg6xqV3brIUihatcKZj1YDUs+M45L0ZbrZWYtkDxY= | ||||
| github.com/pion/rtp v1.5.4/go.mod h1:bg60AL5GotNOlYZsqycbhDtEV3TkfbpXG0KBiUq29Mg= | ||||
| github.com/pion/rtp v1.6.0 h1:4Ssnl/T5W2LzxHj9ssYpGVEQh3YYhQFNVmSWO88MMwk= | ||||
| github.com/pion/rtp v1.6.0/go.mod h1:QgfogHsMBVE/RFNno467U/KBqfUywEH+HK+0rtnwsdI= | ||||
| github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= | ||||
| github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= | ||||
| github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= | ||||
| 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/rtp v1.6.2/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= | ||||
| github.com/pion/rtp v1.6.5 h1:o2cZf8OascA5HF/b0PAbTxRKvOWxTQxWYt7SlToxFGI= | ||||
| github.com/pion/rtp v1.6.5/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= | ||||
| github.com/pion/rtp v1.7.2 h1:HCDKDCixh7PVjkQTsqHAbk1lg+bx059EHxcnyl42dYs= | ||||
| github.com/pion/rtp v1.7.2/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= | ||||
| 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/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||
| 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/shirou/gopsutil v2.20.1+incompatible h1:oIq9Cq4i84Hk8uQAUOG3eNdI/29hBawGrD5YRl6JRDY= | ||||
| github.com/shirou/gopsutil v2.20.1+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= | ||||
| github.com/shirou/gopsutil v2.20.7+incompatible h1:Ymv4OD12d6zm+2yONe39VSmp2XooJe8za7ngOLW/o/w= | ||||
| github.com/shirou/gopsutil v2.20.7+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= | ||||
| github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= | ||||
| github.com/q191201771/naza v0.19.1 h1:4KLcxT2CHztO+7miPRtBG3FFgadSQYQw1gPPPKN7rnY= | ||||
| github.com/q191201771/naza v0.19.1/go.mod h1:5LeGupZZFtYP1g/S203n9vXoUNVdlRnPIfM6rExjqt0= | ||||
| 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/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= | ||||
| github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||||
| github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf h1:Z2X3Os7oRzpdJ75iPqWZc0HeJWFYNCvKsfpQwFpRNTA= | ||||
| github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf/go.mod h1:M8agBzgqHIhgj7wEn9/0hJUZcrvt9VY+Ln+S1I5Mha0= | ||||
| github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= | ||||
| github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/teris-io/shortid v0.0.0-20201117134242-e59966efd125 h1:3SNcvBmEPE1YlB1JpVZouslJpI3GBNoiqW7+wb0Rz7w= | ||||
| github.com/teris-io/shortid v0.0.0-20201117134242-e59966efd125/go.mod h1:M8agBzgqHIhgj7wEn9/0hJUZcrvt9VY+Ln+S1I5Mha0= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= | ||||
| 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/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= | ||||
| golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/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-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= | ||||
| golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20200828161417-c663848e9a16 h1:54u1berWyLujz9htI1BHtZpcCEYaYNUSDFLXMNDd7To= | ||||
| golang.org/x/sys v0.0.0-20200828161417-c663848e9a16/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 h1:siQdpVirKtzPhKl3lZWozZraCFObP8S1v6PRp0bLrtU= | ||||
| golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20211013075003-97ac67df715c h1:taxlMj0D/1sOAuv/CbSD+MMDof2vbyPTqz5FNYKpXt8= | ||||
| golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= | ||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||||
| 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.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
							
								
								
									
										152
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										152
									
								
								main.go
									
									
									
									
									
								
							| @@ -6,69 +6,61 @@ import ( | ||||
| 	"log" | ||||
| 	"net" | ||||
| 	"net/http" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	. "github.com/Monibuca/engine/v2" | ||||
| 	"github.com/Monibuca/engine/v2/util" | ||||
| 	. "github.com/Monibuca/plugin-rtp" | ||||
| 	. "github.com/Monibuca/engine/v3" | ||||
| 	. "github.com/Monibuca/utils/v3" | ||||
| 	"github.com/teris-io/shortid" | ||||
| ) | ||||
|  | ||||
| var collection sync.Map | ||||
| var config = struct { | ||||
| 	ListenAddr string | ||||
| 	AutoPull   bool | ||||
| 	RemoteAddr string | ||||
| 	Timeout    int | ||||
| 	Reconnect  bool | ||||
| }{":554", false, "rtsp://localhost/${streamPath}", 0, false} | ||||
| 	ListenAddr   string | ||||
| 	Timeout      int | ||||
| 	Reconnect    bool | ||||
| 	AutoPullList map[string]string | ||||
| }{":554", 0, false, nil} | ||||
|  | ||||
| func init() { | ||||
| 	InstallPlugin(&PluginConfig{ | ||||
| 		Name:   "RTSP", | ||||
| 		Type:   PLUGIN_PUBLISHER | PLUGIN_HOOK, | ||||
| 		Config: &config, | ||||
| 		Run:    runPlugin, | ||||
| 		HotConfig: map[string]func(interface{}){ | ||||
| 			"AutoPull": func(value interface{}) { | ||||
| 				config.AutoPull = value.(bool) | ||||
| 			}, | ||||
| 		}, | ||||
| 	}) | ||||
| } | ||||
| func runPlugin() { | ||||
| 	OnSubscribeHooks.AddHook(func(s *Subscriber) { | ||||
| 		if config.AutoPull && s.Publisher == nil { | ||||
| 			new(RTSP).PullStream(s.StreamPath, strings.Replace(config.RemoteAddr, "${streamPath}", s.StreamPath, -1)) | ||||
| 		} | ||||
| 	}) | ||||
| 	http.HandleFunc("/rtsp/list", func(w http.ResponseWriter, r *http.Request) { | ||||
| 		sse := util.NewSSE(w, r.Context()) | ||||
| 	http.HandleFunc("/api/rtsp/list", func(w http.ResponseWriter, r *http.Request) { | ||||
| 		sse := 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 | ||||
| 			}) | ||||
| 			var info []*RTSP | ||||
| 			for _, s := range Streams.ToList() { | ||||
| 				if rtsp, ok := s.ExtraProp.(*RTSP); ok { | ||||
| 					info = append(info, rtsp) | ||||
| 				} | ||||
| 			} | ||||
| 			err = sse.WriteJSON(info) | ||||
| 		} | ||||
| 	}) | ||||
| 	http.HandleFunc("/rtsp/pull", func(w http.ResponseWriter, r *http.Request) { | ||||
| 	http.HandleFunc("/api/rtsp/pull", func(w http.ResponseWriter, r *http.Request) { | ||||
| 		CORS(w, r) | ||||
| 		targetURL := r.URL.Query().Get("target") | ||||
| 		streamPath := r.URL.Query().Get("streamPath") | ||||
| 		if err := new(RTSP).PullStream(streamPath, targetURL); err == nil { | ||||
| 		if err := (&RTSP{RTSPClientInfo: RTSPClientInfo{Agent: "Monibuca"}}).PullStream(streamPath, targetURL); err == nil { | ||||
| 			w.Write([]byte(`{"code":0}`)) | ||||
| 		} else { | ||||
| 			w.Write([]byte(fmt.Sprintf(`{"code":1,"msg":"%s"}`, err.Error()))) | ||||
| 		} | ||||
| 	}) | ||||
| 	if len(config.AutoPullList) > 0 { | ||||
| 		for streamPath, url := range config.AutoPullList { | ||||
| 			if err := (&RTSP{RTSPClientInfo: RTSPClientInfo{Agent: "Monibuca"}}).PullStream(streamPath, url); err != nil { | ||||
| 				Println(err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if config.ListenAddr != "" { | ||||
| 		log.Fatal(ListenRtsp(config.ListenAddr)) | ||||
| 		go log.Fatal(ListenRtsp(config.ListenAddr)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -118,60 +110,86 @@ func ListenRtsp(addr string) error { | ||||
| } | ||||
|  | ||||
| type RTSP struct { | ||||
| 	RTP | ||||
| 	RTSPInfo | ||||
| 	*Stream  `json:"-"` | ||||
| 	URL      string | ||||
| 	SDPRaw   string | ||||
| 	InBytes  int | ||||
| 	OutBytes int | ||||
| 	RTSPClientInfo | ||||
| 	ID        string | ||||
| 	Conn      *RichConn | ||||
| 	Conn      *RichConn `json:"-"` | ||||
| 	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 | ||||
| 	SDPMap  map[string]*SDPInfo | ||||
| 	nonce   string | ||||
| 	ASdp    *SDPInfo | ||||
| 	VSdp    *SDPInfo | ||||
| 	Timeout int | ||||
| 	//tcp channels | ||||
| 	aRTPChannel        int | ||||
| 	aRTPControlChannel int | ||||
| 	vRTPChannel        int | ||||
| 	vRTPControlChannel int | ||||
| 	UDPServer          *UDPServer | ||||
| 	UDPClient          *UDPClient | ||||
| 	Auth               func(string) string | ||||
| 	UDPServer          *UDPServer          `json:"-"` | ||||
| 	UDPClient          *UDPClient          `json:"-"` | ||||
| 	Auth               func(string) string `json:"-"` | ||||
| 	HasVideo           bool | ||||
| 	HasAudio           bool | ||||
| 	RtpAudio           *RTPAudio | ||||
| 	RtpVideo           *RTPVideo | ||||
| } | ||||
| 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 | ||||
|  | ||||
| func (rtsp *RTSP) setVideoTrack() { | ||||
| 	if rtsp.VSdp.Codec == "H264" { | ||||
| 		rtsp.RtpVideo = rtsp.NewRTPVideo(7) | ||||
| 		if len(rtsp.VSdp.SpropParameterSets) > 1 { | ||||
| 			rtsp.RtpVideo.PushNalu(0, 0, rtsp.VSdp.SpropParameterSets...) | ||||
| 		} | ||||
| 	} else if rtsp.VSdp.Codec == "H265" { | ||||
| 		rtsp.RtpVideo = rtsp.NewRTPVideo(12) | ||||
| 		if len(rtsp.VSdp.VPS) > 0 { | ||||
| 			rtsp.RtpVideo.PushNalu(0, 0, rtsp.VSdp.VPS, rtsp.VSdp.SPS, rtsp.VSdp.PPS) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| func (rtsp *RTSP) setAudioTrack() { | ||||
| 	var at *RTPAudio | ||||
| 	if len(rtsp.ASdp.Config) > 0 { | ||||
| 		at = rtsp.NewRTPAudio(0) | ||||
| 		at.SetASC(rtsp.ASdp.Config) | ||||
| 	} else { | ||||
| 		switch rtsp.ASdp.Codec { | ||||
| 		case "AAC": | ||||
| 			at = rtsp.NewRTPAudio(10) | ||||
| 		case "PCMA": | ||||
| 			at = rtsp.NewRTPAudio(7) | ||||
| 			at.SoundRate = rtsp.ASdp.TimeScale | ||||
| 			at.SoundSize = 16 | ||||
| 			at.Channels = 1 | ||||
| 			at.ExtraData = []byte{(at.CodecID << 4) | (1 << 1)} | ||||
| 		case "PCMU": | ||||
| 			at = rtsp.NewRTPAudio(8) | ||||
| 			at.SoundRate = rtsp.ASdp.TimeScale | ||||
| 			at.SoundSize = 16 | ||||
| 			at.Channels = 1 | ||||
| 			at.ExtraData = []byte{(at.CodecID << 4) | (1 << 1)} | ||||
| 		default: | ||||
| 			Printf("rtsp audio codec not support:%s", rtsp.ASdp.Codec) | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 	rtsp.RtpAudio = at | ||||
| } | ||||
|  | ||||
| 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 | ||||
|   | ||||
| @@ -15,6 +15,9 @@ type SDPInfo struct { | ||||
| 	Rtpmap             int | ||||
| 	Config             []byte | ||||
| 	SpropParameterSets [][]byte | ||||
| 	VPS                []byte | ||||
| 	PPS                []byte | ||||
| 	SPS                []byte | ||||
| 	PayloadType        int | ||||
| 	SizeLength         int | ||||
| 	IndexLength        int | ||||
| @@ -54,18 +57,15 @@ func ParseSDP(sdpRaw string) map[string]*SDPInfo { | ||||
| 						} | ||||
| 						keyval = strings.Split(field, "/") | ||||
| 						if len(keyval) >= 2 { | ||||
| 							key := keyval[0] | ||||
| 							switch key { | ||||
| 							case "PCMA": | ||||
| 								info.Codec = "pcma" | ||||
| 							case "PCMU": | ||||
| 								info.Codec = "pcmu" | ||||
| 							switch keyval[0] { | ||||
| 							case "h264", "h265", "pcma", "pcmu": | ||||
| 								info.Codec = strings.ToUpper(keyval[0]) | ||||
| 							case "H264", "H265", "PCMA", "PCMU": | ||||
| 								info.Codec = keyval[0] | ||||
| 							case "HEVC": | ||||
| 								info.Codec = "H265" | ||||
| 							case "MPEG4-GENERIC": | ||||
| 								info.Codec = "aac" | ||||
| 							case "H264": | ||||
| 								info.Codec = "h264" | ||||
| 							case "H265": | ||||
| 								info.Codec = "h265" | ||||
| 								info.Codec = "AAC" | ||||
| 							} | ||||
| 							if i, err := strconv.Atoi(keyval[1]); err == nil { | ||||
| 								info.TimeScale = i | ||||
| @@ -85,6 +85,12 @@ func ParseSDP(sdpRaw string) map[string]*SDPInfo { | ||||
| 										info.SizeLength, _ = strconv.Atoi(val) | ||||
| 									case "indexlength": | ||||
| 										info.IndexLength, _ = strconv.Atoi(val) | ||||
| 									case "sprop-vps": | ||||
| 										info.VPS, _ = base64.StdEncoding.DecodeString(val) | ||||
| 									case "sprop-sps": | ||||
| 										info.SPS, _ = base64.StdEncoding.DecodeString(val) | ||||
| 									case "sprop-pps": | ||||
| 										info.PPS, _ = base64.StdEncoding.DecodeString(val) | ||||
| 									case "sprop-parameter-sets": | ||||
| 										fields := strings.Split(val, ",") | ||||
| 										for _, field := range fields { | ||||
|   | ||||
							
								
								
									
										314
									
								
								session.go
									
									
									
									
									
								
							
							
						
						
									
										314
									
								
								session.go
									
									
									
									
									
								
							| @@ -3,6 +3,7 @@ package rtsp | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"crypto/md5" | ||||
| 	"encoding/base64" | ||||
| 	"encoding/binary" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| @@ -11,12 +12,19 @@ import ( | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"time" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	. "github.com/Monibuca/engine/v2" | ||||
| 	. "github.com/Monibuca/plugin-rtp" | ||||
| 	. "github.com/Monibuca/engine/v3" | ||||
| 	. "github.com/Monibuca/utils/v3" | ||||
| 	"github.com/pion/rtp" | ||||
| 	"github.com/pion/rtp/codecs" | ||||
| 	"github.com/teris-io/shortid" | ||||
| ) | ||||
|  | ||||
| type RTPPack struct { | ||||
| 	Type RTPType | ||||
| 	Raw  []byte | ||||
| } | ||||
| type SessionType int | ||||
|  | ||||
| const ( | ||||
| @@ -34,6 +42,15 @@ func (st SessionType) String() string { | ||||
| 	return "unknow" | ||||
| } | ||||
|  | ||||
| type RTPType int | ||||
|  | ||||
| const ( | ||||
| 	RTP_TYPE_AUDIO RTPType = iota | ||||
| 	RTP_TYPE_VIDEO | ||||
| 	RTP_TYPE_AUDIOCONTROL | ||||
| 	RTP_TYPE_VIDEOCONTROL | ||||
| ) | ||||
|  | ||||
| type TransType int | ||||
|  | ||||
| const ( | ||||
| @@ -58,6 +75,9 @@ func (session *RTSP) SessionString() string { | ||||
| } | ||||
|  | ||||
| func (session *RTSP) Stop() { | ||||
| 	if session.Stream != nil { | ||||
| 		session.Close() | ||||
| 	} | ||||
| 	if session.Conn != nil { | ||||
| 		session.connRW.Flush() | ||||
| 		session.Conn.Close() | ||||
| @@ -71,12 +91,6 @@ func (session *RTSP) Stop() { | ||||
| 		session.UDPServer.Stop() | ||||
| 		session.UDPServer = nil | ||||
| 	} | ||||
| 	if session.Running() { | ||||
| 		session.Cancel() | ||||
| 	} | ||||
| 	if session.Stream != nil { | ||||
| 		collection.Delete(session.StreamPath) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // AcceptPush 接受推流 | ||||
| @@ -101,41 +115,43 @@ func (session *RTSP) AcceptPush() { | ||||
| 			} | ||||
| 			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 | ||||
| 			} | ||||
|  | ||||
| 			// t := pack.Timestamp / 90 | ||||
| 			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() | ||||
| 				// pack.Type = RTP_TYPE_AUDIO | ||||
| 				if session.RtpAudio != nil { | ||||
| 					elapsed := time.Since(timer) | ||||
| 					if elapsed >= 30*time.Second { | ||||
| 						Println("Recv an audio RTP package") | ||||
| 						timer = time.Now() | ||||
| 					} | ||||
| 					session.RtpAudio.Push(rtpBytes) | ||||
| 				} | ||||
| 			case session.aRTPControlChannel: | ||||
| 				pack.Type = RTP_TYPE_AUDIOCONTROL | ||||
| 				// 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() | ||||
| 				// pack.Type = RTP_TYPE_VIDEO | ||||
| 				if session.RtpVideo != nil { | ||||
| 					elapsed := time.Since(timer) | ||||
| 					if elapsed >= 30*time.Second { | ||||
| 						Println("Recv an video RTP package") | ||||
| 						timer = time.Now() | ||||
| 					} | ||||
| 					session.RtpVideo.Push(rtpBytes) | ||||
| 				} | ||||
| 			case session.vRTPControlChannel: | ||||
| 				pack.Type = RTP_TYPE_VIDEOCONTROL | ||||
| 				// pack.Type = RTP_TYPE_VIDEOCONTROL | ||||
| 			default: | ||||
| 				Printf("unknow rtp pack type, %v", pack.Type) | ||||
| 				//	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) | ||||
| @@ -244,6 +260,7 @@ func (session *RTSP) handleRequest(req *Request) { | ||||
| 	//} | ||||
| 	Printf("<<<\n%s", req) | ||||
| 	res := NewResponse(200, "OK", req.Header["CSeq"], session.ID, "") | ||||
| 	var streamPath string | ||||
| 	defer func() { | ||||
| 		if p := recover(); p != nil { | ||||
| 			Printf("handleRequest err ocurs:%v", p) | ||||
| @@ -261,6 +278,61 @@ func (session *RTSP) handleRequest(req *Request) { | ||||
| 		case "PLAY", "RECORD": | ||||
| 			switch session.Type { | ||||
| 			case SESSEION_TYPE_PLAYER: | ||||
| 				sub := Subscriber{ | ||||
| 					ID:   session.ID, | ||||
| 					Type: "RTSP", | ||||
| 				} | ||||
| 				if sub.Subscribe(streamPath) == nil { | ||||
| 					at, vt := session.UDPClient.AT, session.UDPClient.VT | ||||
| 					if vt != nil { | ||||
| 						var st uint32 | ||||
| 						onVideo := func(ts uint32, pack *VideoPack) { | ||||
| 							if session.UDPClient == nil { | ||||
| 								return | ||||
| 							} | ||||
| 							for _, nalu := range pack.NALUs { | ||||
| 								for _, pack := range session.UDPClient.VPacketizer.Packetize(nalu, (ts-st)*90) { | ||||
| 									p := &RTPPack{ | ||||
| 										Type: RTP_TYPE_VIDEO, | ||||
| 									} | ||||
| 									p.Raw, _ = pack.Marshal() | ||||
| 									session.SendRTP(p) | ||||
| 								} | ||||
| 							} | ||||
| 							st = ts | ||||
| 						} | ||||
| 						sub.OnVideo = func(ts uint32, pack *VideoPack) { | ||||
| 							if st = ts; st != 0 { | ||||
| 								sub.OnVideo = onVideo | ||||
| 							} | ||||
| 							onVideo(ts, pack) | ||||
| 						} | ||||
| 					} | ||||
| 					if at != nil { | ||||
| 						tb := uint32(at.SoundRate / 1000) | ||||
| 						var st uint32 | ||||
| 						onAudio := func(ts uint32, pack *AudioPack) { | ||||
| 							if session.UDPClient == nil { | ||||
| 								return | ||||
| 							} | ||||
| 							for _, pack := range session.UDPClient.APacketizer.Packetize(pack.Payload, (ts-st)*tb) { | ||||
| 								p := &RTPPack{ | ||||
| 									Type: RTP_TYPE_VIDEO, | ||||
| 								} | ||||
| 								p.Raw, _ = pack.Marshal() | ||||
| 								session.SendRTP(p) | ||||
| 							} | ||||
| 							st = ts | ||||
| 						} | ||||
| 						sub.OnAudio = func(ts uint32, pack *AudioPack) { | ||||
| 							if st = ts; st != 0 { | ||||
| 								sub.OnAudio = onAudio | ||||
| 							} | ||||
| 							onAudio(ts, pack) | ||||
| 						} | ||||
| 					} | ||||
| 					go sub.Play(at, vt) | ||||
| 				} | ||||
| 				// if session.Pusher.HasPlayer(session.Player) { | ||||
| 				// 	session.Player.Pause(false) | ||||
| 				// } else { | ||||
| @@ -278,6 +350,14 @@ func (session *RTSP) handleRequest(req *Request) { | ||||
| 			session.Stop() | ||||
| 		} | ||||
| 	}() | ||||
| 	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, "/") | ||||
| 	if req.Method != "OPTIONS" { | ||||
| 		if session.Auth != nil { | ||||
| 			authLine := req.Header["Authorization"] | ||||
| @@ -295,7 +375,7 @@ func (session *RTSP) handleRequest(req *Request) { | ||||
| 				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) | ||||
| 				res.Header["WWW-Authenticate"] = fmt.Sprintf(`Digest realm="Monibuca", nonce="%s", algorithm="MD5"`, nonce) | ||||
| 				return | ||||
| 			} | ||||
| 		} | ||||
| @@ -305,54 +385,81 @@ func (session *RTSP) handleRequest(req *Request) { | ||||
| 		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.Stream = Publish(streamPath, "RTSP"); session.Stream != nil { | ||||
| 			if session.ASdp, session.HasAudio = session.SDPMap["audio"]; session.HasAudio { | ||||
| 				if len(session.ASdp.Control) >0 { | ||||
| 					session.WriteASC(session.ASdp.Config) | ||||
| 				}else{ | ||||
| 					session.setAudioFormat() | ||||
| 				} | ||||
| 				session.setAudioTrack() | ||||
| 				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]) | ||||
| 				} | ||||
| 				session.setVideoTrack() | ||||
| 				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 { | ||||
| 			res.StatusCode = 404 | ||||
| 			res.Status = "No Such Stream:" + streamPath | ||||
| 			return | ||||
| 		} | ||||
| 		// | ||||
| 		//res.SetBody(session.SDPRaw) | ||||
| 		sdpInfo := []string{ | ||||
| 			"v=0", | ||||
| 			fmt.Sprintf("o=%s 0 0 IN IP4 %d", session.ID, 0), | ||||
| 			"s=monibuca", | ||||
| 			"t=0 0", | ||||
| 			"a=recvonly", | ||||
| 		} | ||||
| 		ssrc := uintptr(unsafe.Pointer(stream)) | ||||
| 		if session.UDPClient == nil { | ||||
| 			session.UDPClient = &UDPClient{ | ||||
| 				Conn: session.Conn.Conn, | ||||
| 			} | ||||
| 		} | ||||
| 		vt, at := stream.WaitVideoTrack(), stream.WaitAudioTrack() | ||||
| 		if vt != nil { | ||||
| 			session.UDPClient.VT = vt | ||||
| 			sdpInfo = append(sdpInfo, "m=video 0 RTP/AVP 96") | ||||
| 			switch vt.CodecID { | ||||
| 			case 7: | ||||
| 				sps := base64.StdEncoding.EncodeToString(vt.ExtraData.NALUs[0]) | ||||
| 				pps := base64.StdEncoding.EncodeToString(vt.ExtraData.NALUs[1]) | ||||
| 				session.UDPClient.VPacketizer = rtp.NewPacketizer(1200, 96, uint32(ssrc), &codecs.H264Payloader{}, rtp.NewFixedSequencer(1), 90000) | ||||
| 				sdpInfo = append(sdpInfo, "a=rtpmap:96 H264/90000", | ||||
| 					fmt.Sprintf("a=fmtp:96 profile-level-id=%02X00%02X; packetization-mode=1; sprop-parameter-sets=%s,%s", vt.SPSInfo.ProfileIdc, vt.SPSInfo.LevelIdc*10, sps, pps)) | ||||
| 			case 12: | ||||
| 				vps := base64.StdEncoding.EncodeToString(vt.ExtraData.NALUs[0]) | ||||
| 				sps := base64.StdEncoding.EncodeToString(vt.ExtraData.NALUs[1]) | ||||
| 				pps := base64.StdEncoding.EncodeToString(vt.ExtraData.NALUs[2]) | ||||
| 				// TODO: | ||||
| 				// session.UDPClient.VPacketizer = rtp.NewPacketizer(1200, 96, uint32(ssrc), &codecs.H265Payloader{}, rtp.NewFixedSequencer(1), 90000) | ||||
| 				sdpInfo = append(sdpInfo, "a=rtpmap:96 H265/90000", | ||||
| 					fmt.Sprintf("a=fmtp:96 packetization-mode=1;sprop-vps=%s;sprop-sps=%s;sprop-pps=%s", vps, sps, pps)) | ||||
| 			} | ||||
| 		} | ||||
| 		if at != nil { | ||||
| 			sdpInfo = append(sdpInfo, "m=audio 0 RTP/AVP 97") | ||||
| 			switch at.CodecID { | ||||
| 			case 7: | ||||
| 				sdpInfo = append(sdpInfo, "a=rtpmap:97 PCMA/8000") | ||||
| 				session.UDPClient.APacketizer = rtp.NewPacketizer(1200, 97, uint32(ssrc), &codecs.G711Payloader{}, rtp.NewFixedSequencer(1), 8000) | ||||
| 				session.UDPClient.AT = at | ||||
| 			case 8: | ||||
| 				sdpInfo = append(sdpInfo, "a=rtpmap:97 PCMU/8000") | ||||
| 				session.UDPClient.APacketizer = rtp.NewPacketizer(1200, 97, uint32(ssrc), &codecs.G711Payloader{}, rtp.NewFixedSequencer(1), 8000) | ||||
| 				session.UDPClient.AT = at | ||||
| 			case 10: | ||||
| 				// TODO: | ||||
| 				sdpInfo = append(sdpInfo, fmt.Sprintf("a=rtpmap:97 MPEG4-GENERIC/%d/%d", at.SoundRate, at.Channels)) | ||||
| 			//	session.UDPClient.APacketizer = rtp.NewPacketizer(1200, 97, uint32(ssrc), &AACPayloader{}, rtp.NewFixedSequencer(1), uint32(at.SoundRate)) | ||||
| 				//session.UDPClient.AT = at | ||||
| 			} | ||||
| 		} | ||||
| 		session.SDPRaw = strings.Join(sdpInfo, "\r\n") + "\r\n" | ||||
| 		res.SetBody(session.SDPRaw) | ||||
| 	case "SETUP": | ||||
| 		ts := req.Header["Transport"] | ||||
| 		// control字段可能是`stream=1`字样,也可能是rtsp://...字样。即control可能是url的path,也可能是整个url | ||||
| @@ -362,16 +469,10 @@ func (session *RTSP) handleRequest(req *Request) { | ||||
| 		// 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 _url.Port() == "" { | ||||
| 			_url.Host = fmt.Sprintf("%s:554", _url.Host) | ||||
| 		} | ||||
| 		if setupUrl.Port() == "" { | ||||
| 			setupUrl.Host = fmt.Sprintf("%s:554", setupUrl.Host) | ||||
| 		} | ||||
| 		setupPath := setupUrl.String() | ||||
| 		setupPath := _url.String() | ||||
|  | ||||
| 		// error status. SETUP without ANNOUNCE or DESCRIBE. | ||||
| 		//if session.Pusher == nil { | ||||
| @@ -379,36 +480,38 @@ func (session *RTSP) handleRequest(req *Request) { | ||||
| 		//	res.Status = "Error Status" | ||||
| 		//	return | ||||
| 		//} | ||||
| 		vPath := "" | ||||
| 		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 | ||||
| 		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 vControlUrl.Port() == "" { | ||||
| 				vControlUrl.Host = fmt.Sprintf("%s:554", vControlUrl.Host) | ||||
| 			} | ||||
| 			vPath = vControlUrl.String() | ||||
| 		} else { | ||||
| 			vPath = session.VSdp.Control | ||||
| 		} | ||||
|  | ||||
| 		aPath := "" | ||||
| 		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 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 | ||||
| 			} | ||||
| 			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+))?") | ||||
| @@ -499,6 +602,25 @@ func (session *RTSP) handleRequest(req *Request) { | ||||
| 					ts = strings.Join(tss, ";") | ||||
| 				} | ||||
| 			} else { | ||||
| 				if session.Type == SESSEION_TYPE_PLAYER { | ||||
| 					if session.UDPClient.VPort == 0 { | ||||
| 						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 | ||||
| 						} | ||||
| 					} else { | ||||
| 						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 | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				Printf("SETUP [UDP] got UnKown control:%s", setupPath) | ||||
| 			} | ||||
| 		} | ||||
|   | ||||
| @@ -2,13 +2,16 @@ package rtsp | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	. "github.com/Monibuca/engine/v2" | ||||
| 	. "github.com/Monibuca/plugin-rtp" | ||||
| 	"net" | ||||
| 	"strings" | ||||
|  | ||||
| 	. "github.com/Monibuca/engine/v3" | ||||
| 	. "github.com/Monibuca/utils/v3" | ||||
| 	"github.com/pion/rtp" | ||||
| ) | ||||
|  | ||||
| type UDPClient struct { | ||||
| 	Conn         net.Conn | ||||
| 	APort        int | ||||
| 	AConn        *net.UDPConn | ||||
| 	AControlPort int | ||||
| @@ -17,8 +20,11 @@ type UDPClient struct { | ||||
| 	VConn        *net.UDPConn | ||||
| 	VControlPort int | ||||
| 	VControlConn *net.UDPConn | ||||
|  | ||||
| 	Stoped bool | ||||
| 	AT           *AudioTrack | ||||
| 	APacketizer  rtp.Packetizer | ||||
| 	VT           *VideoTrack | ||||
| 	VPacketizer  rtp.Packetizer | ||||
| 	Stoped       bool | ||||
| } | ||||
|  | ||||
| func (s *UDPClient) Stop() { | ||||
| @@ -51,7 +57,7 @@ func (c *UDPClient) SetupAudio() (err error) { | ||||
| 			c.Stop() | ||||
| 		} | ||||
| 	}() | ||||
| 	host := c.AConn.RemoteAddr().String() | ||||
| 	host := c.Conn.RemoteAddr().String() | ||||
| 	host = host[:strings.LastIndex(host, ":")] | ||||
| 	addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", host, c.APort)) | ||||
| 	if err != nil { | ||||
| @@ -93,7 +99,7 @@ func (c *UDPClient) SetupVideo() (err error) { | ||||
| 			c.Stop() | ||||
| 		} | ||||
| 	}() | ||||
| 	host := c.VConn.RemoteAddr().String() | ||||
| 	host := c.Conn.RemoteAddr().String() | ||||
| 	host = host[:strings.LastIndex(host, ":")] | ||||
| 	addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", host, c.VPort)) | ||||
| 	if err != nil { | ||||
|   | ||||
| @@ -6,10 +6,8 @@ import ( | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	. "github.com/Monibuca/engine/v2" | ||||
| 	. "github.com/Monibuca/plugin-rtp" | ||||
| 	. "github.com/Monibuca/utils/v3" | ||||
| ) | ||||
|  | ||||
| type UDPServer struct { | ||||
| @@ -26,14 +24,6 @@ func (s *UDPServer) AddInputBytes(bytes int) { | ||||
| 	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 | ||||
| @@ -83,20 +73,17 @@ func (s *UDPServer) SetupAudio() (err error) { | ||||
| 		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) | ||||
| 		// 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() | ||||
| 				} | ||||
| 				// 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) | ||||
| 				var bytes []byte | ||||
| 				s.Session.RtpAudio.Push(append(bytes, bufUDP[:n]...)) | ||||
| 			} else { | ||||
| 				Println("udp server read audio pack error", err) | ||||
| 				continue | ||||
| @@ -131,11 +118,11 @@ func (s *UDPServer) SetupAudio() (err error) { | ||||
| 			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) | ||||
| 				// pack := RTPPack{ | ||||
| 				// 	Type: RTP_TYPE_AUDIOCONTROL, | ||||
| 				// } | ||||
| 				// pack.Unmarshal(bufUDP[:n]) | ||||
| 				// s.HandleRTP(pack) | ||||
| 			} else { | ||||
| 				Println("udp server read audio control pack error", err) | ||||
| 				continue | ||||
| @@ -171,20 +158,17 @@ func (s *UDPServer) SetupVideo() (err error) { | ||||
| 		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) | ||||
| 		// 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() | ||||
| 				} | ||||
| 				// 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) | ||||
| 				var bytes []byte | ||||
| 				s.Session.RtpVideo.Push(append(bytes, bufUDP[:n]...)) | ||||
| 			} else { | ||||
| 				Println("udp server read video pack error", err) | ||||
| 				continue | ||||
| @@ -220,11 +204,11 @@ func (s *UDPServer) SetupVideo() (err error) { | ||||
| 			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) | ||||
| 				// pack := RTPPack{ | ||||
| 				// 	Type: RTP_TYPE_VIDEOCONTROL, | ||||
| 				// } | ||||
| 				// pack.Unmarshal(bufUDP[:n]) | ||||
| 				// s.HandleRTP(pack) | ||||
| 			} else { | ||||
| 				Println("udp server read video control pack error", err) | ||||
| 				continue | ||||
|   | ||||
							
								
								
									
										19
									
								
								ui/dist/demo.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								ui/dist/demo.html
									
									
									
									
										vendored
									
									
								
							| @@ -1,19 +0,0 @@ | ||||
| <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
									
									
								
							
							
						
						
									
										437
									
								
								ui/dist/plugin-rtsp.common.js
									
									
									
									
										vendored
									
									
								
							| @@ -1,437 +0,0 @@ | ||||
| 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
									
									
								
							
							
						
						
									
										1
									
								
								ui/dist/plugin-rtsp.common.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										1
									
								
								ui/dist/plugin-rtsp.css
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								ui/dist/plugin-rtsp.css
									
									
									
									
										vendored
									
									
								
							| @@ -1 +0,0 @@ | ||||
| .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
									
									
								
							
							
						
						
									
										447
									
								
								ui/dist/plugin-rtsp.umd.js
									
									
									
									
										vendored
									
									
								
							| @@ -1,447 +0,0 @@ | ||||
| (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
									
									
								
							
							
						
						
									
										1
									
								
								ui/dist/plugin-rtsp.umd.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								ui/dist/plugin-rtsp.umd.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								ui/dist/plugin-rtsp.umd.min.js
									
									
									
									
										vendored
									
									
								
							| @@ -1,2 +0,0 @@ | ||||
| (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
									
									
								
							
							
						
						
									
										1
									
								
								ui/dist/plugin-rtsp.umd.min.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										9560
									
								
								ui/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										9560
									
								
								ui/package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,15 +0,0 @@ | ||||
| { | ||||
|   "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
									
									
									
									
									
								
							
							
						
						
									
										147
									
								
								ui/src/App.vue
									
									
									
									
									
								
							| @@ -1,147 +0,0 @@ | ||||
| <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