From 98d76ddb7c2dad964258f6c4bf3f7222c3f5e37d Mon Sep 17 00:00:00 2001 From: Tyr Date: Tue, 14 Jan 2020 14:35:53 +0800 Subject: [PATCH] to avoid a null access when audio only streaming --- LFLiveKit/publish/LFStreamRtmpSocket.m | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/LFLiveKit/publish/LFStreamRtmpSocket.m b/LFLiveKit/publish/LFStreamRtmpSocket.m index 89118046..9569926a 100644 --- a/LFLiveKit/publish/LFStreamRtmpSocket.m +++ b/LFLiveKit/publish/LFStreamRtmpSocket.m @@ -320,15 +320,17 @@ - (void)sendMetaData { enc = AMF_EncodeNamedNumber(enc, pend, &av_duration, 0.0); enc = AMF_EncodeNamedNumber(enc, pend, &av_fileSize, 0.0); - // videosize - enc = AMF_EncodeNamedNumber(enc, pend, &av_width, _stream.videoConfiguration.videoSize.width); - enc = AMF_EncodeNamedNumber(enc, pend, &av_height, _stream.videoConfiguration.videoSize.height); + if (_stream.videoConfiguration) { + // videosize + enc = AMF_EncodeNamedNumber(enc, pend, &av_width, _stream.videoConfiguration.videoSize.width); + enc = AMF_EncodeNamedNumber(enc, pend, &av_height, _stream.videoConfiguration.videoSize.height); - // video - enc = AMF_EncodeNamedString(enc, pend, &av_videocodecid, &av_avc1); + // video + enc = AMF_EncodeNamedString(enc, pend, &av_videocodecid, &av_avc1); - enc = AMF_EncodeNamedNumber(enc, pend, &av_videodatarate, _stream.videoConfiguration.videoBitRate / 1000.f); - enc = AMF_EncodeNamedNumber(enc, pend, &av_framerate, _stream.videoConfiguration.videoFrameRate); + enc = AMF_EncodeNamedNumber(enc, pend, &av_videodatarate, _stream.videoConfiguration.videoBitRate / 1000.f); + enc = AMF_EncodeNamedNumber(enc, pend, &av_framerate, _stream.videoConfiguration.videoFrameRate); + } // audio enc = AMF_EncodeNamedString(enc, pend, &av_audiocodecid, &av_mp4a);