Music Hub  ..
A session-wide music playback service
output_observer.h
Go to the documentation of this file.
1 /*
2  * Copyright © 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  */
18 #ifndef CORE_UBUNTU_MEDIA_AUDIO_OUTPUT_OBSERVER_H_
19 #define CORE_UBUNTU_MEDIA_AUDIO_OUTPUT_OBSERVER_H_
20 
21 #include <core/property.h>
22 
23 #include <iosfwd>
24 #include <memory>
25 
26 namespace core
27 {
28 namespace ubuntu
29 {
30 namespace media
31 {
32 namespace audio
33 {
34 // All known states of an audio output.
35 enum class OutputState
36 {
37  // The output is via a private earpiece (i.e. headphones, headset)
38  Earpiece,
39  // The output is via the internal speaker.
40  Speaker,
41  // The output is via an external device (a2dp, etc)
42  External,
43 };
44 
45 // Models observation of audio outputs of a device.
46 // Right now, we are only interested in monitoring the
47 // state of external outputs to react accordingly if
48 // wired or bluetooth outputs are connected/disconnected.
50 {
51 public:
52  // Save us some typing.
53  typedef std::shared_ptr<OutputObserver> Ptr;
54 
55  virtual ~OutputObserver() = default;
56 
57  // Getable/observable property holding the state of external outputs.
58  virtual const core::Property<OutputState>& external_output_state() const = 0;
59 
60 protected:
61  OutputObserver() = default;
62  OutputObserver(const OutputObserver&) = delete;
63  OutputObserver& operator=(const OutputObserver&) = delete;
64 };
65 
66 // Pretty prints the given state to the given output stream.
67 std::ostream& operator<<(std::ostream&, OutputState);
68 
69 // Creats a platform default instance for observing audio outputs.
71 }
72 }
73 }
74 }
75 
76 #endif // CORE_UBUNTU_MEDIA_AUDIO_OUTPUT_OBSERVER_H_
Definition: player.h:33
std::ostream & operator<<(std::ostream &, OutputState)
std::shared_ptr< OutputObserver > Ptr
OutputObserver::Ptr make_platform_default_output_observer()