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  no_media,
42  ready,
43  busy,
44  playing,
45  paused,
46  stopped
47  };
48 
49  struct Volume
50  {
51  static double min();
52  static double max();
53 
54  explicit Volume(double v = max());
55 
56  bool operator!=(const Volume& rhs) const;
57  bool operator==(const Volume& rhs) const;
58 
59  double value;
60  };
61 
63  {
64  public:
65  virtual Track::MetaData meta_data_for_track_with_uri(const Track::UriType& uri) = 0;
66 
67  protected:
68  MetaDataExtractor() = default;
69  MetaDataExtractor(const MetaDataExtractor&) = delete;
70  virtual ~MetaDataExtractor() = default;
71 
72  MetaDataExtractor& operator=(const MetaDataExtractor&) = delete;
73  };
74 
75  virtual const std::shared_ptr<MetaDataExtractor>& meta_data_extractor() const = 0;
76 
77  virtual const core::Property<State>& state() const = 0;
78 
79  virtual bool open_resource_for_uri(const core::ubuntu::media::Track::UriType& uri, bool do_pipeline_reset) = 0;
81  // Throws core::ubuntu::media::Player::Error::OutOfProcessBufferStreamingNotSupported if the implementation does not
82  // support this feature.
83  virtual void create_video_sink(uint32_t texture_id) = 0;
84 
85  virtual bool play(bool use_main_context = false) = 0;
86  virtual bool stop(bool use_main_context = false) = 0;
87  virtual bool pause() = 0;
88  virtual bool seek_to(const std::chrono::microseconds& ts) = 0;
89 
90  virtual const core::Property<bool>& is_video_source() const = 0;
91  virtual const core::Property<bool>& is_audio_source() const = 0;
92 
93  virtual const core::Property<uint64_t>& position() const = 0;
94  virtual const core::Property<uint64_t>& duration() const = 0;
95 
96  virtual const core::Property<Volume>& volume() const = 0;
97  virtual core::Property<Volume>& volume() = 0;
98 
99  virtual const core::Property<core::ubuntu::media::Player::AudioStreamRole>& audio_stream_role() const = 0;
100  virtual core::Property<core::ubuntu::media::Player::AudioStreamRole>& audio_stream_role() = 0;
101 
102  virtual const core::Property<core::ubuntu::media::Player::Orientation>& orientation() const = 0;
103 
104  virtual const core::Property<core::ubuntu::media::Player::Lifetime>& lifetime() const = 0;
105  virtual core::Property<core::ubuntu::media::Player::Lifetime>& lifetime() = 0;
106 
107  virtual const core::Property<std::tuple<Track::UriType, Track::MetaData>>& track_meta_data() const = 0;
108 
109  virtual const core::Signal<void>& about_to_finish_signal() const = 0;
110  virtual const core::Signal<uint64_t>& seeked_to_signal() const = 0;
111  virtual const core::Signal<void>& client_disconnected_signal() const = 0;
112  virtual const core::Signal<void>& end_of_stream_signal() const = 0;
113  virtual const core::Signal<core::ubuntu::media::Player::PlaybackStatus>& playback_status_changed_signal() const = 0;
114  virtual const core::Signal<video::Dimensions>& video_dimension_changed_signal() const = 0;
115  virtual const core::Signal<core::ubuntu::media::Player::Error>& error_signal() const = 0;
116  virtual const core::Signal<int>& on_buffering_changed_signal() const = 0;
117 
118  virtual void reset() = 0;
119 };
120 }
121 }
122 }
123 
124 #endif // CORE_UBUNTU_MEDIA_ENGINE_H_
virtual const core::Property< core::ubuntu::media::Player::Lifetime > & lifetime() const =0
virtual bool play(bool use_main_context=false)=0
virtual const core::Property< State > & state() const =0
bool operator!=(IntWrapper< Tag, IntegerType > const &lhs, IntWrapper< Tag, IntegerType > const &rhs)
Definition: dimensions.h:103
virtual const core::Signal< int > & on_buffering_changed_signal() const =0
bool operator==(IntWrapper< Tag, IntegerType > const &lhs, IntWrapper< Tag, IntegerType > const &rhs)
Definition: dimensions.h:97
Definition: player.h:33
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
virtual const core::Property< uint64_t > & duration() const =0
std::map< std::string, std::string > HeadersType
Definition: player.h:64
virtual const core::Signal< core::ubuntu::media::Player::PlaybackStatus > & playback_status_changed_signal() const =0
virtual const core::Signal< video::Dimensions > & video_dimension_changed_signal() const =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 bool open_resource_for_uri(const core::ubuntu::media::Track::UriType &uri, bool do_pipeline_reset)=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 bool stop(bool use_main_context=false)=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
virtual const core::Signal< void > & client_disconnected_signal() const =0
virtual const core::Property< bool > & is_video_source() const =0