mirror of
				https://github.com/lkmio/lkm.git
				synced 2025-10-31 18:42:37 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			40 lines
		
	
	
		
			614 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			614 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package gb28181
 | |
| 
 | |
| import (
 | |
| 	"net"
 | |
| )
 | |
| 
 | |
| type ActiveSource struct {
 | |
| 	PassiveSource
 | |
| 
 | |
| 	port       int
 | |
| 	remoteAddr net.TCPAddr
 | |
| 	tcp        *TCPClient
 | |
| }
 | |
| 
 | |
| func (a *ActiveSource) Connect(remoteAddr *net.TCPAddr) error {
 | |
| 	client, err := NewTCPClient(a.port, remoteAddr, a)
 | |
| 	if err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 
 | |
| 	a.tcp = client
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| func (a *ActiveSource) SetupType() SetupType {
 | |
| 	return SetupActive
 | |
| }
 | |
| 
 | |
| func NewActiveSource() (*ActiveSource, int, error) {
 | |
| 	var port int
 | |
| 	TransportManger.AllocPort(true, func(port_ uint16) error {
 | |
| 		port = int(port_)
 | |
| 		return nil
 | |
| 	})
 | |
| 
 | |
| 	return &ActiveSource{
 | |
| 		port: port,
 | |
| 	}, port, nil
 | |
| }
 | 
