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
=== modified file 'src/core/media/gstreamer/playbin.cpp'
--- src/core/media/gstreamer/playbin.cpp 2017-02-16 10:16:46 +0000
+++ src/core/media/gstreamer/playbin.cpp 2017-02-27 16:02:35 +0000
@@ -702,9 +702,27 @@
702 };702 };
703703
704 // Initialize to default value prior to querying actual values from the sink.704 // Initialize to default value prior to querying actual values from the sink.
705 uint32_t video_width = 0, video_height = 0;705 int video_width = 0, video_height = 0;
706 g_object_get (video_sink, "height", &video_height, nullptr);706
707 g_object_get (video_sink, "width", &video_width, nullptr);707 // There should be only one pad actually
708 GstIterator *iter = gst_element_iterate_pads(video_sink);
709 for (GValue item{};
710 gst_iterator_next(iter, &item) == GST_ITERATOR_OK;
711 g_value_unset(&item))
712 {
713 GstPad *pad = GST_PAD(g_value_get_object(&item));
714 GstCaps *caps = gst_pad_get_current_caps(pad);
715
716 if (caps) {
717 const GstStructure *s = gst_caps_get_structure(caps, 0);
718 gst_structure_get_int(s, "width", &video_width);
719 gst_structure_get_int(s, "height", &video_height);
720 MH_DEBUG("Video dimensions are %d x %d", video_width, video_height);
721
722 gst_caps_unref(caps);
723 }
724 }
725 gst_iterator_free(iter);
708726
709 // TODO(tvoss): We should probably check here if width and height are valid.727 // TODO(tvoss): We should probably check here if width and height are valid.
710 return core::ubuntu::media::video::Dimensions728 return core::ubuntu::media::video::Dimensions

Subscribers

People subscribed via source and target branches