AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MediaPlayerInterface.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_MEDIAPLAYERINTERFACE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_MEDIAPLAYERINTERFACE_H_
18 
19 #include <chrono>
20 #include <cstdint>
21 #include <future>
22 #include <memory>
23 
35 
36 namespace alexaClientSDK {
37 namespace avsCommon {
38 namespace utils {
39 namespace mediaPlayer {
40 
42 static const std::chrono::milliseconds MEDIA_PLAYER_INVALID_OFFSET{-1};
43 
46 
67 public:
69  using SourceId = uint64_t;
70 
72  static const SourceId ERROR = 0;
73 
77  virtual ~MediaPlayerInterface() = default;
78 
94  virtual SourceId setSource(
95  std::shared_ptr<avsCommon::avs::attachment::AttachmentReader> attachmentReader,
96  const avsCommon::utils::AudioFormat* format = nullptr,
97  const SourceConfig& config = emptySourceConfig()) = 0;
98 
115  virtual SourceId setSource(
116  std::shared_ptr<avsCommon::avs::attachment::AttachmentReader> attachmentReader,
117  std::chrono::milliseconds offsetAdjustment,
118  const avsCommon::utils::AudioFormat* format = nullptr,
119  const SourceConfig& config = emptySourceConfig()) = 0;
120 
139  virtual SourceId setSource(
140  const std::string& url,
141  std::chrono::milliseconds offset = std::chrono::milliseconds::zero(),
142  const SourceConfig& config = emptySourceConfig(),
143  bool repeat = false,
144  const PlaybackContext& playbackContext = PlaybackContext()) = 0;
145 
163  virtual SourceId setSource(
164  std::shared_ptr<std::istream> stream,
165  bool repeat = false,
166  const SourceConfig& config = emptySourceConfig(),
168 
189  virtual bool play(SourceId id) = 0;
190 
206  virtual bool stop(SourceId id) = 0;
207 
229  virtual bool stop(SourceId id, std::chrono::seconds timeToPipelineShutdown) {
230  return false;
231  }
232 
256  virtual bool pause(SourceId id) = 0;
257 
278  virtual bool resume(SourceId id) = 0;
279 
296  virtual bool seekTo(SourceId id, std::chrono::milliseconds location, bool fromStart) {
297  return false;
298  }
299 
310  virtual std::chrono::milliseconds getOffset(SourceId id) = 0;
311 
317  virtual uint64_t getNumBytesBuffered() = 0;
318 
329 
335  virtual void addObserver(
336  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface> playerObserver) = 0;
337 
343  virtual void removeObserver(
344  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface> playerObserver) = 0;
345 
354 
362  virtual std::vector<PlaybackReport> getPlaybackReports();
363 
370 };
371 
374 }
375 
376 inline std::vector<PlaybackReport> MediaPlayerInterface::getPlaybackReports() {
377  return {};
378 }
379 
382 }
383 
384 } // namespace mediaPlayer
385 } // namespace utils
386 } // namespace avsCommon
387 } // namespace alexaClientSDK
388 
389 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_MEDIAPLAYERINTERFACE_H_
virtual void removeObserver(std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface > playerObserver)=0
SourceConfig emptySourceConfig()
Definition: SourceConfig.h:98
virtual utils::Optional< Fingerprint > getFingerprint()
Definition: MediaPlayerInterface.h:380
virtual bool seekTo(SourceId id, std::chrono::milliseconds location, bool fromStart)
Definition: MediaPlayerInterface.h:296
virtual utils::Optional< avsCommon::utils::mediaPlayer::MediaPlayerState > getMediaPlayerState(SourceId id)=0
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
::std::string string
Definition: gtest-port.h:1097
virtual std::vector< PlaybackReport > getPlaybackReports()
Definition: MediaPlayerInterface.h:376
static const std::chrono::milliseconds MEDIA_PLAYER_INVALID_OFFSET
Represents offset returned when MediaPlayer is in an invalid state.
Definition: MediaPlayerInterface.h:42
MediaType
Definition: MediaType.h:29
virtual SourceId setSource(std::shared_ptr< avsCommon::avs::attachment::AttachmentReader > attachmentReader, const avsCommon::utils::AudioFormat *format=nullptr, const SourceConfig &config=emptySourceConfig())=0
virtual std::chrono::milliseconds getOffset(SourceId id)=0
static const SourceId ERROR
An SourceId used to represent an error from calls to setSource().
Definition: MediaPlayerInterface.h:72
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
virtual bool stop(SourceId id, std::chrono::seconds timeToPipelineShutdown)
Definition: MediaPlayerInterface.h:229
virtual void addObserver(std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface > playerObserver)=0
virtual utils::Optional< PlaybackAttributes > getPlaybackAttributes()
Definition: MediaPlayerInterface.h:372

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