Skip to content

Instantly share code, notes, and snippets.

View icywind's full-sized avatar

Rick Cheng icywind

View GitHub Profile
@icywind
icywind / CloudRecordController.cs
Created December 12, 2020 01:21
Cloud Record Controller class
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
using System.Collections;
using System.Collections.Generic;
public class CloudRecordController : MonoBehaviour
{
[SerializeField]
string ServerURL = default;
@icywind
icywind / CloudRecordModel.cs
Created December 11, 2020 03:07
Cloud Record API Responses
using UnityEngine;
using System;
// Returns json {"resourceId":"xxxx", "sid":"yyy", "serverResponse":{"status":5,"fileList":"zzzz.m3u8","fileListMode":"string","sliceStartTime":1606357122528} }
[Serializable]
public class CloudRecordResponseModel
{
public string resourceId;
@icywind
icywind / stop.php
Created December 11, 2020 00:56
Stop the cloud recording
<?php
require_once("config.php");
$curl = curl_init();
// Receive ResourceID and sid from client
$ResourceID = $_POST["resourceId"];
$Channel = $_POST["channel"];
@icywind
icywind / query.php
Created December 11, 2020 00:52
Query the cloud recording session
<?php
require_once("config.php");
$curl = curl_init();
// Receive ResourceID and sid from client
$ResourceID = $_POST["resourceId"];
$Channel = $_POST["sid"];
curl_setopt_array($curl, array(
@icywind
icywind / start.php
Created December 11, 2020 00:41
Start recording
<?php
require_once("config.php");
$curl = curl_init();
// Receive ResourceID from client
$ResourceID = $_POST["resourceId"];
$Channel = $_POST["channel"];
@icywind
icywind / acquire.php
Created December 11, 2020 00:35
Acquire a cloud record resource id
<?php
require_once("config.php");
$Channel = $_POST["channel"];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.agora.io/v1/apps/$AppID/cloud_recording/acquire",
CURLOPT_RETURNTRANSFER => true,
@icywind
icywind / config.php
Created December 11, 2020 00:32
The configuration variables definition
<?php
// Agora
$AppID = "";
$CustomerID="";
$CustomerSecret="";
$AuthSecret = base64_encode("$CustomerID:$CustomerSecret");
// You define
$RecUID = "889988";
@icywind
icywind / AgoraApiHandlersImpl.cs
Created October 21, 2019 18:52
Actual implementation for the Agora SDK event callbacks.
using UnityEngine;
using agora_gaming_rtc;
public class AgoraApiHandlersImpl
{
private IRtcEngine mRtcEngine;
public AgoraApiHandlersImpl(IRtcEngine engine)
{
mRtcEngine = engine;
void SetupUI()
{
GameObject go = GameObject.Find("MyView");
myView = go.AddComponent<VideoSurface>();
go = GameObject.Find("LeaveButton");
go?.GetComponent<Button>()?.onClick.AddListener(Leave);
go = GameObject.Find("JoinButton");
go?.GetComponent<Button>()?.onClick.AddListener(Join);
}
@icywind
icywind / AgoraDemo_JoinLeave.cs
Created August 24, 2020 22:53
Demo Join and Leave implementation
void Join()
{
mRtcEngine.EnableVideo();
mRtcEngine.EnableVideoObserver();
myView.SetEnable(true);
mRtcEngine.JoinChannel(ChannelName, "", 0);
}
void Leave()
{