BaseMediaPlayer.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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. /// <inheritdoc/>
  180. public virtual void AudioConfigurationChanged(bool deviceChanged) { }
  181. // 360 Audio
  182. /// <inheritdoc/>
  183. public virtual void SetAudioHeadRotation(Quaternion q) { }
  184. /// <inheritdoc/>
  185. public virtual void ResetAudioHeadRotation() { }
  186. /// <inheritdoc/>
  187. public virtual void SetAudioChannelMode(Audio360ChannelMode channelMode) { }
  188. /// <inheritdoc/>
  189. public virtual void SetAudioFocusEnabled(bool enabled) { }
  190. /// <inheritdoc/>
  191. public virtual void SetAudioFocusProperties(float offFocusLevel, float widthDegrees) { }
  192. /// <inheritdoc/>
  193. public virtual void SetAudioFocusRotation(Quaternion q) { }
  194. /// <inheritdoc/>
  195. public virtual void ResetAudioFocus() { }
  196. // Streaming
  197. /// <inheritdoc/>
  198. public virtual long GetEstimatedTotalBandwidthUsed() { return -1; }
  199. /// <inheritdoc/>
  200. public virtual void SetPlayWithoutBuffering(bool playWithoutBuffering) { }
  201. // Caching
  202. /// <inheritdoc/>
  203. public virtual bool IsMediaCachingSupported() { return false; }
  204. /// <inheritdoc/>
  205. public virtual void AddMediaToCache(string url, string headers, MediaCachingOptions options) { }
  206. /// <inheritdoc/>
  207. public virtual void CancelDownloadOfMediaToCache(string url) { }
  208. /// <inheritdoc/>
  209. public virtual void PauseDownloadOfMediaToCache(string url) { }
  210. /// <inheritdoc/>
  211. public virtual void ResumeDownloadOfMediaToCache(string url) { }
  212. /// <inheritdoc/>
  213. public virtual void RemoveMediaFromCache(string url) { }
  214. /// <inheritdoc/>
  215. public virtual CachedMediaStatus GetCachedMediaStatus(string url, ref float progress) { return CachedMediaStatus.NotCached; }
  216. // /// <inheritdoc/>
  217. // public virtual bool IsMediaCached() { return false; }
  218. // External playback
  219. /// <inheritdoc/>
  220. public virtual bool IsExternalPlaybackSupported() { return false; }
  221. /// <inheritdoc/>
  222. public virtual bool IsExternalPlaybackActive() { return false; }
  223. /// <inheritdoc/>
  224. public virtual void SetAllowsExternalPlayback(bool enable) { }
  225. /// <inheritdoc/>
  226. public virtual void SetExternalPlaybackVideoGravity(ExternalPlaybackVideoGravity gravity) { }
  227. // Authentication
  228. //public virtual void SetKeyServerURL(string url) { }
  229. /// <inheritdoc/>
  230. public virtual void SetKeyServerAuthToken(string token) { }
  231. /// <inheritdoc/>
  232. public virtual void SetOverrideDecryptionKey(byte[] key) { }
  233. // General
  234. /// <inheritdoc/>
  235. public abstract void Update();
  236. /// <inheritdoc/>
  237. public abstract void Render();
  238. /// <inheritdoc/>
  239. public abstract void Dispose();
  240. // Internal method
  241. public virtual bool GetDecoderPerformance(ref int activeDecodeThreadCount, ref int decodedFrameCount, ref int droppedFrameCount) { return false; }
  242. #if false
  243. public void Update()
  244. {
  245. Native.Update(_instance);
  246. if (UpdateTracks())
  247. {
  248. }
  249. if (UpdateTextCue())
  250. {
  251. }
  252. }
  253. #endif
  254. public virtual void EndUpdate() { }
  255. public virtual IntPtr GetNativePlayerHandle() { return IntPtr.Zero; }
  256. public ErrorCode GetLastError()
  257. {
  258. ErrorCode errorCode = _lastError;
  259. _lastError = ErrorCode.None;
  260. return errorCode;
  261. }
  262. /// <inheritdoc/>
  263. public virtual long GetLastExtendedErrorCode()
  264. {
  265. return 0;
  266. }
  267. public string GetPlayerDescription()
  268. {
  269. return _playerDescription;
  270. }
  271. /// <inheritdoc/>
  272. public virtual bool PlayerSupportsLinearColorSpace()
  273. {
  274. #if UNITY_PLATFORM_SUPPORTS_LINEAR
  275. return true;
  276. #else
  277. return false;
  278. #endif
  279. }
  280. protected string _playerDescription = string.Empty;
  281. protected ErrorCode _lastError = ErrorCode.None;
  282. protected FilterMode _defaultTextureFilterMode = FilterMode.Bilinear;
  283. protected TextureWrapMode _defaultTextureWrapMode = TextureWrapMode.Clamp;
  284. protected int _defaultTextureAnisoLevel = 1;
  285. protected MediaHints _mediaHints;
  286. protected TimeRanges _seekableTimes = new TimeRanges();
  287. protected TimeRanges _bufferedTimes = new TimeRanges();
  288. public TimeRanges GetSeekableTimes() { return _seekableTimes; }
  289. public TimeRanges GetBufferedTimes() { return _bufferedTimes; }
  290. public void GetTextureProperties(out FilterMode filterMode, out TextureWrapMode wrapMode, out int anisoLevel)
  291. {
  292. filterMode = _defaultTextureFilterMode;
  293. wrapMode = _defaultTextureWrapMode;
  294. anisoLevel = _defaultTextureAnisoLevel;
  295. }
  296. public void SetTextureProperties(FilterMode filterMode = FilterMode.Bilinear, TextureWrapMode wrapMode = TextureWrapMode.Clamp, int anisoLevel = 0)
  297. {
  298. _defaultTextureFilterMode = filterMode;
  299. _defaultTextureWrapMode = wrapMode;
  300. _defaultTextureAnisoLevel = anisoLevel;
  301. for (int i = 0; i < GetTextureCount(); ++i)
  302. {
  303. ApplyTextureProperties(GetTexture(i));
  304. }
  305. }
  306. protected virtual void ApplyTextureProperties(Texture texture)
  307. {
  308. if (texture != null)
  309. {
  310. texture.filterMode = _defaultTextureFilterMode;
  311. texture.wrapMode = _defaultTextureWrapMode;
  312. texture.anisoLevel = _defaultTextureAnisoLevel;
  313. }
  314. }
  315. #region Video Display Rate
  316. #if UNITY_EDITOR
  317. private float _displayRateLastRealTime = 0f;
  318. #endif
  319. private float _displayRateTimer;
  320. private int _displayRateLastFrameCount;
  321. private float _displayRate = 1f;
  322. protected void UpdateDisplayFrameRate()
  323. {
  324. const float IntervalSeconds = 0.5f;
  325. if (_displayRateTimer >= IntervalSeconds)
  326. {
  327. int frameCount = GetTextureFrameCount();
  328. int frameDelta = (frameCount - _displayRateLastFrameCount);
  329. _displayRate = (float)frameDelta / _displayRateTimer;
  330. _displayRateTimer -= IntervalSeconds;
  331. if (_displayRateTimer >= IntervalSeconds) _displayRateTimer -= IntervalSeconds;
  332. if (_displayRateTimer >= IntervalSeconds) _displayRateTimer = 0f;
  333. _displayRateLastFrameCount = frameCount;
  334. }
  335. float deltaTime = Time.deltaTime;
  336. #if UNITY_EDITOR
  337. if (!Application.isPlaying)
  338. {
  339. // When not playing Time.deltaTime isn't valid so we have to derive it
  340. deltaTime = (Time.realtimeSinceStartup - _displayRateLastRealTime);
  341. _displayRateLastRealTime = Time.realtimeSinceStartup;
  342. }
  343. #endif
  344. _displayRateTimer += deltaTime;
  345. }
  346. #endregion // Video Display Rate
  347. #region Stall Detection
  348. protected bool IsExpectingNewVideoFrame()
  349. {
  350. if (HasVideo())
  351. {
  352. // If we're playing then we expect a new frame
  353. if (!IsFinished() && (!IsPaused() && IsPlaying() && GetPlaybackRate() != 0.0f))
  354. {
  355. // Check that the video is not a single frame and therefore there is no other frame to display
  356. bool isSingleFrame = (GetTextureFrameCount() > 0 && GetDurationFrames() == 1);
  357. if (!isSingleFrame)
  358. {
  359. // NOTE: if a new frame isn't available then we could either be seeking or stalled
  360. return true;
  361. }
  362. }
  363. }
  364. return false;
  365. }
  366. /// <inheritdoc/>
  367. public virtual bool IsPlaybackStalled()
  368. {
  369. const float StallDetectionDuration = 0.5f;
  370. // Manually detect stalled video if the platform doesn't have native support to detect it
  371. if (SupportsTextureFrameCount() && IsExpectingNewVideoFrame())
  372. {
  373. // Detect a new video frame
  374. int frameCount = GetTextureFrameCount();
  375. if (frameCount != _stallDetectionFrame)
  376. {
  377. _stallDetectionTimer = 0f;
  378. _stallDetectionFrame = frameCount;
  379. }
  380. else
  381. {
  382. // Update the detection timer, but never more than once a Unity frame
  383. if (_stallDetectionGuard != Time.frameCount)
  384. {
  385. _stallDetectionTimer += Time.deltaTime;
  386. }
  387. }
  388. _stallDetectionGuard = Time.frameCount;
  389. float thresholdDuration = StallDetectionDuration;
  390. // Scale by the playback rate, but should be at least StallDetectionDuration
  391. thresholdDuration = Mathf.Max(thresholdDuration / Mathf.Abs(GetPlaybackRate()), StallDetectionDuration);
  392. // If a valid FPS is available then make sure the thresholdDuration
  393. // is at least double that. This is mainly for very low FPS
  394. // content (eg 1 or 2 FPS)
  395. float fps = GetVideoFrameRate();
  396. if (fps > 0f && !float.IsNaN(fps))
  397. {
  398. thresholdDuration = Mathf.Max(thresholdDuration, 2f / fps);
  399. }
  400. return (_stallDetectionTimer > thresholdDuration);
  401. }
  402. else
  403. {
  404. _stallDetectionTimer = 0f;
  405. }
  406. return false;
  407. }
  408. private float _stallDetectionTimer;
  409. private int _stallDetectionFrame;
  410. private int _stallDetectionGuard;
  411. #endregion // Stall Detection
  412. protected List<Subtitle> _subtitles;
  413. protected Subtitle _currentSubtitle;
  414. /// <inheritdoc/>
  415. public bool LoadSubtitlesSRT(string data)
  416. {
  417. if (string.IsNullOrEmpty(data))
  418. {
  419. // Disable subtitles
  420. _subtitles = null;
  421. _currentSubtitle = null;
  422. }
  423. else
  424. {
  425. _subtitles = SubtitleUtils.ParseSubtitlesSRT(data);
  426. _currentSubtitle = null;
  427. }
  428. return (_subtitles != null);
  429. }
  430. /// <inheritdoc/>
  431. public virtual void UpdateSubtitles()
  432. {
  433. if (_subtitles != null)
  434. {
  435. double time = GetCurrentTime();
  436. // TODO: implement a more efficient subtitle index searcher
  437. int searchIndex = 0;
  438. if (_currentSubtitle != null)
  439. {
  440. if (!_currentSubtitle.IsTime(time))
  441. {
  442. if (time > _currentSubtitle.timeEnd)
  443. {
  444. searchIndex = _currentSubtitle.index + 1;
  445. }
  446. _currentSubtitle = null;
  447. }
  448. }
  449. if (_currentSubtitle == null)
  450. {
  451. for (int i = searchIndex; i < _subtitles.Count; i++)
  452. {
  453. if (_subtitles[i].IsTime(time))
  454. {
  455. _currentSubtitle = _subtitles[i];
  456. break;
  457. }
  458. }
  459. }
  460. }
  461. }
  462. /// <inheritdoc/>
  463. public virtual int GetSubtitleIndex()
  464. {
  465. int result = -1;
  466. if (_currentSubtitle != null)
  467. {
  468. result = _currentSubtitle.index;
  469. }
  470. return result;
  471. }
  472. /// <inheritdoc/>
  473. public virtual string GetSubtitleText()
  474. {
  475. string result = string.Empty;
  476. if (_currentSubtitle != null)
  477. {
  478. result = _currentSubtitle.text;
  479. }
  480. else if (_currentTextCue != null)
  481. {
  482. result = _currentTextCue.Text;
  483. }
  484. return result;
  485. }
  486. public virtual void OnEnable()
  487. {
  488. }
  489. /// <inheritdoc/>
  490. public int GetCurrentTimeFrames(float overrideFrameRate = 0f)
  491. {
  492. int result = 0;
  493. float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate();
  494. if (frameRate > 0f)
  495. {
  496. result = Helper.ConvertTimeSecondsToFrame(GetCurrentTime(), frameRate);
  497. result = Mathf.Min(result, GetMaxFrameNumber());
  498. }
  499. return result;
  500. }
  501. /// <inheritdoc/>
  502. public int GetDurationFrames(float overrideFrameRate = 0f)
  503. {
  504. int result = 0;
  505. float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate();
  506. if (frameRate > 0f)
  507. {
  508. result = Helper.ConvertTimeSecondsToFrame(GetDuration(), frameRate);
  509. }
  510. return result;
  511. }
  512. /// <inheritdoc/>
  513. public int GetMaxFrameNumber(float overrideFrameRate = 0f)
  514. {
  515. int result = GetDurationFrames();
  516. result = Mathf.Max(0, result - 1);
  517. return result;
  518. }
  519. /// <inheritdoc/>
  520. public void SeekToFrameRelative(int frameOffset, float overrideFrameRate = 0f)
  521. {
  522. float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate();
  523. if (frameRate > 0f)
  524. {
  525. int frame = Helper.ConvertTimeSecondsToFrame(GetCurrentTime(), frameRate);
  526. frame += frameOffset;
  527. frame = Mathf.Clamp(frame, 0, GetMaxFrameNumber(frameRate));
  528. double time = Helper.ConvertFrameToTimeSeconds(frame, frameRate);
  529. Seek(time);
  530. }
  531. }
  532. /// <inheritdoc/>
  533. public void SeekToFrame(int frame, float overrideFrameRate = 0f)
  534. {
  535. float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate();
  536. if (frameRate > 0f)
  537. {
  538. frame = Mathf.Clamp(frame, 0, GetMaxFrameNumber(frameRate));
  539. double time = Helper.ConvertFrameToTimeSeconds(frame, frameRate);
  540. Seek(time);
  541. }
  542. }
  543. #region IBufferedDisplay Implementation
  544. private int _unityFrameCountBufferedDisplayGuard = -1;
  545. /// <inheritdoc/>
  546. public long UpdateBufferedDisplay()
  547. {
  548. // Guard to make sure we're only updating the buffered frame once per Unity frame
  549. if (Time.frameCount == _unityFrameCountBufferedDisplayGuard) return GetTextureTimeStamp();
  550. _unityFrameCountBufferedDisplayGuard = Time.frameCount;
  551. return InternalUpdateBufferedDisplay();
  552. }
  553. internal virtual long InternalUpdateBufferedDisplay() { return 0; }
  554. /// <inheritdoc/>
  555. public virtual BufferedFramesState GetBufferedFramesState()
  556. {
  557. return new BufferedFramesState();
  558. }
  559. /// <inheritdoc/>
  560. public virtual void SetSlaves(IBufferedDisplay[] slaves) { }
  561. /// <inheritdoc/>
  562. public virtual void SetBufferedDisplayMode(BufferedFrameSelectionMode mode, IBufferedDisplay master = null) { }
  563. /// <inheritdoc/>
  564. public virtual void SetBufferedDisplayOptions(bool pauseOnPrerollComplete) { }
  565. #endregion // IBufferedDisplay Implementation
  566. protected PlaybackQualityStats _playbackQualityStats = new PlaybackQualityStats();
  567. public PlaybackQualityStats GetPlaybackQualityStats()
  568. {
  569. return _playbackQualityStats;
  570. }
  571. }
  572. }