Rialto  0.1
Rialto media pipeline API
IWebAudioPlayer.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's LICENSE file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2022 Sky UK
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef FIREBOLT_RIALTO_I_WEB_AUDIO_PLAYER_H_
21 #define FIREBOLT_RIALTO_I_WEB_AUDIO_PLAYER_H_
22 
32 #include <memory>
33 #include <stdint.h>
34 #include <string>
35 
36 #include "IWebAudioPlayerClient.h"
37 #include "MediaCommon.h"
38 
39 namespace firebolt::rialto
40 {
41 class IWebAudioPlayer;
42 
47 {
48 public:
49  IWebAudioPlayerFactory() = default;
50  virtual ~IWebAudioPlayerFactory() = default;
51 
57  static std::shared_ptr<IWebAudioPlayerFactory> createFactory();
58 
76  virtual std::unique_ptr<IWebAudioPlayer> createWebAudioPlayer(std::weak_ptr<IWebAudioPlayerClient> client,
77  const std::string &audioMimeType,
78  const uint32_t priority,
79  std::weak_ptr<const WebAudioConfig> config) const = 0;
80 };
81 
90 {
91 public:
92  IWebAudioPlayer() = default;
93  virtual ~IWebAudioPlayer() = default;
94 
95  IWebAudioPlayer(const IWebAudioPlayer &) = delete;
96  IWebAudioPlayer &operator=(const IWebAudioPlayer &) = delete;
97  IWebAudioPlayer(IWebAudioPlayer &&) = delete;
98  IWebAudioPlayer &operator=(IWebAudioPlayer &&) = delete;
99 
107  virtual bool play() = 0;
108 
116  virtual bool pause() = 0;
117 
126  virtual bool setEos() = 0;
127 
141  virtual bool getBufferAvailable(uint32_t &availableFrames, std::shared_ptr<WebAudioShmInfo> &webAudioShmInfo) = 0;
142 
153  virtual bool getBufferDelay(uint32_t &delayFrames) = 0;
154 
165  virtual bool writeBuffer(const uint32_t numberOfFrames, void *data) = 0;
166 
181  virtual bool getDeviceInfo(uint32_t &preferredFrames, uint32_t &maximumFrames, bool &supportDeferredPlay) = 0;
182 
193  virtual bool setVolume(double volume) = 0;
194 
204  virtual bool getVolume(double &volume) = 0;
205 
211  virtual std::weak_ptr<IWebAudioPlayerClient> getClient() = 0;
212 };
213 
214 }; // namespace firebolt::rialto
215 
216 #endif // FIREBOLT_RIALTO_I_WEB_AUDIO_PLAYER_H_
firebolt::rialto::IWebAudioPlayer::getDeviceInfo
virtual bool getDeviceInfo(uint32_t &preferredFrames, uint32_t &maximumFrames, bool &supportDeferredPlay)=0
Get device information.
firebolt::rialto::IWebAudioPlayer::pause
virtual bool pause()=0
Pause the web audio.
firebolt::rialto::IWebAudioPlayer::setVolume
virtual bool setVolume(double volume)=0
Set level and transition of audio attenuation.
firebolt::rialto::IWebAudioPlayer::writeBuffer
virtual bool writeBuffer(const uint32_t numberOfFrames, void *data)=0
Write audio frames.
IWebAudioPlayerClient.h
firebolt::rialto::IWebAudioPlayer::getVolume
virtual bool getVolume(double &volume)=0
Get current audio level.
firebolt::rialto::IWebAudioPlayer::play
virtual bool play()=0
Play the web audio.
firebolt::rialto::IWebAudioPlayer::getBufferDelay
virtual bool getBufferDelay(uint32_t &delayFrames)=0
Get the delay frames.
firebolt::rialto::IWebAudioPlayerFactory::createFactory
static std::shared_ptr< IWebAudioPlayerFactory > createFactory()
Create a IWebAudioPlayerFactory instance.
firebolt::rialto::IWebAudioPlayerFactory
IWebAudioPlayer factory class, returns a concrete implementation of IWebAudioPlayer.
Definition: IWebAudioPlayer.h:46
firebolt::rialto::IWebAudioPlayer::setEos
virtual bool setEos()=0
Notify EOS.
firebolt::rialto::IWebAudioPlayer::getClient
virtual std::weak_ptr< IWebAudioPlayerClient > getClient()=0
Returns the web audio player client.
MediaCommon.h
firebolt::rialto::IWebAudioPlayerFactory::createWebAudioPlayer
virtual std::unique_ptr< IWebAudioPlayer > createWebAudioPlayer(std::weak_ptr< IWebAudioPlayerClient > client, const std::string &audioMimeType, const uint32_t priority, std::weak_ptr< const WebAudioConfig > config) const =0
IWebAudioPlayer factory method, returns a concrete implementation of IWebAudioPlayer for playback of ...
firebolt::rialto::IWebAudioPlayer
The definition of the IWebAudioPlayer interface.
Definition: IWebAudioPlayer.h:89
firebolt::rialto::IWebAudioPlayer::getBufferAvailable
virtual bool getBufferAvailable(uint32_t &availableFrames, std::shared_ptr< WebAudioShmInfo > &webAudioShmInfo)=0
Get the available frames.