zlmediakit

package
v0.0.0-...-0ab9942 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "zlmediakit",
	Short: "zlmediakit WebRTC client",
	Long:  `zlmediakit WebRTC client`,
	Run: func(cmd *cobra.Command, args []string) {
		var api *webrtc.API
		conf := &rtc.RTCEngineConfiguration{}

		if *arg_TCP {
			conf.NetworkType = rtc.RTCEngineNETWORKTYPE_TCP
			conf.TCP = &net.TCPAddr{IP: net.IP{0, 0, 0, 0}, Port: 31922}
		}

		if *arg_UDP {
			conf.NetworkType = rtc.RTCEngineNETWORKTYPE_UDP
			conf.UDP = &net.UDPAddr{IP: net.IP{0, 0, 0, 0}, Port: 31921}
		}

		if *arg_UDP && *arg_TCP {
			conf.NetworkType = rtc.RTCEngineNETWORKTYPE_MIX
		}

		api, err := rtc.NewRTCEngine(conf)
		if err != nil {
			logrus.Error(err)
			fmt.Fprintf(os.Stderr, "failed to create rtc engine: %v", err)
			return
		}

		err = rtc.OfferPublishToAnswer(api, *arg_SOURCE, *arg_FPS, func(offer webrtc.SessionDescription) (answer webrtc.SessionDescription, e error) {
			res, e := zlmkit.WebRTC(*arg_IP, *arg_PORT, *arg_APP, *arg_STREAM, rtc.RTCTYPE_PUBLISH, offer)
			if e != nil {
				fmt.Print(e.Error())
				return
			}
			answer = res
			return
		})

		if err != nil {
			fmt.Print(err.Error())
			return
		}

		select {}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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