123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using System;
- namespace Agora.Rtc
- {
- public class MediaPlayerCacheManager : IMediaPlayerCacheManager
- {
- private IRtcEngine _rtcEngineInstance = null;
- private MediaPlayerCacheManagerImpl _mediaPlayerCacheManagerImpl = null;
- private const int ErrorCode = -7;
- private MediaPlayerCacheManager(IRtcEngine rtcEngine, MediaPlayerCacheManagerImpl impl)
- {
- _rtcEngineInstance = rtcEngine;
- _mediaPlayerCacheManagerImpl = impl;
- }
- ~MediaPlayerCacheManager()
- {
- _rtcEngineInstance = null;
- }
- private static MediaPlayerCacheManager instance = null;
- public static MediaPlayerCacheManager Instance
- {
- get
- {
- return instance;
- }
- }
- internal static MediaPlayerCacheManager GetInstance(IRtcEngine rtcEngine, MediaPlayerCacheManagerImpl impl)
- {
- return instance ?? (instance = new MediaPlayerCacheManager(rtcEngine, impl));
- }
- internal static void ReleaseInstance()
- {
- instance = null;
- }
- public override int RemoveAllCaches()
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.RemoveAllCaches();
- }
- public override int RemoveOldCache()
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.RemoveOldCache();
- }
- public override int RemoveCacheByUri(string uri)
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.RemoveCacheByUri(uri);
- }
- public override int SetCacheDir(string path)
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.SetCacheDir(path);
- }
- public override int SetMaxCacheFileCount(int count)
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.SetMaxCacheFileCount(count);
- }
- public override int SetMaxCacheFileSize(long cacheSize)
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.SetMaxCacheFileSize(cacheSize);
- }
- public override int EnableAutoRemoveCache(bool enable)
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.EnableAutoRemoveCache(enable);
- }
- public override int GetCacheDir(out string path, int length)
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- path = "";
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.GetCacheDir(out path, length);
- }
- public override int GetMaxCacheFileCount()
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.GetMaxCacheFileCount();
- }
- public override long GetMaxCacheFileSize()
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.GetMaxCacheFileSize();
- }
- public override int GetCacheFileCount()
- {
- if (_rtcEngineInstance == null || _mediaPlayerCacheManagerImpl == null)
- {
- return ErrorCode;
- }
- return _mediaPlayerCacheManagerImpl.GetCacheFileCount();
- }
- }
- }
|