public async Task <AsyncCallbackMsg> StopRecord()
        {
            if (RecordId != 0)
            {
                Log.Logger.Debug($"【local record live stop begins】:liveId={RecordId}");
                AsyncCallbackMsg stopAsynCallResult = await _sdkService.StopRecord();

                RecordId = 0;

                Log.Logger.Debug(
                    $"【local record live stop result】:result={stopAsynCallResult.Status}, msg={stopAsynCallResult.Message}");
                return(stopAsynCallResult);
            }

            return(AsyncCallbackMsg.GenerateMsg(Messages.WarningNoLiveToStop));
        }
        public async Task <AsyncCallbackMsg> StopPushLiveStream()
        {
            if (LiveId != 0)
            {
                Log.Logger.Debug($"【local push live stop begins】:liveId={LiveId}");
                AsyncCallbackMsg stopAsynCallResult = await _sdkService.StopLiveStream(LiveId);

                LiveId = 0;

                Log.Logger.Debug(
                    $"【local push live stop result】:result={stopAsynCallResult}, msg={stopAsynCallResult.Message}");
                return(stopAsynCallResult);
            }

            return(AsyncCallbackMsg.GenerateMsg(Messages.WarningNoLiveToStop));
        }
        public async Task <AsyncCallbackMsg> StartRecord(List <LiveVideoStream> liveVideoStreamInfos)
        {
            if (string.IsNullOrEmpty(RecordDirectory))
            {
                return(AsyncCallbackMsg.GenerateMsg(Messages.WarningRecordDirectoryNotSet));
            }


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

            AsyncCallbackMsg result = await _sdkService.SetRecordDirectory(RecordDirectory);

            AsyncCallbackMsg setRecordParamResult = await _sdkService.SetRecordParameter(RecordParam);

            string recordFileName = $"{DateTime.Now:yyyy_MM_dd_HH_mm_ss}.mp4";

            Log.Logger.Debug(
                $"【local record live begins】:width={RecordParam.Width}, height={RecordParam.Height}, bitrate={RecordParam.VideoBitrate}, path={Path.Combine(RecordDirectory, recordFileName)}, 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 localRecordResult =
                await
                _sdkService.StartRecord(recordFileName, liveVideoStreamInfos.ToArray(), liveVideoStreamInfos.Count);

            if (localRecordResult.Status == 0)
            {
                RecordId = int.Parse(localRecordResult.Data.ToString());

                Log.Logger.Debug($"【local record live succeeded】:liveId={RecordId}");
            }
            else
            {
                Log.Logger.Error($"【local record live failed】:{localRecordResult.Message}");
            }

            return(localRecordResult);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public AsyncCallbackMsg RefreshLiveStream(List <LiveVideoStream> openedStreamInfos)
        {
            if (LiveId != 0)
            {
                Log.Logger.Debug($"【server refresh live begins】:liveId={LiveId}, videos={openedStreamInfos.Count}");
                for (int i = 0; i < openedStreamInfos.Count; i++)
                {
                    Log.Logger.Debug(
                        $"video{i + 1}:x={openedStreamInfos[i].X}, y={openedStreamInfos[i].Y}, width={openedStreamInfos[i].Width}, height={openedStreamInfos[i].Height}");
                }

                AsyncCallbackMsg updateAsynCallResult = _sdkService.UpdateLiveVideoStreams(LiveId,
                                                                                           openedStreamInfos.ToArray(), openedStreamInfos.Count);
                Log.Logger.Debug(
                    $"【server refresh live result】:result={updateAsynCallResult.Status}, msg={updateAsynCallResult.Message}");
                return(updateAsynCallResult);
            }
            return(AsyncCallbackMsg.GenerateMsg(Messages.WarningNoLiveToRefresh));
        }