private async Task PushLiveAsync() { if (PushLiveChecked) { _localPushLiveService.GetLiveParam(); StartLiveStreamResult result = await _localPushLiveService.StartPushLiveStream( _viewLayoutService.GetStreamLayout(_localPushLiveService.LiveParam.m_nWidth, _localPushLiveService.LiveParam.m_nHeight)); if (HasErrorMsg(result.m_result.m_rc.ToString(), result.m_result.m_message)) { PushLiveChecked = false; } else { PushLiveStreamTips = string.Format( $"分辨率:{_localPushLiveService.LiveParam.m_nWidth}*{_localPushLiveService.LiveParam.m_nHeight}\r\n" + $"码率:{_localPushLiveService.LiveParam.m_nVideoBitrate}\r\n" + $"推流地址:{_localPushLiveService.LiveParam.m_url1}"); } } else { AsynCallResult result = await _localPushLiveService.StopPushLiveStream(); if (HasErrorMsg(result.m_rc.ToString(), result.m_message)) { PushLiveChecked = true; } } }
public async Task <StartLiveStreamResult> StartPushLiveStream(List <LiveVideoStreamInfo> liveVideoStreamInfos, string pushLiveUrl) { if (string.IsNullOrEmpty(LiveParam.m_url1)) { return(new StartLiveStreamResult() { m_result = new AsynCallResult() { m_rc = -1, m_message = Messages.WarningLivePushLiveUrlNotSet } }); } if (LiveParam.m_nWidth == 0 || LiveParam.m_nHeight == 0 || LiveParam.m_nVideoBitrate == 0) { return(new StartLiveStreamResult() { m_result = new AsynCallResult() { m_rc = -1, m_message = Messages.WarningLiveResolutionNotSet } }); } Log.Logger.Debug( $"【local push live begins】:width={LiveParam.m_nWidth}, height={LiveParam.m_nHeight}, bitrate={LiveParam.m_nVideoBitrate}, url={LiveParam.m_url1}, videos={liveVideoStreamInfos.Count}"); for (int i = 0; i < liveVideoStreamInfos.Count; i++) { Log.Logger.Debug( $"video{i + 1}:x={liveVideoStreamInfos[i].XLocation}, y={liveVideoStreamInfos[i].YLocation}, width={liveVideoStreamInfos[i].Width}, height={liveVideoStreamInfos[i].Height}"); } StartLiveStreamResult startLiveStreamResult = await _sdkService.StartLiveStream(LiveParam, liveVideoStreamInfos.ToArray(), liveVideoStreamInfos.Count); LiveId = startLiveStreamResult.m_liveId; if (startLiveStreamResult.m_result.m_rc == 0) { HasPushLiveSuccessfully = true; Log.Logger.Debug($"【local push live succeeded】:liveId={startLiveStreamResult.m_liveId}"); } else { Log.Logger.Error($"【local push live failed】:{startLiveStreamResult.m_result.m_message}"); } return(startLiveStreamResult); }
private async Task StartPushLiveStreamAutomatically() { _serverPushLiveService.GetLiveParam(); UserInfo userInfo = DependencyResolver.Current.GetService <UserInfo>(); StartLiveStreamResult result = await _serverPushLiveService.StartPushLiveStream( GetStreamLayout(_serverPushLiveService.LiveParam.m_nWidth, _serverPushLiveService.LiveParam.m_nHeight), userInfo.PushStreamUrl); if (result.m_result.m_rc == 0) { await _serverPushLiveService.RefreshLiveStream( GetStreamLayout(_serverPushLiveService.LiveParam.m_nWidth, _serverPushLiveService.LiveParam.m_nHeight)); } else { //log error msg } }