Music Hub  ..
A session-wide music playback service
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
engine.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef CORE_UBUNTU_MEDIA_ENGINE_H_
19 #define CORE_UBUNTU_MEDIA_ENGINE_H_
20 
21 #include <core/media/player.h>
22 #include <core/media/track.h>
23 
24 #include <core/property.h>
25 
26 #include <chrono>
27 
28 namespace core
29 {
30 namespace ubuntu
31 {
32 namespace media
33 {
34 class Engine
35 {
36 public:
37 
38  enum class State
39  {
40  ready,
41  busy,
42  playing,
43  paused,
44  stopped
45  };
46 
47  struct Xesam
48  {
49  static const std::string& album();
50  static const std::string& album_artist();
51  static const std::string& artist();
52  static const std::string& as_text();
53  static const std::string& audio_bpm();
54  static const std::string& auto_rating();
55  static const std::string& comment();
56  static const std::string& composer();
57  static const std::string& content_created();
58  static const std::string& disc_number();
59  static const std::string& first_used();
60  static const std::string& genre();
61  static const std::string& last_used();
62  static const std::string& lyricist();
63  static const std::string& title();
64  static const std::string& track_number();
65  static const std::string& url();
66  static const std::string& use_count();
67  static const std::string& user_rating();
68  };
69 
70  struct Volume
71  {
72  static double min();
73  static double max();
74 
75  explicit Volume(double v = max());
76 
77  bool operator!=(const Volume& rhs) const;
78  bool operator==(const Volume& rhs) const;
79 
80  double value;
81  };
82 
84  {
85  public:
87 
88  protected:
89  MetaDataExtractor() = default;
90  MetaDataExtractor(const MetaDataExtractor&) = delete;
91  virtual ~MetaDataExtractor() = default;
92 
94  };
95 
96  virtual const std::shared_ptr<MetaDataExtractor>& meta_data_extractor() const = 0;
97 
98  virtual const core::Property<State>& state() const = 0;
99 
100  virtual bool open_resource_for_uri(const Track::UriType& uri) = 0;
101  virtual void create_video_sink(uint32_t texture_id) = 0;
102 
103  virtual bool play() = 0;
104  virtual bool stop() = 0;
105  virtual bool pause() = 0;
106  virtual bool seek_to(const std::chrono::microseconds& ts) = 0;
107 
108  virtual const core::Property<bool>& is_video_source() const = 0;
109  virtual const core::Property<bool>& is_audio_source() const = 0;
110 
111  virtual const core::Property<uint64_t>& position() const = 0;
112  virtual const core::Property<uint64_t>& duration() const = 0;
113 
114  virtual const core::Property<Volume>& volume() const = 0;
115  virtual core::Property<Volume>& volume() = 0;
116 
117  virtual const core::Property<std::tuple<Track::UriType, Track::MetaData>>& track_meta_data() const = 0;
118 
119  virtual const core::Signal<void>& about_to_finish_signal() const = 0;
120  virtual const core::Signal<uint64_t>& seeked_to_signal() const = 0;
121  virtual const core::Signal<void>& end_of_stream_signal() const = 0;
122  virtual const core::Signal<core::ubuntu::media::Player::PlaybackStatus>& playback_status_changed_signal() const = 0;
123 };
124 }
125 }
126 }
127 
128 #endif // CORE_UBUNTU_MEDIA_ENGINE_H_
static const std::string & lyricist()
Definition: engine.cpp:104
virtual const core::Property< State > & state() const =0
static const std::string & comment()
Definition: engine.cpp:62
static const std::string & track_number()
Definition: engine.cpp:116
static const std::string & use_count()
Definition: engine.cpp:128
static const std::string & auto_rating()
Definition: engine.cpp:56
MetaDataExtractor & operator=(const MetaDataExtractor &)=delete
virtual const core::Signal< uint64_t > & seeked_to_signal() const =0
virtual void create_video_sink(uint32_t texture_id)=0
static const std::string & audio_bpm()
Definition: engine.cpp:50
bool operator!=(const Volume &rhs) const
Definition: engine.cpp:156
virtual const core::Property< uint64_t > & duration() const =0
virtual const core::Signal< core::ubuntu::media::Player::PlaybackStatus > & playback_status_changed_signal() const =0
static const std::string & as_text()
Definition: engine.cpp:44
virtual bool open_resource_for_uri(const Track::UriType &uri)=0
virtual const std::shared_ptr< MetaDataExtractor > & meta_data_extractor() const =0
virtual const core::Property< bool > & is_audio_source() const =0
virtual const core::Property< std::tuple< Track::UriType, Track::MetaData > > & track_meta_data() const =0
virtual bool seek_to(const std::chrono::microseconds &ts)=0
virtual const core::Signal< void > & end_of_stream_signal() const =0
static const std::string & genre()
Definition: engine.cpp:92
static const std::string & title()
Definition: engine.cpp:110
static const std::string & artist()
Definition: engine.cpp:38
static const std::string & content_created()
Definition: engine.cpp:74
static const std::string & first_used()
Definition: engine.cpp:86
virtual Track::MetaData meta_data_for_track_with_uri(const Track::UriType &uri)=0
static const std::string & last_used()
Definition: engine.cpp:98
static const std::string & user_rating()
Definition: engine.cpp:134
static const std::string & album_artist()
Definition: engine.cpp:32
virtual const core::Signal< void > & about_to_finish_signal() const =0
std::string UriType
Definition: track.h:40
virtual const core::Property< uint64_t > & position() const =0
static const std::string & album()
Definition: engine.cpp:26
virtual const core::Property< Volume > & volume() const =0
static const std::string & composer()
Definition: engine.cpp:68
static const std::string & disc_number()
Definition: engine.cpp:80
static const std::string & url()
Definition: engine.cpp:122
bool operator==(const Volume &rhs) const
Definition: engine.cpp:161
virtual const core::Property< bool > & is_video_source() const =0