예제 #1
0
        public async Task <AsyncCallbackMsg> StartPushLiveStream(List <LiveVideoStream> liveVideoStreamInfos,
                                                                 string pushLiveUrl)
        {
            if (string.IsNullOrEmpty(pushLiveUrl))
            {
                return(AsyncCallbackMsg.GenerateMsg(Messages.WarningLivePushLiveUrlNotSet));
            }

            LiveVideoParameter liveParam = LiveParam;

            liveParam.Url1 = pushLiveUrl;

            if (liveParam.Width == 0 || liveParam.Height == 0 || liveParam.VideoBitrate == 0)
            {
                return(AsyncCallbackMsg.GenerateMsg(Messages.WarningLiveResolutionNotSet));
            }

            Log.Logger.Debug(
                $"【server push live begins】:width={liveParam.Width}, height={liveParam.Height}, bitrate={liveParam.VideoBitrate}, url={liveParam.Url1}, videos={liveVideoStreamInfos.Count}");

            for (int i = 0; i < liveVideoStreamInfos.Count; i++)
            {
                Log.Logger.Debug(
                    $"video{i + 1}:x={liveVideoStreamInfos[i].X}, y={liveVideoStreamInfos[i].Y}, width={liveVideoStreamInfos[i].Width}, height={liveVideoStreamInfos[i].Height}");
            }

            AsyncCallbackMsg startLiveStreamResult =
                await _sdkService.StartLiveStream(liveParam, liveVideoStreamInfos.ToArray(), liveVideoStreamInfos.Count);

            if (startLiveStreamResult.Status == 0)
            {
                LiveId = int.Parse(startLiveStreamResult.Data.ToString());

                HasPushLiveSuccessfully = true;
                Log.Logger.Debug($"【server push live succeeded】:liveId={LiveId}");
            }
            else
            {
                HasPushLiveSuccessfully = false;
                Log.Logger.Error($"【server push live failed】:{startLiveStreamResult.Message}");
            }

            return(startLiveStreamResult);
        }