/*******************************************************************************
Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
NOTICE:All information contained herein is, and remains the property of
PICO Technology Co., Ltd. The intellectual and technical concepts
contained herein are proprietary to PICO Technology Co., Ltd. and may be
covered by patents, patents in process, and are protected by trade secret or
copyright law. Dissemination of this information or reproduction of this
material is strictly forbidden unless prior written permission is obtained from
PICO Technology Co., Ltd.
*******************************************************************************/
using Pico.Platform.Models;
using UnityEngine;
namespace Pico.Platform
{
public class HighlightService
{
///
/// Starts a new session. Before using screen recording and capturing-related functions, make sure you are in a session.
///
/// The session ID, which is a string.
public static Task StartSession()
{
if (!CoreService.Initialized)
{
Debug.LogError(CoreService.NotInitializedError);
return null;
}
return new Task(CLIB.ppf_Highlight_StartSession());
}
///
/// Captures the screen.
///
/// The information about this capture, including image path and job ID.
public static Task CaptureScreen()
{
if (!CoreService.Initialized)
{
Debug.LogError(CoreService.NotInitializedError);
return null;
}
return new Task(CLIB.ppf_Highlight_CaptureScreen());
}
///
/// Starts recording the screen.
///
public static Task StartRecord()
{
if (!CoreService.Initialized)
{
Debug.LogError(CoreService.NotInitializedError);
return null;
}
return new Task(CLIB.ppf_Highlight_StartRecord());
}
///
/// Stops recording the screen.
///
/// The infomraiton about this recording, including video path, video duration, video size, and job ID.
public static Task StopRecord()
{
if (!CoreService.Initialized)
{
Debug.LogError(CoreService.NotInitializedError);
return null;
}
return new Task(CLIB.ppf_Highlight_StopRecord());
}
///
/// Lists all the media resources for a session.
///
/// Passes the ID of the session which is returned by `StartSession`.
/// The information about the images captured and videos recorded during this session.
public static Task ListMedia(string sessionId)
{
if (!CoreService.Initialized)
{
Debug.LogError(CoreService.NotInitializedError);
return null;
}
return new Task(CLIB.ppf_Highlight_ListMedia(sessionId));
}
///
/// Saves an image or a video to the device's local storage.
///
/// Passes the ID of the screen-capturing or screen-recording task where the image or video is created.
/// Passes the ID of the session where the task takes place.
/// The job ID and session ID of the image or video saved.
public static Task SaveMedia(string jobId, string sessionId)
{
if (!CoreService.Initialized)
{
Debug.LogError(CoreService.NotInitializedError);
return null;
}
return new Task(CLIB.ppf_Highlight_SaveMedia(jobId, sessionId));
}
///
/// Shares an image or a video to the social media on the mobile phone.
///
/// Passes the ID of the screen-capturing or screen-recording task where the image or video is created.
/// Passes the ID of the session where the task takes place.
/// The job ID and session ID of the image or video shared.
public static Task ShareMedia(string jobId, string sessionId)
{
if (!CoreService.Initialized)
{
Debug.LogError(CoreService.NotInitializedError);
return null;
}
return new Task(CLIB.ppf_Highlight_ShareMedia(jobId, sessionId));
}
///
/// The maiximum duration for a video is 15 minutes.
/// After the `StartRecord` function is called, if the `StopRecord` function is not called in time or if the recording is ended due to other causes, the system will automatically stop recording and return the recording information.
///
/// Returns the recording information.
public static void SetOnRecordStopHandler(Message.Handler handler)
{
Looper.RegisterNotifyHandler(MessageType.Notification_Highlight_OnRecordStop, handler);
}
}
}