Skip to content

Commit

Permalink
droidcamsrc: Store metadata in buffers only if it's supported.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlehtima committed Nov 14, 2016
1 parent 8a54a1e commit 03d59e8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
8 changes: 8 additions & 0 deletions gst-libs/gst/droid/gstwrappedmemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ G_BEGIN_DECLS
#define GST_ALLOCATOR_WRAPPED_MEMORY "WrappedMemory"
#define GST_CAPS_FEATURE_MEMORY_DROID_VIDEO_META_DATA "memory:DroidVideoMetaData"

#define GST_VIDEO_CAPS_MAKE_WITH_FEATURES_METADATA(features,format) \
"video/x-raw(" features "), " \
"format = (string) " format ", " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE ", " \
"metadata = (boolean) { FALSE, TRUE }"

GstAllocator * gst_wrapped_memory_allocator_new (void);

gboolean gst_is_wrapped_memory_memory (GstMemory * mem);
Expand Down
8 changes: 6 additions & 2 deletions gst/droidcamsrc/gstdroidcamsrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static GstStaticPadTemplate vf_src_template_factory =
GST_STATIC_PAD_TEMPLATE (GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME,
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES_METADATA
(GST_CAPS_FEATURE_MEMORY_DROID_MEDIA_BUFFER, "{YV12}") ";"
GST_VIDEO_CAPS_MAKE ("{NV21}")));

Expand All @@ -63,7 +63,7 @@ static GstStaticPadTemplate vid_src_template_factory =
GST_STATIC_PAD_TEMPLATE (GST_BASE_CAMERA_SRC_VIDEO_PAD_NAME,
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES_METADATA
(GST_CAPS_FEATURE_MEMORY_DROID_VIDEO_META_DATA, "{YV12}")));

static gboolean gst_droidcamsrc_pad_activate_mode (GstPad * pad,
Expand Down Expand Up @@ -1641,6 +1641,10 @@ gst_droidcamsrc_vidsrc_negotiate (GstDroidCamSrcPad * data)
gst_structure_fixate_field_nearest_fraction (gst_caps_get_structure (our_caps,
0), "framerate", G_MAXINT, 1);

bool metadata =
droid_media_camera_store_meta_data_in_buffers (src->dev->cam, true);
gst_caps_set_simple (our_caps, "metadata", G_TYPE_BOOLEAN, metadata, NULL);

if (!gst_pad_set_caps (data->pad, our_caps)) {
GST_ERROR_OBJECT (src, "failed to set caps");
goto out;
Expand Down
7 changes: 0 additions & 7 deletions gst/droidcamsrc/gstdroidcamsrcdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,13 +873,6 @@ gst_droidcamsrc_dev_start_video_recording (GstDroidCamSrcDev * dev)
dev->vid->video_frames = 0;
dev->vid->queued_frames = 0;

/* TODO: get that from caps */
if (!droid_media_camera_store_meta_data_in_buffers (dev->cam, true)) {
GST_ELEMENT_ERROR (src, LIBRARY, SETTINGS,
("error storing meta data in buffers for video recording"), (NULL));
goto out;
}

if (!droid_media_camera_start_recording (dev->cam)) {
GST_ELEMENT_ERROR (src, LIBRARY, FAILED, ("error starting video recording"),
(NULL));
Expand Down
6 changes: 3 additions & 3 deletions gst/droidcodec/gstdroidvenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static GstStaticPadTemplate gst_droidvenc_sink_template_factory =
GST_STATIC_PAD_TEMPLATE (GST_VIDEO_ENCODER_SINK_NAME,
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES_METADATA
(GST_CAPS_FEATURE_MEMORY_DROID_VIDEO_META_DATA, "{YV12}")));

enum
Expand Down Expand Up @@ -141,8 +141,8 @@ gst_droidvenc_create_codec (GstDroidVEnc * enc)
md.stride = enc->in_state->info.width;
md.slice_height = enc->in_state->info.height;

/* TODO: get this from caps */
md.meta_data = true;
gst_structure_get_boolean (gst_caps_get_structure (enc->in_state->caps, 0),
"metadata", &md.meta_data);

query = gst_droid_query_new_video_color_format ();
if (!gst_pad_peer_query (GST_VIDEO_ENCODER_SINK_PAD (GST_VIDEO_ENCODER (enc)),
Expand Down

0 comments on commit 03d59e8

Please sign in to comment.