123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace RenderHeads.Media.AVProVideo
- {
- public abstract class BaseMediaPlayer : IMediaPlayer, IMediaControl, IMediaInfo, IMediaProducer, IMediaSubtitles, IDisposable
- {
- public abstract string GetVersion();
- public abstract bool OpenVideoFromFile(string path, long offset, string httpHeaderJson);
- public virtual bool OpenVideoFromBuffer(byte[] buffer)
- {
- return false;
- }
- public abstract void CloseVideo();
- public abstract void SetLooping(bool bLooping);
- public abstract bool IsLooping();
- public abstract bool HasMetaData();
- public abstract bool CanPlay();
- public abstract void Play();
- public abstract void Pause();
- public abstract void Stop();
- public abstract void Rewind();
- public abstract void Seek(float timeMs);
- public abstract void SeekFast(float timeMs);
- public abstract float GetCurrentTimeMs();
- public abstract float GetPlaybackRate();
- public abstract void SetPlaybackRate(float rate);
- public abstract float GetDurationMs();
- public abstract int GetVideoWidth();
- public abstract int GetVideoHeight();
- public virtual Rect GetCropRect()
- {
- return new Rect(0f, 0f, 0f, 0f);
- }
- public abstract float GetVideoDisplayRate();
- public abstract bool HasAudio();
- public abstract bool HasVideo();
- public abstract bool IsSeeking();
- public abstract bool IsPlaying();
- public abstract bool IsPaused();
- public abstract bool IsFinished();
- public abstract bool IsBuffering();
- public virtual bool WaitForNextFrame(Camera dummyCamera, int previousFrameCount)
- {
- return false;
- }
- public virtual int GetTextureCount()
- {
- return 1;
- }
- public abstract Texture GetTexture(int index = 0);
- public abstract int GetTextureFrameCount();
- public virtual long GetTextureTimeStamp()
- {
- return long.MinValue;
- }
- public abstract bool RequiresVerticalFlip();
- public virtual float[] GetTextureTransform()
- {
- float[] array = new float[6];
- array[0] = 1f;
- array[3] = 1f;
- return array;
- }
- public abstract void MuteAudio(bool bMuted);
- public abstract bool IsMuted();
- public abstract void SetVolume(float volume);
- public virtual void SetBalance(float balance)
- {
- }
- public abstract float GetVolume();
- public virtual float GetBalance()
- {
- return 0f;
- }
- public abstract int GetAudioTrackCount();
- public virtual string GetAudioTrackId(int index)
- {
- return index.ToString();
- }
- public abstract int GetCurrentAudioTrack();
- public abstract void SetAudioTrack(int index);
- public abstract string GetCurrentAudioTrackId();
- public abstract int GetCurrentAudioTrackBitrate();
- public virtual int GetNumAudioChannels()
- {
- return -1;
- }
- public virtual void SetAudioHeadRotation(Quaternion q)
- {
- }
- public virtual void ResetAudioHeadRotation()
- {
- }
- public virtual void SetAudioChannelMode(Audio360ChannelMode channelMode)
- {
- }
- public virtual void SetAudioFocusEnabled(bool enabled)
- {
- }
- public virtual void SetAudioFocusProperties(float offFocusLevel, float widthDegrees)
- {
- }
- public virtual void SetAudioFocusRotation(Quaternion q)
- {
- }
- public virtual void ResetAudioFocus()
- {
- }
- public abstract int GetVideoTrackCount();
- public virtual string GetVideoTrackId(int index)
- {
- return index.ToString();
- }
- public abstract int GetCurrentVideoTrack();
- public abstract void SetVideoTrack(int index);
- public abstract string GetCurrentVideoTrackId();
- public abstract int GetCurrentVideoTrackBitrate();
- public abstract float GetVideoFrameRate();
- public abstract float GetBufferingProgress();
- public abstract void Update();
- public abstract void Render();
- public abstract void Dispose();
- public ErrorCode GetLastError()
- {
- return this._lastError;
- }
- public string GetPlayerDescription()
- {
- return this._playerDescription;
- }
- public virtual bool PlayerSupportsLinearColorSpace()
- {
- return true;
- }
- public virtual int GetBufferedTimeRangeCount()
- {
- return 0;
- }
- public virtual bool GetBufferedTimeRange(int index, ref float startTimeMs, ref float endTimeMs)
- {
- return false;
- }
- public void SetTextureProperties(FilterMode filterMode = FilterMode.Bilinear, TextureWrapMode wrapMode = TextureWrapMode.Clamp, int anisoLevel = 0)
- {
- this._defaultTextureFilterMode = filterMode;
- this._defaultTextureWrapMode = wrapMode;
- this._defaultTextureAnisoLevel = anisoLevel;
- for (int i = 0; i < this.GetTextureCount(); i++)
- {
- this.ApplyTextureProperties(this.GetTexture(i));
- }
- }
- protected virtual void ApplyTextureProperties(Texture texture)
- {
- if (texture != null)
- {
- texture.filterMode = this._defaultTextureFilterMode;
- texture.wrapMode = this._defaultTextureWrapMode;
- texture.anisoLevel = this._defaultTextureAnisoLevel;
- }
- }
- public virtual void GrabAudio(float[] buffer, int floatCount, int channelCount)
- {
- }
- public virtual bool IsPlaybackStalled()
- {
- return false;
- }
- public bool LoadSubtitlesSRT(string data)
- {
- if (string.IsNullOrEmpty(data))
- {
- this._subtitles = null;
- this._currentSubtitle = null;
- }
- else
- {
- this._subtitles = Helper.LoadSubtitlesSRT(data);
- }
- return this._subtitles != null;
- }
- public virtual void UpdateSubtitles()
- {
- if (this._subtitles != null)
- {
- float currentTimeMs = this.GetCurrentTimeMs();
- int num = 0;
- if (this._currentSubtitle != null && !this._currentSubtitle.IsTime(currentTimeMs))
- {
- if (currentTimeMs > (float)this._currentSubtitle.timeEndMs)
- {
- num = this._currentSubtitle.index + 1;
- }
- this._currentSubtitle = null;
- }
- if (this._currentSubtitle == null)
- {
- for (int i = num; i < this._subtitles.Count; i++)
- {
- if (this._subtitles[i].IsTime(currentTimeMs))
- {
- this._currentSubtitle = this._subtitles[i];
- break;
- }
- }
- }
- }
- }
- public virtual int GetSubtitleIndex()
- {
- int result = -1;
- if (this._currentSubtitle != null)
- {
- result = this._currentSubtitle.index;
- }
- return result;
- }
- public virtual string GetSubtitleText()
- {
- string result = string.Empty;
- if (this._currentSubtitle != null)
- {
- result = this._currentSubtitle.text;
- }
- return result;
- }
- public virtual void OnEnable()
- {
- }
- protected string _playerDescription = string.Empty;
- protected ErrorCode _lastError;
- protected FilterMode _defaultTextureFilterMode = FilterMode.Bilinear;
- protected TextureWrapMode _defaultTextureWrapMode = TextureWrapMode.Clamp;
- protected int _defaultTextureAnisoLevel = 1;
- protected List<Subtitle> _subtitles;
- protected Subtitle _currentSubtitle;
- }
- }
|