[-]
[+]
|
Changed |
_service:tar_git:gstreamer1.0-droid.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:gst-droid.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,7 +2,7 @@
<service name="tar_git">
<param name="url">https://github.com/sailfishos/gst-droid.git</param>
<param name="branch">master</param>
- <param name="revision">0aeb90829c4a26add975d53a8a4a228bf1cd4c59</param>
+ <param name="revision">31355489511e31b324a16086dcbc0885f8faf8e9</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:gstreamer1.0-droid-0.20200120.0.tar.gz/gst-libs/gst/droid/gstdroidbufferpool.c
^
|
@@ -21,6 +21,7 @@
#include <gst/gst.h>
#include "gstdroidbufferpool.h"
+#include "gstdroidmediabuffer.h"
#define gst_droid_buffer_pool_parent_class parent_class
G_DEFINE_TYPE (GstDroidBufferPool, gst_droid_buffer_pool, GST_TYPE_BUFFER_POOL);
@@ -30,8 +31,11 @@
{
GstDroidBufferPool *dpool = GST_DROID_BUFFER_POOL (pool);
- gst_buffer_remove_all_memory (buffer);
- GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
+ // if the allocator is set then we should keep the memory
+ if (!dpool->allocator) {
+ gst_buffer_remove_all_memory (buffer);
+ GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
+ }
g_mutex_lock (&dpool->lock);
++dpool->num_buffers;
@@ -42,19 +46,74 @@
return GST_BUFFER_POOL_CLASS (parent_class)->reset_buffer (pool, buffer);
}
+static gboolean
+gst_droid_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
+{
+ GstCaps *caps;
+ guint size;
+ GstAllocationParams params = { GST_MEMORY_FLAG_NO_SHARE, 0, 0, 0 };
+ GstDroidBufferPool *pool = GST_DROID_BUFFER_POOL (bpool);
+
+ if (!gst_buffer_pool_config_get_params (config, &caps, &size, NULL, NULL)) {
+ GST_WARNING_OBJECT (pool, "Invalid pool configuration");
+ return FALSE;
+ }
+ // If we have caps then we can create droid buffers
+ if (caps != NULL) {
+ GST_OBJECT_LOCK (pool);
+
+ if (!gst_video_info_from_caps (&pool->video_info, caps)) {
+ GST_OBJECT_UNLOCK (pool);
+ GST_WARNING_OBJECT (pool, "Invalid video caps %" GST_PTR_FORMAT, caps);
+ return FALSE;
+ }
+
+ pool->video_info.size = size;
+
+ GST_DEBUG_OBJECT (pool, "Configured pool. caps: %" GST_PTR_FORMAT, caps);
+ pool->allocator = gst_droid_media_buffer_allocator_new ();
+ gst_object_ref (pool->allocator);
+ gst_buffer_pool_config_set_allocator (config,
+ (GstAllocator *) pool->allocator, ¶ms);
+ GST_OBJECT_UNLOCK (pool);
+ }
+
+ return GST_BUFFER_POOL_CLASS (gst_droid_buffer_pool_parent_class)
+ ->set_config (bpool, config);
+}
+
+static const gchar **
+gst_droid_buffer_pool_get_options (GstBufferPool * bpool)
+{
+ static const gchar *options[] = { GST_BUFFER_POOL_OPTION_VIDEO_META, NULL };
+
+ return options;
+}
+
static GstFlowReturn
-gst_droid_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
+gst_droid_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buf,
GstBufferPoolAcquireParams * params G_GNUC_UNUSED)
{
GstDroidBufferPool *dpool = GST_DROID_BUFFER_POOL (pool);
+ GstBuffer *buffer;
+ GstMemory *memory;
- *buffer = gst_buffer_new ();
- if (!*buffer) {
+ buffer = gst_buffer_new ();
+ if (!buffer) {
return GST_FLOW_ERROR;
}
+ // if the allocator is set then we should create the memory too
+ if (dpool->allocator) {
+ memory = gst_droid_media_buffer_allocator_alloc_new (dpool->allocator,
+ &dpool->video_info, buffer);
+ if (!memory) {
+ return GST_FLOW_ERROR;
+ }
+ }
g_mutex_lock (&dpool->lock);
++dpool->num_buffers;
+ *buf = buffer;
GST_DEBUG_OBJECT (dpool, "num buffers: %d", dpool->num_buffers);
g_cond_signal (&dpool->cond);
g_mutex_unlock (&dpool->lock);
@@ -136,7 +195,10 @@
gst_droid_buffer_pool_finalize (GObject * object)
{
GstDroidBufferPool *pool = GST_DROID_BUFFER_POOL (object);
-
+ if (pool->allocator) {
+ gst_object_unref (pool->allocator);
+ pool->allocator = 0;
+ }
g_mutex_clear (&pool->lock);
g_cond_clear (&pool->cond);
@@ -155,11 +217,15 @@
gstbufferpool_class->reset_buffer = gst_droid_buffer_pool_reset_buffer;
gstbufferpool_class->alloc_buffer = gst_droid_buffer_pool_alloc;
gstbufferpool_class->flush_start = gst_droid_buffer_pool_flush_start;
+ gstbufferpool_class->get_options = gst_droid_buffer_pool_get_options;
+ gstbufferpool_class->set_config = gst_droid_buffer_pool_set_config;
}
static void
-gst_droid_buffer_pool_init (GstDroidBufferPool * pool G_GNUC_UNUSED)
+gst_droid_buffer_pool_init (GstDroidBufferPool * object)
{
+ GstDroidBufferPool *pool = GST_DROID_BUFFER_POOL (object);
+ pool->allocator = 0;
g_mutex_init (&pool->lock);
g_cond_init (&pool->cond);
}
|
[-]
[+]
|
Changed |
_service:tar_git:gstreamer1.0-droid-0.20200120.0.tar.gz/gst-libs/gst/droid/gstdroidbufferpool.h
^
|
@@ -23,6 +23,7 @@
#define __GST_DROID_BUFFER_POOL_H__
#include <gst/gstbufferpool.h>
+#include <gst/video/video-info.h>
G_BEGIN_DECLS
@@ -40,6 +41,8 @@
GMutex lock;
GCond cond;
gint num_buffers;
+ GstAllocator *allocator;
+ GstVideoInfo video_info;
};
struct _GstDroidBufferPoolClass
|
[-]
[+]
|
Changed |
_service:tar_git:gstreamer1.0-droid-0.20200120.0.tar.gz/gst-libs/gst/droid/gstdroidcodec.c
^
|
@@ -38,15 +38,20 @@
static GstBuffer *create_h264enc_codec_data (DroidMediaData * data);
static gboolean create_mpeg4vdec_codec_data_from_codec_data (GstDroidCodec *
codec, GstBuffer * data, DroidMediaData * out);
+static gboolean
+create_mpeg2vdec_codec_data_from_codec_data (GstDroidCodec *
+ codec G_GNUC_UNUSED, GstBuffer * data, DroidMediaData * out);
static gboolean create_h264dec_codec_data_from_codec_data (GstDroidCodec *
codec, GstBuffer * data, DroidMediaData * out);
-static gboolean create_vp8vdec_codec_data_from_codec_data (GstDroidCodec *
+static gboolean create_h265dec_codec_data_from_codec_data (GstDroidCodec *
codec, GstBuffer * data, DroidMediaData * out);
static gboolean create_aacdec_codec_data_from_codec_data (GstDroidCodec * codec,
GstBuffer * data, DroidMediaData * out);
static gboolean create_aacdec_codec_data_from_frame_data (GstDroidCodec * codec,
GstBuffer * frame_data, DroidMediaData * out);
-static gboolean process_h264dec_data (GstDroidCodec * codec, GstBuffer * buffer,
+static gboolean ignore_codec_data (GstDroidCodec * codec, GstBuffer * data,
+ DroidMediaData * out);
+static gboolean process_h26xdec_data (GstDroidCodec * codec, GstBuffer * buffer,
DroidMediaData * out);
static gboolean process_aacdec_data (GstDroidCodec * codec, GstBuffer * buffer,
DroidMediaData * out);
@@ -108,6 +113,14 @@
is_mpega, NULL, NULL, NULL, create_aacdec_codec_data_from_codec_data,
create_aacdec_codec_data_from_frame_data, process_aacdec_data},
+ {GST_DROID_CODEC_DECODER_AUDIO, "audio/AMR", "audio/3gpp",
+ "audio/AMR", FALSE, NULL, NULL, NULL, NULL,
+ ignore_codec_data, NULL, NULL},
+
+ {GST_DROID_CODEC_DECODER_AUDIO, "audio/AMR-WB", "audio/amr-wb",
+ "audio/AMR-WB", FALSE, NULL, NULL, NULL, NULL,
+ ignore_codec_data, NULL, NULL},
+
/* video decoders */
{GST_DROID_CODEC_DECODER_VIDEO, "video/mpeg", "video/mp4v-es",
"video/mpeg, mpegversion=4", TRUE,
@@ -117,15 +130,26 @@
{GST_DROID_CODEC_DECODER_VIDEO, "video/x-h264", "video/avc",
"video/x-h264, stream-format=avc,alignment=au", TRUE,
is_h264_dec, NULL, NULL, NULL,
- create_h264dec_codec_data_from_codec_data, NULL, process_h264dec_data},
+ create_h264dec_codec_data_from_codec_data, NULL, process_h26xdec_data},
{GST_DROID_CODEC_DECODER_VIDEO, "video/x-h263", "video/3gpp",
"video/x-h263", TRUE, NULL,
NULL, NULL, NULL, NULL, NULL, NULL},
{GST_DROID_CODEC_DECODER_VIDEO, "video/x-vp8", "video/x-vnd.on2.vp8",
- "video/x-vp8", TRUE, NULL, NULL, NULL, NULL,
- create_vp8vdec_codec_data_from_codec_data, NULL, NULL},
+ "video/x-vp8", TRUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+
+ {GST_DROID_CODEC_DECODER_VIDEO, "video/x-vp9", "video/x-vnd.on2.vp9",
+ "video/x-vp9", TRUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+
+ {GST_DROID_CODEC_DECODER_VIDEO, "video/mpeg", "video/mpeg2",
+ "video/mpeg, mpegversion=2", TRUE,
+ NULL, NULL, NULL, NULL,
+ create_mpeg2vdec_codec_data_from_codec_data, NULL, NULL},
+
+ {GST_DROID_CODEC_DECODER_VIDEO, "video/x-h265", "video/hevc",
+ "video/x-h265", FALSE, NULL, NULL, NULL, NULL,
+ create_h265dec_codec_data_from_codec_data, NULL, process_h26xdec_data},
/* audio encoders */
{GST_DROID_CODEC_ENCODER_AUDIO, "audio/mpeg", "audio/mp4a-latm",
@@ -217,6 +241,20 @@
continue;
}
+ /* Verify that video codec is supported before enabling it */
+ if (type == GST_DROID_CODEC_DECODER_VIDEO
+ || type == GST_DROID_CODEC_ENCODER_VIDEO) {
+ DroidMediaCodecMetaData md;
+ md.type = codecs[x].droid;
+ md.flags = DROID_MEDIA_CODEC_HW_ONLY;
+ if (!droid_media_codec_is_supported (&md,
+ type == GST_DROID_CODEC_ENCODER_VIDEO)) {
+ GST_INFO ("No hardware support found for %s, disabling codec",
+ codecs[x].droid);
+ continue;
+ }
+ }
+
s = gst_structure_new_from_string (codecs[x].caps);
caps = gst_caps_merge_structure (caps, s);
}
@@ -617,6 +655,16 @@
}
static gboolean
+create_mpeg2vdec_codec_data_from_codec_data (GstDroidCodec *
+ codec G_GNUC_UNUSED, GstBuffer * data G_GNUC_UNUSED, DroidMediaData * out)
+{
+ out->size = 0;
+ out->data = NULL;
+
+ return TRUE;
+}
+
+static gboolean
create_mpeg4vdec_codec_data_from_codec_data (GstDroidCodec *
codec G_GNUC_UNUSED, GstBuffer * data, DroidMediaData * out)
{
@@ -677,7 +725,7 @@
}
static gboolean
-create_vp8vdec_codec_data_from_codec_data (GstDroidCodec * codec,
+create_h264dec_codec_data_from_codec_data (GstDroidCodec * codec,
GstBuffer * data, DroidMediaData * out)
{
GstMapInfo info;
@@ -693,6 +741,10 @@
goto out;
}
+ codec->data->h264_nal = (1 + (info.data[4] & 3));
+
+ GST_INFO ("nal prefix length %d", codec->data->h264_nal);
+
out->size = info.size;
out->data = g_malloc (info.size);
memcpy (out->data, info.data, info.size);
@@ -705,7 +757,7 @@
}
static gboolean
-create_h264dec_codec_data_from_codec_data (GstDroidCodec * codec,
+create_h265dec_codec_data_from_codec_data (GstDroidCodec * codec,
GstBuffer * data, DroidMediaData * out)
{
GstMapInfo info;
@@ -721,7 +773,7 @@
goto out;
}
- codec->data->h264_nal = (1 + (info.data[4] & 3));
+ codec->data->h264_nal = (1 + (info.data[21] & 3));
GST_INFO ("nal prefix length %d", codec->data->h264_nal);
@@ -888,7 +940,16 @@
}
static gboolean
-process_h264dec_data (GstDroidCodec * codec, GstBuffer * buffer,
+ignore_codec_data (GstDroidCodec * codec G_GNUC_UNUSED,
+ GstBuffer * data G_GNUC_UNUSED, DroidMediaData * out G_GNUC_UNUSED)
+{
+ /* Some containers have codec_data which can be ignored */
+ GST_WARNING ("Ignoring codec data");
+ return TRUE;
+}
+
+static gboolean
+process_h26xdec_data (GstDroidCodec * codec, GstBuffer * buffer,
DroidMediaData * out)
{
GstMapInfo info;
|
[-]
[+]
|
Changed |
_service:tar_git:gstreamer1.0-droid-0.20200120.0.tar.gz/gst-libs/gst/droid/gstdroidmediabuffer.c
^
|
@@ -135,7 +135,7 @@
constants.HAL_PIXEL_FORMAT_YV12;
gst_droid_media_buffer_formats[5].gst_format = GST_VIDEO_FORMAT_YV12;
gst_droid_media_buffer_formats[5].bytes_per_pixel = 1;
- gst_droid_media_buffer_formats[5].h_align = 1;
+ gst_droid_media_buffer_formats[5].h_align = 16;
gst_droid_media_buffer_formats[5].v_align = 1;
gst_droid_media_buffer_formats[6].hal_format =
@@ -244,7 +244,7 @@
static GstDroidMediaBufferMemory *
gst_droid_media_buffer_allocator_alloc_from_buffer (GstAllocator * allocator,
DroidMediaBuffer * buffer, int format_index, gsize width, gsize height,
- gsize stride)
+ gsize stride, gsize size)
{
GstDroidMediaBufferMemory *mem = g_slice_new0 (GstDroidMediaBufferMemory);
GstFormat format;
@@ -261,6 +261,8 @@
} else {
format = gst_droid_media_buffer_formats[format_index].gst_format;
if (gst_droid_media_buffer_formats[format_index].bytes_per_pixel != 0) {
+ stride =
+ stride * gst_droid_media_buffer_formats[format_index].bytes_per_pixel;
padded_width =
ALIGN_SIZE (stride,
gst_droid_media_buffer_formats[format_index].h_align) /
@@ -275,11 +277,25 @@
padded_height);
mem->video_info.width = width;
mem->video_info.height = height;
+ mem->video_info.size = size;
- gst_memory_init (GST_MEMORY_CAST (mem),
- GST_MEMORY_FLAG_NO_SHARE, allocator, NULL, mem->video_info.size, 0, 0,
- mem->video_info.size);
+ // Android YV12 requires alignment of the UV stride too.
+ // So we need to reset the gst UV strides and offsets.
+ if (gst_droid_media_buffer_formats[format_index].gst_format ==
+ GST_VIDEO_FORMAT_YV12) {
+ gsize uvStride = ALIGN_SIZE (stride / 2,
+ gst_droid_media_buffer_formats[format_index].h_align);
+ mem->video_info.stride[1] = uvStride;
+ mem->video_info.stride[2] = uvStride;
+ mem->video_info.offset[1] = stride * padded_height *
+ gst_droid_media_buffer_formats[format_index].bytes_per_pixel;
+ mem->video_info.offset[2] =
+ mem->video_info.offset[1] + uvStride * padded_height / 2;
+ }
+ gst_memory_init (GST_MEMORY_CAST (mem),
+ GST_MEMORY_FLAG_NO_SHARE, GST_ALLOCATOR (allocator), NULL,
+ mem->video_info.size, 0, 0, mem->video_info.size);
return mem;
}
@@ -309,7 +325,7 @@
format_index = gst_droid_media_buffer_index_of_hal_format (info.format);
mem = gst_droid_media_buffer_allocator_alloc_from_buffer (allocator, buffer,
- format_index, info.width, info.height, info.stride);
+ format_index, info.width, info.height, info.stride, 1);
GST_DEBUG_OBJECT (allocator, "alloc %p", mem);
@@ -317,12 +333,14 @@
}
GstMemory *
-gst_droid_media_buffer_allocator_alloc_from_data (GstAllocator * allocator,
- GstVideoInfo * info, DroidMediaData * data, DroidMediaBufferCallbacks * cb)
+gst_droid_media_buffer_allocator_alloc_new (GstAllocator * allocator,
+ GstVideoInfo * info, GstBuffer * buffer)
{
GstDroidMediaBufferMemory *mem;
- DroidMediaBuffer *buffer;
+ DroidMediaBuffer *dbuf;
DroidMediaBufferInfo droid_info;
+ DroidMediaBufferCallbacks cb;
+ GstVideoMeta *video_meta;
int format_index;
if (!GST_IS_DROID_MEDIA_BUFFER_ALLOCATOR (allocator)) {
@@ -340,21 +358,33 @@
gst_video_format_to_string (info->finfo->format));
return NULL;
}
+ GST_WARNING_OBJECT (allocator,
+ "GStreamer format %s", gst_video_format_to_string (info->finfo->format));
+ cb.ref = (DroidMediaCallback) gst_buffer_ref;
+ cb.unref = (DroidMediaCallback) gst_buffer_unref;
+ cb.data = buffer;
+ dbuf =
+ droid_media_buffer_create (info->width, info->height,
+ gst_droid_media_buffer_formats[format_index].hal_format, &cb);
- buffer =
- droid_media_buffer_create_from_raw_data (info->width, info->height,
- GST_VIDEO_INFO_COMP_STRIDE (info, 0),
- GST_VIDEO_INFO_COMP_STRIDE (info, 1),
- gst_droid_media_buffer_formats[format_index].hal_format, data, cb);
- if (!buffer) {
+ if (!dbuf) {
GST_ERROR_OBJECT (allocator, "failed to acquire media buffer");
return NULL;
}
- droid_media_buffer_get_info (buffer, &droid_info);
-
- mem = gst_droid_media_buffer_allocator_alloc_from_buffer (allocator, buffer,
- format_index, info->width, info->height, droid_info.stride);
+ droid_media_buffer_get_info (dbuf, &droid_info);
+ mem =
+ gst_droid_media_buffer_allocator_alloc_from_buffer (allocator, dbuf,
+ format_index, info->width, info->height, droid_info.stride, info->size);
+
+ gst_buffer_append_memory (buffer, (GstMemory *) mem);
+
+ video_meta = gst_buffer_add_video_meta_full (buffer,
+ GST_VIDEO_FRAME_FLAG_NONE, mem->video_info.finfo->format,
+ mem->video_info.width, mem->video_info.height,
+ mem->video_info.finfo->n_planes, mem->video_info.offset,
+ mem->video_info.stride);
+ GST_META_FLAG_SET ((GstMeta *) video_meta, GST_META_FLAG_POOLED);
GST_DEBUG_OBJECT (allocator, "alloc %p", mem);
|
[-]
[+]
|
Changed |
_service:tar_git:gstreamer1.0-droid-0.20200120.0.tar.gz/gst-libs/gst/droid/gstdroidmediabuffer.h
^
|
@@ -36,10 +36,8 @@
GstMemory * gst_droid_media_buffer_allocator_alloc (GstAllocator * allocator,
DroidMediaBufferQueue *queue,
DroidMediaBufferCallbacks *cb);
-GstMemory * gst_droid_media_buffer_allocator_alloc_from_data (GstAllocator * allocator,
- GstVideoInfo * info,
- DroidMediaData * data,
- DroidMediaBufferCallbacks *cb);
+GstMemory * gst_droid_media_buffer_allocator_alloc_new (GstAllocator * allocator,
+ GstVideoInfo * info, GstBuffer * buffer);
DroidMediaBuffer * gst_droid_media_buffer_memory_get_buffer (GstMemory * mem);
gboolean gst_is_droid_media_buffer_memory (GstMemory * mem);
|
[-]
[+]
|
Changed |
_service:tar_git:gstreamer1.0-droid-0.20200120.0.tar.gz/gst/droidcamsrc/gstdroidcamsrcdev.c
^
|
@@ -563,6 +563,13 @@
dev->info = info;
dev->cam = droid_media_camera_connect (dev->info->num);
+ if (!dev->cam) {
+ g_rec_mutex_unlock (dev->lock);
+
+ GST_ELEMENT_ERROR (src, LIBRARY, INIT, (NULL), ("error opening camera"));
+ return FALSE;
+ }
+
hal_format = droid_media_camera_get_video_color_format (dev->cam);
if (hal_format == constants.OMX_COLOR_FormatYUV420Planar) {
@@ -580,13 +587,6 @@
dev->viewfinder_format = GST_VIDEO_FORMAT_ENCODED;
}
- if (!dev->cam) {
- g_rec_mutex_unlock (dev->lock);
-
- GST_ELEMENT_ERROR (src, LIBRARY, INIT, (NULL), ("error opening camera"));
- return FALSE;
- }
-
dev->queue = droid_media_camera_get_buffer_queue (dev->cam);
if (!droid_media_camera_lock (dev->cam)) {
|
[-]
[+]
|
Changed |
_service:tar_git:gstreamer1.0-droid-0.20200120.0.tar.gz/gst/droideglsink/gstdroideglsink.c
^
|
@@ -27,6 +27,7 @@
#include <gst/video/video.h>
#include <gst/interfaces/nemovideotexture.h>
#include "gst/droid/gstdroidmediabuffer.h"
+#include "gst/droid/gstdroidbufferpool.h"
GST_DEBUG_CATEGORY_EXTERN (gst_droid_eglsink_debug);
#define GST_CAT_DEFAULT gst_droid_eglsink_debug
@@ -46,7 +47,7 @@
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
(GST_CAPS_FEATURE_MEMORY_DROID_MEDIA_BUFFER,
GST_DROID_MEDIA_BUFFER_MEMORY_VIDEO_FORMATS) "; "
- GST_VIDEO_CAPS_MAKE ("{YV12, NV21}")));
+ GST_VIDEO_CAPS_MAKE (GST_DROID_MEDIA_BUFFER_MEMORY_VIDEO_FORMATS)));
enum
{
@@ -123,7 +124,7 @@
if (!gst_video_info_from_caps (&info, caps)) {
GST_ELEMENT_ERROR (sink, STREAM, FORMAT, (NULL),
- ("ould not locate image format from caps %" GST_PTR_FORMAT, caps));
+ ("Could not locate image format from caps %" GST_PTR_FORMAT, caps));
return FALSE;
}
@@ -136,6 +137,52 @@
return TRUE;
}
+static gboolean
+gst_droideglsink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
+{
+ GstDroidEglSink *sink = GST_DROIDEGLSINK (bsink);
+ GstBufferPool *pool;
+ GstCaps *caps;
+ guint size;
+ gboolean need_pool;
+ GstStructure *config;
+ GstVideoInfo video_info;
+
+ gst_query_parse_allocation (query, &caps, &need_pool);
+
+ if (!caps) {
+ GST_ERROR_OBJECT (sink, "No query caps");
+ return FALSE;
+ }
+
+ if (!gst_video_info_from_caps (&video_info, caps)) {
+ GST_ERROR_OBJECT (sink, "Unable to get video caps");
+ return FALSE;
+ }
+
+ if (need_pool) {
+ pool = gst_droid_buffer_pool_new ();
+ size = video_info.finfo->format == GST_VIDEO_FORMAT_ENCODED
+ ? 1 : video_info.size;
+
+ config = gst_buffer_pool_get_config (pool);
+ gst_buffer_pool_config_set_params (config, caps, size, 2, 0);
+ if (!gst_buffer_pool_set_config (pool, config)) {
+ GST_ERROR_OBJECT (sink, "Failed to set buffer pool configuration");
+ gst_object_unref (pool);
+ return FALSE;
+ }
+ gst_query_add_allocation_pool (query, pool, size, 0, 2);
+ gst_object_unref (pool);
+ }
+
+ gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
+
+ GST_DEBUG_OBJECT (sink, "proposed allocation");
+
+ return TRUE;
+}
+
static void
gst_droideglsink_get_times (GstBaseSink * bsink, GstBuffer * buf,
GstClockTime * start, GstClockTime * end)
@@ -397,7 +444,8 @@
gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_droideglsink_start);
gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_droideglsink_stop);
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_droideglsink_event);
-
+ gstbasesink_class->propose_allocation =
+ GST_DEBUG_FUNCPTR (gst_droideglsink_propose_allocation);
videosink_class->show_frame = GST_DEBUG_FUNCPTR (gst_droideglsink_show_frame);
g_object_class_override_property (gobject_class, PROP_EGL_DISPLAY,
@@ -427,79 +475,6 @@
return NULL;
}
-static GstBuffer *
-gst_droideglsink_copy_buffer (GstDroidEglSink * sink, GstBuffer * buffer)
-{
- GstMapInfo info;
- GstVideoInfo format;
- GstBuffer *buff = gst_buffer_new ();
- GstMemory *mem = NULL;
- GstCaps *caps = NULL;
- DroidMediaData data;
- gboolean unmap = FALSE;
- DroidMediaBufferCallbacks cb;
-
- GST_DEBUG_OBJECT (sink, "copy buffer");
-
- if (!gst_pad_has_current_caps (GST_BASE_SINK_PAD (sink))) {
- goto free_and_out;
- }
-
- if (!gst_buffer_copy_into (buff, buffer,
- GST_BUFFER_COPY_FLAGS |
- GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_META, 0, -1)) {
- goto free_and_out;
- }
-
- if (!gst_buffer_map (buffer, &info, GST_MAP_READ)) {
- goto free_and_out;
- }
-
- unmap = TRUE;
-
- caps = gst_pad_get_current_caps (GST_BASE_SINK_PAD (sink));
- if (!gst_video_info_from_caps (&format, caps)) {
- goto free_and_out;
- }
-
- cb.ref = (DroidMediaCallback) gst_buffer_ref;
- cb.unref = (DroidMediaCallback) gst_buffer_unref;
- cb.data = buff;
-
- data.size = info.size;
- data.data = info.data;
-
- mem = gst_droid_media_buffer_allocator_alloc_from_data (sink->allocator,
- &format, &data, &cb);
-
- if (!mem) {
- goto free_and_out;
- }
-
- gst_buffer_append_memory (buff, mem);
- gst_buffer_unmap (buffer, &info);
- gst_caps_unref (caps);
-
- return buff;
-
-free_and_out:
- if (unmap) {
- gst_buffer_unmap (buffer, &info);
- }
-
- gst_buffer_unref (buff);
-
- if (mem) {
- gst_memory_unref (mem);
- }
-
- if (caps) {
- gst_caps_unref (caps);
- }
-
- return NULL;
-}
-
static gboolean
gst_droideglsink_populate_egl_proc (GstDroidEglSink * sink)
{
@@ -574,14 +549,14 @@
mem =
gst_droideglsink_get_droid_media_buffer_memory (sink, sink->last_buffer);
- if (mem) {
- sink->acquired_buffer = gst_buffer_ref (sink->last_buffer);
- } else {
- /* Construct a new buffer */
- sink->acquired_buffer =
- gst_droideglsink_copy_buffer (sink, sink->last_buffer);
+ if (!mem) {
+ ret = FALSE;
+ GST_WARNING_OBJECT (sink, "no droidmedia buffer available");
+ goto unlock_and_out;
}
+ sink->acquired_buffer = gst_buffer_ref (sink->last_buffer);
+
if (!sink->acquired_buffer) {
ret = FALSE;
GST_INFO_OBJECT (sink, "failed to acquire a buffer");
|