MediaPlayerCustomDataProviderNative.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  4. using AOT;
  5. #endif
  6. namespace Agora.Rtc
  7. {
  8. internal static class MediaPlayerCustomDataProviderNative
  9. {
  10. internal static Dictionary<int, IMediaPlayerCustomDataProvider> CustomDataProviders = new Dictionary<int, IMediaPlayerCustomDataProvider>();
  11. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  12. [MonoPInvokeCallback(typeof(Func_OnSeek_Native))]
  13. #endif
  14. internal static Int64 OnSeek(Int64 offset, int whence, int playerId)
  15. {
  16. if (CustomDataProviders.ContainsKey(playerId))
  17. {
  18. try
  19. {
  20. return CustomDataProviders[playerId].OnSeek(offset, whence);
  21. }
  22. catch (Exception e)
  23. {
  24. AgoraLog.LogError("[Exception] IMediaPlayerCustomDataProvider.OnSeek: " + e);
  25. return 0;
  26. }
  27. }
  28. return 0;
  29. }
  30. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  31. [MonoPInvokeCallback(typeof(Func_onReadData_Native))]
  32. #endif
  33. internal static int OnReadData(IntPtr buffer, int bufferSize, int playerId)
  34. {
  35. if (CustomDataProviders.ContainsKey(playerId))
  36. {
  37. try
  38. {
  39. return CustomDataProviders[playerId].OnReadData(buffer, bufferSize);
  40. }
  41. catch (Exception e)
  42. {
  43. AgoraLog.LogError("[Exception] IMediaPlayerCustomDataProvider.OnReadData: " + e);
  44. return 0;
  45. }
  46. }
  47. return 0;
  48. }
  49. }
  50. }