Merge lp:~phablet-team/media-hub/add-logger into lp:media-hub
- add-logger
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Alfonso Sanchez-Beato |
Approved revision: | 194 |
Merged at revision: | 178 |
Proposed branch: | lp:~phablet-team/media-hub/add-logger |
Merge into: | lp:media-hub |
Prerequisite: | lp:~robru/media-hub/pre_release_hook |
Diff against target: |
2581 lines (+786/-269) 28 files modified
CMakeLists.txt (+1/-1) debian/control.in (+1/-0) include/core/media/player.h (+23/-0) src/core/media/CMakeLists.txt (+9/-0) src/core/media/apparmor/ubuntu.cpp (+7/-6) src/core/media/audio/pulse_audio_output_observer.cpp (+10/-8) src/core/media/gstreamer/engine.cpp (+30/-29) src/core/media/gstreamer/playbin.cpp (+39/-46) src/core/media/logger/logger.cpp (+161/-0) src/core/media/logger/logger.h (+131/-0) src/core/media/non_copyable.h (+36/-0) src/core/media/player_implementation.cpp (+39/-38) src/core/media/player_skeleton.cpp (+6/-4) src/core/media/player_stub.cpp (+10/-6) src/core/media/power/state_controller.cpp (+13/-13) src/core/media/server/server.cpp (+34/-0) src/core/media/service.cpp (+3/-1) src/core/media/service_implementation.cpp (+27/-26) src/core/media/service_skeleton.cpp (+20/-19) src/core/media/telephony/CMakeLists.txt (+1/-0) src/core/media/telephony/call_monitor.cpp (+9/-7) src/core/media/telephony/qtbridge.cpp (+0/-2) src/core/media/track_list_implementation.cpp (+25/-23) src/core/media/track_list_skeleton.cpp (+31/-32) src/core/media/track_list_stub.cpp (+9/-7) src/core/media/util/utils.cpp (+41/-0) src/core/media/util/utils.h (+69/-0) src/core/media/video/platform_default_sink.cpp (+1/-1) |
To merge this branch: | bzr merge lp:~phablet-team/media-hub/add-logger |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alfonso Sanchez-Beato | Approve | ||
Konrad Zapałowicz | code | Pending | |
Review via email:
|
This proposal supersedes a proposal from 2016-04-05.
Commit message
Add a proper logger to media-hub that includes traces, timestamps and other conveniences and no longer rely on cout/cerr.
Description of the change
Add a proper logger to media-hub that includes traces, timestamps and other conveniences and no longer rely on cout/cerr.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Konrad Zapałowicz (kzapalowicz) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : Posted in a previous version of this proposal | # |
I have some concerns with this MP:
* I do not really like moving to the printf way of doing things. Why should be drop type safeness? It would be better to use the boost logger more "natively" with "<<" operators, changing the wrapper class to something similar to what Qt does (qDebug() << message, etc.). Even more, using printf way in the end we need to resort to using stringstream in several places where it was not needed before.
* I still see cout and cerr being used in many places. But please do not change that yet until we have an agreement on how the class Logger should be used.
* I do not think we should introduce functions in the Utils namespace that we do not use. Specially taking into account that I would prefer to avoid using the only one that seems to be used, Sprintf :)
* Line sizes in new files are > 100 in many cases
There are also a couple of inline comments.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Hodapp (jhodapp) wrote : Posted in a previous version of this proposal | # |
> Not many issues compared to the length of the diff and frankly I'm mostly
> concerned about the own noncopyable class.
I am using this same logger which comes from aethercast. It relies on it's own noncopyable class, so just maintaing consistency. Really, this logger should be brought into a standard library for everyone to use, but that's out of the scope of this story.
>
> There is also one thing which is not bad however I would like to highlight it.
> I did not like the need to create stringstream in so many cases to log a line
> as basically this is repeating.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Hodapp (jhodapp) wrote : Posted in a previous version of this proposal | # |
> I have some concerns with this MP:
>
> * I do not really like moving to the printf way of doing things. Why should be
> drop type safeness? It would be better to use the boost logger more "natively"
> with "<<" operators, changing the wrapper class to something similar to what
> Qt does (qDebug() << message, etc.). Even more, using printf way in the end we
> need to resort to using stringstream in several places where it was not needed
> before.
Boost still maintains complete type safety with using the printf style. See the Boost::Log docs about this if you have any questions. This private Boost::Log interface implementation comes from tvoss and we're starting to standardize on it. Not sure why it doesn't use streams but that's outside anything I can really control without rewriting the private logger interface.
>
> * I still see cout and cerr being used in many places. But please do not
> change that yet until we have an agreement on how the class Logger should be
> used.
There are some that will need to remain, but otherwise I've made sure that all superfluous ones have now been removed.
>
> * I do not think we should introduce functions in the Utils namespace that we
> do not use. Specially taking into account that I would prefer to avoid using
> the only one that seems to be used, Sprintf :)
Fixed
>
> * Line sizes in new files are > 100 in many cases
I tried not to do that, any specific ones?
>
> There are also a couple of inline comments.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Hodapp (jhodapp) wrote : Posted in a previous version of this proposal | # |
Replied/addressed inline comments.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Konrad Zapałowicz (kzapalowicz) wrote : Posted in a previous version of this proposal | # |
Thanks for fixes & explanations, ack.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : Posted in a previous version of this proposal | # |
Thanks for the changes. LGTM, although I do not agree with how the Logger is designed. As discussed, we need to rethink it and come back to this when we do so.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alfonso Sanchez-Beato (alfonsosanchezbeato) : | # |
- 195. By Jim Hodapp
-
Make sure everything is licensed under LGPL v3
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-12-16 16:55:51 +0000 | |||
3 | +++ CMakeLists.txt 2016-04-07 00:39:05 +0000 | |||
4 | @@ -43,7 +43,7 @@ | |||
5 | 43 | include(GNUInstallDirs) | 43 | include(GNUInstallDirs) |
6 | 44 | 44 | ||
7 | 45 | find_package(PkgConfig) | 45 | find_package(PkgConfig) |
9 | 46 | find_package(Boost COMPONENTS filesystem system program_options REQUIRED) | 46 | find_package(Boost COMPONENTS filesystem log system thread program_options REQUIRED) |
10 | 47 | find_package(GLog) | 47 | find_package(GLog) |
11 | 48 | pkg_check_modules(DBUS dbus-1 REQUIRED) | 48 | pkg_check_modules(DBUS dbus-1 REQUIRED) |
12 | 49 | pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED) | 49 | pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED) |
13 | 50 | 50 | ||
14 | === modified file 'debian/control.in' | |||
15 | --- debian/control.in 2015-11-22 21:01:02 +0000 | |||
16 | +++ debian/control.in 2016-04-07 00:39:05 +0000 | |||
17 | @@ -12,6 +12,7 @@ | |||
18 | 12 | gstreamer1.0-plugins-good, | 12 | gstreamer1.0-plugins-good, |
19 | 13 | libboost-dev (>=1.53), | 13 | libboost-dev (>=1.53), |
20 | 14 | libboost-filesystem-dev (>=1.53), | 14 | libboost-filesystem-dev (>=1.53), |
21 | 15 | libboost-log-dev (>=1.53), | ||
22 | 15 | libboost-program-options-dev (>=1.53), | 16 | libboost-program-options-dev (>=1.53), |
23 | 16 | libboost-system-dev (>=1.53), | 17 | libboost-system-dev (>=1.53), |
24 | 17 | libdbus-1-dev, | 18 | libdbus-1-dev, |
25 | 18 | 19 | ||
26 | === modified file 'include/core/media/player.h' | |||
27 | --- include/core/media/player.h 2016-02-19 16:14:42 +0000 | |||
28 | +++ include/core/media/player.h 2016-04-07 00:39:05 +0000 | |||
29 | @@ -229,6 +229,29 @@ | |||
30 | 229 | return out; | 229 | return out; |
31 | 230 | } | 230 | } |
32 | 231 | 231 | ||
33 | 232 | inline std::ostream& operator<<(std::ostream& out, Player::Error e) | ||
34 | 233 | { | ||
35 | 234 | switch (e) | ||
36 | 235 | { | ||
37 | 236 | case Player::Error::no_error: | ||
38 | 237 | return out << "Error::no_error"; | ||
39 | 238 | case Player::Error::resource_error: | ||
40 | 239 | return out << "Error::resource_error"; | ||
41 | 240 | case Player::Error::format_error: | ||
42 | 241 | return out << "Error::format_error"; | ||
43 | 242 | case Player::Error::network_error: | ||
44 | 243 | return out << "Error::network_error"; | ||
45 | 244 | case Player::Error::access_denied_error: | ||
46 | 245 | return out << "Error::access_denied_error"; | ||
47 | 246 | case Player::Error::service_missing_error: | ||
48 | 247 | return out << "Error::service_missing_error"; | ||
49 | 248 | default: | ||
50 | 249 | return out << "Unsupported Player error: " << e; | ||
51 | 250 | } | ||
52 | 251 | |||
53 | 252 | return out; | ||
54 | 253 | } | ||
55 | 254 | |||
56 | 232 | } | 255 | } |
57 | 233 | } | 256 | } |
58 | 234 | } | 257 | } |
59 | 235 | 258 | ||
60 | === modified file 'src/core/media/CMakeLists.txt' | |||
61 | --- src/core/media/CMakeLists.txt 2015-09-04 18:46:08 +0000 | |||
62 | +++ src/core/media/CMakeLists.txt 2016-04-07 00:39:05 +0000 | |||
63 | @@ -18,6 +18,7 @@ | |||
64 | 18 | media-hub-common SHARED | 18 | media-hub-common SHARED |
65 | 19 | 19 | ||
66 | 20 | the_session_bus.cpp | 20 | the_session_bus.cpp |
67 | 21 | util/utils.cpp | ||
68 | 21 | ) | 22 | ) |
69 | 22 | 23 | ||
70 | 23 | target_link_libraries( | 24 | target_link_libraries( |
71 | @@ -42,6 +43,8 @@ | |||
72 | 42 | 43 | ||
73 | 43 | ${MEDIA_HUB_HEADERS} | 44 | ${MEDIA_HUB_HEADERS} |
74 | 44 | 45 | ||
75 | 46 | logger/logger.cpp | ||
76 | 47 | |||
77 | 45 | player.cpp | 48 | player.cpp |
78 | 46 | service.cpp | 49 | service.cpp |
79 | 47 | track.cpp | 50 | track.cpp |
80 | @@ -70,6 +73,8 @@ | |||
81 | 70 | 73 | ||
82 | 71 | media-hub-common | 74 | media-hub-common |
83 | 72 | 75 | ||
84 | 76 | ${Boost_LDFLAGS} | ||
85 | 77 | ${Boost_LIBRARIES} | ||
86 | 73 | ${DBUS_LIBRARIES} | 78 | ${DBUS_LIBRARIES} |
87 | 74 | ${DBUS_CPP_LDFLAGS} | 79 | ${DBUS_CPP_LDFLAGS} |
88 | 75 | ${GLog_LIBRARY} | 80 | ${GLog_LIBRARY} |
89 | @@ -87,6 +92,8 @@ | |||
90 | 87 | ${MEDIA_HUB_HEADERS} | 92 | ${MEDIA_HUB_HEADERS} |
91 | 88 | ${MPRIS_HEADERS} | 93 | ${MPRIS_HEADERS} |
92 | 89 | 94 | ||
93 | 95 | logger/logger.cpp | ||
94 | 96 | |||
95 | 90 | client_death_observer.cpp | 97 | client_death_observer.cpp |
96 | 91 | hashed_keyed_player_store.cpp | 98 | hashed_keyed_player_store.cpp |
97 | 92 | hybris_client_death_observer.cpp | 99 | hybris_client_death_observer.cpp |
98 | @@ -123,6 +130,8 @@ | |||
99 | 123 | media-hub-client | 130 | media-hub-client |
100 | 124 | media-hub-common | 131 | media-hub-common |
101 | 125 | call-monitor | 132 | call-monitor |
102 | 133 | ${Boost_LDFLAGS} | ||
103 | 134 | ${Boost_LIBRARIES} | ||
104 | 126 | ${DBUS_LIBRARIES} | 135 | ${DBUS_LIBRARIES} |
105 | 127 | ${DBUS_CPP_LDFLAGS} | 136 | ${DBUS_CPP_LDFLAGS} |
106 | 128 | ${GLog_LIBRARY} | 137 | ${GLog_LIBRARY} |
107 | 129 | 138 | ||
108 | === modified file 'src/core/media/apparmor/ubuntu.cpp' | |||
109 | --- src/core/media/apparmor/ubuntu.cpp 2016-02-23 14:17:04 +0000 | |||
110 | +++ src/core/media/apparmor/ubuntu.cpp 2016-04-07 00:39:05 +0000 | |||
111 | @@ -20,7 +20,8 @@ | |||
112 | 20 | 20 | ||
113 | 21 | #include <core/media/external_services.h> | 21 | #include <core/media/external_services.h> |
114 | 22 | 22 | ||
116 | 23 | #include <iostream> | 23 | #include "core/media/logger/logger.h" |
117 | 24 | |||
118 | 24 | #include <regex> | 25 | #include <regex> |
119 | 25 | 26 | ||
120 | 26 | namespace apparmor = core::ubuntu::media::apparmor; | 27 | namespace apparmor = core::ubuntu::media::apparmor; |
121 | @@ -107,9 +108,9 @@ | |||
122 | 107 | unity_{name == unity_name}, | 108 | unity_{name == unity_name}, |
123 | 108 | has_package_name_{process_context_name(str(), match_, pkg_name_)} | 109 | has_package_name_{process_context_name(str(), match_, pkg_name_)} |
124 | 109 | { | 110 | { |
128 | 110 | std::cout << "apparmor profile name: " << name; | 111 | MH_DEBUG("apparmor profile name: %s", name); |
129 | 111 | std::cout << ", is_unconfined(): " << is_unconfined(); | 112 | MH_DEBUG("is_unconfined(): %s", (is_unconfined() ? "true" : "false")); |
130 | 112 | std::cout << ", has_package_name(): " << has_package_name() << std::endl; | 113 | MH_DEBUG("has_package_name(): %s", (has_package_name() ? "true" : "false")); |
131 | 113 | if (not is_unconfined() and not is_unity() and not has_package_name()) | 114 | if (not is_unconfined() and not is_unity() and not has_package_name()) |
132 | 114 | throw std::logic_error | 115 | throw std::logic_error |
133 | 115 | { | 116 | { |
134 | @@ -163,8 +164,8 @@ | |||
135 | 163 | 164 | ||
136 | 164 | Uri parsed_uri = parse_uri(uri); | 165 | Uri parsed_uri = parse_uri(uri); |
137 | 165 | 166 | ||
140 | 166 | std::cout << "context.profile_name(): " << context.profile_name() << std::endl; | 167 | MH_DEBUG("context.profile_name(): %s", context.profile_name()); |
141 | 167 | std::cout << "parsed_uri.path: " << parsed_uri.path << std::endl; | 168 | MH_DEBUG("parsed_uri.path: %s", parsed_uri.path); |
142 | 168 | 169 | ||
143 | 169 | // All confined apps can access their own files | 170 | // All confined apps can access their own files |
144 | 170 | if (parsed_uri.path.find(std::string(".local/share/" + context.package_name() + "/")) != std::string::npos || | 171 | if (parsed_uri.path.find(std::string(".local/share/" + context.package_name() + "/")) != std::string::npos || |
145 | 171 | 172 | ||
146 | === modified file 'src/core/media/audio/pulse_audio_output_observer.cpp' | |||
147 | --- src/core/media/audio/pulse_audio_output_observer.cpp 2015-03-19 00:04:12 +0000 | |||
148 | +++ src/core/media/audio/pulse_audio_output_observer.cpp 2016-04-07 00:39:05 +0000 | |||
149 | @@ -21,6 +21,8 @@ | |||
150 | 21 | 21 | ||
151 | 22 | #include <pulse/pulseaudio.h> | 22 | #include <pulse/pulseaudio.h> |
152 | 23 | 23 | ||
153 | 24 | #include "core/media/logger/logger.h" | ||
154 | 25 | |||
155 | 24 | #include <cstdint> | 26 | #include <cstdint> |
156 | 25 | 27 | ||
157 | 26 | #include <map> | 28 | #include <map> |
158 | @@ -245,7 +247,7 @@ | |||
159 | 245 | std::get<1>(outputs.back()) | properties.external_output_state; | 247 | std::get<1>(outputs.back()) | properties.external_output_state; |
160 | 246 | std::get<1>(outputs.back()).changed().connect([](media::audio::OutputState state) | 248 | std::get<1>(outputs.back()).changed().connect([](media::audio::OutputState state) |
161 | 247 | { | 249 | { |
163 | 248 | std::cout << "Connection state for port changed to: " << state << std::endl; | 250 | MH_DEBUG("Connection state for port changed to: %s", state); |
164 | 249 | }); | 251 | }); |
165 | 250 | } | 252 | } |
166 | 251 | 253 | ||
167 | @@ -289,8 +291,8 @@ | |||
168 | 289 | void on_sink_event_with_index(std::int32_t index) | 291 | void on_sink_event_with_index(std::int32_t index) |
169 | 290 | { | 292 | { |
170 | 291 | config.reporter->sink_event_with_index(index); | 293 | config.reporter->sink_event_with_index(index); |
173 | 292 | 294 | ||
174 | 293 | // Update server info (active sink) | 295 | // Update server info (active sink) |
175 | 294 | pa::get_server_info_async(context, main_loop, Private::query_for_server_info_finished, this); | 296 | pa::get_server_info_async(context, main_loop, Private::query_for_server_info_finished, this); |
176 | 295 | 297 | ||
177 | 296 | } | 298 | } |
178 | @@ -317,15 +319,15 @@ | |||
179 | 317 | if (std::get<0>(active_sink) != info->index) | 319 | if (std::get<0>(active_sink) != info->index) |
180 | 318 | continue; | 320 | continue; |
181 | 319 | 321 | ||
185 | 320 | std::cout << "Checking if port is available " << " -> " << std::boolalpha << pa::is_port_available_on_sink(info, std::get<0>(element)) << std::endl; | 322 | MH_INFO("Checking if port is available -> %s", |
186 | 321 | bool available = pa::is_port_available_on_sink(info, std::get<0>(element)); | 323 | pa::is_port_available_on_sink(info, std::get<0>(element))); |
187 | 322 | 324 | const bool available = pa::is_port_available_on_sink(info, std::get<0>(element)); | |
188 | 323 | if (available) | 325 | if (available) |
189 | 324 | { | 326 | { |
190 | 325 | std::get<1>(element) = audio::OutputState::Earpiece; | 327 | std::get<1>(element) = audio::OutputState::Earpiece; |
191 | 326 | continue; | 328 | continue; |
192 | 327 | } | 329 | } |
194 | 328 | 330 | ||
195 | 329 | audio::OutputState state; | 331 | audio::OutputState state; |
196 | 330 | if (info->index == primary_sink_index) | 332 | if (info->index == primary_sink_index) |
197 | 331 | state = audio::OutputState::Speaker; | 333 | state = audio::OutputState::Speaker; |
198 | @@ -386,7 +388,7 @@ | |||
199 | 386 | } | 388 | } |
200 | 387 | } | 389 | } |
201 | 388 | 390 | ||
203 | 389 | PulseAudioOutputObserver::Configuration config; | 391 | PulseAudioOutputObserver::Configuration config; |
204 | 390 | pa::ThreadedMainLoopPtr main_loop; | 392 | pa::ThreadedMainLoopPtr main_loop; |
205 | 391 | pa::ContextPtr context; | 393 | pa::ContextPtr context; |
206 | 392 | std::int32_t primary_sink_index; | 394 | std::int32_t primary_sink_index; |
207 | 393 | 395 | ||
208 | === modified file 'src/core/media/gstreamer/engine.cpp' | |||
209 | --- src/core/media/gstreamer/engine.cpp 2016-02-19 16:14:42 +0000 | |||
210 | +++ src/core/media/gstreamer/engine.cpp 2016-04-07 00:39:05 +0000 | |||
211 | @@ -25,6 +25,8 @@ | |||
212 | 25 | #include "meta_data_extractor.h" | 25 | #include "meta_data_extractor.h" |
213 | 26 | #include "playbin.h" | 26 | #include "playbin.h" |
214 | 27 | 27 | ||
215 | 28 | #include "core/media/logger/logger.h" | ||
216 | 29 | |||
217 | 28 | #include <cassert> | 30 | #include <cassert> |
218 | 29 | 31 | ||
219 | 30 | namespace media = core::ubuntu::media; | 32 | namespace media = core::ubuntu::media; |
220 | @@ -67,8 +69,8 @@ | |||
221 | 67 | { | 69 | { |
222 | 68 | if (p.second == "playbin") | 70 | if (p.second == "playbin") |
223 | 69 | { | 71 | { |
226 | 70 | std::cout << "State changed on playbin: " | 72 | MH_INFO("State changed on playbin: %s", |
227 | 71 | << gst_element_state_get_name(p.first.new_state) << std::endl; | 73 | gst_element_state_get_name(p.first.new_state)); |
228 | 72 | const auto status = gst_state_to_player_status(p.first); | 74 | const auto status = gst_state_to_player_status(p.first); |
229 | 73 | /* | 75 | /* |
230 | 74 | * When state moves to "paused" the pipeline is already set. We check that we | 76 | * When state moves to "paused" the pipeline is already set. We check that we |
231 | @@ -76,7 +78,7 @@ | |||
232 | 76 | */ | 78 | */ |
233 | 77 | if (status == media::Player::PlaybackStatus::paused && | 79 | if (status == media::Player::PlaybackStatus::paused && |
234 | 78 | !playbin.can_play_streams()) { | 80 | !playbin.can_play_streams()) { |
236 | 79 | std::cerr << "** Cannot play: some codecs are missing" << std::endl; | 81 | MH_ERROR("** Cannot play: some codecs are missing"); |
237 | 80 | playbin.reset(); | 82 | playbin.reset(); |
238 | 81 | const media::Player::Error e = media::Player::Error::format_error; | 83 | const media::Player::Error e = media::Player::Error::format_error; |
239 | 82 | error(e); | 84 | error(e); |
240 | @@ -96,20 +98,20 @@ | |||
241 | 96 | switch (ewi.error->code) | 98 | switch (ewi.error->code) |
242 | 97 | { | 99 | { |
243 | 98 | case GST_CORE_ERROR_FAILED: | 100 | case GST_CORE_ERROR_FAILED: |
245 | 99 | std::cerr << "** Encountered a GST_CORE_ERROR_FAILED" << std::endl; | 101 | MH_ERROR("** Encountered a GST_CORE_ERROR_FAILED"); |
246 | 100 | ret_error = media::Player::Error::resource_error; | 102 | ret_error = media::Player::Error::resource_error; |
247 | 101 | break; | 103 | break; |
248 | 102 | case GST_CORE_ERROR_NEGOTIATION: | 104 | case GST_CORE_ERROR_NEGOTIATION: |
250 | 103 | std::cerr << "** Encountered a GST_CORE_ERROR_NEGOTIATION" << std::endl; | 105 | MH_ERROR("** Encountered a GST_CORE_ERROR_NEGOTIATION"); |
251 | 104 | ret_error = media::Player::Error::resource_error; | 106 | ret_error = media::Player::Error::resource_error; |
252 | 105 | break; | 107 | break; |
253 | 106 | case GST_CORE_ERROR_MISSING_PLUGIN: | 108 | case GST_CORE_ERROR_MISSING_PLUGIN: |
255 | 107 | std::cerr << "** Encountered a GST_CORE_ERROR_MISSING_PLUGIN" << std::endl; | 109 | MH_ERROR("** Encountered a GST_CORE_ERROR_MISSING_PLUGIN"); |
256 | 108 | ret_error = media::Player::Error::format_error; | 110 | ret_error = media::Player::Error::format_error; |
257 | 109 | break; | 111 | break; |
258 | 110 | default: | 112 | default: |
261 | 111 | std::cerr << "** Encountered an unhandled core error: '" | 113 | MH_ERROR("** Encountered an unhandled core error: '%s' (code: %d)", |
262 | 112 | << ewi.debug << "' (code: " << ewi.error->code << ")" << std::endl; | 114 | ewi.debug, ewi.error->code); |
263 | 113 | ret_error = media::Player::Error::no_error; | 115 | ret_error = media::Player::Error::no_error; |
264 | 114 | break; | 116 | break; |
265 | 115 | } | 117 | } |
266 | @@ -119,36 +121,36 @@ | |||
267 | 119 | switch (ewi.error->code) | 121 | switch (ewi.error->code) |
268 | 120 | { | 122 | { |
269 | 121 | case GST_RESOURCE_ERROR_FAILED: | 123 | case GST_RESOURCE_ERROR_FAILED: |
271 | 122 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_FAILED" << std::endl; | 124 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_FAILED"); |
272 | 123 | ret_error = media::Player::Error::resource_error; | 125 | ret_error = media::Player::Error::resource_error; |
273 | 124 | break; | 126 | break; |
274 | 125 | case GST_RESOURCE_ERROR_NOT_FOUND: | 127 | case GST_RESOURCE_ERROR_NOT_FOUND: |
276 | 126 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_NOT_FOUND" << std::endl; | 128 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_NOT_FOUND"); |
277 | 127 | ret_error = media::Player::Error::resource_error; | 129 | ret_error = media::Player::Error::resource_error; |
278 | 128 | break; | 130 | break; |
279 | 129 | case GST_RESOURCE_ERROR_OPEN_READ: | 131 | case GST_RESOURCE_ERROR_OPEN_READ: |
281 | 130 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_OPEN_READ" << std::endl; | 132 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_OPEN_READ"); |
282 | 131 | ret_error = media::Player::Error::resource_error; | 133 | ret_error = media::Player::Error::resource_error; |
283 | 132 | break; | 134 | break; |
284 | 133 | case GST_RESOURCE_ERROR_OPEN_WRITE: | 135 | case GST_RESOURCE_ERROR_OPEN_WRITE: |
286 | 134 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_OPEN_WRITE" << std::endl; | 136 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_OPEN_WRITE"); |
287 | 135 | ret_error = media::Player::Error::resource_error; | 137 | ret_error = media::Player::Error::resource_error; |
288 | 136 | break; | 138 | break; |
289 | 137 | case GST_RESOURCE_ERROR_READ: | 139 | case GST_RESOURCE_ERROR_READ: |
291 | 138 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_READ" << std::endl; | 140 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_READ"); |
292 | 139 | ret_error = media::Player::Error::resource_error; | 141 | ret_error = media::Player::Error::resource_error; |
293 | 140 | break; | 142 | break; |
294 | 141 | case GST_RESOURCE_ERROR_WRITE: | 143 | case GST_RESOURCE_ERROR_WRITE: |
296 | 142 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_WRITE" << std::endl; | 144 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_WRITE"); |
297 | 143 | ret_error = media::Player::Error::resource_error; | 145 | ret_error = media::Player::Error::resource_error; |
298 | 144 | break; | 146 | break; |
299 | 145 | case GST_RESOURCE_ERROR_NOT_AUTHORIZED: | 147 | case GST_RESOURCE_ERROR_NOT_AUTHORIZED: |
301 | 146 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_NOT_AUTHORIZED" << std::endl; | 148 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_NOT_AUTHORIZED"); |
302 | 147 | ret_error = media::Player::Error::access_denied_error; | 149 | ret_error = media::Player::Error::access_denied_error; |
303 | 148 | break; | 150 | break; |
304 | 149 | default: | 151 | default: |
307 | 150 | std::cerr << "** Encountered an unhandled resource error: '" | 152 | MH_ERROR("** Encountered an unhandled resource error: '%s' (code: %d)", |
308 | 151 | << ewi.debug << "' (code: " << ewi.error->code << ")" << std::endl; | 153 | ewi.debug, ewi.error->code); |
309 | 152 | ret_error = media::Player::Error::no_error; | 154 | ret_error = media::Player::Error::no_error; |
310 | 153 | break; | 155 | break; |
311 | 154 | } | 156 | } |
312 | @@ -158,28 +160,28 @@ | |||
313 | 158 | switch (ewi.error->code) | 160 | switch (ewi.error->code) |
314 | 159 | { | 161 | { |
315 | 160 | case GST_STREAM_ERROR_FAILED: | 162 | case GST_STREAM_ERROR_FAILED: |
317 | 161 | std::cerr << "** Encountered a GST_STREAM_ERROR_FAILED" << std::endl; | 163 | MH_ERROR("** Encountered a GST_STREAM_ERROR_FAILED"); |
318 | 162 | ret_error = media::Player::Error::resource_error; | 164 | ret_error = media::Player::Error::resource_error; |
319 | 163 | break; | 165 | break; |
320 | 164 | case GST_STREAM_ERROR_CODEC_NOT_FOUND: | 166 | case GST_STREAM_ERROR_CODEC_NOT_FOUND: |
322 | 165 | std::cerr << "** Encountered a GST_STREAM_ERROR_CODEC_NOT_FOUND" << std::endl; | 167 | MH_ERROR("** Encountered a GST_STREAM_ERROR_CODEC_NOT_FOUND"); |
323 | 166 | // Missing codecs are handled later, when state switches to "paused" | 168 | // Missing codecs are handled later, when state switches to "paused" |
324 | 167 | ret_error = media::Player::Error::no_error; | 169 | ret_error = media::Player::Error::no_error; |
325 | 168 | break; | 170 | break; |
326 | 169 | case GST_STREAM_ERROR_DECODE: | 171 | case GST_STREAM_ERROR_DECODE: |
328 | 170 | std::cerr << "** Encountered a GST_STREAM_ERROR_DECODE" << std::endl; | 172 | MH_ERROR("** Encountered a GST_STREAM_ERROR_DECODE"); |
329 | 171 | ret_error = media::Player::Error::format_error; | 173 | ret_error = media::Player::Error::format_error; |
330 | 172 | break; | 174 | break; |
331 | 173 | default: | 175 | default: |
334 | 174 | std::cerr << "** Encountered an unhandled stream error: '" | 176 | MH_ERROR("** Encountered an unhandled stream error: '%s' code(%d)", |
335 | 175 | << ewi.debug << "' (code: " << ewi.error->code << ")" << std::endl; | 177 | ewi.debug, ewi.error->code); |
336 | 176 | ret_error = media::Player::Error::no_error; | 178 | ret_error = media::Player::Error::no_error; |
337 | 177 | break; | 179 | break; |
338 | 178 | } | 180 | } |
339 | 179 | } | 181 | } |
340 | 180 | 182 | ||
341 | 181 | if (ret_error != media::Player::Error::no_error) { | 183 | if (ret_error != media::Player::Error::no_error) { |
343 | 182 | std::cerr << "Resetting playbin pipeline after unrecoverable error" << std::endl; | 184 | MH_ERROR("Resetting playbin pipeline after unrecoverable error"); |
344 | 183 | playbin.reset(); | 185 | playbin.reset(); |
345 | 184 | } | 186 | } |
346 | 185 | return ret_error; | 187 | return ret_error; |
347 | @@ -201,7 +203,7 @@ | |||
348 | 201 | 203 | ||
349 | 202 | void on_playbin_info(const gstreamer::Bus::Message::Detail::ErrorWarningInfo& ewi) | 204 | void on_playbin_info(const gstreamer::Bus::Message::Detail::ErrorWarningInfo& ewi) |
350 | 203 | { | 205 | { |
352 | 204 | std::cerr << "Got a playbin info message (no action taken): " << ewi.debug << std::endl; | 206 | MH_DEBUG("Got a playbin info message (no action taken): %s", ewi.debug); |
353 | 205 | } | 207 | } |
354 | 206 | 208 | ||
355 | 207 | void on_tag_available(const gstreamer::Bus::Message::Detail::Tag& tag) | 209 | void on_tag_available(const gstreamer::Bus::Message::Detail::Tag& tag) |
356 | @@ -437,8 +439,7 @@ | |||
357 | 437 | if (result) | 439 | if (result) |
358 | 438 | { | 440 | { |
359 | 439 | d->state = media::Engine::State::playing; | 441 | d->state = media::Engine::State::playing; |
362 | 440 | cout << __PRETTY_FUNCTION__ << endl; | 442 | MH_INFO("Engine: playing uri: %s", d->playbin.uri()); |
361 | 441 | cout << "Engine: playing uri: " << d->playbin.uri() << endl; | ||
363 | 442 | d->playback_status_changed(media::Player::PlaybackStatus::playing); | 443 | d->playback_status_changed(media::Player::PlaybackStatus::playing); |
364 | 443 | } | 444 | } |
365 | 444 | 445 | ||
366 | @@ -450,7 +451,7 @@ | |||
367 | 450 | // No need to wait, and we can immediately return. | 451 | // No need to wait, and we can immediately return. |
368 | 451 | if (d->state == media::Engine::State::stopped) | 452 | if (d->state == media::Engine::State::stopped) |
369 | 452 | { | 453 | { |
371 | 453 | std::cerr << "Current player state is already stopped - no need to change state to stopped" << std::endl; | 454 | MH_DEBUG("Current player state is already stopped - no need to change state to stopped"); |
372 | 454 | return true; | 455 | return true; |
373 | 455 | } | 456 | } |
374 | 456 | 457 | ||
375 | @@ -458,7 +459,7 @@ | |||
376 | 458 | if (result) | 459 | if (result) |
377 | 459 | { | 460 | { |
378 | 460 | d->state = media::Engine::State::stopped; | 461 | d->state = media::Engine::State::stopped; |
380 | 461 | cout << __PRETTY_FUNCTION__ << endl; | 462 | MH_TRACE(""); |
381 | 462 | d->playback_status_changed(media::Player::PlaybackStatus::stopped); | 463 | d->playback_status_changed(media::Player::PlaybackStatus::stopped); |
382 | 463 | } | 464 | } |
383 | 464 | 465 | ||
384 | @@ -472,7 +473,7 @@ | |||
385 | 472 | if (result) | 473 | if (result) |
386 | 473 | { | 474 | { |
387 | 474 | d->state = media::Engine::State::paused; | 475 | d->state = media::Engine::State::paused; |
389 | 475 | cout << __PRETTY_FUNCTION__ << endl; | 476 | MH_TRACE(""); |
390 | 476 | d->playback_status_changed(media::Player::PlaybackStatus::paused); | 477 | d->playback_status_changed(media::Player::PlaybackStatus::paused); |
391 | 477 | } | 478 | } |
392 | 478 | 479 | ||
393 | 479 | 480 | ||
394 | === modified file 'src/core/media/gstreamer/playbin.cpp' | |||
395 | --- src/core/media/gstreamer/playbin.cpp 2016-03-07 21:05:26 +0000 | |||
396 | +++ src/core/media/gstreamer/playbin.cpp 2016-04-07 00:39:05 +0000 | |||
397 | @@ -25,7 +25,8 @@ | |||
398 | 25 | #include <hybris/media/surface_texture_client_hybris.h> | 25 | #include <hybris/media/surface_texture_client_hybris.h> |
399 | 26 | #include <hybris/media/media_codec_layer.h> | 26 | #include <hybris/media/media_codec_layer.h> |
400 | 27 | 27 | ||
402 | 28 | #include "../util/uri_check.h" | 28 | #include "core/media/logger/logger.h" |
403 | 29 | #include "core/media/util/uri_check.h" | ||
404 | 29 | 30 | ||
405 | 30 | #include <utility> | 31 | #include <utility> |
406 | 31 | 32 | ||
407 | @@ -154,13 +155,13 @@ | |||
408 | 154 | { | 155 | { |
409 | 155 | using namespace std; | 156 | using namespace std; |
410 | 156 | 157 | ||
412 | 157 | cout << func << endl; | 158 | MH_DEBUG("%s", func); |
413 | 158 | if (pb.pipeline) | 159 | if (pb.pipeline) |
415 | 159 | cout << "pipeline: " << GST_OBJECT_REFCOUNT(pb.pipeline) << endl; | 160 | MH_DEBUG("pipeline: %d", GST_OBJECT_REFCOUNT(pb.pipeline)); |
416 | 160 | if (pb.video_sink) | 161 | if (pb.video_sink) |
418 | 161 | cout << "video_sink: " << GST_OBJECT_REFCOUNT(pb.video_sink) << endl; | 162 | MH_DEBUG("video_sink: %d", GST_OBJECT_REFCOUNT(pb.video_sink)); |
419 | 162 | if (pb.audio_sink) | 163 | if (pb.audio_sink) |
421 | 163 | cout << "audio_sink: " << GST_OBJECT_REFCOUNT(pb.audio_sink) << endl; | 164 | MH_DEBUG("audio_sink: %d", GST_OBJECT_REFCOUNT(pb.audio_sink)); |
422 | 164 | } | 165 | } |
423 | 165 | #endif | 166 | #endif |
424 | 166 | 167 | ||
425 | @@ -183,7 +184,7 @@ | |||
426 | 183 | 184 | ||
427 | 184 | void gstreamer::Playbin::reset() | 185 | void gstreamer::Playbin::reset() |
428 | 185 | { | 186 | { |
430 | 186 | std::cout << "Client died, resetting pipeline" << std::endl; | 187 | MH_INFO("Client died, resetting pipeline"); |
431 | 187 | // When the client dies, tear down the current pipeline and get it | 188 | // When the client dies, tear down the current pipeline and get it |
432 | 188 | // in a state that is ready for the next client that connects to the | 189 | // in a state that is ready for the next client that connects to the |
433 | 189 | // service | 190 | // service |
434 | @@ -198,19 +199,19 @@ | |||
435 | 198 | 199 | ||
436 | 199 | void gstreamer::Playbin::reset_pipeline() | 200 | void gstreamer::Playbin::reset_pipeline() |
437 | 200 | { | 201 | { |
441 | 201 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 202 | MH_TRACE(""); |
442 | 202 | auto ret = gst_element_set_state(pipeline, GST_STATE_NULL); | 203 | const auto ret = gst_element_set_state(pipeline, GST_STATE_NULL); |
443 | 203 | switch(ret) | 204 | switch (ret) |
444 | 204 | { | 205 | { |
445 | 205 | case GST_STATE_CHANGE_FAILURE: | 206 | case GST_STATE_CHANGE_FAILURE: |
447 | 206 | std::cout << "Failed to reset the pipeline state. Client reconnect may not function properly." << std::endl; | 207 | MH_WARNING("Failed to reset the pipeline state. Client reconnect may not function properly."); |
448 | 207 | break; | 208 | break; |
449 | 208 | case GST_STATE_CHANGE_NO_PREROLL: | 209 | case GST_STATE_CHANGE_NO_PREROLL: |
450 | 209 | case GST_STATE_CHANGE_SUCCESS: | 210 | case GST_STATE_CHANGE_SUCCESS: |
451 | 210 | case GST_STATE_CHANGE_ASYNC: | 211 | case GST_STATE_CHANGE_ASYNC: |
452 | 211 | break; | 212 | break; |
453 | 212 | default: | 213 | default: |
455 | 213 | std::cout << "Failed to reset the pipeline state. Client reconnect may not function properly." << std::endl; | 214 | MH_WARNING("Failed to reset the pipeline state. Client reconnect may not function properly."); |
456 | 214 | } | 215 | } |
457 | 215 | file_type = MEDIA_FILE_TYPE_NONE; | 216 | file_type = MEDIA_FILE_TYPE_NONE; |
458 | 216 | is_missing_audio_codec = false; | 217 | is_missing_audio_codec = false; |
459 | @@ -225,7 +226,7 @@ | |||
460 | 225 | return; | 226 | return; |
461 | 226 | 227 | ||
462 | 227 | gchar *desc = gst_missing_plugin_message_get_description(message); | 228 | gchar *desc = gst_missing_plugin_message_get_description(message); |
464 | 228 | std::cerr << "Missing plugin: " << desc << std::endl; | 229 | MH_WARNING("Missing plugin: %s", desc); |
465 | 229 | g_free(desc); | 230 | g_free(desc); |
466 | 230 | 231 | ||
467 | 231 | const GstStructure *msg_data = gst_message_get_structure(message); | 232 | const GstStructure *msg_data = gst_message_get_structure(message); |
468 | @@ -234,13 +235,13 @@ | |||
469 | 234 | 235 | ||
470 | 235 | GstCaps *caps; | 236 | GstCaps *caps; |
471 | 236 | if (!gst_structure_get(msg_data, "detail", GST_TYPE_CAPS, &caps, NULL)) { | 237 | if (!gst_structure_get(msg_data, "detail", GST_TYPE_CAPS, &caps, NULL)) { |
473 | 237 | std::cerr << __PRETTY_FUNCTION__ << ": No detail" << std::endl; | 238 | MH_ERROR("No detail"); |
474 | 238 | return; | 239 | return; |
475 | 239 | } | 240 | } |
476 | 240 | 241 | ||
477 | 241 | GstStructure *caps_data = gst_caps_get_structure(caps, 0); | 242 | GstStructure *caps_data = gst_caps_get_structure(caps, 0); |
478 | 242 | if (!caps_data) { | 243 | if (!caps_data) { |
480 | 243 | std::cerr << __PRETTY_FUNCTION__ << ": No caps data" << std::endl; | 244 | MH_ERROR("No caps data"); |
481 | 244 | return; | 245 | return; |
482 | 245 | } | 246 | } |
483 | 246 | 247 | ||
484 | @@ -250,7 +251,7 @@ | |||
485 | 250 | else if (strstr(mime, "video")) | 251 | else if (strstr(mime, "video")) |
486 | 251 | is_missing_video_codec = true; | 252 | is_missing_video_codec = true; |
487 | 252 | 253 | ||
489 | 253 | std::cerr << "Missing decoder for " << mime << std::endl; | 254 | MH_ERROR("Missing decoder for %s", mime); |
490 | 254 | } | 255 | } |
491 | 255 | 256 | ||
492 | 256 | void gstreamer::Playbin::on_new_message_async(const Bus::Message& message) | 257 | void gstreamer::Playbin::on_new_message_async(const Bus::Message& message) |
493 | @@ -324,7 +325,7 @@ | |||
494 | 324 | ::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME"), | 325 | ::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME"), |
495 | 325 | "audio-sink"); | 326 | "audio-sink"); |
496 | 326 | 327 | ||
498 | 327 | std::cout << "audio_sink: " << ::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME") << std::endl; | 328 | MH_INFO("audio_sink: %s", ::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME")); |
499 | 328 | 329 | ||
500 | 329 | g_object_set ( | 330 | g_object_set ( |
501 | 330 | pipeline, | 331 | pipeline, |
502 | @@ -339,7 +340,7 @@ | |||
503 | 339 | ::getenv("CORE_UBUNTU_MEDIA_SERVICE_VIDEO_SINK_NAME"), | 340 | ::getenv("CORE_UBUNTU_MEDIA_SERVICE_VIDEO_SINK_NAME"), |
504 | 340 | "video-sink"); | 341 | "video-sink"); |
505 | 341 | 342 | ||
507 | 342 | std::cout << "video_sink: " << ::getenv("CORE_UBUNTU_MEDIA_SERVICE_VIDEO_SINK_NAME") << std::endl; | 343 | MH_INFO("video_sink: %s", ::getenv("CORE_UBUNTU_MEDIA_SERVICE_VIDEO_SINK_NAME")); |
508 | 343 | 344 | ||
509 | 344 | g_object_set ( | 345 | g_object_set ( |
510 | 345 | pipeline, | 346 | pipeline, |
511 | @@ -404,16 +405,17 @@ | |||
512 | 404 | /** Sets the new audio stream role on the pulsesink in playbin */ | 405 | /** Sets the new audio stream role on the pulsesink in playbin */ |
513 | 405 | void gstreamer::Playbin::set_audio_stream_role(media::Player::AudioStreamRole new_audio_role) | 406 | void gstreamer::Playbin::set_audio_stream_role(media::Player::AudioStreamRole new_audio_role) |
514 | 406 | { | 407 | { |
517 | 407 | std::string role_str("props,media.role=" + get_audio_role_str(new_audio_role)); | 408 | const std::string role_str("props,media.role=" + get_audio_role_str(new_audio_role)); |
518 | 408 | std::cout << "Audio stream role: " << role_str << std::endl; | 409 | MH_INFO("Audio stream role: %s", role_str); |
519 | 409 | 410 | ||
520 | 410 | GstStructure *props = gst_structure_from_string (role_str.c_str(), NULL); | 411 | GstStructure *props = gst_structure_from_string (role_str.c_str(), NULL); |
522 | 411 | if (audio_sink != nullptr && props != nullptr) { | 412 | if (audio_sink != nullptr && props != nullptr) |
523 | 413 | { | ||
524 | 412 | g_object_set (audio_sink, "stream-properties", props, NULL); | 414 | g_object_set (audio_sink, "stream-properties", props, NULL); |
529 | 413 | } else { | 415 | } |
530 | 414 | std::cerr << | 416 | else |
531 | 415 | "Warning: couldn't set audio stream role - couldn't get audio_sink from pipeline" << | 417 | { |
532 | 416 | std::endl; | 418 | MH_WARNING("Couldn't set audio stream role - couldn't get audio_sink from pipeline"); |
533 | 417 | } | 419 | } |
534 | 418 | 420 | ||
535 | 419 | gst_structure_free (props); | 421 | gst_structure_free (props); |
536 | @@ -475,9 +477,7 @@ | |||
537 | 475 | { | 477 | { |
538 | 476 | // First decode the URI just in case it's partially encoded already | 478 | // First decode the URI just in case it's partially encoded already |
539 | 477 | tmp_uri = decode_uri(uri); | 479 | tmp_uri = decode_uri(uri); |
543 | 478 | #ifdef VERBOSE_DEBUG | 480 | MH_DEBUG("File URI was encoded, now decoded: %s", tmp_uri); |
541 | 479 | std::cout << "File URI was encoded, now decoded: " << tmp_uri << std::endl; | ||
542 | 480 | #endif | ||
544 | 481 | } | 481 | } |
545 | 482 | tmp_uri = encode_uri(tmp_uri); | 482 | tmp_uri = encode_uri(tmp_uri); |
546 | 483 | } | 483 | } |
547 | @@ -538,7 +538,7 @@ | |||
548 | 538 | 538 | ||
549 | 539 | auto ret = gst_element_set_state(pipeline, new_state); | 539 | auto ret = gst_element_set_state(pipeline, new_state); |
550 | 540 | 540 | ||
552 | 541 | std::cout << __PRETTY_FUNCTION__ << ": requested state change." << std::endl; | 541 | MH_DEBUG("Requested state change."); |
553 | 542 | 542 | ||
554 | 543 | bool result = false; GstState current, pending; | 543 | bool result = false; GstState current, pending; |
555 | 544 | switch(ret) | 544 | switch(ret) |
556 | @@ -570,15 +570,15 @@ | |||
557 | 570 | } | 570 | } |
558 | 571 | catch (const std::exception& e) | 571 | catch (const std::exception& e) |
559 | 572 | { | 572 | { |
561 | 573 | std::cerr << "Problem querying video dimensions: " << e.what() << std::endl; | 573 | MH_WARNING("Problem querying video dimensions: %s", e.what()); |
562 | 574 | } | 574 | } |
563 | 575 | catch (...) | 575 | catch (...) |
564 | 576 | { | 576 | { |
566 | 577 | std::cerr << "Problem querying video dimensions." << std::endl; | 577 | MH_WARNING("Problem querying video dimensions."); |
567 | 578 | } | 578 | } |
568 | 579 | 579 | ||
569 | 580 | #ifdef DEBUG_GST_PIPELINE | 580 | #ifdef DEBUG_GST_PIPELINE |
571 | 581 | std::cout << "Dumping pipeline dot file" << std::endl; | 581 | MH_DEBUG("Dumping pipeline dot file"); |
572 | 582 | GST_DEBUG_BIN_TO_DOT_FILE((GstBin*)pipeline, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline"); | 582 | GST_DEBUG_BIN_TO_DOT_FILE((GstBin*)pipeline, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline"); |
573 | 583 | #endif | 583 | #endif |
574 | 584 | } | 584 | } |
575 | @@ -656,17 +656,13 @@ | |||
576 | 656 | // We have a URI and it is already percent encoded | 656 | // We have a URI and it is already percent encoded |
577 | 657 | if (uri_scheme and strlen(uri_scheme) > 0 and uri_check->is_encoded()) | 657 | if (uri_scheme and strlen(uri_scheme) > 0 and uri_check->is_encoded()) |
578 | 658 | { | 658 | { |
582 | 659 | #ifdef VERBOSE_DEBUG | 659 | MH_DEBUG("Is a URI and is already percent encoded"); |
580 | 660 | std::cout << "Is a URI and is already percent encoded" << std::endl; | ||
581 | 661 | #endif | ||
583 | 662 | encoded_uri = uri; | 660 | encoded_uri = uri; |
584 | 663 | } | 661 | } |
585 | 664 | // We have a URI but it's not already percent encoded | 662 | // We have a URI but it's not already percent encoded |
586 | 665 | else if (uri_scheme and strlen(uri_scheme) > 0 and !uri_check->is_encoded()) | 663 | else if (uri_scheme and strlen(uri_scheme) > 0 and !uri_check->is_encoded()) |
587 | 666 | { | 664 | { |
591 | 667 | #ifdef VERBOSE_DEBUG | 665 | MH_DEBUG("Is a URI and is not already percent encoded"); |
589 | 668 | std::cout << "Is a URI and is not already percent encoded" << std::endl; | ||
590 | 669 | #endif | ||
592 | 670 | gchar *encoded = g_uri_escape_string(uri.c_str(), | 666 | gchar *encoded = g_uri_escape_string(uri.c_str(), |
593 | 671 | "!$&'()*+,;=:/?[]@", // reserved chars | 667 | "!$&'()*+,;=:/?[]@", // reserved chars |
594 | 672 | TRUE); // Allow UTF-8 chars | 668 | TRUE); // Allow UTF-8 chars |
595 | @@ -681,9 +677,7 @@ | |||
596 | 681 | else // We have a path and not a URI. Turn it into a full URI and encode it | 677 | else // We have a path and not a URI. Turn it into a full URI and encode it |
597 | 682 | { | 678 | { |
598 | 683 | GError *error = nullptr; | 679 | GError *error = nullptr; |
602 | 684 | #ifdef VERBOSE_DEBUG | 680 | MH_DEBUG("Is a path and is not already percent encoded"); |
600 | 685 | std::cout << "Is a path and is not already percent encoded" << std::endl; | ||
601 | 686 | #endif | ||
603 | 687 | gchar *str = g_filename_to_uri(uri.c_str(), nullptr, &error); | 681 | gchar *str = g_filename_to_uri(uri.c_str(), nullptr, &error); |
604 | 688 | if (!str) | 682 | if (!str) |
605 | 689 | { | 683 | { |
606 | @@ -694,8 +688,7 @@ | |||
607 | 694 | g_free(str); | 688 | g_free(str); |
608 | 695 | if (error != nullptr) | 689 | if (error != nullptr) |
609 | 696 | { | 690 | { |
612 | 697 | std::cerr << "Warning: failed to get actual track content type: " << error->message | 691 | MH_WARNING("Failed to get actual track content type: %s", error->message); |
611 | 698 | << std::endl; | ||
613 | 699 | g_error_free(error); | 692 | g_error_free(error); |
614 | 700 | g_free(str); | 693 | g_free(str); |
615 | 701 | g_free(uri_scheme); | 694 | g_free(uri_scheme); |
616 | @@ -742,11 +735,11 @@ | |||
617 | 742 | const std::string content_type {file_info_from_uri(encoded_uri)}; | 735 | const std::string content_type {file_info_from_uri(encoded_uri)}; |
618 | 743 | if (content_type.empty()) | 736 | if (content_type.empty()) |
619 | 744 | { | 737 | { |
621 | 745 | std::cerr << "Warning: failed to get actual track content type" << std::endl; | 738 | MH_WARNING("Failed to get actual track content type"); |
622 | 746 | return std::string("audio/video/"); | 739 | return std::string("audio/video/"); |
623 | 747 | } | 740 | } |
624 | 748 | 741 | ||
626 | 749 | std::cout << "Found content type: " << content_type << std::endl; | 742 | MH_INFO("Found content type: %s", content_type); |
627 | 750 | 743 | ||
628 | 751 | return content_type; | 744 | return content_type; |
629 | 752 | } | 745 | } |
630 | @@ -758,7 +751,7 @@ | |||
631 | 758 | 751 | ||
632 | 759 | if (get_file_content_type(uri).find("audio/") == 0) | 752 | if (get_file_content_type(uri).find("audio/") == 0) |
633 | 760 | { | 753 | { |
635 | 761 | std::cout << "Found audio content" << std::endl; | 754 | MH_INFO("Found audio content"); |
636 | 762 | return true; | 755 | return true; |
637 | 763 | } | 756 | } |
638 | 764 | 757 | ||
639 | @@ -772,7 +765,7 @@ | |||
640 | 772 | 765 | ||
641 | 773 | if (get_file_content_type(uri).find("video/") == 0) | 766 | if (get_file_content_type(uri).find("video/") == 0) |
642 | 774 | { | 767 | { |
644 | 775 | std::cout << "Found video content" << std::endl; | 768 | MH_INFO("Found video content"); |
645 | 776 | return true; | 769 | return true; |
646 | 777 | } | 770 | } |
647 | 778 | 771 | ||
648 | 779 | 772 | ||
649 | === added directory 'src/core/media/logger' | |||
650 | === added file 'src/core/media/logger/logger.cpp' | |||
651 | --- src/core/media/logger/logger.cpp 1970-01-01 00:00:00 +0000 | |||
652 | +++ src/core/media/logger/logger.cpp 2016-04-07 00:39:05 +0000 | |||
653 | @@ -0,0 +1,161 @@ | |||
654 | 1 | /* | ||
655 | 2 | * Copyright © 2016 Canonical Ltd. | ||
656 | 3 | * | ||
657 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
658 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
659 | 6 | * as published by the Free Software Foundation. | ||
660 | 7 | * | ||
661 | 8 | * This program is distributed in the hope that it will be useful, | ||
662 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
663 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
664 | 11 | * GNU Lesser General Public License for more details. | ||
665 | 12 | * | ||
666 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
667 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
668 | 15 | * | ||
669 | 16 | */ | ||
670 | 17 | |||
671 | 18 | #include <thread> | ||
672 | 19 | |||
673 | 20 | #include "logger.h" | ||
674 | 21 | |||
675 | 22 | #define BOOST_LOG_DYN_LINK | ||
676 | 23 | #include <boost/date_time.hpp> | ||
677 | 24 | #include <boost/filesystem.hpp> | ||
678 | 25 | #include <boost/log/trivial.hpp> | ||
679 | 26 | #include <boost/log/expressions.hpp> | ||
680 | 27 | #include <boost/log/support/date_time.hpp> | ||
681 | 28 | #include <boost/log/utility/manipulators.hpp> | ||
682 | 29 | #include <boost/log/utility/setup.hpp> | ||
683 | 30 | |||
684 | 31 | namespace media = core::ubuntu::media; | ||
685 | 32 | |||
686 | 33 | namespace { | ||
687 | 34 | namespace attrs { | ||
688 | 35 | BOOST_LOG_ATTRIBUTE_KEYWORD(Severity, "core::ubuntu::media::Severity", media::Logger::Severity) | ||
689 | 36 | BOOST_LOG_ATTRIBUTE_KEYWORD(Location, "Location", media::Logger::Location) | ||
690 | 37 | BOOST_LOG_ATTRIBUTE_KEYWORD(Timestamp, "Timestamp", boost::posix_time::ptime) | ||
691 | 38 | } | ||
692 | 39 | |||
693 | 40 | struct BoostLogLogger : public media::Logger { | ||
694 | 41 | BoostLogLogger() : | ||
695 | 42 | initialized_(false) { | ||
696 | 43 | } | ||
697 | 44 | |||
698 | 45 | void Init(const media::Logger::Severity &severity = media::Logger::Severity::kWarning) override { | ||
699 | 46 | if (initialized_) | ||
700 | 47 | return; | ||
701 | 48 | |||
702 | 49 | boost::log::formatter formatter = boost::log::expressions::stream | ||
703 | 50 | << "[" << attrs::Severity << " " | ||
704 | 51 | << boost::log::expressions::format_date_time< boost::posix_time::ptime >("Timestamp", "%Y-%m-%d %H:%M:%S.%f") | ||
705 | 52 | << "] " | ||
706 | 53 | << boost::log::expressions::if_(boost::log::expressions::has_attr(attrs::Location)) | ||
707 | 54 | [ | ||
708 | 55 | boost::log::expressions::stream << "[" << attrs::Location << "] " | ||
709 | 56 | ] | ||
710 | 57 | << boost::log::expressions::smessage; | ||
711 | 58 | |||
712 | 59 | boost::log::core::get()->remove_all_sinks(); | ||
713 | 60 | auto logger = boost::log::add_console_log(std::cout); | ||
714 | 61 | logger->set_formatter(formatter); | ||
715 | 62 | |||
716 | 63 | // FIXME need to enable this once we found how we wrap this | ||
717 | 64 | // properly into our service architecture. For now left as | ||
718 | 65 | // it is. | ||
719 | 66 | boost::ignore_unused_variable_warning(severity); | ||
720 | 67 | // logger->set_filter(attrs::Severity < severity); | ||
721 | 68 | |||
722 | 69 | initialized_ = true; | ||
723 | 70 | } | ||
724 | 71 | |||
725 | 72 | void Log(Severity severity, const std::string& message, const boost::optional<Location> &loc) { | ||
726 | 73 | if (!initialized_) | ||
727 | 74 | Init(); | ||
728 | 75 | |||
729 | 76 | if (auto rec = boost::log::trivial::logger::get().open_record()) { | ||
730 | 77 | boost::log::record_ostream out{rec}; | ||
731 | 78 | out << boost::log::add_value(attrs::Severity, severity) | ||
732 | 79 | << boost::log::add_value(attrs::Timestamp, boost::posix_time::microsec_clock::universal_time()) | ||
733 | 80 | << message; | ||
734 | 81 | |||
735 | 82 | if (loc) { | ||
736 | 83 | // We have to pass in a temporary as boost::log (<= 1.55) expects a | ||
737 | 84 | // mutable reference to be passed to boost::log::add_value(...). | ||
738 | 85 | auto tmp = *loc; | ||
739 | 86 | out << boost::log::add_value(attrs::Location, tmp); | ||
740 | 87 | } | ||
741 | 88 | |||
742 | 89 | boost::log::trivial::logger::get().push_record(std::move(rec)); | ||
743 | 90 | } | ||
744 | 91 | } | ||
745 | 92 | |||
746 | 93 | private: | ||
747 | 94 | bool initialized_; | ||
748 | 95 | }; | ||
749 | 96 | |||
750 | 97 | std::shared_ptr<media::Logger>& MutableInstance() { | ||
751 | 98 | static std::shared_ptr<media::Logger> instance{new BoostLogLogger()}; | ||
752 | 99 | return instance; | ||
753 | 100 | } | ||
754 | 101 | |||
755 | 102 | void SetInstance(const std::shared_ptr<media::Logger>& logger) { | ||
756 | 103 | MutableInstance() = logger; | ||
757 | 104 | } | ||
758 | 105 | } | ||
759 | 106 | |||
760 | 107 | void media::Logger::Trace(const std::string& message, const boost::optional<Location>& location) { | ||
761 | 108 | Log(Severity::kTrace, message, location); | ||
762 | 109 | } | ||
763 | 110 | |||
764 | 111 | void media::Logger::Debug(const std::string& message, const boost::optional<Location>& location) { | ||
765 | 112 | Log(Severity::kDebug, message, location); | ||
766 | 113 | } | ||
767 | 114 | |||
768 | 115 | void media::Logger::Info(const std::string& message, const boost::optional<Location>& location) { | ||
769 | 116 | Log(Severity::kInfo, message, location); | ||
770 | 117 | } | ||
771 | 118 | |||
772 | 119 | void media::Logger::Warning(const std::string& message, const boost::optional<Location>& location) { | ||
773 | 120 | Log(Severity::kWarning, message, location); | ||
774 | 121 | } | ||
775 | 122 | |||
776 | 123 | void media::Logger::Error(const std::string& message, const boost::optional<Location>& location) { | ||
777 | 124 | Log(Severity::kError, message, location); | ||
778 | 125 | } | ||
779 | 126 | |||
780 | 127 | void media::Logger::Fatal(const std::string& message, const boost::optional<Location>& location) { | ||
781 | 128 | Log(Severity::kFatal, message, location); | ||
782 | 129 | } | ||
783 | 130 | |||
784 | 131 | namespace core { | ||
785 | 132 | namespace ubuntu { | ||
786 | 133 | namespace media { | ||
787 | 134 | |||
788 | 135 | std::ostream& operator<<(std::ostream& strm, Logger::Severity severity) { | ||
789 | 136 | switch (severity) { | ||
790 | 137 | case media::Logger::Severity::kTrace: return strm << "TT"; | ||
791 | 138 | case media::Logger::Severity::kDebug: return strm << "DD"; | ||
792 | 139 | case media::Logger::Severity::kInfo: return strm << "II"; | ||
793 | 140 | case media::Logger::Severity::kWarning: return strm << "WW"; | ||
794 | 141 | case media::Logger::Severity::kError: return strm << "EE"; | ||
795 | 142 | case media::Logger::Severity::kFatal: return strm << "FF"; | ||
796 | 143 | default: return strm << static_cast<uint>(severity); | ||
797 | 144 | } | ||
798 | 145 | } | ||
799 | 146 | |||
800 | 147 | std::ostream& operator<<(std::ostream& out, const Logger::Location &location) { | ||
801 | 148 | return out << Utils::Sprintf("%s:%d@%s", boost::filesystem::path(location.file).filename().string(), location.line, location.function); | ||
802 | 149 | } | ||
803 | 150 | |||
804 | 151 | Logger& Log() { | ||
805 | 152 | return *MutableInstance(); | ||
806 | 153 | } | ||
807 | 154 | |||
808 | 155 | void SetLogger(const std::shared_ptr<Logger>& logger) { | ||
809 | 156 | SetInstance(logger); | ||
810 | 157 | } | ||
811 | 158 | |||
812 | 159 | } // namespace media | ||
813 | 160 | } // namespace ubuntu | ||
814 | 161 | } // namespace core | ||
815 | 0 | 162 | ||
816 | === added file 'src/core/media/logger/logger.h' | |||
817 | --- src/core/media/logger/logger.h 1970-01-01 00:00:00 +0000 | |||
818 | +++ src/core/media/logger/logger.h 2016-04-07 00:39:05 +0000 | |||
819 | @@ -0,0 +1,131 @@ | |||
820 | 1 | /* | ||
821 | 2 | * Copyright © 2016 Canonical Ltd. | ||
822 | 3 | * | ||
823 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
824 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
825 | 6 | * as published by the Free Software Foundation. | ||
826 | 7 | * | ||
827 | 8 | * This program is distributed in the hope that it will be useful, | ||
828 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
829 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
830 | 11 | * GNU Lesser General Public License for more details. | ||
831 | 12 | * | ||
832 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
833 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
834 | 15 | * | ||
835 | 16 | */ | ||
836 | 17 | |||
837 | 18 | #ifndef LOGGER_H_ | ||
838 | 19 | #define LOGGER_H_ | ||
839 | 20 | |||
840 | 21 | #include "core/media/non_copyable.h" | ||
841 | 22 | #include "core/media/util/utils.h" | ||
842 | 23 | |||
843 | 24 | #include <boost/optional.hpp> | ||
844 | 25 | |||
845 | 26 | #include <string> | ||
846 | 27 | |||
847 | 28 | namespace core { | ||
848 | 29 | namespace ubuntu { | ||
849 | 30 | namespace media { | ||
850 | 31 | // A Logger enables persisting of messages describing & explaining the | ||
851 | 32 | // state of the system. | ||
852 | 33 | class Logger : public core::ubuntu::media::NonCopyable { | ||
853 | 34 | public: | ||
854 | 35 | // Severity enumerates all known severity levels | ||
855 | 36 | // applicable to log messages. | ||
856 | 37 | enum class Severity { | ||
857 | 38 | kTrace, | ||
858 | 39 | kDebug, | ||
859 | 40 | kInfo, | ||
860 | 41 | kWarning, | ||
861 | 42 | kError, | ||
862 | 43 | kFatal | ||
863 | 44 | }; | ||
864 | 45 | |||
865 | 46 | // A Location describes the origin of a log message. | ||
866 | 47 | struct Location { | ||
867 | 48 | std::string file; // The name of the file that contains the log message. | ||
868 | 49 | std::string function; // The function that contains the log message. | ||
869 | 50 | std::uint32_t line; // The line in file that resulted in the log message. | ||
870 | 51 | }; | ||
871 | 52 | |||
872 | 53 | virtual void Init(const core::ubuntu::media::Logger::Severity &severity = core::ubuntu::media::Logger::Severity::kWarning) = 0; | ||
873 | 54 | |||
874 | 55 | virtual void Log(Severity severity, const std::string &message, const boost::optional<Location>& location) = 0; | ||
875 | 56 | |||
876 | 57 | virtual void Trace(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
877 | 58 | virtual void Debug(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
878 | 59 | virtual void Info(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
879 | 60 | virtual void Warning(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
880 | 61 | virtual void Error(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
881 | 62 | virtual void Fatal(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
882 | 63 | |||
883 | 64 | |||
884 | 65 | template<typename... T> | ||
885 | 66 | void Tracef(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
886 | 67 | Trace(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
887 | 68 | } | ||
888 | 69 | |||
889 | 70 | template<typename... T> | ||
890 | 71 | void Debugf(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
891 | 72 | Debug(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
892 | 73 | } | ||
893 | 74 | |||
894 | 75 | template<typename... T> | ||
895 | 76 | void Infof(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
896 | 77 | Info(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
897 | 78 | } | ||
898 | 79 | |||
899 | 80 | template<typename... T> | ||
900 | 81 | void Warningf(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
901 | 82 | Warning(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
902 | 83 | } | ||
903 | 84 | |||
904 | 85 | template<typename... T> | ||
905 | 86 | void Errorf(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
906 | 87 | Error(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
907 | 88 | } | ||
908 | 89 | |||
909 | 90 | template<typename... T> | ||
910 | 91 | void Fatalf(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
911 | 92 | Fatal(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
912 | 93 | } | ||
913 | 94 | |||
914 | 95 | protected: | ||
915 | 96 | Logger() = default; | ||
916 | 97 | }; | ||
917 | 98 | |||
918 | 99 | // operator<< inserts severity into out. | ||
919 | 100 | std::ostream& operator<<(std::ostream& out, Logger::Severity severity); | ||
920 | 101 | |||
921 | 102 | // operator<< inserts location into out. | ||
922 | 103 | std::ostream& operator<<(std::ostream& out, const Logger::Location &location); | ||
923 | 104 | |||
924 | 105 | // Log returns the core::ubuntu::media-wide configured logger instance. | ||
925 | 106 | // Save to call before/after main. | ||
926 | 107 | Logger& Log(); | ||
927 | 108 | // SetLog installs the given logger as core::ubuntu::media-wide default logger. | ||
928 | 109 | void SetLogger(const std::shared_ptr<Logger>& logger); | ||
929 | 110 | |||
930 | 111 | #define TRACE(...) Log().Tracef(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
931 | 112 | #define DEBUG(...) Log().Debugf(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
932 | 113 | #define INFO(...) Log().Infof(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
933 | 114 | #define WARNING(...) Log().Warningf(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
934 | 115 | #define ERROR(...) Log().Errorf(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
935 | 116 | #define FATAL(...) Log().Fatalf(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
936 | 117 | } // namespace media | ||
937 | 118 | } // namespace ubuntu | ||
938 | 119 | } // namespace core | ||
939 | 120 | |||
940 | 121 | #define MH_TRACE(...) core::ubuntu::media::Log().Tracef(\ | ||
941 | 122 | core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
942 | 123 | #define MH_DEBUG(...) core::ubuntu::media::Log().Debugf(\ | ||
943 | 124 | core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
944 | 125 | #define MH_INFO(...) core::ubuntu::media::Log().Infof(\ | ||
945 | 126 | core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
946 | 127 | #define MH_WARNING(...) core::ubuntu::media::Log().Warningf(core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
947 | 128 | #define MH_ERROR(...) core::ubuntu::media::Log().Errorf(core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
948 | 129 | #define MH_FATAL(...) core::ubuntu::media::Log().Fatalf(core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
949 | 130 | |||
950 | 131 | #endif | ||
951 | 0 | 132 | ||
952 | === added file 'src/core/media/non_copyable.h' | |||
953 | --- src/core/media/non_copyable.h 1970-01-01 00:00:00 +0000 | |||
954 | +++ src/core/media/non_copyable.h 2016-04-07 00:39:05 +0000 | |||
955 | @@ -0,0 +1,36 @@ | |||
956 | 1 | /* | ||
957 | 2 | * Copyright © 2016 Canonical Ltd. | ||
958 | 3 | * | ||
959 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
960 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
961 | 6 | * as published by the Free Software Foundation. | ||
962 | 7 | * | ||
963 | 8 | * This program is distributed in the hope that it will be useful, | ||
964 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
965 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
966 | 11 | * GNU Lesser General Public License for more details. | ||
967 | 12 | * | ||
968 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
969 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
970 | 15 | * | ||
971 | 16 | */ | ||
972 | 17 | |||
973 | 18 | #ifndef NON_COPYABLE_H_ | ||
974 | 19 | #define NON_COPYABLE_H_ | ||
975 | 20 | |||
976 | 21 | namespace core { | ||
977 | 22 | namespace ubuntu { | ||
978 | 23 | namespace media { | ||
979 | 24 | // The alert reader might wonder why we don't use boost::noncopyable. The reason | ||
980 | 25 | // is simple: We would like to have a convenient virtual d'tor available. | ||
981 | 26 | struct NonCopyable { | ||
982 | 27 | NonCopyable() = default; | ||
983 | 28 | NonCopyable(const NonCopyable&) = delete; | ||
984 | 29 | virtual ~NonCopyable() = default; | ||
985 | 30 | NonCopyable& operator=(const NonCopyable&) = delete; | ||
986 | 31 | }; | ||
987 | 32 | } | ||
988 | 33 | } | ||
989 | 34 | } | ||
990 | 35 | |||
991 | 36 | #endif | ||
992 | 0 | 37 | ||
993 | === modified file 'src/core/media/player_implementation.cpp' | |||
994 | --- src/core/media/player_implementation.cpp 2016-02-19 16:14:42 +0000 | |||
995 | +++ src/core/media/player_implementation.cpp 2016-04-07 00:39:05 +0000 | |||
996 | @@ -28,9 +28,10 @@ | |||
997 | 28 | 28 | ||
998 | 29 | #include "gstreamer/engine.h" | 29 | #include "gstreamer/engine.h" |
999 | 30 | 30 | ||
1000 | 31 | #include "core/media/logger/logger.h" | ||
1001 | 32 | |||
1002 | 31 | #include <memory> | 33 | #include <memory> |
1003 | 32 | #include <exception> | 34 | #include <exception> |
1004 | 33 | #include <iostream> | ||
1005 | 34 | #include <mutex> | 35 | #include <mutex> |
1006 | 35 | 36 | ||
1007 | 36 | #define UNUSED __attribute__((unused)) | 37 | #define UNUSED __attribute__((unused)) |
1008 | @@ -75,22 +76,22 @@ | |||
1009 | 75 | // Poor man's logging of release/acquire events. | 76 | // Poor man's logging of release/acquire events. |
1010 | 76 | display_state_lock->acquired().connect([](media::power::DisplayState state) | 77 | display_state_lock->acquired().connect([](media::power::DisplayState state) |
1011 | 77 | { | 78 | { |
1013 | 78 | std::cout << "Acquired new display state: " << state << std::endl; | 79 | MH_INFO("Acquired new display state: %s", state); |
1014 | 79 | }); | 80 | }); |
1015 | 80 | 81 | ||
1016 | 81 | display_state_lock->released().connect([](media::power::DisplayState state) | 82 | display_state_lock->released().connect([](media::power::DisplayState state) |
1017 | 82 | { | 83 | { |
1019 | 83 | std::cout << "Released display state: " << state << std::endl; | 84 | MH_INFO("Released display state: %s", state); |
1020 | 84 | }); | 85 | }); |
1021 | 85 | 86 | ||
1022 | 86 | system_state_lock->acquired().connect([](media::power::SystemState state) | 87 | system_state_lock->acquired().connect([](media::power::SystemState state) |
1023 | 87 | { | 88 | { |
1025 | 88 | std::cout << "Acquired new system state: " << state << std::endl; | 89 | MH_INFO("Acquired new system state: %s", state); |
1026 | 89 | }); | 90 | }); |
1027 | 90 | 91 | ||
1028 | 91 | system_state_lock->released().connect([](media::power::SystemState state) | 92 | system_state_lock->released().connect([](media::power::SystemState state) |
1029 | 92 | { | 93 | { |
1031 | 93 | std::cout << "Released system state: " << state << std::endl; | 94 | MH_INFO("Released system state: %s", state); |
1032 | 94 | }); | 95 | }); |
1033 | 95 | } | 96 | } |
1034 | 96 | 97 | ||
1035 | @@ -120,7 +121,7 @@ | |||
1036 | 120 | */ | 121 | */ |
1037 | 121 | return [this](const Engine::State& state) | 122 | return [this](const Engine::State& state) |
1038 | 122 | { | 123 | { |
1040 | 123 | std::cout << "Setting state for parent: " << parent << std::endl; | 124 | MH_DEBUG("Setting state for parent: %s", parent); |
1041 | 124 | switch(state) | 125 | switch(state) |
1042 | 125 | { | 126 | { |
1043 | 126 | case Engine::State::ready: | 127 | case Engine::State::ready: |
1044 | @@ -139,7 +140,7 @@ | |||
1045 | 139 | parent->meta_data_for_current_track().set(std::get<1>(engine->track_meta_data().get())); | 140 | parent->meta_data_for_current_track().set(std::get<1>(engine->track_meta_data().get())); |
1046 | 140 | // And update our playback status. | 141 | // And update our playback status. |
1047 | 141 | parent->playback_status().set(media::Player::playing); | 142 | parent->playback_status().set(media::Player::playing); |
1049 | 142 | std::cout << "Requesting power state" << std::endl; | 143 | MH_INFO("Requesting power state"); |
1050 | 143 | request_power_state(); | 144 | request_power_state(); |
1051 | 144 | break; | 145 | break; |
1052 | 145 | } | 146 | } |
1053 | @@ -174,45 +175,44 @@ | |||
1054 | 174 | { | 175 | { |
1055 | 175 | return [this](const media::Player::PlaybackStatus& status) | 176 | return [this](const media::Player::PlaybackStatus& status) |
1056 | 176 | { | 177 | { |
1058 | 177 | std::cout << "Emiting playback_status_changed signal: " << status << std::endl; | 178 | MH_INFO("Emiting playback_status_changed signal: %s", status); |
1059 | 178 | parent->emit_playback_status_changed(status); | 179 | parent->emit_playback_status_changed(status); |
1060 | 179 | }; | 180 | }; |
1061 | 180 | } | 181 | } |
1062 | 181 | 182 | ||
1063 | 182 | void request_power_state() | 183 | void request_power_state() |
1064 | 183 | { | 184 | { |
1066 | 184 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 185 | MH_TRACE(""); |
1067 | 185 | try | 186 | try |
1068 | 186 | { | 187 | { |
1069 | 187 | if (parent->is_video_source()) | 188 | if (parent->is_video_source()) |
1070 | 188 | { | 189 | { |
1071 | 189 | if (++display_wakelock_count == 1) | 190 | if (++display_wakelock_count == 1) |
1072 | 190 | { | 191 | { |
1074 | 191 | std::cout << "Requesting new display wakelock." << std::endl; | 192 | MH_INFO("Requesting new display wakelock."); |
1075 | 192 | display_state_lock->request_acquire(media::power::DisplayState::on); | 193 | display_state_lock->request_acquire(media::power::DisplayState::on); |
1077 | 193 | std::cout << "Requested new display wakelock." << std::endl; | 194 | MH_INFO("Requested new display wakelock."); |
1078 | 194 | } | 195 | } |
1079 | 195 | } | 196 | } |
1080 | 196 | else | 197 | else |
1081 | 197 | { | 198 | { |
1082 | 198 | if (++system_wakelock_count == 1) | 199 | if (++system_wakelock_count == 1) |
1083 | 199 | { | 200 | { |
1085 | 200 | std::cout << "Requesting new system wakelock." << std::endl; | 201 | MH_INFO("Requesting new system wakelock."); |
1086 | 201 | system_state_lock->request_acquire(media::power::SystemState::active); | 202 | system_state_lock->request_acquire(media::power::SystemState::active); |
1088 | 202 | std::cout << "Requested new system wakelock." << std::endl; | 203 | MH_INFO("Requested new system wakelock."); |
1089 | 203 | } | 204 | } |
1090 | 204 | } | 205 | } |
1091 | 205 | } | 206 | } |
1092 | 206 | catch(const std::exception& e) | 207 | catch(const std::exception& e) |
1093 | 207 | { | 208 | { |
1096 | 208 | std::cerr << "Warning: failed to request power state: "; | 209 | MH_WARNING("Failed to request power state: %s", e.what()); |
1095 | 209 | std::cerr << e.what() << std::endl; | ||
1097 | 210 | } | 210 | } |
1098 | 211 | } | 211 | } |
1099 | 212 | 212 | ||
1100 | 213 | void clear_wakelock(const wakelock_clear_t &wakelock) | 213 | void clear_wakelock(const wakelock_clear_t &wakelock) |
1101 | 214 | { | 214 | { |
1103 | 215 | cout << __PRETTY_FUNCTION__ << endl; | 215 | MH_TRACE(""); |
1104 | 216 | try | 216 | try |
1105 | 217 | { | 217 | { |
1106 | 218 | switch (wakelock) | 218 | switch (wakelock) |
1107 | @@ -223,7 +223,7 @@ | |||
1108 | 223 | // Only actually clear the system wakelock once the count reaches zero | 223 | // Only actually clear the system wakelock once the count reaches zero |
1109 | 224 | if (--system_wakelock_count == 0) | 224 | if (--system_wakelock_count == 0) |
1110 | 225 | { | 225 | { |
1112 | 226 | std::cout << "Clearing system wakelock." << std::endl; | 226 | MH_INFO("Clearing system wakelock."); |
1113 | 227 | system_state_lock->request_release(media::power::SystemState::active); | 227 | system_state_lock->request_release(media::power::SystemState::active); |
1114 | 228 | } | 228 | } |
1115 | 229 | break; | 229 | break; |
1116 | @@ -231,19 +231,18 @@ | |||
1117 | 231 | // Only actually clear the display wakelock once the count reaches zero | 231 | // Only actually clear the display wakelock once the count reaches zero |
1118 | 232 | if (--display_wakelock_count == 0) | 232 | if (--display_wakelock_count == 0) |
1119 | 233 | { | 233 | { |
1121 | 234 | std::cout << "Clearing display wakelock." << std::endl; | 234 | MH_INFO("Clearing display wakelock."); |
1122 | 235 | display_state_lock->request_release(media::power::DisplayState::on); | 235 | display_state_lock->request_release(media::power::DisplayState::on); |
1123 | 236 | } | 236 | } |
1124 | 237 | break; | 237 | break; |
1125 | 238 | case wakelock_clear_t::WAKELOCK_CLEAR_INVALID: | 238 | case wakelock_clear_t::WAKELOCK_CLEAR_INVALID: |
1126 | 239 | default: | 239 | default: |
1128 | 240 | cerr << "Can't clear invalid wakelock type" << endl; | 240 | MH_WARNING("Can't clear invalid wakelock type"); |
1129 | 241 | } | 241 | } |
1130 | 242 | } | 242 | } |
1131 | 243 | catch(const std::exception& e) | 243 | catch(const std::exception& e) |
1132 | 244 | { | 244 | { |
1135 | 245 | std::cerr << "Warning: failed to clear power state: "; | 245 | MH_WARNING("Failed to request clear power state: %s", e.what()); |
1134 | 246 | std::cerr << e.what() << std::endl; | ||
1136 | 247 | } | 246 | } |
1137 | 248 | } | 247 | } |
1138 | 249 | 248 | ||
1139 | @@ -294,9 +293,9 @@ | |||
1140 | 294 | { | 293 | { |
1141 | 295 | // Using a TrackList for playback, added tracks via add_track(), but open_uri hasn't | 294 | // Using a TrackList for playback, added tracks via add_track(), but open_uri hasn't |
1142 | 296 | // been called yet to load a media resource | 295 | // been called yet to load a media resource |
1146 | 297 | std::cout << "Calling d->engine->open_resource_for_uri() for first track added only: " | 296 | MH_INFO("Calling d->engine->open_resource_for_uri() for first track added only: %s", |
1147 | 298 | << uri << std::endl; | 297 | uri); |
1148 | 299 | std::cout << "\twith a Track::Id: " << id << std::endl; | 298 | MH_INFO("\twith a Track::Id: %s", id); |
1149 | 300 | static const bool do_pipeline_reset = false; | 299 | static const bool do_pipeline_reset = false; |
1150 | 301 | engine->open_resource_for_uri(uri, do_pipeline_reset); | 300 | engine->open_resource_for_uri(uri, do_pipeline_reset); |
1151 | 302 | } | 301 | } |
1152 | @@ -311,10 +310,10 @@ | |||
1153 | 311 | auto n_tracks = track_list->tracks()->size(); | 310 | auto n_tracks = track_list->tracks()->size(); |
1154 | 312 | bool has_tracks = (n_tracks > 0) ? true : false; | 311 | bool has_tracks = (n_tracks > 0) ? true : false; |
1155 | 313 | 312 | ||
1160 | 314 | std::cout << "Updating MPRIS TrackList properties" | 313 | MH_INFO("Updating MPRIS TrackList properties:"); |
1161 | 315 | << "; Tracks: " << n_tracks | 314 | MH_INFO("\tTracks: %d", n_tracks); |
1162 | 316 | << ", has_previous: " << has_previous | 315 | MH_INFO("\thas_previous: %d", has_previous); |
1163 | 317 | << ", has_next: " << has_next << std::endl; | 316 | MH_INFO("\thas_next: %d", has_next); |
1164 | 318 | 317 | ||
1165 | 319 | // Update properties | 318 | // Update properties |
1166 | 320 | parent->can_play().set(has_tracks); | 319 | parent->can_play().set(has_tracks); |
1167 | @@ -418,7 +417,7 @@ | |||
1168 | 418 | // When the client changes the loop status, make sure to update the TrackList | 417 | // When the client changes the loop status, make sure to update the TrackList |
1169 | 419 | Parent::loop_status().changed().connect([this](media::Player::LoopStatus loop_status) | 418 | Parent::loop_status().changed().connect([this](media::Player::LoopStatus loop_status) |
1170 | 420 | { | 419 | { |
1172 | 421 | std::cout << "LoopStatus: " << loop_status << std::endl; | 420 | MH_INFO("LoopStatus: %s", loop_status); |
1173 | 422 | d->track_list->on_loop_status_changed(loop_status); | 421 | d->track_list->on_loop_status_changed(loop_status); |
1174 | 423 | }); | 422 | }); |
1175 | 424 | 423 | ||
1176 | @@ -465,7 +464,7 @@ | |||
1177 | 465 | const Track::UriType uri = d->track_list->query_uri_for_track(d->track_list->next()); | 464 | const Track::UriType uri = d->track_list->query_uri_for_track(d->track_list->next()); |
1178 | 466 | if (prev_track_id != d->track_list->current() && !uri.empty()) | 465 | if (prev_track_id != d->track_list->current() && !uri.empty()) |
1179 | 467 | { | 466 | { |
1181 | 468 | std::cout << "Advancing to next track on playbin: " << uri << std::endl; | 467 | MH_INFO("Advancing to next track on playbin: %s", uri); |
1182 | 469 | static const bool do_pipeline_reset = false; | 468 | static const bool do_pipeline_reset = false; |
1183 | 470 | d->engine->open_resource_for_uri(uri, do_pipeline_reset); | 469 | d->engine->open_resource_for_uri(uri, do_pipeline_reset); |
1184 | 471 | } | 470 | } |
1185 | @@ -508,7 +507,7 @@ | |||
1186 | 508 | if (d->engine->state() != gstreamer::Engine::State::ready | 507 | if (d->engine->state() != gstreamer::Engine::State::ready |
1187 | 509 | && d->engine->state() != gstreamer::Engine::State::stopped) | 508 | && d->engine->state() != gstreamer::Engine::State::stopped) |
1188 | 510 | { | 509 | { |
1190 | 511 | std::cout << "End of tracklist reached, stopping playback" << std::endl; | 510 | MH_INFO("End of tracklist reached, stopping playback"); |
1191 | 512 | d->engine->stop(); | 511 | d->engine->stop(); |
1192 | 513 | } | 512 | } |
1193 | 514 | }); | 513 | }); |
1194 | @@ -528,15 +527,15 @@ | |||
1195 | 528 | const Track::UriType uri = d->track_list->query_uri_for_track(id); | 527 | const Track::UriType uri = d->track_list->query_uri_for_track(id); |
1196 | 529 | if (!uri.empty()) | 528 | if (!uri.empty()) |
1197 | 530 | { | 529 | { |
1200 | 531 | std::cout << "Setting next track on playbin (on_go_to_track signal): " << uri << std::endl; | 530 | MH_INFO("Setting next track on playbin (on_go_to_track signal): %s", uri); |
1201 | 532 | std::cout << "\twith a Track::Id: " << id << std::endl; | 531 | MH_INFO("\twith a Track::Id: %s", id); |
1202 | 533 | static const bool do_pipeline_reset = true; | 532 | static const bool do_pipeline_reset = true; |
1203 | 534 | d->engine->open_resource_for_uri(uri, do_pipeline_reset); | 533 | d->engine->open_resource_for_uri(uri, do_pipeline_reset); |
1204 | 535 | } | 534 | } |
1205 | 536 | 535 | ||
1206 | 537 | if (auto_play) | 536 | if (auto_play) |
1207 | 538 | { | 537 | { |
1209 | 539 | std::cout << "Restoring playing state in on_go_to_track()" << std::endl; | 538 | MH_DEBUG("Restoring playing state"); |
1210 | 540 | d->engine->play(); | 539 | d->engine->play(); |
1211 | 541 | } | 540 | } |
1212 | 542 | 541 | ||
1213 | @@ -545,7 +544,7 @@ | |||
1214 | 545 | 544 | ||
1215 | 546 | d->track_list->on_track_added().connect([this](const media::Track::Id& id) | 545 | d->track_list->on_track_added().connect([this](const media::Track::Id& id) |
1216 | 547 | { | 546 | { |
1218 | 548 | std::cout << "** Track was added, handling in PlayerImplementation" << std::endl; | 547 | MH_TRACE("** Track was added, handling in PlayerImplementation"); |
1219 | 549 | if (d->track_list->tracks()->size() == 1) | 548 | if (d->track_list->tracks()->size() == 1) |
1220 | 550 | d->open_first_track_from_tracklist(id); | 549 | d->open_first_track_from_tracklist(id); |
1221 | 551 | 550 | ||
1222 | @@ -554,7 +553,7 @@ | |||
1223 | 554 | 553 | ||
1224 | 555 | d->track_list->on_tracks_added().connect([this](const media::TrackList::ContainerURI& tracks) | 554 | d->track_list->on_tracks_added().connect([this](const media::TrackList::ContainerURI& tracks) |
1225 | 556 | { | 555 | { |
1227 | 557 | std::cout << "** Track was added, handling in PlayerImplementation" << std::endl; | 556 | MH_TRACE("** Track was added, handling in PlayerImplementation"); |
1228 | 558 | // If the two sizes are the same, that means the TrackList was previously empty and we need | 557 | // If the two sizes are the same, that means the TrackList was previously empty and we need |
1229 | 559 | // to open the first track in the TrackList so that is_audio_source() and is_video_source() | 558 | // to open the first track in the TrackList so that is_audio_source() and is_video_source() |
1230 | 560 | // will function correctly. | 559 | // will function correctly. |
1231 | @@ -689,7 +688,7 @@ | |||
1232 | 689 | 688 | ||
1233 | 690 | // If empty uri, give the same meaning as QMediaPlayer::setMedia("") | 689 | // If empty uri, give the same meaning as QMediaPlayer::setMedia("") |
1234 | 691 | if (uri.empty()) { | 690 | if (uri.empty()) { |
1236 | 692 | cout << __PRETTY_FUNCTION__ << ": resetting current media" << endl; | 691 | MH_DEBUG("Resetting current media"); |
1237 | 693 | return true; | 692 | return true; |
1238 | 694 | } | 693 | } |
1239 | 695 | 694 | ||
1240 | @@ -722,19 +721,21 @@ | |||
1241 | 722 | template<typename Parent> | 721 | template<typename Parent> |
1242 | 723 | void media::PlayerImplementation<Parent>::play() | 722 | void media::PlayerImplementation<Parent>::play() |
1243 | 724 | { | 723 | { |
1244 | 724 | MH_TRACE(""); | ||
1245 | 725 | d->engine->play(); | 725 | d->engine->play(); |
1246 | 726 | } | 726 | } |
1247 | 727 | 727 | ||
1248 | 728 | template<typename Parent> | 728 | template<typename Parent> |
1249 | 729 | void media::PlayerImplementation<Parent>::pause() | 729 | void media::PlayerImplementation<Parent>::pause() |
1250 | 730 | { | 730 | { |
1251 | 731 | MH_TRACE(""); | ||
1252 | 731 | d->engine->pause(); | 732 | d->engine->pause(); |
1253 | 732 | } | 733 | } |
1254 | 733 | 734 | ||
1255 | 734 | template<typename Parent> | 735 | template<typename Parent> |
1256 | 735 | void media::PlayerImplementation<Parent>::stop() | 736 | void media::PlayerImplementation<Parent>::stop() |
1257 | 736 | { | 737 | { |
1259 | 737 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 738 | MH_TRACE(""); |
1260 | 738 | d->engine->stop(); | 739 | d->engine->stop(); |
1261 | 739 | } | 740 | } |
1262 | 740 | 741 | ||
1263 | 741 | 742 | ||
1264 | === modified file 'src/core/media/player_skeleton.cpp' | |||
1265 | --- src/core/media/player_skeleton.cpp 2016-02-19 16:14:42 +0000 | |||
1266 | +++ src/core/media/player_skeleton.cpp 2016-04-07 00:39:05 +0000 | |||
1267 | @@ -31,6 +31,8 @@ | |||
1268 | 31 | #include "mpris/metadata.h" | 31 | #include "mpris/metadata.h" |
1269 | 32 | #include "mpris/player.h" | 32 | #include "mpris/player.h" |
1270 | 33 | #include "mpris/playlists.h" | 33 | #include "mpris/playlists.h" |
1271 | 34 | |||
1272 | 35 | #include "core/media/logger/logger.h" | ||
1273 | 34 | #include "util/uri_check.h" | 36 | #include "util/uri_check.h" |
1274 | 35 | 37 | ||
1275 | 36 | #include <core/dbus/object.h> | 38 | #include <core/dbus/object.h> |
1276 | @@ -189,7 +191,7 @@ | |||
1277 | 189 | { | 191 | { |
1278 | 190 | const std::string err_str = {"Warning: Failed to open uri " + uri + | 192 | const std::string err_str = {"Warning: Failed to open uri " + uri + |
1279 | 191 | " because it can't be found."}; | 193 | " because it can't be found."}; |
1281 | 192 | std::cerr << err_str << std::endl; | 194 | MH_ERROR("%s", err_str); |
1282 | 193 | reply = dbus::Message::make_error( | 195 | reply = dbus::Message::make_error( |
1283 | 194 | in, | 196 | in, |
1284 | 195 | mpris::Player::Error::UriNotFound::name, | 197 | mpris::Player::Error::UriNotFound::name, |
1285 | @@ -207,7 +209,7 @@ | |||
1286 | 207 | { | 209 | { |
1287 | 208 | const std::string err_str = {"Warning: Failed to authenticate necessary " | 210 | const std::string err_str = {"Warning: Failed to authenticate necessary " |
1288 | 209 | "apparmor permissions to open uri: " + std::get<1>(result)}; | 211 | "apparmor permissions to open uri: " + std::get<1>(result)}; |
1290 | 210 | std::cerr << err_str << std::endl; | 212 | MH_ERROR("%s", err_str); |
1291 | 211 | reply = dbus::Message::make_error( | 213 | reply = dbus::Message::make_error( |
1292 | 212 | in, | 214 | in, |
1293 | 213 | mpris::Player::Error::InsufficientAppArmorPermissions::name, | 215 | mpris::Player::Error::InsufficientAppArmorPermissions::name, |
1294 | @@ -236,7 +238,7 @@ | |||
1295 | 236 | { | 238 | { |
1296 | 237 | const std::string err_str = {"Warning: Failed to open uri " + uri + | 239 | const std::string err_str = {"Warning: Failed to open uri " + uri + |
1297 | 238 | " because it can't be found."}; | 240 | " because it can't be found."}; |
1299 | 239 | std::cerr << err_str << std::endl; | 241 | MH_ERROR("%s", err_str); |
1300 | 240 | reply = dbus::Message::make_error( | 242 | reply = dbus::Message::make_error( |
1301 | 241 | in, | 243 | in, |
1302 | 242 | mpris::Player::Error::UriNotFound::name, | 244 | mpris::Player::Error::UriNotFound::name, |
1303 | @@ -254,7 +256,7 @@ | |||
1304 | 254 | { | 256 | { |
1305 | 255 | const std::string err_str = {"Warning: Failed to authenticate necessary " | 257 | const std::string err_str = {"Warning: Failed to authenticate necessary " |
1306 | 256 | "apparmor permissions to open uri: " + std::get<1>(result)}; | 258 | "apparmor permissions to open uri: " + std::get<1>(result)}; |
1308 | 257 | std::cerr << err_str << std::endl; | 259 | MH_ERROR("%s", err_str); |
1309 | 258 | reply = dbus::Message::make_error( | 260 | reply = dbus::Message::make_error( |
1310 | 259 | in, | 261 | in, |
1311 | 260 | mpris::Player::Error::InsufficientAppArmorPermissions::name, | 262 | mpris::Player::Error::InsufficientAppArmorPermissions::name, |
1312 | 261 | 263 | ||
1313 | === modified file 'src/core/media/player_stub.cpp' | |||
1314 | --- src/core/media/player_stub.cpp 2016-02-19 16:14:42 +0000 | |||
1315 | +++ src/core/media/player_stub.cpp 2016-04-07 00:39:05 +0000 | |||
1316 | @@ -30,10 +30,13 @@ | |||
1317 | 30 | 30 | ||
1318 | 31 | #include "mpris/player.h" | 31 | #include "mpris/player.h" |
1319 | 32 | 32 | ||
1320 | 33 | #include "core/media/logger/logger.h" | ||
1321 | 34 | |||
1322 | 33 | #include <core/dbus/property.h> | 35 | #include <core/dbus/property.h> |
1323 | 34 | #include <core/dbus/types/object_path.h> | 36 | #include <core/dbus/types/object_path.h> |
1324 | 35 | 37 | ||
1325 | 36 | #include <limits> | 38 | #include <limits> |
1326 | 39 | #include <sstream> | ||
1327 | 37 | 40 | ||
1328 | 38 | #define UNUSED __attribute__((unused)) | 41 | #define UNUSED __attribute__((unused)) |
1329 | 39 | 42 | ||
1330 | @@ -159,37 +162,38 @@ | |||
1331 | 159 | { | 162 | { |
1332 | 160 | dbus.seeked_to->connect([this](std::uint64_t value) | 163 | dbus.seeked_to->connect([this](std::uint64_t value) |
1333 | 161 | { | 164 | { |
1335 | 162 | std::cout << "SeekedTo signal arrived via the bus." << std::endl; | 165 | MH_DEBUG("SeekedTo signal arrived via the bus."); |
1336 | 163 | seeked_to(value); | 166 | seeked_to(value); |
1337 | 164 | }); | 167 | }); |
1338 | 165 | 168 | ||
1339 | 166 | dbus.about_to_finish->connect([this]() | 169 | dbus.about_to_finish->connect([this]() |
1340 | 167 | { | 170 | { |
1342 | 168 | std::cout << "AboutToFinish signal arrived via the bus." << std::endl; | 171 | MH_DEBUG("AboutToFinish signal arrived via the bus."); |
1343 | 169 | about_to_finish(); | 172 | about_to_finish(); |
1344 | 170 | }); | 173 | }); |
1345 | 171 | 174 | ||
1346 | 172 | dbus.end_of_stream->connect([this]() | 175 | dbus.end_of_stream->connect([this]() |
1347 | 173 | { | 176 | { |
1349 | 174 | std::cout << "EndOfStream signal arrived via the bus." << std::endl; | 177 | MH_DEBUG("EndOfStream signal arrived via the bus."); |
1350 | 175 | end_of_stream(); | 178 | end_of_stream(); |
1351 | 176 | }); | 179 | }); |
1352 | 177 | 180 | ||
1353 | 178 | dbus.playback_status_changed->connect([this](const media::Player::PlaybackStatus& status) | 181 | dbus.playback_status_changed->connect([this](const media::Player::PlaybackStatus& status) |
1354 | 179 | { | 182 | { |
1356 | 180 | std::cout << "PlaybackStatusChanged signal arrived via the bus (Status: " << status << ")" << std::endl; | 183 | MH_DEBUG("PlaybackStatusChanged signal arrived via the bus (status: %s)", |
1357 | 184 | status); | ||
1358 | 181 | playback_status_changed(status); | 185 | playback_status_changed(status); |
1359 | 182 | }); | 186 | }); |
1360 | 183 | 187 | ||
1361 | 184 | dbus.video_dimension_changed->connect([this](const media::video::Dimensions dimensions) | 188 | dbus.video_dimension_changed->connect([this](const media::video::Dimensions dimensions) |
1362 | 185 | { | 189 | { |
1364 | 186 | std::cout << "VideoDimensionChanged signal arrived via the bus." << std::endl; | 190 | MH_DEBUG("VideoDimensionChanged signal arrived via the bus."); |
1365 | 187 | video_dimension_changed(dimensions); | 191 | video_dimension_changed(dimensions); |
1366 | 188 | }); | 192 | }); |
1367 | 189 | 193 | ||
1368 | 190 | dbus.error->connect([this](const media::Player::Error& e) | 194 | dbus.error->connect([this](const media::Player::Error& e) |
1369 | 191 | { | 195 | { |
1371 | 192 | std::cout << "Error signal arrived via the bus (Error: " << e << ")" << std::endl; | 196 | MH_DEBUG("Error signal arrived via the bus (error: %s)", e); |
1372 | 193 | error(e); | 197 | error(e); |
1373 | 194 | }); | 198 | }); |
1374 | 195 | } | 199 | } |
1375 | 196 | 200 | ||
1376 | === modified file 'src/core/media/power/state_controller.cpp' | |||
1377 | --- src/core/media/power/state_controller.cpp 2015-05-27 18:37:24 +0000 | |||
1378 | +++ src/core/media/power/state_controller.cpp 2016-04-07 00:39:05 +0000 | |||
1379 | @@ -16,13 +16,13 @@ | |||
1380 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
1381 | 17 | */ | 17 | */ |
1382 | 18 | 18 | ||
1383 | 19 | #include "core/media/logger/logger.h" | ||
1384 | 20 | |||
1385 | 19 | #include <core/media/power/state_controller.h> | 21 | #include <core/media/power/state_controller.h> |
1386 | 20 | 22 | ||
1387 | 21 | #include <core/dbus/macros.h> | 23 | #include <core/dbus/macros.h> |
1388 | 22 | #include <core/dbus/object.h> | 24 | #include <core/dbus/object.h> |
1389 | 23 | 25 | ||
1390 | 24 | #include <iostream> | ||
1391 | 25 | |||
1392 | 26 | namespace media = core::ubuntu::media; | 26 | namespace media = core::ubuntu::media; |
1393 | 27 | 27 | ||
1394 | 28 | namespace com { namespace canonical { | 28 | namespace com { namespace canonical { |
1395 | @@ -98,7 +98,7 @@ | |||
1396 | 98 | // From core::ubuntu::media::power::StateController::Lock<DisplayState> | 98 | // From core::ubuntu::media::power::StateController::Lock<DisplayState> |
1397 | 99 | void request_acquire(media::power::DisplayState state) override | 99 | void request_acquire(media::power::DisplayState state) override |
1398 | 100 | { | 100 | { |
1400 | 101 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 101 | MH_TRACE(""); |
1401 | 102 | 102 | ||
1402 | 103 | if (state == media::power::DisplayState::off) | 103 | if (state == media::power::DisplayState::off) |
1403 | 104 | return; | 104 | return; |
1404 | @@ -110,7 +110,7 @@ | |||
1405 | 110 | { | 110 | { |
1406 | 111 | if (result.is_error()) | 111 | if (result.is_error()) |
1407 | 112 | { | 112 | { |
1409 | 113 | std::cerr << result.error().print() << std::endl; | 113 | MH_ERROR("%s", result.error().print()); |
1410 | 114 | return; | 114 | return; |
1411 | 115 | } | 115 | } |
1412 | 116 | 116 | ||
1413 | @@ -149,7 +149,7 @@ | |||
1414 | 149 | { | 149 | { |
1415 | 150 | if (result.is_error()) | 150 | if (result.is_error()) |
1416 | 151 | { | 151 | { |
1418 | 152 | std::cerr << result.error().print() << std::endl; | 152 | MH_ERROR("%s", result.error().print()); |
1419 | 153 | return; | 153 | return; |
1420 | 154 | } | 154 | } |
1421 | 155 | 155 | ||
1422 | @@ -207,7 +207,7 @@ | |||
1423 | 207 | // the system to stay active. | 207 | // the system to stay active. |
1424 | 208 | void request_acquire(media::power::SystemState state) override | 208 | void request_acquire(media::power::SystemState state) override |
1425 | 209 | { | 209 | { |
1427 | 210 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 210 | MH_TRACE(""); |
1428 | 211 | 211 | ||
1429 | 212 | if (state == media::power::SystemState::suspend) | 212 | if (state == media::power::SystemState::suspend) |
1430 | 213 | return; | 213 | return; |
1431 | @@ -223,7 +223,7 @@ | |||
1432 | 223 | } | 223 | } |
1433 | 224 | else | 224 | else |
1434 | 225 | { | 225 | { |
1436 | 226 | std::cerr << "Failed to lock system_state_cookie_store_guard and check system lock state" << std::endl; | 226 | MH_WARNING("Failed to lock system_state_cookie_store_guard and check system lock state"); |
1437 | 227 | // Prevent system_state_cookie_store.count(state) and the actual call to requestSysState below from | 227 | // Prevent system_state_cookie_store.count(state) and the actual call to requestSysState below from |
1438 | 228 | // getting out of sync. | 228 | // getting out of sync. |
1439 | 229 | return; | 229 | return; |
1440 | @@ -236,7 +236,7 @@ | |||
1441 | 236 | { | 236 | { |
1442 | 237 | if (result.is_error()) | 237 | if (result.is_error()) |
1443 | 238 | { | 238 | { |
1445 | 239 | std::cerr << result.error().print() << std::endl; | 239 | MH_ERROR("%s", result.error().print()); |
1446 | 240 | return; | 240 | return; |
1447 | 241 | } | 241 | } |
1448 | 242 | 242 | ||
1449 | @@ -249,7 +249,7 @@ | |||
1450 | 249 | if (ul.owns_lock()) | 249 | if (ul.owns_lock()) |
1451 | 250 | sp->system_state_cookie_store[state] = result.value(); | 250 | sp->system_state_cookie_store[state] = result.value(); |
1452 | 251 | else | 251 | else |
1454 | 252 | std::cerr << "Failed to lock system_state_cookie_store_guard and update system lock state" << std::endl; | 252 | MH_WARNING("Failed to lock system_state_cookie_store_guard and update system lock state"); |
1455 | 253 | } | 253 | } |
1456 | 254 | 254 | ||
1457 | 255 | sp->signals.acquired(state); | 255 | sp->signals.acquired(state); |
1458 | @@ -275,7 +275,7 @@ | |||
1459 | 275 | } | 275 | } |
1460 | 276 | else | 276 | else |
1461 | 277 | { | 277 | { |
1463 | 278 | std::cerr << "Failed to lock system_state_cookie_store_guard and check system lock state" << std::endl; | 278 | MH_WARNING("Failed to lock system_state_cookie_store_guard and check system lock state"); |
1464 | 279 | // Prevent system_state_cookie_store.count(state) and the actual call to clearSysState below from | 279 | // Prevent system_state_cookie_store.count(state) and the actual call to clearSysState below from |
1465 | 280 | // getting out of sync. | 280 | // getting out of sync. |
1466 | 281 | return; | 281 | return; |
1467 | @@ -287,7 +287,7 @@ | |||
1468 | 287 | object->invoke_method_asynchronously_with_callback<com::canonical::powerd::Interface::clearSysState, void>([this, wp, state](const core::dbus::Result<void>& result) | 287 | object->invoke_method_asynchronously_with_callback<com::canonical::powerd::Interface::clearSysState, void>([this, wp, state](const core::dbus::Result<void>& result) |
1469 | 288 | { | 288 | { |
1470 | 289 | if (result.is_error()) | 289 | if (result.is_error()) |
1472 | 290 | std::cerr << result.error().print() << std::endl; | 290 | MH_ERROR("%s", result.error().print()); |
1473 | 291 | 291 | ||
1474 | 292 | if (auto sp = wp.lock()) | 292 | if (auto sp = wp.lock()) |
1475 | 293 | { | 293 | { |
1476 | @@ -297,7 +297,7 @@ | |||
1477 | 297 | if (ul.owns_lock()) | 297 | if (ul.owns_lock()) |
1478 | 298 | sp->system_state_cookie_store.erase(state); | 298 | sp->system_state_cookie_store.erase(state); |
1479 | 299 | else | 299 | else |
1481 | 300 | std::cerr << "Failed to lock system_state_cookie_store_guard and erase system lock state" << std::endl; | 300 | MH_WARNING("Failed to lock system_state_cookie_store_guard and erase system lock state"); |
1482 | 301 | } | 301 | } |
1483 | 302 | 302 | ||
1484 | 303 | sp->signals.released(state); | 303 | sp->signals.released(state); |
1485 | @@ -369,7 +369,7 @@ | |||
1486 | 369 | 369 | ||
1487 | 370 | media::power::StateController::Ptr media::power::make_platform_default_state_controller(core::ubuntu::media::helper::ExternalServices& external_services) | 370 | media::power::StateController::Ptr media::power::make_platform_default_state_controller(core::ubuntu::media::helper::ExternalServices& external_services) |
1488 | 371 | { | 371 | { |
1490 | 372 | return std::make_shared<impl::StateController>(external_services); | 372 | return std::make_shared<::impl::StateController>(external_services); |
1491 | 373 | } | 373 | } |
1492 | 374 | 374 | ||
1493 | 375 | // operator<< pretty prints the given display state to the given output stream. | 375 | // operator<< pretty prints the given display state to the given output stream. |
1494 | 376 | 376 | ||
1495 | === modified file 'src/core/media/server/server.cpp' | |||
1496 | --- src/core/media/server/server.cpp 2015-04-10 16:13:55 +0000 | |||
1497 | +++ src/core/media/server/server.cpp 2016-04-07 00:39:05 +0000 | |||
1498 | @@ -21,6 +21,7 @@ | |||
1499 | 21 | #include <core/media/track_list.h> | 21 | #include <core/media/track_list.h> |
1500 | 22 | 22 | ||
1501 | 23 | #include "core/media/hashed_keyed_player_store.h" | 23 | #include "core/media/hashed_keyed_player_store.h" |
1502 | 24 | #include "core/media/logger/logger.h" | ||
1503 | 24 | #include "core/media/service_implementation.h" | 25 | #include "core/media/service_implementation.h" |
1504 | 25 | 26 | ||
1505 | 26 | #include <core/posix/signal.h> | 27 | #include <core/posix/signal.h> |
1506 | @@ -36,6 +37,37 @@ | |||
1507 | 36 | 37 | ||
1508 | 37 | namespace | 38 | namespace |
1509 | 38 | { | 39 | { |
1510 | 40 | void logger_init() | ||
1511 | 41 | { | ||
1512 | 42 | const char *level = ::getenv("MH_LOG_LEVEL"); | ||
1513 | 43 | // Default level is kInfo | ||
1514 | 44 | media::Logger::Severity severity{media::Logger::Severity::kInfo}; | ||
1515 | 45 | if (level) | ||
1516 | 46 | { | ||
1517 | 47 | if (strcmp(level, "trace") == 0) | ||
1518 | 48 | severity = media::Logger::Severity::kTrace; | ||
1519 | 49 | else if (strcmp(level, "debug") == 0) | ||
1520 | 50 | severity = media::Logger::Severity::kDebug; | ||
1521 | 51 | else if (strcmp(level, "info") == 0) | ||
1522 | 52 | severity = media::Logger::Severity::kInfo; | ||
1523 | 53 | else if (strcmp(level, "warning") == 0) | ||
1524 | 54 | severity = media::Logger::Severity::kWarning; | ||
1525 | 55 | else if (strcmp(level, "error") == 0) | ||
1526 | 56 | severity = media::Logger::Severity::kError; | ||
1527 | 57 | else if (strcmp(level, "fatal") == 0) | ||
1528 | 58 | severity = media::Logger::Severity::kFatal; | ||
1529 | 59 | else | ||
1530 | 60 | std::cerr << "Invalid log level \"" << level | ||
1531 | 61 | << "\", setting to info. Valid options: [trace, debug, info, warning, error, fatal]. " | ||
1532 | 62 | << std::endl; | ||
1533 | 63 | } | ||
1534 | 64 | else | ||
1535 | 65 | std::cout << "Using default log level: info" << std::endl; | ||
1536 | 66 | |||
1537 | 67 | media::Log().Init(severity); | ||
1538 | 68 | cout << "Log level: " << severity << std::endl; | ||
1539 | 69 | } | ||
1540 | 70 | |||
1541 | 39 | // All platform-specific initialization routines go here. | 71 | // All platform-specific initialization routines go here. |
1542 | 40 | void platform_init() | 72 | void platform_init() |
1543 | 41 | { | 73 | { |
1544 | @@ -66,6 +98,8 @@ | |||
1545 | 66 | trap->stop(); | 98 | trap->stop(); |
1546 | 67 | }); | 99 | }); |
1547 | 68 | 100 | ||
1548 | 101 | logger_init(); | ||
1549 | 102 | |||
1550 | 69 | // Init platform-specific functionality. | 103 | // Init platform-specific functionality. |
1551 | 70 | platform_init(); | 104 | platform_init(); |
1552 | 71 | 105 | ||
1553 | 72 | 106 | ||
1554 | === modified file 'src/core/media/service.cpp' | |||
1555 | --- src/core/media/service.cpp 2014-04-09 14:05:55 +0000 | |||
1556 | +++ src/core/media/service.cpp 2016-04-07 00:39:05 +0000 | |||
1557 | @@ -18,13 +18,15 @@ | |||
1558 | 18 | 18 | ||
1559 | 19 | #include <core/media/service.h> | 19 | #include <core/media/service.h> |
1560 | 20 | 20 | ||
1561 | 21 | #include "core/media/logger/logger.h" | ||
1562 | 22 | |||
1563 | 21 | #include "service_stub.h" | 23 | #include "service_stub.h" |
1564 | 22 | 24 | ||
1565 | 23 | namespace media = core::ubuntu::media; | 25 | namespace media = core::ubuntu::media; |
1566 | 24 | 26 | ||
1567 | 25 | const std::shared_ptr<media::Service> media::Service::Client::instance() | 27 | const std::shared_ptr<media::Service> media::Service::Client::instance() |
1568 | 26 | { | 28 | { |
1570 | 27 | std::cout << "Creating a new static Service instance" << std::endl; | 29 | MH_TRACE(""); |
1571 | 28 | static std::shared_ptr<media::Service> instance{new media::ServiceStub()}; | 30 | static std::shared_ptr<media::Service> instance{new media::ServiceStub()}; |
1572 | 29 | return instance; | 31 | return instance; |
1573 | 30 | } | 32 | } |
1574 | 31 | 33 | ||
1575 | === modified file 'src/core/media/service_implementation.cpp' | |||
1576 | --- src/core/media/service_implementation.cpp 2016-03-02 18:32:46 +0000 | |||
1577 | +++ src/core/media/service_implementation.cpp 2016-04-07 00:39:05 +0000 | |||
1578 | @@ -33,6 +33,9 @@ | |||
1579 | 33 | #include "recorder_observer.h" | 33 | #include "recorder_observer.h" |
1580 | 34 | #include "telephony/call_monitor.h" | 34 | #include "telephony/call_monitor.h" |
1581 | 35 | 35 | ||
1582 | 36 | #include "util/timeout.h" | ||
1583 | 37 | #include "core/media/logger/logger.h" | ||
1584 | 38 | |||
1585 | 36 | #include <boost/asio.hpp> | 39 | #include <boost/asio.hpp> |
1586 | 37 | 40 | ||
1587 | 38 | #include <string> | 41 | #include <string> |
1588 | @@ -45,8 +48,6 @@ | |||
1589 | 45 | 48 | ||
1590 | 46 | #include <pulse/pulseaudio.h> | 49 | #include <pulse/pulseaudio.h> |
1591 | 47 | 50 | ||
1592 | 48 | #include "util/timeout.h" | ||
1593 | 49 | |||
1594 | 50 | namespace media = core::ubuntu::media; | 51 | namespace media = core::ubuntu::media; |
1595 | 51 | 52 | ||
1596 | 52 | using namespace std; | 53 | using namespace std; |
1597 | @@ -126,16 +127,16 @@ | |||
1598 | 126 | switch (state) | 127 | switch (state) |
1599 | 127 | { | 128 | { |
1600 | 128 | case audio::OutputState::Earpiece: | 129 | case audio::OutputState::Earpiece: |
1602 | 129 | std::cout << "AudioOutputObserver reports that output is now Headphones/Headset." << std::endl; | 130 | MH_INFO("AudioOutputObserver reports that output is now Headphones/Headset."); |
1603 | 130 | break; | 131 | break; |
1604 | 131 | case audio::OutputState::Speaker: | 132 | case audio::OutputState::Speaker: |
1606 | 132 | std::cout << "AudioOutputObserver reports that output is now Speaker." << std::endl; | 133 | MH_INFO("AudioOutputObserver reports that output is now Speaker."); |
1607 | 133 | // Whatever player session is currently playing, make sure it is NOT resumed after | 134 | // Whatever player session is currently playing, make sure it is NOT resumed after |
1608 | 134 | // a phonecall is hung up | 135 | // a phonecall is hung up |
1609 | 135 | pause_all_multimedia_sessions(resume_play_after_phonecall); | 136 | pause_all_multimedia_sessions(resume_play_after_phonecall); |
1610 | 136 | break; | 137 | break; |
1611 | 137 | case audio::OutputState::External: | 138 | case audio::OutputState::External: |
1613 | 138 | std::cout << "AudioOutputObserver reports that output is now External." << std::endl; | 139 | MH_INFO("AudioOutputObserver reports that output is now External."); |
1614 | 139 | break; | 140 | break; |
1615 | 140 | } | 141 | } |
1616 | 141 | d->audio_output_state = state; | 142 | d->audio_output_state = state; |
1617 | @@ -146,13 +147,13 @@ | |||
1618 | 146 | const bool resume_play_after_phonecall = true; | 147 | const bool resume_play_after_phonecall = true; |
1619 | 147 | switch (state) { | 148 | switch (state) { |
1620 | 148 | case media::telephony::CallMonitor::State::OffHook: | 149 | case media::telephony::CallMonitor::State::OffHook: |
1622 | 149 | std::cout << "Got call started signal, pausing all multimedia sessions" << std::endl; | 150 | MH_INFO("Got call started signal, pausing all multimedia sessions"); |
1623 | 150 | // Whatever player session is currently playing, make sure it gets resumed after | 151 | // Whatever player session is currently playing, make sure it gets resumed after |
1624 | 151 | // a phonecall is hung up | 152 | // a phonecall is hung up |
1625 | 152 | pause_all_multimedia_sessions(resume_play_after_phonecall); | 153 | pause_all_multimedia_sessions(resume_play_after_phonecall); |
1626 | 153 | break; | 154 | break; |
1627 | 154 | case media::telephony::CallMonitor::State::OnHook: | 155 | case media::telephony::CallMonitor::State::OnHook: |
1629 | 155 | std::cout << "Got call ended signal, resuming paused multimedia sessions" << std::endl; | 156 | MH_INFO("Got call ended signal, resuming paused multimedia sessions"); |
1630 | 156 | resume_paused_multimedia_sessions(false); | 157 | resume_paused_multimedia_sessions(false); |
1631 | 157 | break; | 158 | break; |
1632 | 158 | } | 159 | } |
1633 | @@ -217,10 +218,10 @@ | |||
1634 | 217 | d->configuration.player_store->remove_player_for_key(key); | 218 | d->configuration.player_store->remove_player_for_key(key); |
1635 | 218 | } | 219 | } |
1636 | 219 | catch (const std::out_of_range &e) { | 220 | catch (const std::out_of_range &e) { |
1641 | 220 | std::cerr << "Failed to look up Player instance for key " << key | 221 | MH_WARNING("Failed to look up Player instance for key %d" |
1642 | 221 | << ", no valid Player instance for that key value. Removal of Player from Player store" | 222 | ", no valid Player instance for that key value. Removal of Player from Player store" |
1643 | 222 | << " might not have completed. This most likely means that media-hub-server has" | 223 | " might not have completed. This most likely means that media-hub-server has" |
1644 | 223 | << " crashed and restarted." << std::endl; | 224 | " crashed and restarted.", key); |
1645 | 224 | return; | 225 | return; |
1646 | 225 | } | 226 | } |
1647 | 226 | }); | 227 | }); |
1648 | @@ -264,11 +265,11 @@ | |||
1649 | 264 | 265 | ||
1650 | 265 | void media::ServiceImplementation::pause_other_sessions(media::Player::PlayerKey key) | 266 | void media::ServiceImplementation::pause_other_sessions(media::Player::PlayerKey key) |
1651 | 266 | { | 267 | { |
1653 | 267 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 268 | MH_TRACE(""); |
1654 | 268 | 269 | ||
1655 | 269 | if (not d->configuration.player_store->has_player_for_key(key)) | 270 | if (not d->configuration.player_store->has_player_for_key(key)) |
1656 | 270 | { | 271 | { |
1658 | 271 | cerr << "Could not find Player by key: " << key << endl; | 272 | MH_WARNING("Could not find Player by key: %d", key); |
1659 | 272 | return; | 273 | return; |
1660 | 273 | } | 274 | } |
1661 | 274 | 275 | ||
1662 | @@ -291,7 +292,7 @@ | |||
1663 | 291 | current_player->audio_stream_role() == media::Player::multimedia && | 292 | current_player->audio_stream_role() == media::Player::multimedia && |
1664 | 292 | other_player->audio_stream_role() == media::Player::multimedia) | 293 | other_player->audio_stream_role() == media::Player::multimedia) |
1665 | 293 | { | 294 | { |
1667 | 294 | cout << "Pausing Player with key: " << other_key << endl; | 295 | MH_INFO("Pausing Player with key: %d", other_key); |
1668 | 295 | other_player->pause(); | 296 | other_player->pause(); |
1669 | 296 | } | 297 | } |
1670 | 297 | }); | 298 | }); |
1671 | @@ -306,8 +307,8 @@ | |||
1672 | 306 | { | 307 | { |
1673 | 307 | auto paused_player_pair = std::make_pair(key, resume_play_after_phonecall); | 308 | auto paused_player_pair = std::make_pair(key, resume_play_after_phonecall); |
1674 | 308 | d->paused_sessions.push_back(paused_player_pair); | 309 | d->paused_sessions.push_back(paused_player_pair); |
1677 | 309 | std::cout << "Pausing Player with key: " << key << ", resuming after phone call? " | 310 | MH_INFO("Pausing Player with key: %d, resuming after phone call? %s", key, |
1678 | 310 | << (resume_play_after_phonecall ? "yes" : "no") << std::endl; | 311 | (resume_play_after_phonecall ? "yes" : "no")); |
1679 | 311 | player->pause(); | 312 | player->pause(); |
1680 | 312 | } | 313 | } |
1681 | 313 | }); | 314 | }); |
1682 | @@ -324,17 +325,17 @@ | |||
1683 | 324 | player = d->configuration.player_store->player_for_key(key); | 325 | player = d->configuration.player_store->player_for_key(key); |
1684 | 325 | } | 326 | } |
1685 | 326 | catch (const std::out_of_range &e) { | 327 | catch (const std::out_of_range &e) { |
1690 | 327 | std::cerr << "Failed to look up Player instance for key " << key | 328 | MH_WARNING("Failed to look up Player instance for key %d" |
1691 | 328 | << ", no valid Player instance for that key value and cannot automatically resume" | 329 | ", no valid Player instance for that key value and cannot automatically resume" |
1692 | 329 | << " paused players. This most likely means that media-hub-server has crashed and" | 330 | " paused players. This most likely means that media-hub-server has crashed and" |
1693 | 330 | << " restarted." << std::endl; | 331 | " restarted.", key); |
1694 | 331 | return; | 332 | return; |
1695 | 332 | } | 333 | } |
1696 | 333 | // Only resume video playback if explicitly desired | 334 | // Only resume video playback if explicitly desired |
1697 | 334 | if ((resume_video_sessions || player->is_audio_source()) && resume_play_after_phonecall) | 335 | if ((resume_video_sessions || player->is_audio_source()) && resume_play_after_phonecall) |
1698 | 335 | player->play(); | 336 | player->play(); |
1699 | 336 | else | 337 | else |
1701 | 337 | std::cout << "Not auto-resuming video player session or other type of player session." << std::endl; | 338 | MH_INFO("Not auto-resuming video player session or other type of player session."); |
1702 | 338 | }); | 339 | }); |
1703 | 339 | 340 | ||
1704 | 340 | d->paused_sessions.clear(); | 341 | d->paused_sessions.clear(); |
1705 | @@ -350,16 +351,16 @@ | |||
1706 | 350 | player = d->configuration.player_store->player_for_key(d->resume_key); | 351 | player = d->configuration.player_store->player_for_key(d->resume_key); |
1707 | 351 | } | 352 | } |
1708 | 352 | catch (const std::out_of_range &e) { | 353 | catch (const std::out_of_range &e) { |
1713 | 353 | std::cerr << "Failed to look up Player instance for key " << d->resume_key | 354 | MH_WARNING("Failed to look up Player instance for key %d" |
1714 | 354 | << ", no valid Player instance for that key value and cannot automatically resume" | 355 | ", no valid Player instance for that key value and cannot automatically resume" |
1715 | 355 | << " paused Player. This most likely means that media-hub-server has crashed and" | 356 | " paused Player. This most likely means that media-hub-server has crashed and" |
1716 | 356 | << " restarted." << std::endl; | 357 | " restarted.", d->resume_key); |
1717 | 357 | return; | 358 | return; |
1718 | 358 | } | 359 | } |
1719 | 359 | 360 | ||
1720 | 360 | if (player->playback_status() == Player::paused) | 361 | if (player->playback_status() == Player::paused) |
1721 | 361 | { | 362 | { |
1723 | 362 | cout << "Resuming playback of Player with key: " << d->resume_key << endl; | 363 | MH_INFO("Resuming playback of Player with key: %d", d->resume_key); |
1724 | 363 | player->play(); | 364 | player->play(); |
1725 | 364 | d->resume_key = std::numeric_limits<std::uint32_t>::max(); | 365 | d->resume_key = std::numeric_limits<std::uint32_t>::max(); |
1726 | 365 | } | 366 | } |
1727 | 366 | 367 | ||
1728 | === modified file 'src/core/media/service_skeleton.cpp' | |||
1729 | --- src/core/media/service_skeleton.cpp 2016-03-02 18:32:46 +0000 | |||
1730 | +++ src/core/media/service_skeleton.cpp 2016-04-07 00:39:05 +0000 | |||
1731 | @@ -29,6 +29,8 @@ | |||
1732 | 29 | #include "the_session_bus.h" | 29 | #include "the_session_bus.h" |
1733 | 30 | #include "xesam.h" | 30 | #include "xesam.h" |
1734 | 31 | 31 | ||
1735 | 32 | #include "core/media/logger/logger.h" | ||
1736 | 33 | |||
1737 | 32 | #include <core/dbus/message.h> | 34 | #include <core/dbus/message.h> |
1738 | 33 | #include <core/dbus/object.h> | 35 | #include <core/dbus/object.h> |
1739 | 34 | #include <core/dbus/types/object_path.h> | 36 | #include <core/dbus/types/object_path.h> |
1740 | @@ -134,9 +136,8 @@ | |||
1741 | 134 | impl->access_service()->add_object_for_path(op) | 136 | impl->access_service()->add_object_for_path(op) |
1742 | 135 | }; | 137 | }; |
1743 | 136 | 138 | ||
1747 | 137 | cout << "Session created by request of: " << msg->sender() | 139 | MH_DEBUG("Session created by request of: %s, key: %d, uuid: %d, path: %s", |
1748 | 138 | << ", key: " << key << ", uuid: " << uuid | 140 | msg->sender(), key, uuid, op); |
1746 | 139 | << ", path:" << op << std::endl; | ||
1749 | 140 | 141 | ||
1750 | 141 | try | 142 | try |
1751 | 142 | { | 143 | { |
1752 | @@ -147,7 +148,7 @@ | |||
1753 | 147 | request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), | 148 | request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), |
1754 | 148 | [this, key, msg](const media::apparmor::ubuntu::Context& context) | 149 | [this, key, msg](const media::apparmor::ubuntu::Context& context) |
1755 | 149 | { | 150 | { |
1757 | 150 | fprintf(stderr, "%s():%d -- app_name='%s', attached\n", __func__, __LINE__, context.str().c_str()); | 151 | MH_DEBUG(" -- app_name='%s', attached", context.str()); |
1758 | 151 | player_owner_map.emplace(std::make_pair(key, std::make_tuple(context.str(), true, msg->sender()))); | 152 | player_owner_map.emplace(std::make_pair(key, std::make_tuple(context.str(), true, msg->sender()))); |
1759 | 152 | }); | 153 | }); |
1760 | 153 | 154 | ||
1761 | @@ -231,7 +232,8 @@ | |||
1762 | 231 | [this, msg, key, op](const media::apparmor::ubuntu::Context& context) | 232 | [this, msg, key, op](const media::apparmor::ubuntu::Context& context) |
1763 | 232 | { | 233 | { |
1764 | 233 | auto info = player_owner_map.at(key); | 234 | auto info = player_owner_map.at(key); |
1766 | 234 | fprintf(stderr, "%s():%d -- reattach app_name='%s', info='%s', '%s'\n", __func__, __LINE__, context.str().c_str(), std::get<0>(info).c_str(), std::get<2>(info).c_str()); | 235 | MH_DEBUG(" -- reattach app_name='%s', info='%s', '%s'", |
1767 | 236 | context.str(), std::get<0>(info), std::get<2>(info)); | ||
1768 | 235 | if (std::get<0>(info) == context.str()) { | 237 | if (std::get<0>(info) == context.str()) { |
1769 | 236 | std::get<1>(info) = true; // Set to Attached | 238 | std::get<1>(info) = true; // Set to Attached |
1770 | 237 | std::get<2>(info) = msg->sender(); // Register new owner | 239 | std::get<2>(info) = msg->sender(); // Register new owner |
1771 | @@ -242,7 +244,7 @@ | |||
1772 | 242 | // We only care to allow the MPRIS controls to apply to multimedia player (i.e. audio, video) | 244 | // We only care to allow the MPRIS controls to apply to multimedia player (i.e. audio, video) |
1773 | 243 | if (player->audio_stream_role() == media::Player::AudioStreamRole::multimedia) | 245 | if (player->audio_stream_role() == media::Player::AudioStreamRole::multimedia) |
1774 | 244 | { | 246 | { |
1776 | 245 | std::cout << "Setting current_player" << std::endl; | 247 | MH_TRACE("Setting current_player"); |
1777 | 246 | exported.set_current_player(player); | 248 | exported.set_current_player(player); |
1778 | 247 | } | 249 | } |
1779 | 248 | 250 | ||
1780 | @@ -305,7 +307,8 @@ | |||
1781 | 305 | [this, msg, key](const media::apparmor::ubuntu::Context& context) | 307 | [this, msg, key](const media::apparmor::ubuntu::Context& context) |
1782 | 306 | { | 308 | { |
1783 | 307 | auto info = player_owner_map.at(key); | 309 | auto info = player_owner_map.at(key); |
1785 | 308 | fprintf(stderr, "%s():%d -- Destroying app_name='%s', info='%s', '%s'\n", __func__, __LINE__, context.str().c_str(), std::get<0>(info).c_str(), std::get<2>(info).c_str()); | 310 | MH_DEBUG(" -- Destroying app_name='%s', info='%s', '%s'", |
1786 | 311 | context.str(), std::get<0>(info), std::get<2>(info)); | ||
1787 | 309 | if (std::get<0>(info) == context.str()) { | 312 | if (std::get<0>(info) == context.str()) { |
1788 | 310 | player_owner_map.erase(key); | 313 | player_owner_map.erase(key); |
1789 | 311 | 314 | ||
1790 | @@ -454,7 +457,7 @@ | |||
1791 | 454 | core::dbus::Message::Ptr reply; | 457 | core::dbus::Message::Ptr reply; |
1792 | 455 | if (not configuration.player_store->has_player_for_key(key)) | 458 | if (not configuration.player_store->has_player_for_key(key)) |
1793 | 456 | { | 459 | { |
1795 | 457 | std::cerr << __PRETTY_FUNCTION__ << " player key not found - " << key << std::endl; | 460 | MH_WARNING("Player key not found: %d", key); |
1796 | 458 | reply = dbus::Message::make_error( | 461 | reply = dbus::Message::make_error( |
1797 | 459 | msg, | 462 | msg, |
1798 | 460 | mpris::Service::Errors::PlayerKeyNotFound::name(), | 463 | mpris::Service::Errors::PlayerKeyNotFound::name(), |
1799 | @@ -467,10 +470,9 @@ | |||
1800 | 467 | reply = dbus::Message::make_method_return(msg); | 470 | reply = dbus::Message::make_method_return(msg); |
1801 | 468 | } | 471 | } |
1802 | 469 | catch (const std::out_of_range &e) { | 472 | catch (const std::out_of_range &e) { |
1807 | 470 | std::cerr << "Failed to look up Player instance for key " << key | 473 | MH_WARNING("Failed to look up Player instance for key %d\ |
1808 | 471 | << ", no valid Player instance for that key value and cannot set current player." | 474 | , no valid Player instance for that key value and cannot set current player.\ |
1809 | 472 | << " This most likely means that media-hub-server has crashed and restarted." | 475 | This most likely means that media-hub-server has crashed and restarted.", key); |
1806 | 473 | << std::endl; | ||
1810 | 474 | reply = dbus::Message::make_error( | 476 | reply = dbus::Message::make_error( |
1811 | 475 | msg, | 477 | msg, |
1812 | 476 | mpris::Service::Errors::PlayerKeyNotFound::name(), | 478 | mpris::Service::Errors::PlayerKeyNotFound::name(), |
1813 | @@ -491,10 +493,9 @@ | |||
1814 | 491 | reply = dbus::Message::make_method_return(msg); | 493 | reply = dbus::Message::make_method_return(msg); |
1815 | 492 | } | 494 | } |
1816 | 493 | catch (const std::out_of_range &e) { | 495 | catch (const std::out_of_range &e) { |
1821 | 494 | std::cerr << "Failed to look up Player instance for key " << key | 496 | MH_WARNING("Failed to look up Player instance for key %d\ |
1822 | 495 | << ", no valid Player instance for that key value and cannot pause other Players." | 497 | , no valid Player instance for that key value and cannot set current player.\ |
1823 | 496 | << " This most likely means that media-hub-server has crashed and restarted." | 498 | This most likely means that media-hub-server has crashed and restarted.", key); |
1820 | 497 | << std::endl; | ||
1824 | 498 | reply = dbus::Message::make_error( | 499 | reply = dbus::Message::make_error( |
1825 | 499 | msg, | 500 | msg, |
1826 | 500 | mpris::Service::Errors::PlayerKeyNotFound::name(), | 501 | mpris::Service::Errors::PlayerKeyNotFound::name(), |
1827 | @@ -529,7 +530,7 @@ | |||
1828 | 529 | // TODO(tvoss): These three elements really should be configurable. | 530 | // TODO(tvoss): These three elements really should be configurable. |
1829 | 530 | defaults.identity = "core::media::Hub"; | 531 | defaults.identity = "core::media::Hub"; |
1830 | 531 | defaults.desktop_entry = "mediaplayer-app"; | 532 | defaults.desktop_entry = "mediaplayer-app"; |
1832 | 532 | defaults.supported_mime_types = {"audio/mpeg3"}; | 533 | defaults.supported_mime_types = {"audio/mpeg3", "video/mpeg4"}; |
1833 | 533 | 534 | ||
1834 | 534 | return defaults; | 535 | return defaults; |
1835 | 535 | } | 536 | } |
1836 | @@ -668,7 +669,7 @@ | |||
1837 | 668 | 669 | ||
1838 | 669 | void set_current_player(const std::shared_ptr<media::Player>& cp) | 670 | void set_current_player(const std::shared_ptr<media::Player>& cp) |
1839 | 670 | { | 671 | { |
1841 | 671 | std::cout << "*** " << __PRETTY_FUNCTION__ << std::endl; | 672 | MH_TRACE(""); |
1842 | 672 | // We will not keep the object alive. | 673 | // We will not keep the object alive. |
1843 | 673 | current_player = cp; | 674 | current_player = cp; |
1844 | 674 | 675 | ||
1845 | @@ -784,7 +785,7 @@ | |||
1846 | 784 | 785 | ||
1847 | 785 | void reset_current_player() | 786 | void reset_current_player() |
1848 | 786 | { | 787 | { |
1850 | 787 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 788 | MH_TRACE(""); |
1851 | 788 | // And announce that we can no longer be controlled. | 789 | // And announce that we can no longer be controlled. |
1852 | 789 | player.properties.can_control->set(false); | 790 | player.properties.can_control->set(false); |
1853 | 790 | current_player.reset(); | 791 | current_player.reset(); |
1854 | 791 | 792 | ||
1855 | === modified file 'src/core/media/telephony/CMakeLists.txt' | |||
1856 | --- src/core/media/telephony/CMakeLists.txt 2014-10-31 07:49:33 +0000 | |||
1857 | +++ src/core/media/telephony/CMakeLists.txt 2016-04-07 00:39:05 +0000 | |||
1858 | @@ -9,6 +9,7 @@ | |||
1859 | 9 | 9 | ||
1860 | 10 | include_directories( | 10 | include_directories( |
1861 | 11 | ${TP_QT5_INCLUDE_DIRS} | 11 | ${TP_QT5_INCLUDE_DIRS} |
1862 | 12 | ${PROJECT_SOURCE_DIR}/src/ | ||
1863 | 12 | ) | 13 | ) |
1864 | 13 | 14 | ||
1865 | 14 | add_library(call-monitor STATIC | 15 | add_library(call-monitor STATIC |
1866 | 15 | 16 | ||
1867 | === modified file 'src/core/media/telephony/call_monitor.cpp' | |||
1868 | --- src/core/media/telephony/call_monitor.cpp 2015-01-26 11:01:02 +0000 | |||
1869 | +++ src/core/media/telephony/call_monitor.cpp 2016-04-07 00:39:05 +0000 | |||
1870 | @@ -19,6 +19,8 @@ | |||
1871 | 19 | 19 | ||
1872 | 20 | #include "call_monitor.h" | 20 | #include "call_monitor.h" |
1873 | 21 | 21 | ||
1874 | 22 | #include "core/media/logger/logger.h" | ||
1875 | 23 | |||
1876 | 22 | #include "qtbridge.h" | 24 | #include "qtbridge.h" |
1877 | 23 | #include <TelepathyQt/AccountManager> | 25 | #include <TelepathyQt/AccountManager> |
1878 | 24 | #include <TelepathyQt/SimpleCallObserver> | 26 | #include <TelepathyQt/SimpleCallObserver> |
1879 | @@ -95,7 +97,7 @@ | |||
1880 | 95 | 97 | ||
1881 | 96 | void accountManagerReady(Tp::PendingOperation* operation) { | 98 | void accountManagerReady(Tp::PendingOperation* operation) { |
1882 | 97 | if (operation->isError()) { | 99 | if (operation->isError()) { |
1884 | 98 | std::cerr << "TelepathyBridge: Operation failed (accountManagerReady)" << std::endl; | 100 | MH_ERROR("TelepathyBridge: Operation failed (accountManagerReady)"); |
1885 | 99 | QTimer::singleShot(1000, this, SLOT(accountManagerSetup())); // again | 101 | QTimer::singleShot(1000, this, SLOT(accountManagerSetup())); // again |
1886 | 100 | return; | 102 | return; |
1887 | 101 | } | 103 | } |
1888 | @@ -118,13 +120,13 @@ | |||
1889 | 118 | 120 | ||
1890 | 119 | void accountReady(Tp::PendingOperation* operation) { | 121 | void accountReady(Tp::PendingOperation* operation) { |
1891 | 120 | if (operation->isError()) { | 122 | if (operation->isError()) { |
1893 | 121 | std::cerr << "TelepathyAccount: Operation failed (accountReady)" << std::endl; | 123 | MH_ERROR("TelepathyAccount: Operation failed (accountReady)"); |
1894 | 122 | return; | 124 | return; |
1895 | 123 | } | 125 | } |
1896 | 124 | 126 | ||
1897 | 125 | Tp::PendingReady* pendingReady = qobject_cast<Tp::PendingReady*>(operation); | 127 | Tp::PendingReady* pendingReady = qobject_cast<Tp::PendingReady*>(operation); |
1898 | 126 | if (pendingReady == 0) { | 128 | if (pendingReady == 0) { |
1900 | 127 | std::cerr << "Rejecting account because could not understand ready status" << std::endl; | 129 | MH_ERROR("Rejecting account because could not understand ready status"); |
1901 | 128 | return; | 130 | return; |
1902 | 129 | } | 131 | } |
1903 | 130 | 132 | ||
1904 | @@ -176,16 +178,16 @@ | |||
1905 | 176 | { | 178 | { |
1906 | 177 | qt::core::world::enter_with_task([this]() | 179 | qt::core::world::enter_with_task([this]() |
1907 | 178 | { | 180 | { |
1909 | 179 | std::cout << "CallMonitor: Creating TelepathyBridge" << std::endl; | 181 | MH_DEBUG("CallMonitor: Creating TelepathyBridge"); |
1910 | 180 | mBridge = new TelepathyBridge(); | 182 | mBridge = new TelepathyBridge(); |
1911 | 181 | cv.notify_all(); | 183 | cv.notify_all(); |
1912 | 182 | }); | 184 | }); |
1913 | 183 | }); | 185 | }); |
1914 | 184 | })); | 186 | })); |
1915 | 185 | } catch(const std::system_error& error) { | 187 | } catch(const std::system_error& error) { |
1917 | 186 | std::cerr << "exception(std::system_error) in CallMonitor thread start" << error.what() << std::endl; | 188 | MH_ERROR("exception(std::system_error) in CallMonitor thread start %s", error.what()); |
1918 | 187 | } catch(...) { | 189 | } catch(...) { |
1920 | 188 | std::cerr << "exception(...) in CallMonitor thread start" << std::endl; | 190 | MH_ERROR("exception(...) in CallMonitor thread start"); |
1921 | 189 | } | 191 | } |
1922 | 190 | 192 | ||
1923 | 191 | // Wait until telepathy bridge is set, so we can hook up the change signals | 193 | // Wait until telepathy bridge is set, so we can hook up the change signals |
1924 | @@ -234,7 +236,7 @@ | |||
1925 | 234 | 236 | ||
1926 | 235 | media::telephony::CallMonitor::Ptr media::telephony::make_platform_default_call_monitor() | 237 | media::telephony::CallMonitor::Ptr media::telephony::make_platform_default_call_monitor() |
1927 | 236 | { | 238 | { |
1929 | 237 | return std::make_shared<impl::CallMonitor>(); | 239 | return std::make_shared<::impl::CallMonitor>(); |
1930 | 238 | } | 240 | } |
1931 | 239 | 241 | ||
1932 | 240 | #include "call_monitor.moc" | 242 | #include "call_monitor.moc" |
1933 | 241 | 243 | ||
1934 | === modified file 'src/core/media/telephony/qtbridge.cpp' | |||
1935 | --- src/core/media/telephony/qtbridge.cpp 2014-10-31 07:49:33 +0000 | |||
1936 | +++ src/core/media/telephony/qtbridge.cpp 2016-04-07 00:39:05 +0000 | |||
1937 | @@ -26,8 +26,6 @@ | |||
1938 | 26 | #include<QThread> | 26 | #include<QThread> |
1939 | 27 | #include<QDebug> | 27 | #include<QDebug> |
1940 | 28 | 28 | ||
1941 | 29 | #include <iostream> | ||
1942 | 30 | |||
1943 | 31 | namespace | 29 | namespace |
1944 | 32 | { | 30 | { |
1945 | 33 | QCoreApplication* app = nullptr; | 31 | QCoreApplication* app = nullptr; |
1946 | 34 | 32 | ||
1947 | === modified file 'src/core/media/track_list_implementation.cpp' | |||
1948 | --- src/core/media/track_list_implementation.cpp 2016-02-22 18:58:52 +0000 | |||
1949 | +++ src/core/media/track_list_implementation.cpp 2016-04-07 00:39:05 +0000 | |||
1950 | @@ -18,6 +18,7 @@ | |||
1951 | 18 | 18 | ||
1952 | 19 | #include <algorithm> | 19 | #include <algorithm> |
1953 | 20 | #include <random> | 20 | #include <random> |
1954 | 21 | #include <sstream> | ||
1955 | 21 | #include <stdio.h> | 22 | #include <stdio.h> |
1956 | 22 | #include <stdlib.h> | 23 | #include <stdlib.h> |
1957 | 23 | #include <tuple> | 24 | #include <tuple> |
1958 | @@ -29,6 +30,8 @@ | |||
1959 | 29 | 30 | ||
1960 | 30 | #include "engine.h" | 31 | #include "engine.h" |
1961 | 31 | 32 | ||
1962 | 33 | #include "core/media/logger/logger.h" | ||
1963 | 34 | |||
1964 | 32 | namespace dbus = core::dbus; | 35 | namespace dbus = core::dbus; |
1965 | 33 | namespace media = core::ubuntu::media; | 36 | namespace media = core::ubuntu::media; |
1966 | 34 | 37 | ||
1967 | @@ -125,14 +128,14 @@ | |||
1968 | 125 | const media::Track::Id& position, | 128 | const media::Track::Id& position, |
1969 | 126 | bool make_current) | 129 | bool make_current) |
1970 | 127 | { | 130 | { |
1972 | 128 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 131 | MH_TRACE(""); |
1973 | 129 | 132 | ||
1974 | 130 | std::stringstream ss; | 133 | std::stringstream ss; |
1975 | 131 | ss << d->object->path().as_string() << "/" << d->track_counter++; | 134 | ss << d->object->path().as_string() << "/" << d->track_counter++; |
1976 | 132 | Track::Id id{ss.str()}; | 135 | Track::Id id{ss.str()}; |
1977 | 133 | 136 | ||
1980 | 134 | std::cout << "Adding Track::Id: " << id << std::endl; | 137 | MH_DEBUG("Adding Track::Id: %s", id); |
1981 | 135 | std::cout << "\tURI: " << uri << std::endl; | 138 | MH_DEBUG("\tURI: %s", uri); |
1982 | 136 | 139 | ||
1983 | 137 | const auto current = get_current_track(); | 140 | const auto current = get_current_track(); |
1984 | 138 | 141 | ||
1985 | @@ -159,7 +162,7 @@ | |||
1986 | 159 | set_current_track(current); | 162 | set_current_track(current); |
1987 | 160 | } | 163 | } |
1988 | 161 | 164 | ||
1990 | 162 | std::cout << "Signaling that we just added track id: " << id << std::endl; | 165 | MH_DEBUG("Signaling that we just added track id: %s", id); |
1991 | 163 | // Signal to the client that a track was added to the TrackList | 166 | // Signal to the client that a track was added to the TrackList |
1992 | 164 | on_track_added()(id); | 167 | on_track_added()(id); |
1993 | 165 | 168 | ||
1994 | @@ -172,7 +175,7 @@ | |||
1995 | 172 | 175 | ||
1996 | 173 | void media::TrackListImplementation::add_tracks_with_uri_at(const ContainerURI& uris, const Track::Id& position) | 176 | void media::TrackListImplementation::add_tracks_with_uri_at(const ContainerURI& uris, const Track::Id& position) |
1997 | 174 | { | 177 | { |
1999 | 175 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 178 | MH_TRACE(""); |
2000 | 176 | 179 | ||
2001 | 177 | const auto current = get_current_track(); | 180 | const auto current = get_current_track(); |
2002 | 178 | 181 | ||
2003 | @@ -184,8 +187,8 @@ | |||
2004 | 184 | std::stringstream ss; | 187 | std::stringstream ss; |
2005 | 185 | ss << d->object->path().as_string() << "/" << d->track_counter++; | 188 | ss << d->object->path().as_string() << "/" << d->track_counter++; |
2006 | 186 | Track::Id id{ss.str()}; | 189 | Track::Id id{ss.str()}; |
2009 | 187 | std::cout << "Adding Track::Id: " << id << std::endl; | 190 | MH_DEBUG("Adding Track::Id: %s", id); |
2010 | 188 | std::cout << "\tURI: " << uri << std::endl; | 191 | MH_DEBUG("\tURI: %s", uri); |
2011 | 189 | 192 | ||
2012 | 190 | tmp.push_back(id); | 193 | tmp.push_back(id); |
2013 | 191 | 194 | ||
2014 | @@ -217,7 +220,7 @@ | |||
2015 | 217 | 220 | ||
2016 | 218 | set_current_track(current); | 221 | set_current_track(current); |
2017 | 219 | 222 | ||
2019 | 220 | std::cout << "Signaling that we just added " << tmp.size() << " tracks to the TrackList" << std::endl; | 223 | MH_DEBUG("Signaling that we just added %d tracks to the TrackList", tmp.size()); |
2020 | 221 | on_tracks_added()(tmp); | 224 | on_tracks_added()(tmp); |
2021 | 222 | 225 | ||
2022 | 223 | if (!current_id.empty()) | 226 | if (!current_id.empty()) |
2023 | @@ -227,30 +230,30 @@ | |||
2024 | 227 | bool media::TrackListImplementation::move_track(const media::Track::Id& id, | 230 | bool media::TrackListImplementation::move_track(const media::Track::Id& id, |
2025 | 228 | const media::Track::Id& to) | 231 | const media::Track::Id& to) |
2026 | 229 | { | 232 | { |
2028 | 230 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 233 | MH_TRACE(""); |
2029 | 231 | 234 | ||
2031 | 232 | std::cout << "-----------------------------------------------------" << std::endl; | 235 | MH_DEBUG("-----------------------------------------------------"); |
2032 | 233 | if (id.empty() or to.empty()) | 236 | if (id.empty() or to.empty()) |
2033 | 234 | { | 237 | { |
2035 | 235 | std::cerr << "Can't move track since 'id' or 'to' are empty" << std::endl; | 238 | MH_ERROR("Can't move track since 'id' or 'to' are empty"); |
2036 | 236 | return false; | 239 | return false; |
2037 | 237 | } | 240 | } |
2038 | 238 | 241 | ||
2039 | 239 | if (id == to) | 242 | if (id == to) |
2040 | 240 | { | 243 | { |
2042 | 241 | std::cerr << "Can't move track to it's same position" << std::endl; | 244 | MH_ERROR("Can't move track to it's same position"); |
2043 | 242 | return false; | 245 | return false; |
2044 | 243 | } | 246 | } |
2045 | 244 | 247 | ||
2046 | 245 | if (tracks().get().size() == 1) | 248 | if (tracks().get().size() == 1) |
2047 | 246 | { | 249 | { |
2049 | 247 | std::cerr << "Can't move track since TrackList contains only one track" << std::endl; | 250 | MH_ERROR("Can't move track since TrackList contains only one track"); |
2050 | 248 | return false; | 251 | return false; |
2051 | 249 | } | 252 | } |
2052 | 250 | 253 | ||
2053 | 251 | bool ret = false; | 254 | bool ret = false; |
2054 | 252 | const media::Track::Id current_id = *current_iterator(); | 255 | const media::Track::Id current_id = *current_iterator(); |
2056 | 253 | std::cout << "current_track id: " << current_id << std::endl; | 256 | MH_DEBUG("current_track id: %s", current_id); |
2057 | 254 | // Get an iterator that points to the track that is the insertion point | 257 | // Get an iterator that points to the track that is the insertion point |
2058 | 255 | auto insert_point_it = std::find(tracks().get().begin(), tracks().get().end(), to); | 258 | auto insert_point_it = std::find(tracks().get().begin(), tracks().get().end(), to); |
2059 | 256 | if (insert_point_it != tracks().get().end()) | 259 | if (insert_point_it != tracks().get().end()) |
2060 | @@ -260,7 +263,6 @@ | |||
2061 | 260 | { | 263 | { |
2062 | 261 | // Get an iterator that points to the track to move within the TrackList | 264 | // Get an iterator that points to the track to move within the TrackList |
2063 | 262 | auto to_move_it = std::find(tracks().get().begin(), tracks().get().end(), id); | 265 | auto to_move_it = std::find(tracks().get().begin(), tracks().get().end(), id); |
2064 | 263 | std::cout << "Erasing old track position: " << *to_move_it << std::endl; | ||
2065 | 264 | if (to_move_it != tracks().get().end()) | 266 | if (to_move_it != tracks().get().end()) |
2066 | 265 | { | 267 | { |
2067 | 266 | container.erase(to_move_it); | 268 | container.erase(to_move_it); |
2068 | @@ -282,11 +284,11 @@ | |||
2069 | 282 | { | 284 | { |
2070 | 283 | throw media::TrackList::Errors::FailedToMoveTrack(); | 285 | throw media::TrackList::Errors::FailedToMoveTrack(); |
2071 | 284 | } | 286 | } |
2073 | 285 | std::cout << "*** Updated current_iterator, id: " << *current_iterator() << std::endl; | 287 | MH_DEBUG("*** Updated current_iterator, id: %s", *current_iterator()); |
2074 | 286 | } | 288 | } |
2075 | 287 | else | 289 | else |
2076 | 288 | { | 290 | { |
2078 | 289 | std::cerr << "Can't update current_iterator - failed to find track after move" << std::endl; | 291 | MH_ERROR("Can't update current_iterator - failed to find track after move"); |
2079 | 290 | throw media::TrackList::Errors::FailedToMoveTrack(); | 292 | throw media::TrackList::Errors::FailedToMoveTrack(); |
2080 | 291 | } | 293 | } |
2081 | 292 | 294 | ||
2082 | @@ -295,10 +297,10 @@ | |||
2083 | 295 | 297 | ||
2084 | 296 | if (result) | 298 | if (result) |
2085 | 297 | { | 299 | { |
2088 | 298 | std::cout << "TrackList after move" << std::endl; | 300 | MH_DEBUG("TrackList after move"); |
2089 | 299 | for(auto track : tracks().get()) | 301 | for(const auto track : tracks().get()) |
2090 | 300 | { | 302 | { |
2092 | 301 | std::cout << track << std::endl; | 303 | MH_DEBUG("%s", track); |
2093 | 302 | } | 304 | } |
2094 | 303 | const media::TrackList::TrackIdTuple ids = std::make_tuple(id, to); | 305 | const media::TrackList::TrackIdTuple ids = std::make_tuple(id, to); |
2095 | 304 | // Signal to the client that track 'id' was moved within the TrackList | 306 | // Signal to the client that track 'id' was moved within the TrackList |
2096 | @@ -312,7 +314,7 @@ | |||
2097 | 312 | ("Failed to find source track " + id); | 314 | ("Failed to find source track " + id); |
2098 | 313 | } | 315 | } |
2099 | 314 | 316 | ||
2101 | 315 | std::cout << "-----------------------------------------------------" << std::endl; | 317 | MH_DEBUG("-----------------------------------------------------"); |
2102 | 316 | 318 | ||
2103 | 317 | return ret; | 319 | return ret; |
2104 | 318 | } | 320 | } |
2105 | @@ -345,7 +347,7 @@ | |||
2106 | 345 | 347 | ||
2107 | 346 | void media::TrackListImplementation::go_to(const media::Track::Id& track) | 348 | void media::TrackListImplementation::go_to(const media::Track::Id& track) |
2108 | 347 | { | 349 | { |
2110 | 348 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 350 | MH_TRACE(""); |
2111 | 349 | // Signal the Player instance to go to a specific track for playback | 351 | // Signal the Player instance to go to a specific track for playback |
2112 | 350 | on_go_to_track()(track); | 352 | on_go_to_track()(track); |
2113 | 351 | on_track_changed()(track); | 353 | on_track_changed()(track); |
2114 | @@ -373,7 +375,7 @@ | |||
2115 | 373 | 375 | ||
2116 | 374 | void media::TrackListImplementation::reset() | 376 | void media::TrackListImplementation::reset() |
2117 | 375 | { | 377 | { |
2119 | 376 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 378 | MH_TRACE(""); |
2120 | 377 | 379 | ||
2121 | 378 | // Make sure playback stops | 380 | // Make sure playback stops |
2122 | 379 | on_end_of_tracklist()(); | 381 | on_end_of_tracklist()(); |
2123 | 380 | 382 | ||
2124 | === modified file 'src/core/media/track_list_skeleton.cpp' | |||
2125 | --- src/core/media/track_list_skeleton.cpp 2016-02-22 16:16:52 +0000 | |||
2126 | +++ src/core/media/track_list_skeleton.cpp 2016-04-07 00:39:05 +0000 | |||
2127 | @@ -29,7 +29,9 @@ | |||
2128 | 29 | 29 | ||
2129 | 30 | #include "mpris/player.h" | 30 | #include "mpris/player.h" |
2130 | 31 | #include "mpris/track_list.h" | 31 | #include "mpris/track_list.h" |
2131 | 32 | |||
2132 | 32 | #include "util/uri_check.h" | 33 | #include "util/uri_check.h" |
2133 | 34 | #include "core/media/logger/logger.h" | ||
2134 | 33 | 35 | ||
2135 | 34 | #include <core/dbus/object.h> | 36 | #include <core/dbus/object.h> |
2136 | 35 | #include <core/dbus/property.h> | 37 | #include <core/dbus/property.h> |
2137 | @@ -40,7 +42,6 @@ | |||
2138 | 40 | 42 | ||
2139 | 41 | #include <iostream> | 43 | #include <iostream> |
2140 | 42 | #include <limits> | 44 | #include <limits> |
2141 | 43 | #include <sstream> | ||
2142 | 44 | #include <cstdint> | 45 | #include <cstdint> |
2143 | 45 | 46 | ||
2144 | 46 | namespace dbus = core::dbus; | 47 | namespace dbus = core::dbus; |
2145 | @@ -104,7 +105,7 @@ | |||
2146 | 104 | 105 | ||
2147 | 105 | void handle_add_track_with_uri_at(const core::dbus::Message::Ptr& msg) | 106 | void handle_add_track_with_uri_at(const core::dbus::Message::Ptr& msg) |
2148 | 106 | { | 107 | { |
2150 | 107 | std::cout << "*** " << __PRETTY_FUNCTION__ << std::endl; | 108 | MH_TRACE(""); |
2151 | 108 | request_context_resolver->resolve_context_for_dbus_name_async | 109 | request_context_resolver->resolve_context_for_dbus_name_async |
2152 | 109 | (msg->sender(), [this, msg](const media::apparmor::ubuntu::Context& context) | 110 | (msg->sender(), [this, msg](const media::apparmor::ubuntu::Context& context) |
2153 | 110 | { | 111 | { |
2154 | @@ -124,7 +125,7 @@ | |||
2155 | 124 | { | 125 | { |
2156 | 125 | const std::string err_str = {"Warning: Not adding track " + uri + | 126 | const std::string err_str = {"Warning: Not adding track " + uri + |
2157 | 126 | " to TrackList because it can't be found."}; | 127 | " to TrackList because it can't be found."}; |
2159 | 127 | std::cerr << err_str << std::endl; | 128 | MH_WARNING("%s", err_str.c_str()); |
2160 | 128 | reply = dbus::Message::make_error( | 129 | reply = dbus::Message::make_error( |
2161 | 129 | msg, | 130 | msg, |
2162 | 130 | mpris::Player::Error::UriNotFound::name, | 131 | mpris::Player::Error::UriNotFound::name, |
2163 | @@ -141,7 +142,7 @@ | |||
2164 | 141 | { | 142 | { |
2165 | 142 | const std::string err_str = {"Warning: Not adding track " + uri + | 143 | const std::string err_str = {"Warning: Not adding track " + uri + |
2166 | 143 | " to TrackList because of inadequate client apparmor permissions."}; | 144 | " to TrackList because of inadequate client apparmor permissions."}; |
2168 | 144 | std::cerr << err_str << std::endl; | 145 | MH_WARNING("%s", err_str.c_str()); |
2169 | 145 | reply = dbus::Message::make_error( | 146 | reply = dbus::Message::make_error( |
2170 | 146 | msg, | 147 | msg, |
2171 | 147 | mpris::TrackList::Error::InsufficientPermissionsToAddTrack::name, | 148 | mpris::TrackList::Error::InsufficientPermissionsToAddTrack::name, |
2172 | @@ -155,7 +156,7 @@ | |||
2173 | 155 | 156 | ||
2174 | 156 | void handle_add_tracks_with_uri_at(const core::dbus::Message::Ptr& msg) | 157 | void handle_add_tracks_with_uri_at(const core::dbus::Message::Ptr& msg) |
2175 | 157 | { | 158 | { |
2177 | 158 | std::cout << "*** " << __PRETTY_FUNCTION__ << std::endl; | 159 | MH_TRACE(""); |
2178 | 159 | request_context_resolver->resolve_context_for_dbus_name_async | 160 | request_context_resolver->resolve_context_for_dbus_name_async |
2179 | 160 | (msg->sender(), [this, msg](const media::apparmor::ubuntu::Context& context) | 161 | (msg->sender(), [this, msg](const media::apparmor::ubuntu::Context& context) |
2180 | 161 | { | 162 | { |
2181 | @@ -176,7 +177,7 @@ | |||
2182 | 176 | { | 177 | { |
2183 | 177 | uri_err_str = {"Warning: Not adding track " + uri + | 178 | uri_err_str = {"Warning: Not adding track " + uri + |
2184 | 178 | " to TrackList because it can't be found."}; | 179 | " to TrackList because it can't be found."}; |
2186 | 179 | std::cerr << uri_err_str << std::endl; | 180 | MH_WARNING("%s", uri_err_str.c_str()); |
2187 | 180 | reply = dbus::Message::make_error( | 181 | reply = dbus::Message::make_error( |
2188 | 181 | msg, | 182 | msg, |
2189 | 182 | mpris::Player::Error::UriNotFound::name, | 183 | mpris::Player::Error::UriNotFound::name, |
2190 | @@ -201,7 +202,7 @@ | |||
2191 | 201 | } | 202 | } |
2192 | 202 | else | 203 | else |
2193 | 203 | { | 204 | { |
2195 | 204 | std::cerr << err_str << std::endl; | 205 | MH_WARNING("%s", err_str.c_str()); |
2196 | 205 | reply = dbus::Message::make_error( | 206 | reply = dbus::Message::make_error( |
2197 | 206 | msg, | 207 | msg, |
2198 | 207 | mpris::TrackList::Error::InsufficientPermissionsToAddTrack::name, | 208 | mpris::TrackList::Error::InsufficientPermissionsToAddTrack::name, |
2199 | @@ -225,7 +226,7 @@ | |||
2200 | 225 | { | 226 | { |
2201 | 226 | const std::string err_str = {"Error: Not moving track " + id + | 227 | const std::string err_str = {"Error: Not moving track " + id + |
2202 | 227 | " to destination " + to}; | 228 | " to destination " + to}; |
2204 | 228 | std::cerr << err_str << std::endl; | 229 | MH_WARNING("%s", err_str.c_str()); |
2205 | 229 | reply = dbus::Message::make_error( | 230 | reply = dbus::Message::make_error( |
2206 | 230 | msg, | 231 | msg, |
2207 | 231 | mpris::TrackList::Error::FailedToMoveTrack::name, | 232 | mpris::TrackList::Error::FailedToMoveTrack::name, |
2208 | @@ -262,9 +263,9 @@ | |||
2209 | 262 | 263 | ||
2210 | 263 | auto id_it = find(impl->tracks().get().begin(), impl->tracks().get().end(), track); | 264 | auto id_it = find(impl->tracks().get().begin(), impl->tracks().get().end(), track); |
2211 | 264 | if (id_it == impl->tracks().get().end()) { | 265 | if (id_it == impl->tracks().get().end()) { |
2213 | 265 | ostringstream err_str; | 266 | stringstream err_str; |
2214 | 266 | err_str << "Track " << track << " not found in track list"; | 267 | err_str << "Track " << track << " not found in track list"; |
2216 | 267 | cout << __PRETTY_FUNCTION__ << " WARNING " << err_str.str() << endl; | 268 | MH_WARNING("%s", err_str.str()); |
2217 | 268 | auto reply = dbus::Message::make_error( | 269 | auto reply = dbus::Message::make_error( |
2218 | 269 | msg, | 270 | msg, |
2219 | 270 | mpris::TrackList::Error::TrackNotFound::name, | 271 | mpris::TrackList::Error::TrackNotFound::name, |
2220 | @@ -278,7 +279,7 @@ | |||
2221 | 278 | 279 | ||
2222 | 279 | if (id_it == impl->current_iterator()) | 280 | if (id_it == impl->current_iterator()) |
2223 | 280 | { | 281 | { |
2225 | 281 | cout << "Removing current track" << endl; | 282 | MH_DEBUG("Removing current track"); |
2226 | 282 | deleting_current = true; | 283 | deleting_current = true; |
2227 | 283 | 284 | ||
2228 | 284 | if (current_track != empty_iterator) | 285 | if (current_track != empty_iterator) |
2229 | @@ -537,10 +538,10 @@ | |||
2230 | 537 | 538 | ||
2231 | 538 | media::Track::Id media::TrackListSkeleton::next() | 539 | media::Track::Id media::TrackListSkeleton::next() |
2232 | 539 | { | 540 | { |
2234 | 540 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 541 | MH_TRACE(""); |
2235 | 541 | if (tracks().get().empty()) { | 542 | if (tracks().get().empty()) { |
2236 | 542 | // TODO Change ServiceSkeleton to return with error from DBus call | 543 | // TODO Change ServiceSkeleton to return with error from DBus call |
2238 | 543 | std::cerr << "ERROR: no tracks, cannot go to next" << std::endl; | 544 | MH_ERROR("No tracks, cannot go to next"); |
2239 | 544 | return media::Track::Id{}; | 545 | return media::Track::Id{}; |
2240 | 545 | } | 546 | } |
2241 | 546 | 547 | ||
2242 | @@ -549,13 +550,13 @@ | |||
2243 | 549 | // End of the track reached so loop around to the beginning of the track | 550 | // End of the track reached so loop around to the beginning of the track |
2244 | 550 | if (d->loop_status == media::Player::LoopStatus::track) | 551 | if (d->loop_status == media::Player::LoopStatus::track) |
2245 | 551 | { | 552 | { |
2247 | 552 | std::cout << "Looping on the current track since LoopStatus is set to track" << std::endl; | 553 | MH_INFO("Looping on the current track since LoopStatus is set to track"); |
2248 | 553 | go_to_track = true; | 554 | go_to_track = true; |
2249 | 554 | } | 555 | } |
2250 | 555 | // End of the tracklist reached so loop around to the beginning of the tracklist | 556 | // End of the tracklist reached so loop around to the beginning of the tracklist |
2251 | 556 | else if (d->loop_status == media::Player::LoopStatus::playlist && not has_next()) | 557 | else if (d->loop_status == media::Player::LoopStatus::playlist && not has_next()) |
2252 | 557 | { | 558 | { |
2254 | 558 | std::cout << "Looping on the tracklist since LoopStatus is set to playlist" << std::endl; | 559 | MH_INFO("Looping on the tracklist since LoopStatus is set to playlist"); |
2255 | 559 | 560 | ||
2256 | 560 | if (shuffle()) | 561 | if (shuffle()) |
2257 | 561 | { | 562 | { |
2258 | @@ -574,7 +575,7 @@ | |||
2259 | 574 | { | 575 | { |
2260 | 575 | auto it = get_current_shuffled(); | 576 | auto it = get_current_shuffled(); |
2261 | 576 | if (++it != shuffled_tracks().end()) { | 577 | if (++it != shuffled_tracks().end()) { |
2263 | 577 | cout << "Advancing to next track: " << *it << endl; | 578 | MH_INFO("Advancing to next track: %s", *it); |
2264 | 578 | set_current_track(*it); | 579 | set_current_track(*it); |
2265 | 579 | go_to_track = true; | 580 | go_to_track = true; |
2266 | 580 | } | 581 | } |
2267 | @@ -584,7 +585,7 @@ | |||
2268 | 584 | const auto it = std::next(current_iterator()); | 585 | const auto it = std::next(current_iterator()); |
2269 | 585 | if (not is_last_track(it)) | 586 | if (not is_last_track(it)) |
2270 | 586 | { | 587 | { |
2272 | 587 | cout << "Advancing to next track: " << *it << endl; | 588 | MH_INFO("Advancing to next track: %s", *it); |
2273 | 588 | d->current_track = it; | 589 | d->current_track = it; |
2274 | 589 | go_to_track = true; | 590 | go_to_track = true; |
2275 | 590 | } | 591 | } |
2276 | @@ -594,7 +595,7 @@ | |||
2277 | 594 | 595 | ||
2278 | 595 | if (go_to_track) | 596 | if (go_to_track) |
2279 | 596 | { | 597 | { |
2281 | 597 | cout << "next track id is " << *(current_iterator()) << endl; | 598 | MH_DEBUG("next track id is %s", *(current_iterator())); |
2282 | 598 | on_track_changed()(*(current_iterator())); | 599 | on_track_changed()(*(current_iterator())); |
2283 | 599 | const media::Track::Id id = *(current_iterator()); | 600 | const media::Track::Id id = *(current_iterator()); |
2284 | 600 | // Signal the PlayerImplementation to play the next track | 601 | // Signal the PlayerImplementation to play the next track |
2285 | @@ -603,7 +604,7 @@ | |||
2286 | 603 | else | 604 | else |
2287 | 604 | { | 605 | { |
2288 | 605 | // At the end of the tracklist and not set to loop | 606 | // At the end of the tracklist and not set to loop |
2290 | 606 | cout << "End of tracklist reached" << endl; | 607 | MH_INFO("End of tracklist reached"); |
2291 | 607 | on_end_of_tracklist()(); | 608 | on_end_of_tracklist()(); |
2292 | 608 | } | 609 | } |
2293 | 609 | 610 | ||
2294 | @@ -612,10 +613,10 @@ | |||
2295 | 612 | 613 | ||
2296 | 613 | media::Track::Id media::TrackListSkeleton::previous() | 614 | media::Track::Id media::TrackListSkeleton::previous() |
2297 | 614 | { | 615 | { |
2299 | 615 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 616 | MH_TRACE(""); |
2300 | 616 | if (tracks().get().empty()) { | 617 | if (tracks().get().empty()) { |
2301 | 617 | // TODO Change ServiceSkeleton to return with error from DBus call | 618 | // TODO Change ServiceSkeleton to return with error from DBus call |
2303 | 618 | std::cerr << "ERROR: no tracks, cannot go to previous" << std::endl; | 619 | MH_ERROR("No tracks, cannot go to previous"); |
2304 | 619 | return media::Track::Id{}; | 620 | return media::Track::Id{}; |
2305 | 620 | } | 621 | } |
2306 | 621 | 622 | ||
2307 | @@ -627,19 +628,19 @@ | |||
2308 | 627 | // repeat it from the beginning | 628 | // repeat it from the beginning |
2309 | 628 | if (d->current_position > max_position) | 629 | if (d->current_position > max_position) |
2310 | 629 | { | 630 | { |
2312 | 630 | std::cout << "Repeating current track..." << std::endl; | 631 | MH_INFO("Repeating current track..."); |
2313 | 631 | go_to_track = true; | 632 | go_to_track = true; |
2314 | 632 | } | 633 | } |
2315 | 633 | // Loop on the current track forever | 634 | // Loop on the current track forever |
2316 | 634 | else if (d->loop_status == media::Player::LoopStatus::track) | 635 | else if (d->loop_status == media::Player::LoopStatus::track) |
2317 | 635 | { | 636 | { |
2319 | 636 | std::cout << "Looping on the current track..." << std::endl; | 637 | MH_INFO("Looping on the current track..."); |
2320 | 637 | go_to_track = true; | 638 | go_to_track = true; |
2321 | 638 | } | 639 | } |
2322 | 639 | // Loop over the whole playlist and repeat | 640 | // Loop over the whole playlist and repeat |
2323 | 640 | else if (d->loop_status == media::Player::LoopStatus::playlist && not has_previous()) | 641 | else if (d->loop_status == media::Player::LoopStatus::playlist && not has_previous()) |
2324 | 641 | { | 642 | { |
2326 | 642 | std::cout << "Looping on the entire TrackList..." << std::endl; | 643 | MH_INFO("Looping on the entire TrackList..."); |
2327 | 643 | 644 | ||
2328 | 644 | if (shuffle()) | 645 | if (shuffle()) |
2329 | 645 | { | 646 | { |
2330 | @@ -680,7 +681,7 @@ | |||
2331 | 680 | else | 681 | else |
2332 | 681 | { | 682 | { |
2333 | 682 | // At the beginning of the tracklist and not set to loop | 683 | // At the beginning of the tracklist and not set to loop |
2335 | 683 | cout << "Beginning of tracklist reached" << endl; | 684 | MH_INFO("Beginning of tracklist reached"); |
2336 | 684 | on_end_of_tracklist()(); | 685 | on_end_of_tracklist()(); |
2337 | 685 | } | 686 | } |
2338 | 686 | 687 | ||
2339 | @@ -698,12 +699,12 @@ | |||
2340 | 698 | // a segfault when calling current() | 699 | // a segfault when calling current() |
2341 | 699 | if (tracks().get().size() && (d->current_track == d->empty_iterator)) | 700 | if (tracks().get().size() && (d->current_track == d->empty_iterator)) |
2342 | 700 | { | 701 | { |
2344 | 701 | std::cout << "Wrapping d->current_track back to begin()" << std::endl; | 702 | MH_DEBUG("Wrapping d->current_track back to begin()"); |
2345 | 702 | d->current_track = d->skeleton.properties.tracks->get().begin(); | 703 | d->current_track = d->skeleton.properties.tracks->get().begin(); |
2346 | 703 | } | 704 | } |
2347 | 704 | else if (tracks().get().empty()) | 705 | else if (tracks().get().empty()) |
2348 | 705 | { | 706 | { |
2350 | 706 | std::cerr << "TrackList is empty therefore there is no valid current track" << std::endl; | 707 | MH_ERROR("TrackList is empty therefore there is no valid current track"); |
2351 | 707 | } | 708 | } |
2352 | 708 | 709 | ||
2353 | 709 | return d->current_track; | 710 | return d->current_track; |
2354 | @@ -711,11 +712,10 @@ | |||
2355 | 711 | 712 | ||
2356 | 712 | bool media::TrackListSkeleton::update_current_iterator(const TrackList::ConstIterator &it) | 713 | bool media::TrackListSkeleton::update_current_iterator(const TrackList::ConstIterator &it) |
2357 | 713 | { | 714 | { |
2359 | 714 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 715 | MH_TRACE(""); |
2360 | 715 | if (it == tracks().get().end()) | 716 | if (it == tracks().get().end()) |
2361 | 716 | return false; | 717 | return false; |
2362 | 717 | 718 | ||
2363 | 718 | std::cout << "Updating current_track iterator" << std::endl; | ||
2364 | 719 | d->current_track = it; | 719 | d->current_track = it; |
2365 | 720 | 720 | ||
2366 | 721 | return true; | 721 | return true; |
2367 | @@ -780,8 +780,7 @@ | |||
2368 | 780 | 780 | ||
2369 | 781 | void media::TrackListSkeleton::on_shuffle_changed(bool shuffle) | 781 | void media::TrackListSkeleton::on_shuffle_changed(bool shuffle) |
2370 | 782 | { | 782 | { |
2373 | 783 | cout << __PRETTY_FUNCTION__ << endl; | 783 | MH_TRACE(""); |
2372 | 784 | |||
2374 | 785 | set_shuffle(shuffle); | 784 | set_shuffle(shuffle); |
2375 | 786 | } | 785 | } |
2376 | 787 | 786 | ||
2377 | @@ -793,7 +792,7 @@ | |||
2378 | 793 | const core::Signal<media::TrackList::ContainerTrackIdTuple>& media::TrackListSkeleton::on_track_list_replaced() const | 792 | const core::Signal<media::TrackList::ContainerTrackIdTuple>& media::TrackListSkeleton::on_track_list_replaced() const |
2379 | 794 | { | 793 | { |
2380 | 795 | // Print the TrackList instance | 794 | // Print the TrackList instance |
2382 | 796 | std::cout << *this << std::endl; | 795 | MH_DEBUG("%s", *this); |
2383 | 797 | return d->signals.on_track_list_replaced; | 796 | return d->signals.on_track_list_replaced; |
2384 | 798 | } | 797 | } |
2385 | 799 | 798 | ||
2386 | 800 | 799 | ||
2387 | === modified file 'src/core/media/track_list_stub.cpp' | |||
2388 | --- src/core/media/track_list_stub.cpp 2016-02-19 16:14:42 +0000 | |||
2389 | +++ src/core/media/track_list_stub.cpp 2016-04-07 00:39:05 +0000 | |||
2390 | @@ -28,6 +28,8 @@ | |||
2391 | 28 | #include "mpris/player.h" | 28 | #include "mpris/player.h" |
2392 | 29 | #include "mpris/track_list.h" | 29 | #include "mpris/track_list.h" |
2393 | 30 | 30 | ||
2394 | 31 | #include "core/media/logger/logger.h" | ||
2395 | 32 | |||
2396 | 31 | #include <core/dbus/property.h> | 33 | #include <core/dbus/property.h> |
2397 | 32 | #include <core/dbus/types/object_path.h> | 34 | #include <core/dbus/types/object_path.h> |
2398 | 33 | #include <core/dbus/types/variant.h> | 35 | #include <core/dbus/types/variant.h> |
2399 | @@ -111,43 +113,43 @@ | |||
2400 | 111 | { | 113 | { |
2401 | 112 | dbus.on_track_added->connect([this](const Track::Id& id) | 114 | dbus.on_track_added->connect([this](const Track::Id& id) |
2402 | 113 | { | 115 | { |
2404 | 114 | std::cout << "OnTrackAdded signal arrived via the bus." << std::endl; | 116 | MH_DEBUG("OnTrackAdded signal arrived via the bus."); |
2405 | 115 | on_track_added(id); | 117 | on_track_added(id); |
2406 | 116 | }); | 118 | }); |
2407 | 117 | 119 | ||
2408 | 118 | dbus.on_tracks_added->connect([this](const media::TrackList::ContainerURI& tracks) | 120 | dbus.on_tracks_added->connect([this](const media::TrackList::ContainerURI& tracks) |
2409 | 119 | { | 121 | { |
2411 | 120 | std::cout << "OnTracksAdded signal arrived via the bus." << std::endl; | 122 | MH_DEBUG("OnTracksAdded signal arrived via the bus."); |
2412 | 121 | on_tracks_added(tracks); | 123 | on_tracks_added(tracks); |
2413 | 122 | }); | 124 | }); |
2414 | 123 | 125 | ||
2415 | 124 | dbus.on_track_moved->connect([this](const media::TrackList::TrackIdTuple& ids) | 126 | dbus.on_track_moved->connect([this](const media::TrackList::TrackIdTuple& ids) |
2416 | 125 | { | 127 | { |
2418 | 126 | std::cout << "OnTrackMoved signal arrived via the bus." << std::endl; | 128 | MH_DEBUG("OnTrackMoved signal arrived via the bus."); |
2419 | 127 | on_track_moved(ids); | 129 | on_track_moved(ids); |
2420 | 128 | }); | 130 | }); |
2421 | 129 | 131 | ||
2422 | 130 | dbus.on_track_removed->connect([this](const Track::Id& id) | 132 | dbus.on_track_removed->connect([this](const Track::Id& id) |
2423 | 131 | { | 133 | { |
2425 | 132 | std::cout << "OnTrackRemoved signal arrived via the bus." << std::endl; | 134 | MH_DEBUG("OnTrackRemoved signal arrived via the bus."); |
2426 | 133 | on_track_removed(id); | 135 | on_track_removed(id); |
2427 | 134 | }); | 136 | }); |
2428 | 135 | 137 | ||
2429 | 136 | dbus.on_track_list_reset->connect([this](void) | 138 | dbus.on_track_list_reset->connect([this](void) |
2430 | 137 | { | 139 | { |
2432 | 138 | std::cout << "OnTrackListReset signal arrived via the bus." << std::endl; | 140 | MH_DEBUG("OnTrackListReset signal arrived via the bus."); |
2433 | 139 | on_track_list_reset(); | 141 | on_track_list_reset(); |
2434 | 140 | }); | 142 | }); |
2435 | 141 | 143 | ||
2436 | 142 | dbus.on_track_list_replaced->connect([this](const media::TrackList::ContainerTrackIdTuple& list) | 144 | dbus.on_track_list_replaced->connect([this](const media::TrackList::ContainerTrackIdTuple& list) |
2437 | 143 | { | 145 | { |
2439 | 144 | std::cout << "OnTrackListReplaced signal arrived via the bus." << std::endl; | 146 | MH_DEBUG("OnTrackListReplaced signal arrived via the bus."); |
2440 | 145 | on_track_list_replaced(list); | 147 | on_track_list_replaced(list); |
2441 | 146 | }); | 148 | }); |
2442 | 147 | 149 | ||
2443 | 148 | dbus.on_track_changed->connect([this](const Track::Id& id) | 150 | dbus.on_track_changed->connect([this](const Track::Id& id) |
2444 | 149 | { | 151 | { |
2446 | 150 | std::cout << "OnTrackChanged signal arrived via the bus." << std::endl; | 152 | MH_DEBUG("OnTrackChanged signal arrived via the bus."); |
2447 | 151 | on_track_changed(id); | 153 | on_track_changed(id); |
2448 | 152 | }); | 154 | }); |
2449 | 153 | } | 155 | } |
2450 | 154 | 156 | ||
2451 | === added file 'src/core/media/util/utils.cpp' | |||
2452 | --- src/core/media/util/utils.cpp 1970-01-01 00:00:00 +0000 | |||
2453 | +++ src/core/media/util/utils.cpp 2016-04-07 00:39:05 +0000 | |||
2454 | @@ -0,0 +1,41 @@ | |||
2455 | 1 | /* | ||
2456 | 2 | * Copyright © 2016 Canonical Ltd. | ||
2457 | 3 | * | ||
2458 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2459 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
2460 | 6 | * as published by the Free Software Foundation. | ||
2461 | 7 | * | ||
2462 | 8 | * This program is distributed in the hope that it will be useful, | ||
2463 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2464 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2465 | 11 | * GNU Lesser General Public License for more details. | ||
2466 | 12 | * | ||
2467 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2468 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2469 | 15 | * | ||
2470 | 16 | */ | ||
2471 | 17 | |||
2472 | 18 | #include <boost/filesystem.hpp> | ||
2473 | 19 | #include <boost/algorithm/string.hpp> | ||
2474 | 20 | |||
2475 | 21 | #include <memory> | ||
2476 | 22 | #include <fstream> | ||
2477 | 23 | #include <sstream> | ||
2478 | 24 | |||
2479 | 25 | #include <cstring> | ||
2480 | 26 | #include <cstdarg> | ||
2481 | 27 | |||
2482 | 28 | #include "utils.h" | ||
2483 | 29 | |||
2484 | 30 | namespace media = core::ubuntu::media; | ||
2485 | 31 | |||
2486 | 32 | uint64_t media::Utils::GetNowNs() { | ||
2487 | 33 | struct timespec ts; | ||
2488 | 34 | memset(&ts, 0, sizeof(ts)); | ||
2489 | 35 | clock_gettime(CLOCK_MONOTONIC, &ts); | ||
2490 | 36 | return ts.tv_sec * 1000000000LL + ts.tv_nsec; | ||
2491 | 37 | } | ||
2492 | 38 | |||
2493 | 39 | uint64_t media::Utils::GetNowUs() { | ||
2494 | 40 | return GetNowNs() / 1000; | ||
2495 | 41 | } | ||
2496 | 0 | 42 | ||
2497 | === added file 'src/core/media/util/utils.h' | |||
2498 | --- src/core/media/util/utils.h 1970-01-01 00:00:00 +0000 | |||
2499 | +++ src/core/media/util/utils.h 2016-04-07 00:39:05 +0000 | |||
2500 | @@ -0,0 +1,69 @@ | |||
2501 | 1 | /* | ||
2502 | 2 | * Copyright © 2016 Canonical Ltd. | ||
2503 | 3 | * | ||
2504 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2505 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
2506 | 6 | * as published by the Free Software Foundation. | ||
2507 | 7 | * | ||
2508 | 8 | * This program is distributed in the hope that it will be useful, | ||
2509 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2510 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2511 | 11 | * GNU Lesser General Public License for more details. | ||
2512 | 12 | * | ||
2513 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2514 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2515 | 15 | * | ||
2516 | 16 | */ | ||
2517 | 17 | |||
2518 | 18 | #ifndef UTILS_H_ | ||
2519 | 19 | #define UTILS_H_ | ||
2520 | 20 | |||
2521 | 21 | #include <boost/format.hpp> | ||
2522 | 22 | |||
2523 | 23 | #include <string> | ||
2524 | 24 | #include <vector> | ||
2525 | 25 | |||
2526 | 26 | #define MCS_STR_VALUE(str) #str | ||
2527 | 27 | |||
2528 | 28 | namespace core { | ||
2529 | 29 | namespace ubuntu { | ||
2530 | 30 | namespace media { | ||
2531 | 31 | typedef int64_t TimestampNs; | ||
2532 | 32 | typedef int64_t TimestampUs; | ||
2533 | 33 | struct Utils | ||
2534 | 34 | { | ||
2535 | 35 | // Merely used as a namespace. | ||
2536 | 36 | Utils() = delete; | ||
2537 | 37 | |||
2538 | 38 | // Sprintf - much like what you would expect :) | ||
2539 | 39 | template<typename... Types> | ||
2540 | 40 | static std::string Sprintf(const std::string& fmt_str, Types&&... args); | ||
2541 | 41 | // GetEnv - returns a variable value from the environment | ||
2542 | 42 | static uint64_t GetNowNs(); | ||
2543 | 43 | // GetNowUs - get a timestamp in microseconds | ||
2544 | 44 | static uint64_t GetNowUs(); | ||
2545 | 45 | }; | ||
2546 | 46 | |||
2547 | 47 | namespace impl { | ||
2548 | 48 | // Base case, just return the passed in boost::format instance. | ||
2549 | 49 | inline boost::format& Sprintf(boost::format& f) | ||
2550 | 50 | { | ||
2551 | 51 | return f; | ||
2552 | 52 | } | ||
2553 | 53 | // Sprintf recursively walks the parameter pack at compile time. | ||
2554 | 54 | template <typename Head, typename... Tail> | ||
2555 | 55 | inline boost::format& Sprintf(boost::format& f, Head const& head, Tail&&... tail) { | ||
2556 | 56 | return Sprintf(f % head, std::forward<Tail>(tail)...); | ||
2557 | 57 | } | ||
2558 | 58 | } // namespace impl | ||
2559 | 59 | } // namespace media | ||
2560 | 60 | } // namespace ubuntu | ||
2561 | 61 | } // namespace core | ||
2562 | 62 | |||
2563 | 63 | template <typename... Types> | ||
2564 | 64 | inline std::string core::ubuntu::media::Utils::Sprintf(const std::string& format, Types&&... args) { | ||
2565 | 65 | boost::format f(format); | ||
2566 | 66 | return core::ubuntu::media::impl::Sprintf(f, std::forward<Types>(args)...).str(); | ||
2567 | 67 | } | ||
2568 | 68 | |||
2569 | 69 | #endif | ||
2570 | 0 | 70 | ||
2571 | === modified file 'src/core/media/video/platform_default_sink.cpp' | |||
2572 | --- src/core/media/video/platform_default_sink.cpp 2015-01-29 12:12:43 +0000 | |||
2573 | +++ src/core/media/video/platform_default_sink.cpp 2016-04-07 00:39:05 +0000 | |||
2574 | @@ -36,7 +36,7 @@ | |||
2575 | 36 | // and returns true or returns false and leaves 'matrix' unchanged in case | 36 | // and returns true or returns false and leaves 'matrix' unchanged in case |
2576 | 37 | // of issues. | 37 | // of issues. |
2577 | 38 | bool transformation_matrix(float*) const | 38 | bool transformation_matrix(float*) const |
2579 | 39 | { | 39 | { |
2580 | 40 | return true; | 40 | return true; |
2581 | 41 | } | 41 | } |
2582 | 42 | 42 |
Not many issues compared to the length of the diff and frankly I'm mostly concerned about the own noncopyable class.
There is also one thing which is not bad however I would like to highlight it. I did not like the need to create stringstream in so many cases to log a line as basically this is repeating.