AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
PooledMediaPlayerFactory.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_POOLEDMEDIAPLAYERFACTORY_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_POOLEDMEDIAPLAYERFACTORY_H_
18 
19 #include <vector>
20 #include <unordered_set>
21 
25 
26 namespace alexaClientSDK {
27 namespace mediaPlayer {
28 
34 public:
41  static std::unique_ptr<PooledMediaPlayerFactory> create(
42  const std::vector<std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>>& pool,
43  const avsCommon::utils::mediaPlayer::Fingerprint& fingerprint = {});
44 
45  virtual ~PooledMediaPlayerFactory();
46 
50  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> acquireMediaPlayer() override;
51  bool releaseMediaPlayer(std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> mediaPlayer) override;
52  bool isMediaPlayerAvailable() override;
53  void addObserver(
54  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerFactoryObserverInterface> observer) override;
55  void removeObserver(
56  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerFactoryObserverInterface> observer) override;
58 
59 protected:
68  const std::vector<std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>>& mediaPlayerPool,
69  const avsCommon::utils::mediaPlayer::Fingerprint& fingerprint = {});
70 
74  void notifyObservers();
75 
77  std::vector<std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>> m_availablePlayerPool;
79  std::vector<std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>> m_inUsePlayerPool;
82  std::unordered_set<std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerFactoryObserverInterface>> m_observers;
85 };
86 
87 } // namespace mediaPlayer
88 } // namespace alexaClientSDK
89 
90 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_POOLEDMEDIAPLAYERFACTORY_H_
static std::unique_ptr< PooledMediaPlayerFactory > create(const std::vector< std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface >> &pool, const avsCommon::utils::mediaPlayer::Fingerprint &fingerprint={})
void addObserver(std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerFactoryObserverInterface > observer) override
PooledMediaPlayerFactory(const std::vector< std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface >> &mediaPlayerPool, const avsCommon::utils::mediaPlayer::Fingerprint &fingerprint={})
avsCommon::utils::mediaPlayer::Fingerprint m_fingerprint
MediaPlayer version information.
Definition: PooledMediaPlayerFactory.h:84
std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface > acquireMediaPlayer() override
std::unordered_set< std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerFactoryObserverInterface > > m_observers
Definition: PooledMediaPlayerFactory.h:82
bool releaseMediaPlayer(std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface > mediaPlayer) override
std::vector< std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface > > m_availablePlayerPool
The collection of available players.
Definition: PooledMediaPlayerFactory.h:77
Definition: MediaPlayerFactoryInterface.h:38
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void removeObserver(std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerFactoryObserverInterface > observer) override
Definition: PooledMediaPlayerFactory.h:33
std::vector< std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface > > m_inUsePlayerPool
The collection of players in use.
Definition: PooledMediaPlayerFactory.h:79
avsCommon::utils::mediaPlayer::Fingerprint getFingerprint() override

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0