Merge lp:~phablet-team/media-hub/fix-black-video-bugs into lp:media-hub

Proposed by Jim Hodapp
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 148
Merged at revision: 147
Proposed branch: lp:~phablet-team/media-hub/fix-black-video-bugs
Merge into: lp:media-hub
Diff against target: 89 lines (+19/-7)
2 files modified
src/core/media/gstreamer/playbin.cpp (+17/-6)
src/core/media/gstreamer/playbin.h (+2/-1)
To merge this branch: bzr merge lp:~phablet-team/media-hub/fix-black-video-bugs
Reviewer Review Type Date Requested Status
Alfonso Sanchez-Beato Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+262096@code.launchpad.net

Commit message

Only send the video_dimensions_changed signal if the dimensions actually changed. Also, no longer need is_eos flag.

Description of the change

Only send the video_dimensions_changed signal if the dimensions actually changed. Also, no longer need is_eos flag.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/media/gstreamer/playbin.cpp'
2--- src/core/media/gstreamer/playbin.cpp 2015-06-01 21:34:46 +0000
3+++ src/core/media/gstreamer/playbin.cpp 2015-06-16 14:42:38 +0000
4@@ -100,8 +100,10 @@
5 std::placeholders::_1))),
6 is_seeking(false),
7 previous_position(0),
8+ cached_video_dimensions{
9+ core::ubuntu::media::video::Height{0},
10+ core::ubuntu::media::video::Width{0}},
11 player_lifetime(media::Player::Lifetime::normal),
12- is_eos(false),
13 about_to_finish_handler_id(0),
14 source_setup_handler_id(0)
15 {
16@@ -208,7 +210,6 @@
17 }
18 break;
19 case GST_MESSAGE_EOS:
20- is_eos = true;
21 signals.on_end_of_stream();
22 default:
23 break;
24@@ -450,14 +451,15 @@
25 }
26
27 // We only should query the pipeline if we actually succeeded in
28- // setting the requested state. Also don't send on_video_dimensions_changed
29- // signal during EOS.
30- if (result && new_state == GST_STATE_PLAYING && !is_eos)
31+ // setting the requested state.
32+ if (result && new_state == GST_STATE_PLAYING)
33 {
34 // Get the video height/width from the video sink
35 try
36 {
37- signals.on_video_dimensions_changed(get_video_dimensions());
38+ const core::ubuntu::media::video::Dimensions new_dimensions = get_video_dimensions();
39+ emit_video_dimensions_changed_if_changed(new_dimensions);
40+ cached_video_dimensions = new_dimensions;
41 }
42 catch (const std::exception& e)
43 {
44@@ -499,6 +501,7 @@
45 uint32_t video_width = 0, video_height = 0;
46 g_object_get (video_sink, "height", &video_height, nullptr);
47 g_object_get (video_sink, "width", &video_width, nullptr);
48+
49 // TODO(tvoss): We should probably check here if width and height are valid.
50 return core::ubuntu::media::video::Dimensions
51 {
52@@ -507,6 +510,14 @@
53 };
54 }
55
56+void gstreamer::Playbin::emit_video_dimensions_changed_if_changed(const core::ubuntu::media::video::Dimensions &new_dimensions)
57+{
58+ // Only signal the application layer if the dimensions have in fact changed. This might happen
59+ // if reusing the same media-hub session to play two different video sources.
60+ if (new_dimensions != cached_video_dimensions)
61+ signals.on_video_dimensions_changed(new_dimensions);
62+}
63+
64 std::string gstreamer::Playbin::get_file_content_type(const std::string& uri) const
65 {
66 if (uri.empty())
67
68=== modified file 'src/core/media/gstreamer/playbin.h'
69--- src/core/media/gstreamer/playbin.h 2015-06-01 21:34:46 +0000
70+++ src/core/media/gstreamer/playbin.h 2015-06-16 14:42:38 +0000
71@@ -101,6 +101,7 @@
72 bool seek(const std::chrono::microseconds& ms);
73
74 core::ubuntu::media::video::Dimensions get_video_dimensions() const;
75+ void emit_video_dimensions_changed_if_changed(const core::ubuntu::media::video::Dimensions &new_dimensions);
76
77 std::string get_file_content_type(const std::string& uri) const;
78
79@@ -116,9 +117,9 @@
80 core::Connection on_new_message_connection_async;
81 bool is_seeking;
82 mutable uint64_t previous_position;
83+ core::ubuntu::media::video::Dimensions cached_video_dimensions;
84 core::ubuntu::media::Player::HeadersType request_headers;
85 core::ubuntu::media::Player::Lifetime player_lifetime;
86- bool is_eos;
87 gulong about_to_finish_handler_id;
88 gulong source_setup_handler_id;
89 struct

Subscribers

People subscribed via source and target branches

to all changes: