Music Hub  ..
A session-wide music playback service
engine.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013-2014 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  * Jim Hodapp <jim.hodapp@canonical.com>
18  */
19 #ifndef CORE_UBUNTU_MEDIA_ENGINE_H_
20 #define CORE_UBUNTU_MEDIA_ENGINE_H_
21 
22 #include <core/media/player.h>
23 #include <core/media/track.h>
24 
25 #include <core/property.h>
26 
27 #include <chrono>
28 
29 namespace core
30 {
31 namespace ubuntu
32 {
33 namespace media
34 {
35 class Engine
36 {
37 public:
38 
39  enum class State
40  {
41  ready,
42  busy,
43  playing,
44  paused,
45  stopped
46  };
47 
48  struct Volume
49  {
50  static double min();
51  static double max();
52 
53  explicit Volume(double v = max());
54 
55  bool operator!=(const Volume& rhs) const;
56  bool operator==(const Volume& rhs) const;
57 
58  double value;
59  };
60 
62  {
63  public:
65 
66  protected:
67  MetaDataExtractor() = default;
68  MetaDataExtractor(const MetaDataExtractor&) = delete;
69  virtual ~MetaDataExtractor() = default;
70 
72  };
73 
74  virtual const std::shared_ptr<MetaDataExtractor>& meta_data_extractor() const = 0;
75 
76  virtual const core::Property<State>& state() const = 0;
77 
78  virtual bool open_resource_for_uri(const Track::UriType& uri) = 0;
80  virtual void create_video_sink(uint32_t texture_id) = 0;
81 
82  virtual bool play() = 0;
83  virtual bool stop() = 0;
84  virtual bool pause() = 0;
85  virtual bool seek_to(const std::chrono::microseconds& ts) = 0;
86 
87  virtual const core::Property<bool>& is_video_source() const = 0;
88  virtual const core::Property<bool>& is_audio_source() const = 0;
89 
90  virtual const core::Property<uint64_t>& position() const = 0;
91  virtual const core::Property<uint64_t>& duration() const = 0;
92 
93  virtual const core::Property<Volume>& volume() const = 0;
94  virtual core::Property<Volume>& volume() = 0;
95 
96  virtual const core::Property<core::ubuntu::media::Player::AudioStreamRole>& audio_stream_role() const = 0;
97  virtual core::Property<core::ubuntu::media::Player::AudioStreamRole>& audio_stream_role() = 0;
98 
99  virtual const core::Property<core::ubuntu::media::Player::Orientation>& orientation() const = 0;
100 
101  virtual const core::Property<core::ubuntu::media::Player::Lifetime>& lifetime() const = 0;
102  virtual core::Property<core::ubuntu::media::Player::Lifetime>& lifetime() = 0;
103 
104  virtual const core::Property<std::tuple<Track::UriType, Track::MetaData>>& track_meta_data() const = 0;
105 
106  virtual const core::Signal<void>& about_to_finish_signal() const = 0;
107  virtual const core::Signal<uint64_t>& seeked_to_signal() const = 0;
108  virtual const core::Signal<void>& client_disconnected_signal() const = 0;
109  virtual const core::Signal<void>& end_of_stream_signal() const = 0;
110  virtual const core::Signal<core::ubuntu::media::Player::PlaybackStatus>& playback_status_changed_signal() const = 0;
111  virtual const core::Signal<uint32_t, uint32_t>& video_dimension_changed_signal() const = 0;
112  virtual const core::Signal<core::ubuntu::media::Player::Error>& error_signal() const = 0;
113 
114  virtual void reset() = 0;
115 };
116 }
117 }
118 }
119 
120 #endif // CORE_UBUNTU_MEDIA_ENGINE_H_
virtual const core::Property< core::ubuntu::media::Player::Lifetime > & lifetime() const =0
virtual const core::Property< State > & state() const =0
Definition: player.h:29
MetaDataExtractor & operator=(const MetaDataExtractor &)=delete
virtual const core::Property< core::ubuntu::media::Player::AudioStreamRole > & audio_stream_role() const =0
virtual const core::Signal< uint64_t > & seeked_to_signal() const =0
virtual void create_video_sink(uint32_t texture_id)=0
bool operator!=(const Volume &rhs) const
Definition: engine.cpp:43
virtual const core::Property< uint64_t > & duration() const =0
std::map< std::string, std::string > HeadersType
Definition: player.h:45
virtual const core::Signal< core::ubuntu::media::Player::PlaybackStatus > & playback_status_changed_signal() const =0
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
virtual const core::Signal< uint32_t, uint32_t > & video_dimension_changed_signal() const =0
virtual Track::MetaData meta_data_for_track_with_uri(const Track::UriType &uri)=0
virtual const core::Signal< void > & about_to_finish_signal() const =0
std::string UriType
Definition: track.h:40
virtual const core::Signal< core::ubuntu::media::Player::Error > & error_signal() const =0
virtual const core::Property< uint64_t > & position() const =0
virtual const core::Property< core::ubuntu::media::Player::Orientation > & orientation() const =0
virtual const core::Property< Volume > & volume() const =0
bool operator==(const Volume &rhs) const
Definition: engine.cpp:48
virtual const core::Signal< void > & client_disconnected_signal() const =0
virtual const core::Property< bool > & is_video_source() const =0