kodi
AEStream.h
1 /*
2  * Copyright (C) 2010-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "cores/AudioEngine/Utils/AEAudioFormat.h"
12 #include <stdint.h>
13 
14 extern "C" {
15 #include <libavcodec/avcodec.h>
16 }
17 
18 class IAudioCallback;
19 
24 {
25 public:
26  virtual ~IAEClockCallback() = default;
27  virtual double GetClock() = 0;
28  virtual double GetClockSpeed() { return 1.0; }
29 };
30 
32 {
33 public:
34  double delay;
35  double error;
36  double rr;
37  unsigned int errortime;
38  enum AESyncState
39  {
40  SYNC_OFF,
41  SYNC_INSYNC,
42  SYNC_START,
43  SYNC_MUTE,
44  SYNC_ADJUST
45  };
46  AESyncState state;
47 };
48 
52 class IAEStream
53 {
54 protected:
55  friend class IAE;
56  IAEStream() = default;
57  virtual ~IAEStream() = default;
58 
59 public:
60  struct ExtData
61  {
62  double pts = 0;
63  bool hasDownmix = false;
64  double centerMixLevel = 1;
65  };
66 
67 public:
72  virtual unsigned int GetSpace() = 0;
73 
82  virtual unsigned int AddData(const uint8_t* const *data, unsigned int offset, unsigned int frames, ExtData *extData) = 0;
83 
89  virtual double GetDelay() = 0;
90 
95  virtual CAESyncInfo GetSyncInfo() = 0;
96 
101  virtual bool IsBuffering() = 0;
102 
108  virtual double GetCacheTime() = 0;
109 
114  virtual double GetCacheTotal() = 0;
115 
120  virtual double GetMaxDelay() = 0;
121 
125  virtual void Pause() = 0;
126 
130  virtual void Resume() = 0;
131 
136  virtual void Drain(bool wait) = 0;
137 
141  virtual bool IsDraining() = 0;
142 
146  virtual bool IsDrained() = 0;
147 
151  virtual void Flush() = 0;
152 
157  virtual float GetVolume() = 0;
158 
163  virtual void SetVolume(float volume) = 0;
164 
169  virtual float GetReplayGain() = 0;
170 
175  virtual void SetReplayGain(float factor) = 0;
176 
181  virtual float GetAmplification() = 0;
182 
187  virtual void SetAmplification(float amplify) = 0;
188 
195  virtual void SetFFmpegInfo(int profile, enum AVMatrixEncoding matrix_encoding, enum AVAudioServiceType audio_service_type) = 0;
196 
201  virtual unsigned int GetFrameSize() const = 0;
202 
207  virtual unsigned int GetChannelCount() const = 0;
208 
213  virtual unsigned int GetSampleRate() const = 0;
214 
219  virtual enum AEDataFormat GetDataFormat() const = 0;
220 
226  virtual double GetResampleRatio() = 0;
227 
233  virtual void SetResampleRatio(double ratio) = 0;
234 
238  virtual void SetResampleMode(int mode) = 0;
239 
245  virtual void RegisterAudioCallback(IAudioCallback* pCallback) = 0;
246 
250  virtual void UnRegisterAudioCallback() = 0;
251 
259  virtual void FadeVolume(float from, float target, unsigned int time) {} /* FIXME: once all the engines have these new methods */
260 
265  virtual bool IsFading() { return false; }
266 
270  virtual void RegisterSlave(IAEStream *stream) = 0;
271 };
272 
Callback interface for VideoPlayer clock needed by AE for sync.
Definition: AEStream.h:23
Definition: IAudioCallback.h:15
IAEStream Stream Interface for streaming audio.
Definition: AEStream.h:52
virtual void FadeVolume(float from, float target, unsigned int time)
Fade the volume level over the specified time.
Definition: AEStream.h:259
Definition: AEStream.h:60
IAE Interface.
Definition: AE.h:81
Definition: AEStream.h:31
virtual bool IsFading()
Returns if a fade is still running.
Definition: AEStream.h:265