123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Vinno.FIS.TRTCClient.Common.Enum;
- using Vinno.vCloud.FIS.CrossPlatform.Common;
- using Vinno.vCloud.FIS.CrossPlatform.Common.Enum;
- using Vinno.vCloud.FIS.CrossPlatform.Common.LiveVideo;
- namespace Vinno.vCloud.FIS.CrossPlatform.Android.LiveVideo.RTMP
- {
- public class USRtmpMergePusherV2 : USMergePusherBaseV2
- {
- private DaniuPusher _pusher;
- public USRtmpMergePusherV2() : base()
- {
- IsTRTCMode = false;
- InitCacheImage(false);
- }
- public override bool StartPusher(IExtendedData pushParams, IEnumerable<CPVideoDeviceOutputInfo> deviceInfos)
- {
- try
- {
- var rtmpParams = pushParams as RtmpExtendedData;
- if (rtmpParams == null || rtmpParams.UserInfos.Count == 0)
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError("USRtmpMergePusherV2 Extended Data Is Null!");
- return false;
- }
- var url = rtmpParams.UserInfos.FirstOrDefault()?.PushUrl;
- if (string.IsNullOrEmpty(url))
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError("USRtmpMergePusherV2 Push Url Is Null!");
- return false;
- }
- var micIndex = CrossPlatformHelper.Instance.HardwareDetector.GetMicIndex(pushParams.MicDeviceId);
- _pusher = new DaniuPusher(url, MergeWidth, MergeHeight, MergeFrameRate, EnumAudioMode.Mic, pushParams.IsMute);
- _pusher.StatusChanged += OnStatusChanged;
- _pusher.StartPush();
- return base.StartPusher(pushParams, deviceInfos);
- }
- catch (Exception e)
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError($"Start USRtmpMergePusherV2 Error:{e}");
- }
- return false;
- }
- public override void SetMute(bool isMute)
- {
- _pusher?.SetMute(isMute);
- }
- public override bool StopPusher()
- {
- try
- {
- base.StopPusher();
- if (_pusher != null)
- {
- _pusher.StatusChanged -= OnStatusChanged;
- _pusher.StopPush();
- }
- return true;
- }
- catch (Exception e)
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError($"Stop USRtmpMergePusherV2 Error:{e}");
- }
- return false;
- }
- private void OnStatusChanged(object sender, CPLiveStatusData e)
- {
- if (e.Status == EnumLiveStatus.Connected)
- {
- PushLiveStateChanged();
- }
- }
- protected override unsafe void DealWithFullBuffer(ImageFrameData frame)
- {
- _pusher?.PushImage(frame);
- }
- protected override EnumArea GetArea(EnumLiveChannelCategory category)
- {
- if (category == EnumLiveChannelCategory.Main)
- {
- return EnumArea.Main;
- }
- if (category == EnumLiveChannelCategory.Auxiliary1)
- {
- return EnumArea.Bottom;
- }
- throw new Exception($"RTMP Can not get correct area by category:{category}");
- }
- public override void DoDispose()
- {
- StopPusher();
- base.DoDispose();
- }
- public override void SwitchMic(string micId)
- {
- }
- }
- }
|