123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- using Android.App;
- using Com.Tencent.Trtc;
- using System;
- using System.IO;
- using Vinno.FIS.TRTCClient.Common;
- using Vinno.FIS.TRTCClient.Common.FileTransfer;
- using Vinno.FIS.TRTCClient.Common.Log;
- using Vinno.vCloud.FIS.CrossPlatform.Android.Consultation;
- using Vinno.vCloud.FIS.CrossPlatform.Android.Consultation.RTC;
- using Vinno.vCloud.FIS.CrossPlatform.Android.Consultation.RTMP;
- using Vinno.vCloud.FIS.CrossPlatform.Android.Hardware;
- using Vinno.vCloud.FIS.CrossPlatform.Android.LiveVideo;
- using Vinno.vCloud.FIS.CrossPlatform.Common;
- using Vinno.vCloud.FIS.CrossPlatform.Common.Enum;
- using Vinno.vCloud.FIS.CrossPlatform.Common.Helper;
- namespace Vinno.vCloud.FIS.CrossPlatform.Android
- {
- public class FISAndroid
- {
- internal static string FISLogPath;
- internal static string FISFolderPath;
- internal static FileTransferReader FileReaderFromTRTCLiveVideoToCommon;
- internal static FileTransferWriter FileWrtierFromCommonToTRTCLiveVideo;
- internal static FileTransferReader FileReaderFromTRTCConsultationToCommon;
- internal static FileTransferWriter FileWrtierFromCommonToTRTCConsultation;
- public static void Initialize(string fisLogFolderPath, string fisFolderPath)
- {
- if (string.IsNullOrEmpty(fisFolderPath))
- {
- FISFolderPath = Path.Combine(Application.Context.GetExternalFilesDir(null).Path, "FIS");
- }
- else
- {
- FISFolderPath = fisFolderPath;
- }
- if (string.IsNullOrEmpty(fisLogFolderPath))
- {
- FISLogPath = Path.Combine(FISFolderPath, "FISLogs");
- }
- else
- {
- FISLogPath = fisLogFolderPath;
- }
- DirectoryHelper.CreateDirectory(FISFolderPath);
- DirectoryHelper.CreateDirectory(FISLogPath);
- MobileInfo.Initialize();
- CrossPlatformHelper.Instance.Platform = EnumPlatform.Android;
- CrossPlatformHelper.Instance.LiveVideoPusherCreator = new LiveVideoPusherCreator();
- CrossPlatformHelper.Instance.HardwareDetector = new HardwareDetector();
- CrossPlatformHelper.Instance.ImageHelperCreator = new ImageHelperCreator();
- CrossPlatformHelper.Instance.RtmpPusherCreator = new RtmpPusherCreator();
- CrossPlatformHelper.Instance.RtmpPlayerCreator = new RtmpPlayerCreator();
- CrossPlatformHelper.Instance.CapturerCreator = new CapturerCreator();
- CrossPlatformHelper.Instance.RtcRoomCreator = new RtcRoomCreator();
- CrossPlatformHelper.Instance.LiveVideoPusherCreatorV2 = new LiveVideoPusherCreatorV2();
- FileWrtierFromCommonToTRTCLiveVideo = new FileTransferWriter(FISTRTCConsts.CommonToTRTCLiveVideoMessageTransferFolder, FISTRTCConsts.DataTransferFolderForTRTCLiveVideo, FISFolderPath, FISTRTCConsts.CommonToTRTCLiveVideoReserveMessageTransferFolder);
- FileWrtierFromCommonToTRTCLiveVideo.LogMsgThrow += OnLogMsgThrow;
- FileReaderFromTRTCLiveVideoToCommon = new FileTransferReader(FISTRTCConsts.TRTCLiveVideoToCommonMessageTransferFolder, FISTRTCConsts.DataTransferFolderForTRTCLiveVideo, FISFolderPath, null);
- FileReaderFromTRTCLiveVideoToCommon.LogMsgThrow += OnLogMsgThrow;
- FileReaderFromTRTCLiveVideoToCommon.StartContinuousRead();
- FileWrtierFromCommonToTRTCConsultation = new FileTransferWriter(FISTRTCConsts.CommonToTRTCConsultationMessageTransferFolder, FISTRTCConsts.DataTransferFolderForTRTCConsultation, FISFolderPath, FISTRTCConsts.CommonToTRTCConsultationReserveMessageTransferFolder);
- FileWrtierFromCommonToTRTCConsultation.LogMsgThrow += OnLogMsgThrow;
- FileReaderFromTRTCConsultationToCommon = new FileTransferReader(FISTRTCConsts.TRTCConsultationToCommonMessageTransferFolder, FISTRTCConsts.DataTransferFolderForTRTCConsultation, FISFolderPath, null);
- FileReaderFromTRTCConsultationToCommon.LogMsgThrow += OnLogMsgThrow;
- FileReaderFromTRTCConsultationToCommon.StartContinuousRead();
- InitSetTRTCSDKLogPath();
- }
- private static void OnLogMsgThrow(object sender, LogEventArgs e)
- {
- switch (e.LogType)
- {
- case DeviceLogCategory.Error:
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError(e.Msg);
- break;
- case DeviceLogCategory.Info:
- CrossPlatformHelper.Instance.LogWriter?.WriteLineInfo(e.Msg);
- break;
- case DeviceLogCategory.Warn:
- CrossPlatformHelper.Instance.LogWriter?.WriteLineWarn(e.Msg);
- break;
- case DeviceLogCategory.Verb:
- CrossPlatformHelper.Instance.LogWriter?.WriteLineDebug(e.Msg);
- break;
- }
- }
- private static void InitSetTRTCSDKLogPath()
- {
- try
- {
- var logDirectory = Path.Combine(FISLogPath, "TRTCLogs");
- if (!Directory.Exists(logDirectory))
- {
- Directory.CreateDirectory(logDirectory);
- }
- TRTCCloud.SetLogCompressEnabled(false);
- TRTCCloud.SetLogDirPath(logDirectory);
- TRTCCloud.SetLogLevel(TRTCCloudDef.TrtcLogLevelError);
- var version = TRTCCloud.SDKVersion;
- CrossPlatformHelper.Instance.LogWriter?.WriteLineInfo($"TRTC Version:{version}");
- }
- catch (Exception e)
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError($"Init set TRTC sdk log path error:{e}");
- }
- }
- }
- }
|