AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
TestMediaPlayer.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_INTEGRATION_INCLUDE_INTEGRATION_TESTMEDIAPLAYER_H_
17 #define ALEXA_CLIENT_SDK_INTEGRATION_INCLUDE_INTEGRATION_TESTMEDIAPLAYER_H_
18 
19 #include <chrono>
20 #include <condition_variable>
21 #include <deque>
22 #include <mutex>
23 #include <thread>
24 #include <iostream>
25 #include <string>
26 #include <future>
27 #include <unordered_set>
28 
33 
34 namespace alexaClientSDK {
35 namespace integration {
36 namespace test {
37 
44 public:
45  // Destructor.
47 
49  std::shared_ptr<avsCommon::avs::attachment::AttachmentReader> attachmentReader,
50  const avsCommon::utils::AudioFormat* audioFormat = nullptr,
53 
55  std::shared_ptr<avsCommon::avs::attachment::AttachmentReader> attachmentReader,
56  std::chrono::milliseconds offsetAdjustment,
57  const avsCommon::utils::AudioFormat* audioFormat = nullptr,
60 
62  std::shared_ptr<std::istream> stream,
63  bool repeat,
66 
68  const std::string& url,
69  std::chrono::milliseconds offset = std::chrono::milliseconds::zero(),
71  bool repeat = false,
72  const avsCommon::utils::mediaPlayer::PlaybackContext& playbackContext =
74 
76 
78 
80 
82 
83  std::chrono::milliseconds getOffset(avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId id) override;
84 
85  void addObserver(
86  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface> playerObserver) override;
87 
88  void removeObserver(
89  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface> playerObserver) override;
90 
93 
94  uint64_t getNumBytesBuffered() override;
95 
96 private:
98  std::unordered_set<std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface>> m_observers;
100  bool m_playbackFinished = false;
102  std::shared_ptr<avsCommon::avs::attachment::AttachmentReader> m_attachmentReader;
104  std::shared_ptr<avsCommon::utils::timing::Timer> m_timer;
105  // istream for Alerts.
106  std::shared_ptr<std::istream> m_istream;
107 };
108 } // namespace test
109 } // namespace integration
110 } // namespace alexaClientSDK
111 
112 #endif // ALEXA_CLIENT_SDK_INTEGRATION_INCLUDE_INTEGRATION_TESTMEDIAPLAYER_H_
std::chrono::milliseconds getOffset(avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId id) override
Definition: TestMediaPlayer.cpp:123
bool stop(avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId id) override
Definition: TestMediaPlayer.cpp:100
SourceConfig emptySourceConfig()
Definition: SourceConfig.h:98
uint64_t getNumBytesBuffered() override
Definition: TestMediaPlayer.cpp:137
avsCommon::utils::Optional< avsCommon::utils::mediaPlayer::MediaPlayerState > getMediaPlayerState(avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId id) override
Definition: TestMediaPlayer.cpp:141
uint64_t SourceId
A type that identifies which source is currently being operated on. This must be unique across all in...
Definition: MediaPlayerInterface.h:69
MediaType
Definition: MediaType.h:29
void removeObserver(std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface > playerObserver) override
Definition: TestMediaPlayer.cpp:132
bool pause(avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId id) override
Definition: TestMediaPlayer.cpp:114
~TestMediaPlayer()
Definition: TestMediaPlayer.cpp:41
bool play(avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId id) override
Definition: TestMediaPlayer.cpp:79
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId setSource(std::shared_ptr< avsCommon::avs::attachment::AttachmentReader > attachmentReader, const avsCommon::utils::AudioFormat *audioFormat=nullptr, const avsCommon::utils::mediaPlayer::SourceConfig &config=avsCommon::utils::mediaPlayer::emptySourceConfig()) override
Definition: TestMediaPlayer.cpp:44
void addObserver(std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface > playerObserver) override
Definition: TestMediaPlayer.cpp:127
bool resume(avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId id) override
Definition: TestMediaPlayer.cpp:119

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