Music Hub  ..
A session-wide music playback service
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
player.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  * Jim Hodapp <jim.hodapp@canonical.com>
18  */
19 #ifndef CORE_UBUNTU_MEDIA_PLAYER_H_
20 #define CORE_UBUNTU_MEDIA_PLAYER_H_
21 
22 #include <core/media/track.h>
23 
24 #include <core/property.h>
25 
26 #include <chrono>
27 #include <memory>
28 
29 namespace core
30 {
31 namespace ubuntu
32 {
33 namespace media
34 {
35 class Service;
36 class TrackList;
37 
38 class Player : public std::enable_shared_from_this<Player>
39 {
40  public:
41  typedef double PlaybackRate;
42  typedef double Volume;
43  typedef uint32_t PlayerKey;
44  typedef void* GLConsumerWrapperHybris;
45  typedef std::map<std::string, std::string> HeadersType;
46 
48  typedef void (*FrameAvailableCbHybris)(GLConsumerWrapperHybris wrapper, void *context);
49  typedef void (*FrameAvailableCb)(void *context);
50  typedef void (*PlaybackCompleteCb)(void *context);
51 
52  struct Configuration;
53 
54  struct Client
55  {
56  Client() = delete;
57 
58  static const Configuration& default_configuration();
59  };
60 
62  {
68  };
69 
71  {
75  };
76 
83  {
88  };
89 
91  {
96  };
97 
98  enum Lifetime
99  {
102  };
103 
104  Player(const Player&) = delete;
105  virtual ~Player();
106 
107  Player& operator=(const Player&) = delete;
108  bool operator==(const Player&) const = delete;
109 
110  virtual std::shared_ptr<TrackList> track_list() = 0;
111  virtual PlayerKey key() const = 0;
112 
113  virtual bool open_uri(const Track::UriType& uri) = 0;
114  virtual bool open_uri(const Track::UriType& uri, const HeadersType&) = 0;
115  virtual void create_video_sink(uint32_t texture_id) = 0;
116  virtual GLConsumerWrapperHybris gl_consumer() const = 0;
117  virtual void next() = 0;
118  virtual void previous() = 0;
119  virtual void play() = 0;
120  virtual void pause() = 0;
121  virtual void stop() = 0;
122  virtual void seek_to(const std::chrono::microseconds& offset) = 0;
123 
124  // TODO: Convert this to be a signal
125  virtual void set_frame_available_callback(FrameAvailableCb cb, void *context) = 0;
126  virtual void set_playback_complete_callback(PlaybackCompleteCb cb, void *context) = 0;
127 
128  virtual const core::Property<bool>& can_play() const = 0;
129  virtual const core::Property<bool>& can_pause() const = 0;
130  virtual const core::Property<bool>& can_seek() const = 0;
131  virtual const core::Property<bool>& can_go_previous() const = 0;
132  virtual const core::Property<bool>& can_go_next() const = 0;
133  virtual const core::Property<bool>& is_video_source() const = 0;
134  virtual const core::Property<bool>& is_audio_source() const = 0;
135  virtual const core::Property<PlaybackStatus>& playback_status() const = 0;
136  virtual const core::Property<LoopStatus>& loop_status() const = 0;
137  virtual const core::Property<PlaybackRate>& playback_rate() const = 0;
138  virtual const core::Property<bool>& is_shuffle() const = 0;
139  virtual const core::Property<Track::MetaData>& meta_data_for_current_track() const = 0;
140  virtual const core::Property<Volume>& volume() const = 0;
141  virtual const core::Property<PlaybackRate>& minimum_playback_rate() const = 0;
142  virtual const core::Property<PlaybackRate>& maximum_playback_rate() const = 0;
143  virtual const core::Property<int64_t>& position() const = 0;
144  virtual const core::Property<int64_t>& duration() const = 0;
145  virtual const core::Property<AudioStreamRole>& audio_stream_role() const = 0;
146  virtual const core::Property<Orientation>& orientation() const = 0;
147  virtual const core::Property<Lifetime>& lifetime() const = 0;
148 
149  virtual core::Property<LoopStatus>& loop_status() = 0;
150  virtual core::Property<PlaybackRate>& playback_rate() = 0;
151  virtual core::Property<bool>& is_shuffle() = 0;
152  virtual core::Property<Volume>& volume() = 0;
153  virtual core::Property<AudioStreamRole>& audio_stream_role() = 0;
154  virtual core::Property<Lifetime>& lifetime() = 0;
155 
156  virtual const core::Signal<int64_t>& seeked_to() const = 0;
157  virtual const core::Signal<void>& end_of_stream() const = 0;
158  virtual core::Signal<PlaybackStatus>& playback_status_changed() = 0;
163  virtual const core::Signal<uint64_t>& video_dimension_changed() const = 0;
164  protected:
165  Player();
166 
167 };
168 }
169 }
170 }
171 
172 #endif // CORE_UBUNTU_MEDIA_PLAYER_H_
virtual const core::Property< PlaybackStatus > & playback_status() const =0
void * GLConsumerWrapperHybris
Definition: player.h:44
virtual const core::Property< int64_t > & position() const =0
virtual const core::Property< bool > & is_video_source() const =0
virtual const core::Property< bool > & can_play() const =0
bool operator==(const Player &) const =delete
virtual const core::Property< bool > & can_seek() const =0
virtual const core::Property< Track::MetaData > & meta_data_for_current_track() const =0
virtual void previous()=0
virtual const core::Property< int64_t > & duration() const =0
Definition: player.h:29
virtual const core::Property< bool > & can_go_previous() const =0
virtual core::Signal< PlaybackStatus > & playback_status_changed()=0
std::map< std::string, std::string > HeadersType
Definition: player.h:45
virtual const core::Property< bool > & is_audio_source() const =0
virtual const core::Property< PlaybackRate > & playback_rate() const =0
Player & operator=(const Player &)=delete
virtual const core::Property< Volume > & volume() const =0
void(* FrameAvailableCb)(void *context)
Definition: player.h:49
virtual bool open_uri(const Track::UriType &uri)=0
virtual const core::Property< bool > & can_pause() const =0
virtual void create_video_sink(uint32_t texture_id)=0
virtual void set_playback_complete_callback(PlaybackCompleteCb cb, void *context)=0
virtual const core::Property< bool > & can_go_next() const =0
static const Configuration & default_configuration()
Definition: player.cpp:25
void(* PlaybackCompleteCb)(void *context)
Definition: player.h:50
virtual const core::Signal< void > & end_of_stream() const =0
virtual void set_frame_available_callback(FrameAvailableCb cb, void *context)=0
virtual GLConsumerWrapperHybris gl_consumer() const =0
virtual const core::Property< bool > & is_shuffle() const =0
virtual const core::Property< PlaybackRate > & maximum_playback_rate() const =0
virtual const core::Property< Lifetime > & lifetime() const =0
std::string UriType
Definition: track.h:40
virtual PlayerKey key() const =0
virtual const core::Property< AudioStreamRole > & audio_stream_role() const =0
virtual const core::Property< PlaybackRate > & minimum_playback_rate() const =0
virtual const core::Signal< int64_t > & seeked_to() const =0
virtual const core::Signal< uint64_t > & video_dimension_changed() const =0
virtual const core::Property< LoopStatus > & loop_status() const =0
virtual const core::Property< Orientation > & orientation() const =0
virtual std::shared_ptr< TrackList > track_list()=0
void(* FrameAvailableCbHybris)(GLConsumerWrapperHybris wrapper, void *context)
Definition: player.h:48
virtual void seek_to(const std::chrono::microseconds &offset)=0