BaseMediaPlayer.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. #if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_IOS || UNITY_ANDROID
  2. #define UNITY_PLATFORM_SUPPORTS_LINEAR
  3. #endif
  4. using System;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. //-----------------------------------------------------------------------------
  8. // Copyright 2015-2021 RenderHeads Ltd. All rights reserved.
  9. //-----------------------------------------------------------------------------
  10. namespace RenderHeads.Media.AVProVideo
  11. {
  12. /// <summary>
  13. /// Base class for all platform specific MediaPlayers
  14. /// </summary>
  15. public abstract partial class BaseMediaPlayer : IMediaPlayer, IMediaControl, IMediaInfo, IMediaCache, ITextureProducer, IMediaSubtitles, IVideoTracks, IAudioTracks, ITextTracks, IBufferedDisplay, System.IDisposable
  16. {
  17. public BaseMediaPlayer()
  18. {
  19. InitTracks();
  20. }
  21. public abstract string GetVersion();
  22. public abstract string GetExpectedVersion();
  23. /// <inheritdoc/>
  24. public abstract bool OpenMedia(string path, long offset, string customHttpHeaders, MediaHints mediaHints, int forceFileFormat = 0, bool startWithHighestBitrate = false);
  25. #if NETFX_CORE
  26. /// <inheritdoc/>
  27. public virtual bool OpenMedia(Windows.Storage.Streams.IRandomAccessStream ras, string path, long offset, string customHttpHeaders) { return false; }
  28. #endif
  29. /// <inheritdoc/>
  30. public virtual bool OpenMediaFromBuffer(byte[] buffer) { return false; }
  31. /// <inheritdoc/>
  32. public virtual bool StartOpenMediaFromBuffer(ulong length) { return false; }
  33. /// <inheritdoc/>
  34. public virtual bool AddChunkToMediaBuffer(byte[] chunk, ulong offset, ulong length) { return false; }
  35. /// <inheritdoc/>
  36. public virtual bool EndOpenMediaFromBuffer() { return false; }
  37. /// <inheritdoc/>
  38. public virtual void CloseMedia()
  39. {
  40. #if UNITY_EDITOR
  41. _displayRateLastRealTime = 0f;
  42. #endif
  43. _displayRateTimer = 0f;
  44. _displayRateLastFrameCount = 0;
  45. _displayRate = 0f;
  46. _stallDetectionTimer = 0f;
  47. _stallDetectionFrame = 0;
  48. _lastError = ErrorCode.None;
  49. _textTracks.Clear();
  50. _audioTracks.Clear();
  51. _videoTracks.Clear();
  52. _currentTextCue = null;
  53. _mediaHints = new MediaHints();
  54. }
  55. /// <inheritdoc/>
  56. public abstract void SetLooping(bool looping);
  57. /// <inheritdoc/>
  58. public abstract bool IsLooping();
  59. /// <inheritdoc/>
  60. public abstract bool HasMetaData();
  61. /// <inheritdoc/>
  62. public abstract bool CanPlay();
  63. /// <inheritdoc/>
  64. public abstract void Play();
  65. /// <inheritdoc/>
  66. public abstract void Pause();
  67. /// <inheritdoc/>
  68. public abstract void Stop();
  69. /// <inheritdoc/>
  70. public virtual void Rewind() { SeekFast(0.0); }
  71. /// <inheritdoc/>
  72. public abstract void Seek(double time);
  73. /// <inheritdoc/>
  74. public abstract void SeekFast(double time);
  75. /// <inheritdoc/>
  76. public virtual void SeekWithTolerance(double time, double timeDeltaBefore, double timeDeltaAfter) { Seek(time); }
  77. /// <inheritdoc/>
  78. public abstract double GetCurrentTime();
  79. /// <inheritdoc/>
  80. public virtual DateTime GetProgramDateTime() { return DateTime.MinValue; }
  81. /// <inheritdoc/>
  82. public abstract float GetPlaybackRate();
  83. /// <inheritdoc/>
  84. public abstract void SetPlaybackRate(float rate);
  85. // Basic Properties
  86. /// <inheritdoc/>
  87. public abstract double GetDuration();
  88. /// <inheritdoc/>
  89. public abstract int GetVideoWidth();
  90. /// <inheritdoc/>
  91. public abstract int GetVideoHeight();
  92. /// <inheritdoc/>
  93. public abstract float GetVideoFrameRate();
  94. /// <inheritdoc/>
  95. public virtual float GetVideoDisplayRate() { return _displayRate; }
  96. /// <inheritdoc/>
  97. public abstract bool HasAudio();
  98. /// <inheritdoc/>
  99. public abstract bool HasVideo();
  100. /// <inheritdoc/>
  101. public bool IsVideoStereo() { return GetTextureStereoPacking() != StereoPacking.None; }
  102. // Basic State
  103. /// <inheritdoc/>
  104. public abstract bool IsSeeking();
  105. /// <inheritdoc/>
  106. public abstract bool IsPlaying();
  107. /// <inheritdoc/>
  108. public abstract bool IsPaused();
  109. /// <inheritdoc/>
  110. public abstract bool IsFinished();
  111. /// <inheritdoc/>
  112. public abstract bool IsBuffering();
  113. /// <inheritdoc/>
  114. public virtual bool WaitForNextFrame(Camera dummyCamera, int previousFrameCount) { return false; }
  115. // Textures
  116. /// <inheritdoc/>
  117. public virtual int GetTextureCount() { return 1; }
  118. /// <inheritdoc/>
  119. public abstract Texture GetTexture(int index = 0);
  120. /// <inheritdoc/>
  121. public abstract int GetTextureFrameCount();
  122. /// <inheritdoc/>
  123. public virtual bool SupportsTextureFrameCount() { return true; }
  124. /// <inheritdoc/>
  125. public virtual long GetTextureTimeStamp() { return long.MinValue; }
  126. /// <inheritdoc/>
  127. public abstract bool RequiresVerticalFlip();
  128. /// <inheritdoc/>
  129. public virtual float[] GetTextureTransform() { return new float[] { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f }; }
  130. /// <inheritdoc/>
  131. public virtual float GetTexturePixelAspectRatio() { return 1f; }
  132. /// <inheritdoc/>
  133. public virtual Matrix4x4 GetYpCbCrTransform() { return Matrix4x4.identity; }
  134. public StereoPacking GetTextureStereoPacking()
  135. {
  136. StereoPacking result = InternalGetTextureStereoPacking();
  137. if (result == StereoPacking.Unknown)
  138. {
  139. // If stereo is unknown, fall back to media hints or no packing
  140. result = _mediaHints.stereoPacking;
  141. }
  142. return result;
  143. }
  144. internal abstract StereoPacking InternalGetTextureStereoPacking();
  145. public virtual TransparencyMode GetTextureTransparency()
  146. {
  147. return _mediaHints.transparency;
  148. }
  149. public AlphaPacking GetTextureAlphaPacking()
  150. {
  151. if (GetTextureTransparency() == TransparencyMode.Transparent)
  152. {
  153. return _mediaHints.alphaPacking;
  154. }
  155. return AlphaPacking.None;
  156. }
  157. // Audio General
  158. /// <inheritdoc/>
  159. public abstract void MuteAudio(bool bMuted);
  160. /// <inheritdoc/>
  161. public abstract bool IsMuted();
  162. /// <inheritdoc/>
  163. public abstract void SetVolume(float volume);
  164. /// <inheritdoc/>
  165. public virtual void SetBalance(float balance) { }
  166. /// <inheritdoc/>
  167. public abstract float GetVolume();
  168. /// <inheritdoc/>
  169. public virtual float GetBalance() { return 0f; }
  170. // Audio Grabbing
  171. /// <inheritdoc/>
  172. public virtual int GetAudioChannelCount() { return -1; }
  173. /// <inheritdoc/>
  174. public virtual AudioChannelMaskFlags GetAudioChannelMask() { return 0; }
  175. /// <inheritdoc/>
  176. public virtual int GrabAudio(float[] audioData, int audioDataFloatCount, int channelCount) { return 0; }
  177. /// <inheritdoc/>
  178. public virtual int GetAudioBufferedSampleCount() { return 0; }
  179. // 360 Audio
  180. /// <inheritdoc/>
  181. public virtual void SetAudioHeadRotation(Quaternion q) { }
  182. /// <inheritdoc/>
  183. public virtual void ResetAudioHeadRotation() { }
  184. /// <inheritdoc/>
  185. public virtual void SetAudioChannelMode(Audio360ChannelMode channelMode) { }
  186. /// <inheritdoc/>
  187. public virtual void SetAudioFocusEnabled(bool enabled) { }
  188. /// <inheritdoc/>
  189. public virtual void SetAudioFocusProperties(float offFocusLevel, float widthDegrees) { }
  190. /// <inheritdoc/>
  191. public virtual void SetAudioFocusRotation(Quaternion q) { }
  192. /// <inheritdoc/>
  193. public virtual void ResetAudioFocus() { }
  194. // Streaming
  195. /// <inheritdoc/>
  196. public virtual long GetEstimatedTotalBandwidthUsed() { return -1; }
  197. /// <inheritdoc/>
  198. public virtual void SetPlayWithoutBuffering(bool playWithoutBuffering) { }
  199. // Caching
  200. /// <inheritdoc/>
  201. public virtual bool IsMediaCachingSupported() { return false; }
  202. /// <inheritdoc/>
  203. public virtual void AddMediaToCache(string url, string headers, MediaCachingOptions options) { }
  204. /// <inheritdoc/>
  205. public virtual void CancelDownloadOfMediaToCache(string url) { }
  206. /// <inheritdoc/>
  207. public virtual void PauseDownloadOfMediaToCache(string url) { }
  208. /// <inheritdoc/>
  209. public virtual void ResumeDownloadOfMediaToCache(string url) { }
  210. /// <inheritdoc/>
  211. public virtual void RemoveMediaFromCache(string url) { }
  212. /// <inheritdoc/>
  213. public virtual CachedMediaStatus GetCachedMediaStatus(string url, ref float progress) { return CachedMediaStatus.NotCached; }
  214. // /// <inheritdoc/>
  215. // public virtual bool IsMediaCached() { return false; }
  216. // External playback
  217. /// <inheritdoc/>
  218. public virtual bool IsExternalPlaybackSupported() { return false; }
  219. /// <inheritdoc/>
  220. public virtual bool IsExternalPlaybackActive() { return false; }
  221. /// <inheritdoc/>
  222. public virtual void SetAllowsExternalPlayback(bool enable) { }
  223. /// <inheritdoc/>
  224. public virtual void SetExternalPlaybackVideoGravity(ExternalPlaybackVideoGravity gravity) { }
  225. // Authentication
  226. //public virtual void SetKeyServerURL(string url) { }
  227. /// <inheritdoc/>
  228. public virtual void SetKeyServerAuthToken(string token) { }
  229. /// <inheritdoc/>
  230. public virtual void SetOverrideDecryptionKey(byte[] key) { }
  231. // General
  232. /// <inheritdoc/>
  233. public abstract void Update();
  234. /// <inheritdoc/>
  235. public abstract void Render();
  236. /// <inheritdoc/>
  237. public abstract void Dispose();
  238. // Internal method
  239. public virtual bool GetDecoderPerformance(ref int activeDecodeThreadCount, ref int decodedFrameCount, ref int droppedFrameCount) { return false; }
  240. #if false
  241. public void Update()
  242. {
  243. Native.Update(_instance);
  244. if (UpdateTracks())
  245. {
  246. }
  247. if (UpdateTextCue())
  248. {
  249. }
  250. }
  251. #endif
  252. public virtual void EndUpdate() { }
  253. public virtual IntPtr GetNativePlayerHandle() { return IntPtr.Zero; }
  254. public ErrorCode GetLastError()
  255. {
  256. ErrorCode errorCode = _lastError;
  257. _lastError = ErrorCode.None;
  258. return errorCode;
  259. }
  260. /// <inheritdoc/>
  261. public virtual long GetLastExtendedErrorCode()
  262. {
  263. return 0;
  264. }
  265. public string GetPlayerDescription()
  266. {
  267. return _playerDescription;
  268. }
  269. /// <inheritdoc/>
  270. public virtual bool PlayerSupportsLinearColorSpace()
  271. {
  272. #if UNITY_PLATFORM_SUPPORTS_LINEAR
  273. return true;
  274. #else
  275. return false;
  276. #endif
  277. }
  278. protected string _playerDescription = string.Empty;
  279. protected ErrorCode _lastError = ErrorCode.None;
  280. protected FilterMode _defaultTextureFilterMode = FilterMode.Bilinear;
  281. protected TextureWrapMode _defaultTextureWrapMode = TextureWrapMode.Clamp;
  282. protected int _defaultTextureAnisoLevel = 1;
  283. protected MediaHints _mediaHints;
  284. protected TimeRanges _seekableTimes = new TimeRanges();
  285. protected TimeRanges _bufferedTimes = new TimeRanges();
  286. public TimeRanges GetSeekableTimes() { return _seekableTimes; }
  287. public TimeRanges GetBufferedTimes() { return _bufferedTimes; }
  288. public void GetTextureProperties(out FilterMode filterMode, out TextureWrapMode wrapMode, out int anisoLevel)
  289. {
  290. filterMode = _defaultTextureFilterMode;
  291. wrapMode = _defaultTextureWrapMode;
  292. anisoLevel = _defaultTextureAnisoLevel;
  293. }
  294. public void SetTextureProperties(FilterMode filterMode = FilterMode.Bilinear, TextureWrapMode wrapMode = TextureWrapMode.Clamp, int anisoLevel = 0)
  295. {
  296. _defaultTextureFilterMode = filterMode;
  297. _defaultTextureWrapMode = wrapMode;
  298. _defaultTextureAnisoLevel = anisoLevel;
  299. for (int i = 0; i < GetTextureCount(); ++i)
  300. {
  301. ApplyTextureProperties(GetTexture(i));
  302. }
  303. }
  304. protected virtual void ApplyTextureProperties(Texture texture)
  305. {
  306. if (texture != null)
  307. {
  308. texture.filterMode = _defaultTextureFilterMode;
  309. texture.wrapMode = _defaultTextureWrapMode;
  310. texture.anisoLevel = _defaultTextureAnisoLevel;
  311. }
  312. }
  313. #region Video Display Rate
  314. #if UNITY_EDITOR
  315. private float _displayRateLastRealTime = 0f;
  316. #endif
  317. private float _displayRateTimer;
  318. private int _displayRateLastFrameCount;
  319. private float _displayRate = 1f;
  320. protected void UpdateDisplayFrameRate()
  321. {
  322. const float IntervalSeconds = 0.5f;
  323. if (_displayRateTimer >= IntervalSeconds)
  324. {
  325. int frameCount = GetTextureFrameCount();
  326. int frameDelta = (frameCount - _displayRateLastFrameCount);
  327. _displayRate = (float)frameDelta / _displayRateTimer;
  328. _displayRateTimer -= IntervalSeconds;
  329. if (_displayRateTimer >= IntervalSeconds) _displayRateTimer -= IntervalSeconds;
  330. if (_displayRateTimer >= IntervalSeconds) _displayRateTimer = 0f;
  331. _displayRateLastFrameCount = frameCount;
  332. }
  333. float deltaTime = Time.deltaTime;
  334. #if UNITY_EDITOR
  335. if (!Application.isPlaying)
  336. {
  337. // When not playing Time.deltaTime isn't valid so we have to derive it
  338. deltaTime = (Time.realtimeSinceStartup - _displayRateLastRealTime);
  339. _displayRateLastRealTime = Time.realtimeSinceStartup;
  340. }
  341. #endif
  342. _displayRateTimer += deltaTime;
  343. }
  344. #endregion // Video Display Rate
  345. #region Stall Detection
  346. protected bool IsExpectingNewVideoFrame()
  347. {
  348. if (HasVideo())
  349. {
  350. // If we're playing then we expect a new frame
  351. if (!IsFinished() && (!IsPaused() && IsPlaying() && GetPlaybackRate() != 0.0f))
  352. {
  353. // Check that the video is not a single frame and therefore there is no other frame to display
  354. bool isSingleFrame = (GetTextureFrameCount() > 0 && GetDurationFrames() == 1);
  355. if (!isSingleFrame)
  356. {
  357. // NOTE: if a new frame isn't available then we could either be seeking or stalled
  358. return true;
  359. }
  360. }
  361. }
  362. return false;
  363. }
  364. /// <inheritdoc/>
  365. public virtual bool IsPlaybackStalled()
  366. {
  367. const float StallDetectionDuration = 0.5f;
  368. // Manually detect stalled video if the platform doesn't have native support to detect it
  369. if (SupportsTextureFrameCount() && IsExpectingNewVideoFrame())
  370. {
  371. // Detect a new video frame
  372. int frameCount = GetTextureFrameCount();
  373. if (frameCount != _stallDetectionFrame)
  374. {
  375. _stallDetectionTimer = 0f;
  376. _stallDetectionFrame = frameCount;
  377. }
  378. else
  379. {
  380. // Update the detection timer, but never more than once a Unity frame
  381. if (_stallDetectionGuard != Time.frameCount)
  382. {
  383. _stallDetectionTimer += Time.deltaTime;
  384. }
  385. }
  386. _stallDetectionGuard = Time.frameCount;
  387. float thresholdDuration = StallDetectionDuration;
  388. // Scale by the playback rate, but should be at least StallDetectionDuration
  389. thresholdDuration = Mathf.Max(thresholdDuration / Mathf.Abs(GetPlaybackRate()), StallDetectionDuration);
  390. // If a valid FPS is available then make sure the thresholdDuration
  391. // is at least double that. This is mainly for very low FPS
  392. // content (eg 1 or 2 FPS)
  393. float fps = GetVideoFrameRate();
  394. if (fps > 0f && !float.IsNaN(fps))
  395. {
  396. thresholdDuration = Mathf.Max(thresholdDuration, 2f / fps);
  397. }
  398. return (_stallDetectionTimer > thresholdDuration);
  399. }
  400. else
  401. {
  402. _stallDetectionTimer = 0f;
  403. }
  404. return false;
  405. }
  406. private float _stallDetectionTimer;
  407. private int _stallDetectionFrame;
  408. private int _stallDetectionGuard;
  409. #endregion // Stall Detection
  410. protected List<Subtitle> _subtitles;
  411. protected Subtitle _currentSubtitle;
  412. /// <inheritdoc/>
  413. public bool LoadSubtitlesSRT(string data)
  414. {
  415. if (string.IsNullOrEmpty(data))
  416. {
  417. // Disable subtitles
  418. _subtitles = null;
  419. _currentSubtitle = null;
  420. }
  421. else
  422. {
  423. _subtitles = SubtitleUtils.ParseSubtitlesSRT(data);
  424. _currentSubtitle = null;
  425. }
  426. return (_subtitles != null);
  427. }
  428. /// <inheritdoc/>
  429. public virtual void UpdateSubtitles()
  430. {
  431. if (_subtitles != null)
  432. {
  433. double time = GetCurrentTime();
  434. // TODO: implement a more efficient subtitle index searcher
  435. int searchIndex = 0;
  436. if (_currentSubtitle != null)
  437. {
  438. if (!_currentSubtitle.IsTime(time))
  439. {
  440. if (time > _currentSubtitle.timeEnd)
  441. {
  442. searchIndex = _currentSubtitle.index + 1;
  443. }
  444. _currentSubtitle = null;
  445. }
  446. }
  447. if (_currentSubtitle == null)
  448. {
  449. for (int i = searchIndex; i < _subtitles.Count; i++)
  450. {
  451. if (_subtitles[i].IsTime(time))
  452. {
  453. _currentSubtitle = _subtitles[i];
  454. break;
  455. }
  456. }
  457. }
  458. }
  459. }
  460. /// <inheritdoc/>
  461. public virtual int GetSubtitleIndex()
  462. {
  463. int result = -1;
  464. if (_currentSubtitle != null)
  465. {
  466. result = _currentSubtitle.index;
  467. }
  468. return result;
  469. }
  470. /// <inheritdoc/>
  471. public virtual string GetSubtitleText()
  472. {
  473. string result = string.Empty;
  474. if (_currentSubtitle != null)
  475. {
  476. result = _currentSubtitle.text;
  477. }
  478. else if (_currentTextCue != null)
  479. {
  480. result = _currentTextCue.Text;
  481. }
  482. return result;
  483. }
  484. public virtual void OnEnable()
  485. {
  486. }
  487. /// <inheritdoc/>
  488. public int GetCurrentTimeFrames(float overrideFrameRate = 0f)
  489. {
  490. int result = 0;
  491. float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate();
  492. if (frameRate > 0f)
  493. {
  494. result = Helper.ConvertTimeSecondsToFrame(GetCurrentTime(), frameRate);
  495. result = Mathf.Min(result, GetMaxFrameNumber());
  496. }
  497. return result;
  498. }
  499. /// <inheritdoc/>
  500. public int GetDurationFrames(float overrideFrameRate = 0f)
  501. {
  502. int result = 0;
  503. float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate();
  504. if (frameRate > 0f)
  505. {
  506. result = Helper.ConvertTimeSecondsToFrame(GetDuration(), frameRate);
  507. }
  508. return result;
  509. }
  510. /// <inheritdoc/>
  511. public int GetMaxFrameNumber(float overrideFrameRate = 0f)
  512. {
  513. int result = GetDurationFrames();
  514. result = Mathf.Max(0, result - 1);
  515. return result;
  516. }
  517. /// <inheritdoc/>
  518. public void SeekToFrameRelative(int frameOffset, float overrideFrameRate = 0f)
  519. {
  520. float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate();
  521. if (frameRate > 0f)
  522. {
  523. int frame = Helper.ConvertTimeSecondsToFrame(GetCurrentTime(), frameRate);
  524. frame += frameOffset;
  525. frame = Mathf.Clamp(frame, 0, GetMaxFrameNumber(frameRate));
  526. double time = Helper.ConvertFrameToTimeSeconds(frame, frameRate);
  527. Seek(time);
  528. }
  529. }
  530. /// <inheritdoc/>
  531. public void SeekToFrame(int frame, float overrideFrameRate = 0f)
  532. {
  533. float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate();
  534. if (frameRate > 0f)
  535. {
  536. frame = Mathf.Clamp(frame, 0, GetMaxFrameNumber(frameRate));
  537. double time = Helper.ConvertFrameToTimeSeconds(frame, frameRate);
  538. Seek(time);
  539. }
  540. }
  541. #region IBufferedDisplay Implementation
  542. private int _unityFrameCountBufferedDisplayGuard = -1;
  543. /// <inheritdoc/>
  544. public long UpdateBufferedDisplay()
  545. {
  546. // Guard to make sure we're only updating the buffered frame once per Unity frame
  547. if (Time.frameCount == _unityFrameCountBufferedDisplayGuard) return GetTextureTimeStamp();
  548. _unityFrameCountBufferedDisplayGuard = Time.frameCount;
  549. return InternalUpdateBufferedDisplay();
  550. }
  551. internal virtual long InternalUpdateBufferedDisplay() { return 0; }
  552. /// <inheritdoc/>
  553. public virtual BufferedFramesState GetBufferedFramesState()
  554. {
  555. return new BufferedFramesState();
  556. }
  557. /// <inheritdoc/>
  558. public virtual void SetSlaves(IBufferedDisplay[] slaves) { }
  559. /// <inheritdoc/>
  560. public virtual void SetBufferedDisplayMode(BufferedFrameSelectionMode mode, IBufferedDisplay master = null) { }
  561. /// <inheritdoc/>
  562. public virtual void SetBufferedDisplayOptions(bool pauseOnPrerollComplete) { }
  563. #endregion // IBufferedDisplay Implementation
  564. protected PlaybackQualityStats _playbackQualityStats = new PlaybackQualityStats();
  565. public PlaybackQualityStats GetPlaybackQualityStats()
  566. {
  567. return _playbackQualityStats;
  568. }
  569. }
  570. }