Janus源码分析(6)——Streaming分析

1. 运行效果图

Streaming演示的是播放视频或音频流,可用于网络直播或转播,效果如下图所示:
Janus源码分析(6)——Streaming分析_第1张图片

2. Streaming插件API分析

2.1 会议配置信息及API分类

1、插件配置文件位置 conf/janus.plugin.streaming.jcfg,流配置格式如下:

stream-name: {
	type = rtp|live|ondemand|rtsp
		   rtp = stream originated by an external tool (e.g., gstreamer or
				 ffmpeg) and sent to the plugin via RTP
		   live = local file streamed live to multiple viewers
				  (multiple viewers = same streaming context)
		   ondemand = local file streamed on-demand to a single listener
					  (multiple viewers = different streaming contexts)
		   rtsp = stream originated by an external RTSP feed (only
				  available if libcurl support was compiled)
	id = <unique numeric ID>
	description = This is my awesome stream
	is_private = true|false (private streams don't appear when you do a 'list' request)
	filename = path to the local file to stream (only for live/ondemand)
	secret = <optional password needed for manipulating (e.g., destroying
					or enabling/disabling) the stream>
	pin = <optional password needed for watching the stream>
	audio = true|false (do/don't stream audio)
	video = true|false (do/don't stream video)
	   The following options are only valid for the 'rtp' type:
	data = true|false (do/don't stream text via datachannels)
	audioport = local port for receiving audio frames
	audiortcpport = local port for receiving and sending audio RTCP feedback
	audiomcast = multicast group for receiving audio frames, if any
	audioiface = network interface or IP address to bind to, if any (binds to all otherwise)
	audiopt = <audio RTP payload type> (e.g., 111)
	audiortpmap = RTP map of the audio codec (e.g., opus/48000/2)
	audiofmtp = Codec specific parameters, if any
	audioskew = true|false (whether the plugin should perform skew
			analisys and compensation on incoming audio RTP stream, EXPERIMENTAL)
	videoport = local port for receiving video frames (only for rtp)
	videortcpport = local port for receiving and sending video RTCP feedback
	videomcast = multicast group for receiving video frames, if any
	videoiface = network interface or IP address to bind to, if any (binds to all otherwise)
	videopt = <video RTP payload type> (e.g., 100)
	videortpmap = RTP map of the video codec (e.g., VP8/90000)
	videofmtp = Codec specific parameters, if any
	videobufferkf = true|false (whether the plugin should store the latest
			keyframe and send it immediately for new viewers, EXPERIMENTAL)
	videosimulcast = true|false (do|don't enable video simulcasting)
	videoport2 = second local port for receiving video frames (only for rtp, and simulcasting)
	videoport3 = third local port for receiving video frames (only for rtp, and simulcasting)
	videoskew = true|false (whether the plugin should perform skew
			analisys and compensation on incoming video RTP stream, EXPERIMENTAL)
	videosvc = true|false (whether the video will have SVC support; works only for VP9-SVC, default=false)
	collision = in case of collision (more than one SSRC hitting the same port), the plugin
			will discard incoming RTP packets with a new SSRC unless this many milliseconds
			passed, which would then change the current SSRC (0=disabled)
	dataport = local port for receiving data messages to relay
	dataiface = network interface or IP address to bind to, if any (binds to all otherwise)
	databuffermsg = true|false (whether the plugin should store the latest
			message and send it immediately for new viewers)
	threads = number of threads to assist with the relaying part, which can help
			if you expect a lot of viewers that may cause the RTP receiving part
			in the Streaming plugin to slow down and fail to catch up (default=0)

	In case you want to use SRTP for your RTP-based mountpoint, you'll need
	to configure the SRTP-related properties as well, namely the suite to
	use for hashing (32 or 80) and the crypto information for decrypting
	the stream (as a base64 encoded string the way SDES does it). Notice
	that with SRTP involved you'll have to pay extra attention to what you
	feed the mountpoint, as you may risk getting SRTP decrypt errors:
	srtpsuite = 32
	srtpcrypto = WbTBosdVUZqEb6Htqhn+m3z7wUh4RJVR8nE15GbN

	The following options are only valid for the 'rstp' type:
	url = RTSP stream URL
	rtsp_user = RTSP authorization username, if needed
	rtsp_pwd = RTSP authorization password, if needed
	rtsp_failcheck = whether an error should be returned if connecting to the RTSP server fails (default=true)
	rtspiface = network interface IP address or device name to listen on when receiving RTSP streams
}

实际配置中可参考示例配置文件中给出的配置信息:
Janus源码分析(6)——Streaming分析_第2张图片

2、Streaming插件分2种类型API:同步请求、异步请求;

2.2 同步请求API

Janus源码分析(6)——Streaming分析_第3张图片

2.3 异步请求API

Janus源码分析(6)——Streaming分析_第4张图片

3. 主要API处理分析

3.1 获取流列表list

Janus源码分析(6)——Streaming分析_第5张图片

3.2 观看流watch

4. 参考资料

  • 官网Streaming插件API文档
    https://janus.conf.meetecho.com/docs/streaming.html

你可能感兴趣的:(WebRTC)