123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using FFmpeg.AutoGen;
- using ManageLiteAV;
- using System;
- using System.IO;
- using Vinno.vCloud.FIS.CrossPlatform.Common;
- using Vinno.vCloud.FIS.CrossPlatform.Common.Enum;
- using Vinno.vCloud.FIS.CrossPlatform.Common.Helper;
- using Vinno.vCloud.FIS.CrossPlatform.Windows.Consultation;
- using Vinno.vCloud.FIS.CrossPlatform.Windows.Consultation.RTC;
- using Vinno.vCloud.FIS.CrossPlatform.Windows.Consultation.RTMP;
- using Vinno.vCloud.FIS.CrossPlatform.Windows.Hardware;
- using Vinno.vCloud.FIS.CrossPlatform.Windows.LiveVideo;
- using Vinno.vCloud.FIS.CrossPlatform.Windows.RTMPSDK;
- using static Vinno.vCloud.FIS.CrossPlatform.Windows.RTMPSDK.NTSmartLogDefine;
- namespace Vinno.vCloud.FIS.CrossPlatform.Windows
- {
- public class FISWin
- {
- public static string FISLogPath { get; private set; }
- /// <summary>
- /// Initilize for windows platform.
- /// </summary>
- public static void Initialize(string fisLogPath)
- {
- if (string.IsNullOrEmpty(fisLogPath))
- {
- FISLogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FISLogs");
- }
- else
- {
- FISLogPath = fisLogPath;
- }
- DirectoryHelper.CreateDirectory(FISLogPath);
- CpuInfo.Initialize();// initialize cpu info
- CrossPlatformHelper.Instance.Platform = EnumPlatform.Windows;
- CrossPlatformHelper.Instance.LiveVideoPusherCreator = new LiveVideoPusherCreator();
- CrossPlatformHelper.Instance.LiveVideoPusherCreatorForSonopost = new LiveVideoPusherCreatorForSonopost();
- CrossPlatformHelper.Instance.LiveVideoPusherCreatorV2 = new LiveVideoPusherCreatorV2();
- CrossPlatformHelper.Instance.RtcRoomCreator = new RtcRoomCreator();
- CrossPlatformHelper.Instance.RtmpPlayerCreator = new RtmpPlayerCreator();
- CrossPlatformHelper.Instance.RtmpPusherCreator = new RtmpPusherCreator();
- CrossPlatformHelper.Instance.DriverHelper = new DriverHelper();
- CrossPlatformHelper.Instance.HardwareDetector = new HardwareDetector();
- CrossPlatformHelper.Instance.ImageHelperCreator = new ImageHelperCreator();
- CrossPlatformHelper.Instance.CapturerCreator = new CapturerCreator();
- CrossPlatformHelper.Instance.StrokeHelper = new StrokeHelper();
- InitSetSmartSDKLogPath();
- InitSetTRTCSDKLogPath();
- RegistSmartSDK();
- RegisterFFmpegBinaries();
- }
- private static void InitSetTRTCSDKLogPath()
- {
- try
- {
- var logDirectory = Path.Combine(FISLogPath, "TRTCLogs");
- DirectoryHelper.CreateDirectory(logDirectory);
- var trtccloud = ITRTCCloud.getTRTCShareInstance();
- trtccloud.setLogCompressEnabled(false);
- trtccloud.setLogLevel(TRTCLogLevel.TRTCLogLevelError);
- trtccloud.setLogDirPath(logDirectory);
- CrossPlatformHelper.Instance.LogWriter?.WriteLineInfo($"Set TRTC sdk Log Path Success");
- var version = trtccloud.getSDKVersion();
- CrossPlatformHelper.Instance.LogWriter?.WriteLineInfo($"TRTC Version:{version}");
- }
- catch (Exception e)
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError($"Init set TRTC sdk log path error:{e}");
- }
- }
- private static void InitSetSmartSDKLogPath()
- {
- try
- {
- var logDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SmartLogs");
- if (!string.IsNullOrEmpty(FISLogPath))
- {
- logDirectory = Path.Combine(FISLogPath, "SmartLogs");
- }
- DirectoryHelper.CreateDirectory(logDirectory);
- var ret = Environment.Is64BitProcess ?
- NTSmartLog_x64.NT_SL_SetPath(logDirectory) : NTSmartLog_x86.NT_SL_SetPath(logDirectory);
- #if DEBUG
- ret = Environment.Is64BitProcess ?
- NTSmartLog_x64.NT_SL_SetLevel((uint)SL_LOG_LEVEL.SL_DEBUG_LEVEL) : NTSmartLog_x86.NT_SL_SetLevel((uint)SL_LOG_LEVEL.SL_DEBUG_LEVEL);
- #else
- ret = Environment.Is64BitProcess ?
- NTSmartLog_x64.NT_SL_SetLevel((uint)SL_LOG_LEVEL.SL_ERROR_LEVEL) : NTSmartLog_x86.NT_SL_SetLevel((uint)SL_LOG_LEVEL.SL_ERROR_LEVEL);
- #endif
- var path = Path.Combine(logDirectory, "smart_sdk.log");
- if (File.Exists(path))
- {
- FileInfo fi = new FileInfo(path);
- var createTime = fi.CreationTime.ToString("yyyyMMddHHmmss");
- var newFilePath = Path.Combine(logDirectory, $"smart_sdk_{createTime}.log");
- File.Copy(path, newFilePath, true);
- }
- CrossPlatformHelper.Instance.LogWriter?.WriteLineInfo($"Set smart sdk Log Path Success");
- }
- catch (Exception e)
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError($"Init set smart sdk log path error:{e}");
- }
- }
- private static void RegistSmartSDK()
- {
- var ret = Environment.Is64BitProcess
- ? NTSmartPublisherSDK_x64.NT_PB_SetSDKClientKey("03396870E2CA4E4F98593EC368EE77ED", "9ACF4FBED7EF4E56833941DE29267C9F79130CBB4C7345E2859ED4E1E2DC9EDD", 0, IntPtr.Zero) :
- NTSmartPublisherSDK_x86.NT_PB_SetSDKClientKey("03396870E2CA4E4F98593EC368EE77ED", "9ACF4FBED7EF4E56833941DE29267C9F79130CBB4C7345E2859ED4E1E2DC9EDD", 0, IntPtr.Zero);
- if (NTBaseCodeDefine.NT_ERC_OK != ret)
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError("Regist Publisher failed.");
- return;
- }
- ret = Environment.Is64BitProcess
- ? NTSmartPlayerSDK_x64.NT_SP_SetSDKClientKey("03396870E2CA4E4F98593EC368EE77ED", "9ACF4FBED7EF4E56833941DE29267C9F79130CBB4C7345E2859ED4E1E2DC9EDD", 0, IntPtr.Zero) :
- NTSmartPlayerSDK_x86.NT_SP_SetSDKClientKey("03396870E2CA4E4F98593EC368EE77ED", "9ACF4FBED7EF4E56833941DE29267C9F79130CBB4C7345E2859ED4E1E2DC9EDD", 0, IntPtr.Zero);
- if (NTBaseCodeDefine.NT_ERC_OK != ret)
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineError("Regist Player failed.");
- return;
- }
- ret = Environment.Is64BitProcess
- ? NTSmartPublisherSDK_x64.NT_PB_Init(0, IntPtr.Zero)
- : NTSmartPublisherSDK_x86.NT_PB_Init(0, IntPtr.Zero);
- if (NTBaseCodeDefine.NT_ERC_OK != ret)
- {
- throw new InvalidOperationException("Initialize SDK failed.");
- }
- }
- private static void RegisterFFmpegBinaries()
- {
- var ffmpegBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "x64");
- if (Directory.Exists(ffmpegBinaryPath))
- {
- CrossPlatformHelper.Instance.LogWriter?.WriteLineInfo($"FFmpeg binaries found in: {ffmpegBinaryPath}");
- ffmpeg.RootPath = ffmpegBinaryPath;
- }
- else
- {
- throw new Exception("ffmpegBinaryPath is not Exist");
- }
- }
- }
- }
|