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 
47  typedef void (*FrameAvailableCbHybris)(GLConsumerWrapperHybris wrapper, void *context);
48  typedef void (*FrameAvailableCb)(void *context);
49  typedef void (*PlaybackCompleteCb)(void *context);
50 
51  struct Configuration;
52 
53  struct Client
54  {
55  Client() = delete;
56 
57  static const Configuration& default_configuration();
58  };
59 
61  {
67  };
68 
70  {
74  };
75 
82  {
87  };
88 
89  Player(const Player&) = delete;
90  virtual ~Player();
91 
92  Player& operator=(const Player&) = delete;
93  bool operator==(const Player&) const = delete;
94 
95  virtual std::shared_ptr<TrackList> track_list() = 0;
96  virtual PlayerKey key() const = 0;
97 
98  virtual bool open_uri(const Track::UriType& uri) = 0;
99  virtual void create_video_sink(uint32_t texture_id) = 0;
100  virtual GLConsumerWrapperHybris gl_consumer() const = 0;
101  virtual void next() = 0;
102  virtual void previous() = 0;
103  virtual void play() = 0;
104  virtual void pause() = 0;
105  virtual void stop() = 0;
106  virtual void seek_to(const std::chrono::microseconds& offset) = 0;
107 
108  // TODO: Convert this to be a signal
109  virtual void set_frame_available_callback(FrameAvailableCb cb, void *context) = 0;
110  virtual void set_playback_complete_callback(PlaybackCompleteCb cb, void *context) = 0;
111 
112  virtual const core::Property<bool>& can_play() const = 0;
113  virtual const core::Property<bool>& can_pause() const = 0;
114  virtual const core::Property<bool>& can_seek() const = 0;
115  virtual const core::Property<bool>& can_go_previous() const = 0;
116  virtual const core::Property<bool>& can_go_next() const = 0;
117  virtual const core::Property<bool>& is_video_source() const = 0;
118  virtual const core::Property<bool>& is_audio_source() const = 0;
119  virtual const core::Property<PlaybackStatus>& playback_status() const = 0;
120  virtual const core::Property<LoopStatus>& loop_status() const = 0;
121  virtual const core::Property<PlaybackRate>& playback_rate() const = 0;
122  virtual const core::Property<bool>& is_shuffle() const = 0;
123  virtual const core::Property<Track::MetaData>& meta_data_for_current_track() const = 0;
124  virtual const core::Property<Volume>& volume() const = 0;
125  virtual const core::Property<PlaybackRate>& minimum_playback_rate() const = 0;
126  virtual const core::Property<PlaybackRate>& maximum_playback_rate() const = 0;
127  virtual const core::Property<int64_t>& position() const = 0;
128  virtual const core::Property<int64_t>& duration() const = 0;
129  virtual const core::Property<AudioStreamRole>& audio_stream_role() const = 0;
130 
131  virtual core::Property<LoopStatus>& loop_status() = 0;
132  virtual core::Property<PlaybackRate>& playback_rate() = 0;
133  virtual core::Property<bool>& is_shuffle() = 0;
134  virtual core::Property<Volume>& volume() = 0;
135  virtual core::Property<AudioStreamRole>& audio_stream_role() = 0;
136 
137  virtual const core::Signal<int64_t>& seeked_to() const = 0;
138  virtual const core::Signal<void>& end_of_stream() const = 0;
139  virtual core::Signal<PlaybackStatus>& playback_status_changed() = 0;
140  protected:
141  Player();
142 
143 };
144 }
145 }
146 }
147 
148 #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
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:48
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:49
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
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::Property< LoopStatus > & loop_status() const =0
virtual std::shared_ptr< TrackList > track_list()=0
void(* FrameAvailableCbHybris)(GLConsumerWrapperHybris wrapper, void *context)
Definition: player.h:47
virtual void seek_to(const std::chrono::microseconds &offset)=0