Merge lp:~alfonsosanchezbeato/media-hub/get-dim-from-caps into lp:media-hub

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Jim Hodapp
Approved revision: 215
Merged at revision: 216
Proposed branch: lp:~alfonsosanchezbeato/media-hub/get-dim-from-caps
Merge into: lp:media-hub
Diff against target: 34 lines (+21/-3)
1 file modified
src/core/media/gstreamer/playbin.cpp (+21/-3)
To merge this branch: bzr merge lp:~alfonsosanchezbeato/media-hub/get-dim-from-caps
Reviewer Review Type Date Requested Status
Jim Hodapp (community) Approve
Review via email: mp+318373@code.launchpad.net

Commit message

Use caps instead of custom properties to retrieve video dimensions

Description of the change

Use caps instead of custom properties to retrieve video dimensions

To post a comment you must log in.
Revision history for this message
Jim Hodapp (jhodapp) wrote :

Were you able to test this on the phone as well?

Some changes needed inline below.

review: Needs Fixing (code)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

See below, repushing too.

215. By Alfonso Sanchez-Beato

Add const to GstStructure

Revision history for this message
Jim Hodapp (jhodapp) wrote :

LGTM

review: Approve
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Tested on Meizu Pro 5 and for desktop, works as expected in both cases.

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 2017-02-16 10:16:46 +0000
3+++ src/core/media/gstreamer/playbin.cpp 2017-02-27 16:02:35 +0000
4@@ -702,9 +702,27 @@
5 };
6
7 // Initialize to default value prior to querying actual values from the sink.
8- uint32_t video_width = 0, video_height = 0;
9- g_object_get (video_sink, "height", &video_height, nullptr);
10- g_object_get (video_sink, "width", &video_width, nullptr);
11+ int video_width = 0, video_height = 0;
12+
13+ // There should be only one pad actually
14+ GstIterator *iter = gst_element_iterate_pads(video_sink);
15+ for (GValue item{};
16+ gst_iterator_next(iter, &item) == GST_ITERATOR_OK;
17+ g_value_unset(&item))
18+ {
19+ GstPad *pad = GST_PAD(g_value_get_object(&item));
20+ GstCaps *caps = gst_pad_get_current_caps(pad);
21+
22+ if (caps) {
23+ const GstStructure *s = gst_caps_get_structure(caps, 0);
24+ gst_structure_get_int(s, "width", &video_width);
25+ gst_structure_get_int(s, "height", &video_height);
26+ MH_DEBUG("Video dimensions are %d x %d", video_width, video_height);
27+
28+ gst_caps_unref(caps);
29+ }
30+ }
31+ gst_iterator_free(iter);
32
33 // TODO(tvoss): We should probably check here if width and height are valid.
34 return core::ubuntu::media::video::Dimensions

Subscribers

People subscribed via source and target branches