提交
This commit is contained in:
@@ -25,7 +25,7 @@ public class XrealMixedRecorder : IVideoRecorder, IController
|
|||||||
|
|
||||||
public ResolutionLevel resolutionLevel = ResolutionLevel.High;
|
public ResolutionLevel resolutionLevel = ResolutionLevel.High;
|
||||||
public BlendMode blendMode = BlendMode.Blend;
|
public BlendMode blendMode = BlendMode.Blend;
|
||||||
public AudioState audioState = AudioState.ApplicationAndMicAudio;
|
public AudioState audioState = AudioState.MicAudio;
|
||||||
public CaptureSide captureside = CaptureSide.Single;
|
public CaptureSide captureside = CaptureSide.Single;
|
||||||
public bool useGreenBackGround = false;
|
public bool useGreenBackGround = false;
|
||||||
|
|
||||||
@@ -40,24 +40,19 @@ public class XrealMixedRecorder : IVideoRecorder, IController
|
|||||||
|
|
||||||
/// <summary> Save the video to Application.persistentDataPath. </summary>
|
/// <summary> Save the video to Application.persistentDataPath. </summary>
|
||||||
/// <value> The full pathname of the video save file. </value>
|
/// <value> The full pathname of the video save file. </value>
|
||||||
private string VideoSaveExtension => Path.Combine(Application.persistentDataPath, "Recording");
|
public string VideoSavePath
|
||||||
|
|
||||||
private string VideoSavePath
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var timeStamp = Time.time.ToString().Replace(".", "").Replace(":", "");
|
string timeStamp = Time.time.ToString().Replace(".", "").Replace(":", "");
|
||||||
var filename =
|
string filename = string.Format("Xreal_Record_{0}.mp4", timeStamp);
|
||||||
$"{this.GetSystem<IGlobalConfigSystem>().GetConnectionId()}{timeStamp}.mp4";
|
return Path.Combine(Application.persistentDataPath, filename);
|
||||||
return Path.Combine(Application.persistentDataPath, VideoSaveExtension, filename);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _videoSavePath;
|
|
||||||
|
|
||||||
public void StartRecording()
|
public void StartRecording()
|
||||||
{
|
{
|
||||||
_videoSavePath = VideoSavePath;
|
|
||||||
if (_videoCapture == null)
|
if (_videoCapture == null)
|
||||||
CreateVideoCapture(StartVideoCapture);
|
CreateVideoCapture(StartVideoCapture);
|
||||||
else if (_videoCapture.IsRecording)
|
else if (_videoCapture.IsRecording)
|
||||||
@@ -112,9 +107,10 @@ public class XrealMixedRecorder : IVideoRecorder, IController
|
|||||||
|
|
||||||
var encoder = _videoCapture.GetContext().GetEncoder() as VideoEncoder;
|
var encoder = _videoCapture.GetContext().GetEncoder() as VideoEncoder;
|
||||||
var path = encoder.EncodeConfig.outPutPath;
|
var path = encoder.EncodeConfig.outPutPath;
|
||||||
|
Debug.Log("Stopped Video Capture Mode!--path"+path);
|
||||||
var filename = string.Format("Xreal_Shot_Video_{0}.mp4",
|
var filename = string.Format("Xreal_Shot_Video_{0}.mp4",
|
||||||
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString());
|
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString());
|
||||||
|
Debug.Log("Stopped Video Capture Mode!--path"+filename);
|
||||||
await DelayInsertVideoToGallery(path, filename, "Record");
|
await DelayInsertVideoToGallery(path, filename, "Record");
|
||||||
OnStoppedRecordingVideoAction?.Invoke(path);
|
OnStoppedRecordingVideoAction?.Invoke(path);
|
||||||
// Release video capture resource.
|
// Release video capture resource.
|
||||||
@@ -221,7 +217,18 @@ public class XrealMixedRecorder : IVideoRecorder, IController
|
|||||||
|
|
||||||
Debug.Log("Started Video Capture Mode!");
|
Debug.Log("Started Video Capture Mode!");
|
||||||
|
|
||||||
_videoCapture.StartRecordingAsync(_videoSavePath, (a) => OnStartedRecordingVideo?.Invoke());
|
_videoCapture.StartRecordingAsync(VideoSavePath, (a) =>
|
||||||
|
{
|
||||||
|
OnStartedRecordingVideo?.Invoke();
|
||||||
|
if (!a.success)
|
||||||
|
{
|
||||||
|
Debug.Log("Started Recording Video Faild!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log("Started Recording Video!");
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IArchitecture GetArchitecture()
|
public IArchitecture GetArchitecture()
|
||||||
|
|||||||
@@ -23,8 +23,29 @@ namespace Stary.Evo
|
|||||||
#else
|
#else
|
||||||
authorization = CustomPlayerPrefs.GetString("Authorization");
|
authorization = CustomPlayerPrefs.GetString("Authorization");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async UniTask GetCertificateData()
|
||||||
|
{
|
||||||
var certPath = Path.Combine(Application.streamingAssetsPath, "server.crt");
|
var certPath = Path.Combine(Application.streamingAssetsPath, "server.crt");
|
||||||
certificateData = File.ReadAllBytes(certPath);
|
if (certificateData == null)
|
||||||
|
{
|
||||||
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
// Android平台使用UnityWebRequest读取
|
||||||
|
var webRequest = UnityWebRequest.Get(certPath);
|
||||||
|
await webRequest.SendWebRequest();
|
||||||
|
if (webRequest.result == UnityWebRequest.Result.Success)
|
||||||
|
{
|
||||||
|
certificateData = webRequest.downloadHandler.data;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// 其他平台使用File读取
|
||||||
|
if (File.Exists(certPath))
|
||||||
|
{
|
||||||
|
certificateData = File.ReadAllBytes(certPath);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<bool> Login(string url, string username, string password)
|
public static async Task<bool> Login(string url, string username, string password)
|
||||||
@@ -222,6 +243,7 @@ namespace Stary.Evo
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
await GetCertificateData();
|
||||||
using var webRequest = UnityWebRequest.Get(url);
|
using var webRequest = UnityWebRequest.Get(url);
|
||||||
webRequest.downloadHandler = new DownloadHandlerFile(tempPath);
|
webRequest.downloadHandler = new DownloadHandlerFile(tempPath);
|
||||||
webRequest.certificateHandler = new SelfSignedCertHandler(certificateData);
|
webRequest.certificateHandler = new SelfSignedCertHandler(certificateData);
|
||||||
@@ -282,6 +304,7 @@ namespace Stary.Evo
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
await GetCertificateData();
|
||||||
var fullUrl = url.TrimEnd('/') + "/" + path.TrimStart('/');
|
var fullUrl = url.TrimEnd('/') + "/" + path.TrimStart('/');
|
||||||
using var webRequest = new UnityWebRequest(fullUrl, UnityWebRequest.kHttpVerbGET);
|
using var webRequest = new UnityWebRequest(fullUrl, UnityWebRequest.kHttpVerbGET);
|
||||||
webRequest.downloadHandler = new DownloadHandlerBuffer();
|
webRequest.downloadHandler = new DownloadHandlerBuffer();
|
||||||
@@ -517,6 +540,7 @@ namespace Stary.Evo
|
|||||||
MainPanel.UsersItem host,
|
MainPanel.UsersItem host,
|
||||||
List<MainPanel.UsersItem> participants)
|
List<MainPanel.UsersItem> participants)
|
||||||
{
|
{
|
||||||
|
await GetCertificateData();
|
||||||
var bytes = File.ReadAllBytes(filePath);
|
var bytes = File.ReadAllBytes(filePath);
|
||||||
var fileName = Path.GetFileName(filePath);
|
var fileName = Path.GetFileName(filePath);
|
||||||
|
|
||||||
@@ -544,5 +568,6 @@ namespace Stary.Evo
|
|||||||
else
|
else
|
||||||
Debug.Log($"上传成功: {request.downloadHandler.text}");
|
Debug.Log($"上传成功: {request.downloadHandler.text}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,8 @@ MonoBehaviour:
|
|||||||
AddtionalPermissions:
|
AddtionalPermissions:
|
||||||
- CAMERA
|
- CAMERA
|
||||||
- VIBRATION
|
- VIBRATION
|
||||||
- AUDIO
|
- RECORD_AUDIO
|
||||||
|
- FOREGROUND_SERVICE_MEDIA_PROJECTION
|
||||||
EnableAutoLogcat: 1
|
EnableAutoLogcat: 1
|
||||||
EnableNativeSessionManager: 0
|
EnableNativeSessionManager: 0
|
||||||
SupportDevices: 0100000002000000
|
SupportDevices: 0100000002000000
|
||||||
|
|||||||
Reference in New Issue
Block a user