Exemplo n.º 1
0
// ampAddr: address to listen on for AMP requests
// rtspURL: base URL used when sending RTSP requests to the backend media server
// localProxyIP: address to receive RTP/RTCP packets from the media server
func RegisterAmpProxy(server *protocols.Server, rtspURL, localProxyIP string) (*AmpProxy, error) {
	u, err := url.Parse(rtspURL)
	if err != nil {
		return nil, err
	}
	if u.Scheme != "rtsp" {
		return nil, errors.New("Need rtsp:// rtspURL for AmpProxy")
	}

	ip, err := net.ResolveIPAddr("ip", localProxyIP)
	if err != nil {
		return nil, fmt.Errorf("Failed to resolve IP address %v: %v", localProxyIP, err)
	}

	proxy := &AmpProxy{
		rtspURL:   u,
		proxyHost: ip.String(),
		sessions:  make(protocols.Sessions),
		Server:    server,
	}
	if err := amp.RegisterServer(server, proxy); err != nil {
		return nil, err
	}
	// TODO if second registration fails, the first registration still stays in the server...
	if err := amp_control.RegisterServer(server, proxy); err != nil {
		return nil, err
	}
	return proxy, nil
}
Exemplo n.º 2
0
func RegisterPluginServer(server *protocols.Server) (*protocols.PluginServer, error) {
	handler := new(ampPluginServerHandler)
	err := amp.RegisterServer(server, handler)
	if err != nil {
		return nil, err
	}
	handler.PluginServer = protocols.NewPluginServer(server)
	return handler.PluginServer, nil
}
Exemplo n.º 3
0
func RegisterLoadServer(server *protocols.Server) (*LoadServer, error) {
	load := &LoadServer{
		sessions: make(protocols.Sessions),
		Server:   server,
	}
	if err := amp.RegisterServer(server, load); err != nil {
		return nil, err
	}
	// TODO if second registration fails, the first registration still stays in the server...
	if err := amp_control.RegisterServer(server, load); err != nil {
		return nil, err
	}
	return load, nil
}