AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MediaPlayerObserverInterface.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_MEDIAPLAYEROBSERVERINTERFACE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_MEDIAPLAYEROBSERVERINTERFACE_H_
18 
19 #include <string>
20 #include <vector>
21 #include <memory>
22 
24 
25 #include "MediaPlayerInterface.h"
26 #include "MediaPlayerState.h"
27 
28 namespace alexaClientSDK {
29 namespace avsCommon {
30 namespace utils {
31 namespace mediaPlayer {
32 
47 public:
50 
52  enum class TagType { STRING, UINT, INT, DOUBLE, BOOLEAN };
53 
57  struct TagKeyValueType {
64  };
65 
66  typedef std::vector<TagKeyValueType> VectorOfTags;
67 
71  virtual ~MediaPlayerObserverInterface() = default;
72 
79  virtual void onFirstByteRead(SourceId id, const MediaPlayerState& state) = 0;
80 
91  virtual void onPlaybackStarted(SourceId id, const MediaPlayerState& state) = 0;
92 
102  virtual void onPlaybackFinished(SourceId id, const MediaPlayerState& state) = 0;
103 
116  virtual void onPlaybackError(
117  SourceId id,
118  const ErrorType& type,
119  std::string error,
120  const MediaPlayerState& state) = 0;
121 
131  virtual void onPlaybackPaused(SourceId, const MediaPlayerState&){};
132 
142  virtual void onPlaybackResumed(SourceId, const MediaPlayerState&){};
143 
153  virtual void onPlaybackStopped(SourceId, const MediaPlayerState&){};
154 
166  }
167 
179  }
180 
194  }
195 
208  virtual void onSeeked(SourceId, const MediaPlayerState&, const MediaPlayerState&) {
209  }
210 
224  virtual void onTags(SourceId, std::unique_ptr<const VectorOfTags>, const MediaPlayerState&){};
225 };
226 
234 inline std::ostream& operator<<(std::ostream& stream, const MediaPlayerState& state) {
235  stream << "MediaPlayerState: offsetInMilliseconds=" << state.offset.count();
236  if (state.mediaPlayerProtection.hasValue()) {
237  stream << "," << state.mediaPlayerProtection.value();
238  }
239  if (state.playlistType.hasValue()) {
240  stream << "," << state.playlistType.value();
241  }
242  return stream;
243 }
244 
245 } // namespace mediaPlayer
246 } // namespace utils
247 } // namespace avsCommon
248 } // namespace alexaClientSDK
249 
250 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_MEDIAPLAYEROBSERVERINTERFACE_H_
virtual void onPlaybackStopped(SourceId, const MediaPlayerState &)
Definition: MediaPlayerObserverInterface.h:153
std::string value
Value extracted from the stream tag.
Definition: MediaPlayerObserverInterface.h:61
virtual void onSeeked(SourceId, const MediaPlayerState &, const MediaPlayerState &)
Definition: MediaPlayerObserverInterface.h:208
virtual void onFirstByteRead(SourceId id, const MediaPlayerState &state)=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 void onPlaybackError(SourceId id, const ErrorType &type, std::string error, const MediaPlayerState &state)=0
Optional< std::string > playlistType
Definition: MediaPlayerState.h:130
virtual void onPlaybackFinished(SourceId id, const MediaPlayerState &state)=0
std::vector< TagKeyValueType > VectorOfTags
Definition: MediaPlayerObserverInterface.h:66
MediaPlayerObserverInterface::TagType type
Type of the stream tag.
Definition: MediaPlayerObserverInterface.h:63
bool hasValue() const
Definition: Optional.h:203
virtual void onPlaybackStarted(SourceId id, const MediaPlayerState &state)=0
TagType
The different types of metadata "stream tags".
Definition: MediaPlayerObserverInterface.h:52
MediaPlayerInterface::SourceId SourceId
A type that identifies which source is currently being operated on.
Definition: MediaPlayerObserverInterface.h:49
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
virtual void onBufferingComplete(SourceId, const MediaPlayerState &)
Definition: MediaPlayerObserverInterface.h:193
virtual void onBufferRefilled(SourceId, const MediaPlayerState &)
Definition: MediaPlayerObserverInterface.h:178
std::string key
Key extracted from the stream tag.
Definition: MediaPlayerObserverInterface.h:59
virtual void onTags(SourceId, std::unique_ptr< const VectorOfTags >, const MediaPlayerState &)
Definition: MediaPlayerObserverInterface.h:224
type
Definition: upload.py:443
virtual void onBufferUnderrun(SourceId, const MediaPlayerState &)
Definition: MediaPlayerObserverInterface.h:165
ErrorType
Identifies the specific type of error in a PlaybackFailed event.
Definition: ErrorTypes.h:28
virtual void onPlaybackResumed(SourceId, const MediaPlayerState &)
Definition: MediaPlayerObserverInterface.h:142
ValueT value() const
Definition: Optional.h:208
std::chrono::milliseconds offset
Offset in milliseconds.
Definition: MediaPlayerState.h:118
Optional< MediaPlayerProtection > mediaPlayerProtection
Optional: MediaPlayerProtection information.
Definition: MediaPlayerState.h:124
std::ostream & operator<<(std::ostream &stream, const ErrorType &errorType)
Definition: ErrorTypes.h:158
virtual void onPlaybackPaused(SourceId, const MediaPlayerState &)
Definition: MediaPlayerObserverInterface.h:131

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