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

1. 運行效果圖

Streaming演示的是播放視頻或音頻流,可用於網絡直播或轉播,效果如下圖所示:
在這裏插入圖片描述

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
}

實際配置中可參考示例配置文件中給出的配置信息:
在這裏插入圖片描述

2、Streaming插件分2種類型API:同步請求、異步請求;

2.2 同步請求API

在這裏插入圖片描述

2.3 異步請求API

在這裏插入圖片描述

3. 主要API處理分析

3.1 獲取流列表list

在這裏插入圖片描述

3.2 觀看流watch

在這裏插入圖片描述

4. 參考資料

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章