Skip to content

Commit

Permalink
Adjust volume; rename namespace; preprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
icywind committed Mar 21, 2023
1 parent d0605f1 commit 91f1571
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 19 deletions.
8 changes: 8 additions & 0 deletions AgoraEngine/ML2Support/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions AgoraEngine/ML2Support/Editor/PreprocessorDefine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections.Generic;
using UnityEditor;

namespace Agora.Rtc.Extended
{
// This class adds neccessary preprocessors for run ML2 related code
// Otherwise, it assume normal Unity app assemblies for using Agora
static class PreprocessorDefine
{
/// <summary>
/// Add define symbols as soon as Unity gets done compiling.
/// </summary>
[InitializeOnLoadMethod]
public static void AddDefineSymbols()
{
string currentDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
HashSet<string> defines = new HashSet<string>(currentDefines.Split(';'))
{
"ML2_ENABLE"
};

// only touch PlayerSettings if we actually modified it,
// otherwise it shows up as changed in git each time.
string newDefines = string.Join(";", defines);
if (newDefines != currentDefines)
{
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, newDefines);
}
}
}
}
11 changes: 11 additions & 0 deletions AgoraEngine/ML2Support/Editor/PreprocessorDefine.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion AgoraEngine/ML2Support/Scripts/AgoraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Agora.Rtc;
using Agora.Util;

namespace agora_sample
namespace Agora.Rtc.Extended
{
/// <summary>
/// The AgoraController serves as the simple plugin controller for MagicLeap2.
Expand Down
2 changes: 1 addition & 1 deletion AgoraEngine/ML2Support/Scripts/CustomAudioCapturer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using UnityEngine.XR.MagicLeap;
#endif

namespace agora_sample
namespace Agora.Rtc.Extended
{
/// <summary>
/// The Custom Audio Capturer class uses Microphone audio source to
Expand Down
4 changes: 2 additions & 2 deletions AgoraEngine/ML2Support/Scripts/CustomAudioObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Agora_RTC_Plugin.API_Example.Examples.Advanced.ProcessAudioRawData;
using Agora.Util;

namespace agora_sample
namespace Agora.Rtc.Extended
{
/// <summary>
/// The Custom AudioSink Player class receives audio frames from the
Expand Down Expand Up @@ -201,4 +201,4 @@ public override bool OnPlaybackAudioFrameBeforeMixing(string channel_id,
}

#endregion
}
}
5 changes: 4 additions & 1 deletion AgoraEngine/ML2Support/Scripts/CustomAudioSinkPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Agora.Rtc;
using RingBuffer;

namespace agora_sample
namespace Agora.Rtc.Extended
{
/// <summary>
/// The Custom AudioSink Player class receives audio frames from the
Expand Down Expand Up @@ -61,6 +61,9 @@ public override void Init(IRtcEngine engine, object rtclock)
mRtcEngine = engine;
_rtclock = rtclock;
mRtcEngine.SetExternalAudioSink(true, SAMPLE_RATE, CHANNEL);

// Increase playback overall volume
mRtcEngine.AdjustPlaybackSignalVolume(200);
}

void KickStartAudio(AudioSource aud, string clipName)
Expand Down
7 changes: 5 additions & 2 deletions AgoraEngine/ML2Support/Scripts/CustomVideoCapturer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using Agora.Rtc;

namespace agora_sample
namespace Agora.Rtc.Extended
{
public class CustomVideoCapturer : IVideoCaptureManager
{
Expand Down Expand Up @@ -374,7 +374,10 @@ void ShareScreen(byte[] bytes, int width, int height)
//externalVideoFrame.rotation = 180;
externalVideoFrame.timestamp = 0;
//Push the external video frame with the frame we just created
_rtcEngine.PushVideoFrame(externalVideoFrame);
lock (_rtclock)
{
_rtcEngine.PushVideoFrame(externalVideoFrame);
}
if (++timestamp % 100 == 0)
{
Debug.Log("Pushed video frame = " + timestamp);
Expand Down
2 changes: 1 addition & 1 deletion AgoraEngine/ML2Support/Scripts/IAudioCaptureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using UnityEngine;

namespace agora_sample
namespace Agora.Rtc.Extended
{
public abstract class IAudioCaptureManager : MonoBehaviour
{
Expand Down
2 changes: 1 addition & 1 deletion AgoraEngine/ML2Support/Scripts/IAudioRenderManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace agora_sample
namespace Agora.Rtc.Extended
{
public abstract class IAudioRenderManager : MonoBehaviour
{
Expand Down
2 changes: 1 addition & 1 deletion AgoraEngine/ML2Support/Scripts/IVideoCaptureManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace agora_sample
namespace Agora.Rtc.Extended
{
/// <summary>
/// This interface declares the neccessary methods for managing the views for video streaming.
Expand Down
4 changes: 2 additions & 2 deletions AgoraEngine/ML2Support/Scripts/IVideoRenderManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace agora_sample
namespace Agora.Rtc.Extended
{
/// <summary>
/// This interface declares the neccessary methods for managing the views for video streaming.
Expand All @@ -9,4 +9,4 @@ public interface IVideoRenderManager
void MakeVideoView(uint uid);
void UpdateVideoView(uint uid, int width, int height, int rotation);
}
}
}
2 changes: 1 addition & 1 deletion AgoraEngine/ML2Support/Scripts/VideoRenderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Agora.Rtc;
using Agora.Util;

namespace agora_sample
namespace Agora.Rtc.Extended
{
/// <summary>
/// The Video Render Manager manages the remote user's view transform.
Expand Down
8 changes: 2 additions & 6 deletions AgoraEngine/ML2Support/TestDrivers/VirtualCameraDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using System.Collections.Generic;
using Agora.Rtc;
using UnityEngine;
using Agora.Rtc.Extended;

namespace agora_sample
{
// This example runs on the non-ML2 environment to test pushVideoFrame
public class VirtualCameraDemo : IVideoCaptureManager
{
[SerializeField]
Expand All @@ -19,12 +21,6 @@ public class VirtualCameraDemo : IVideoCaptureManager
width = 1280,
height = 720
};
//[SerializeField]
//private int bitrate = 1130;
//private FRAME_RATE frameRate = FRAME_RATE.FRAME_RATE_FPS_30;
//[SerializeField]
//private VIDEO_MIRROR_MODE_TYPE mirrorMode = VIDEO_MIRROR_MODE_TYPE.VIDEO_MIRROR_MODE_DISABLED;
// use bitrate: 2260 for broadcast mode

// Pixel format
public static TextureFormat ConvertFormat = TextureFormat.RGBA32;
Expand Down

0 comments on commit 91f1571

Please sign in to comment.