本文整理汇总了C++中GST_OBJECT_UNLOCK函数的典型用法代码示例。如果您正苦于以下问题:C++ GST_OBJECT_UNLOCK函数的具体用法?C++ GST_OBJECT_UNLOCK怎么用?C++ GST_OBJECT_UNLOCK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GST_OBJECT_UNLOCK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gst_wildmidi_parse_song
static GstFlowReturn
gst_wildmidi_parse_song (GstWildmidi * wildmidi)
{
struct _WM_Info *info;
GstCaps *outcaps;
guint8 *data;
guint size;
GST_DEBUG_OBJECT (wildmidi, "Parsing song");
size = gst_adapter_available (wildmidi->adapter);
data = gst_adapter_take (wildmidi->adapter, size);
/* this method takes our memory block */
GST_OBJECT_LOCK (wildmidi);
wildmidi->song = WildMidi_OpenBuffer (data, size);
if (!wildmidi->song)
goto open_failed;
#ifdef HAVE_WILDMIDI_0_2_2
WildMidi_LoadSamples (wildmidi->song);
#endif
#ifdef HAVE_WILDMIDI_0_2_2
WildMidi_SetOption (wildmidi->song, WM_MO_LINEAR_VOLUME,
wildmidi->linear_volume);
WildMidi_SetOption (wildmidi->song, WM_MO_EXPENSIVE_INTERPOLATION,
wildmidi->high_quality);
#else
WildMidi_SetOption (wildmidi->song, WM_MO_LOG_VOLUME,
!wildmidi->linear_volume);
WildMidi_SetOption (wildmidi->song, WM_MO_ENHANCED_RESAMPLING,
wildmidi->high_quality);
#endif
info = WildMidi_GetInfo (wildmidi->song);
GST_OBJECT_UNLOCK (wildmidi);
wildmidi->o_len = info->approx_total_samples;
outcaps = gst_caps_copy (gst_pad_get_pad_template_caps (wildmidi->srcpad));
gst_pad_set_caps (wildmidi->srcpad, outcaps);
gst_caps_unref (outcaps);
/* we keep an internal segment in samples */
gst_segment_init (wildmidi->o_segment, GST_FORMAT_DEFAULT);
gst_pad_push_event (wildmidi->srcpad,
gst_wildmidi_get_new_segment_event (wildmidi, GST_FORMAT_TIME));
GST_DEBUG_OBJECT (wildmidi, "Parsing song done");
return GST_FLOW_OK;
/* ERRORS */
open_failed:
{
GST_OBJECT_UNLOCK (wildmidi);
GST_ELEMENT_ERROR (wildmidi, STREAM, DECODE, (NULL),
("Unable to parse midi data"));
return GST_FLOW_ERROR;
}
}
开发者ID:Distrotech,项目名称:gst-plugins-bad,代码行数:64,代码来源:gstwildmidi.c
示例2: gst_dicetv_transform
static GstFlowReturn
gst_dicetv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
{
GstDiceTV *filter = GST_DICETV (trans);
guint32 *src, *dest;
gint i, map_x, map_y, map_i, base, dx, dy, di;
gint video_width, g_cube_bits, g_cube_size;
gint g_map_height, g_map_width;
GstFlowReturn ret = GST_FLOW_OK;
GstClockTime timestamp, stream_time;
const guint8 *dicemap;
src = (guint32 *) GST_BUFFER_DATA (in);
dest = (guint32 *) GST_BUFFER_DATA (out);
timestamp = GST_BUFFER_TIMESTAMP (in);
stream_time =
gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME, timestamp);
GST_DEBUG_OBJECT (filter, "sync to %" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp));
if (GST_CLOCK_TIME_IS_VALID (stream_time))
gst_object_sync_values (G_OBJECT (filter), stream_time);
GST_OBJECT_LOCK (filter);
video_width = filter->width;
g_cube_bits = filter->g_cube_bits;
g_cube_size = filter->g_cube_size;
g_map_height = filter->g_map_height;
g_map_width = filter->g_map_width;
dicemap = filter->dicemap;
map_i = 0;
for (map_y = 0; map_y < g_map_height; map_y++) {
for (map_x = 0; map_x < g_map_width; map_x++) {
base = (map_y << g_cube_bits) * video_width + (map_x << g_cube_bits);
switch (dicemap[map_i]) {
case DICE_UP:
for (dy = 0; dy < g_cube_size; dy++) {
i = base + dy * video_width;
for (dx = 0; dx < g_cube_size; dx++) {
dest[i] = src[i];
i++;
}
}
break;
case DICE_LEFT:
for (dy = 0; dy < g_cube_size; dy++) {
i = base + dy * video_width;
for (dx = 0; dx < g_cube_size; dx++) {
di = base + (dx * video_width) + (g_cube_size - dy - 1);
dest[di] = src[i];
i++;
}
}
break;
case DICE_DOWN:
for (dy = 0; dy < g_cube_size; dy++) {
di = base + dy * video_width;
i = base + (g_cube_size - dy - 1) * video_width + g_cube_size;
for (dx = 0; dx < g_cube_size; dx++) {
i--;
dest[di] = src[i];
di++;
}
}
break;
case DICE_RIGHT:
for (dy = 0; dy < g_cube_size; dy++) {
i = base + (dy * video_width);
for (dx = 0; dx < g_cube_size; dx++) {
di = base + dy + (g_cube_size - dx - 1) * video_width;
dest[di] = src[i];
i++;
}
}
break;
default:
g_assert_not_reached ();
break;
}
map_i++;
}
}
GST_OBJECT_UNLOCK (filter);
return ret;
}
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:92,代码来源:gstdice.c
示例3: gst_shm_sink_render
static GstFlowReturn
gst_shm_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
GstShmSink *self = GST_SHM_SINK (bsink);
int rv = 0;
GstMapInfo map;
gboolean need_new_memory = FALSE;
GstFlowReturn ret = GST_FLOW_OK;
GstMemory *memory = NULL;
GstBuffer *sendbuf = NULL;
GST_OBJECT_LOCK (self);
while (self->wait_for_connection && !self->clients) {
g_cond_wait (&self->cond, GST_OBJECT_GET_LOCK (self));
if (self->unlock)
goto flushing;
}
while (!gst_shm_sink_can_render (self, GST_BUFFER_TIMESTAMP (buf))) {
g_cond_wait (&self->cond, GST_OBJECT_GET_LOCK (self));
if (self->unlock)
goto flushing;
}
if (gst_buffer_n_memory (buf) > 1) {
GST_LOG_OBJECT (self, "Buffer %p has %d GstMemory, we only support a single"
" one, need to do a memcpy", buf, gst_buffer_n_memory (buf));
need_new_memory = TRUE;
} else {
memory = gst_buffer_peek_memory (buf, 0);
if (memory->allocator != GST_ALLOCATOR (self->allocator)) {
need_new_memory = TRUE;
GST_LOG_OBJECT (self, "Memory in buffer %p was not allocated by "
"%" GST_PTR_FORMAT ", will memcpy", buf, memory->allocator);
}
}
if (need_new_memory) {
if (gst_buffer_get_size (buf) > sp_writer_get_max_buf_size (self->pipe)) {
gsize area_size = sp_writer_get_max_buf_size (self->pipe);
GST_OBJECT_UNLOCK (self);
GST_ELEMENT_ERROR (self, RESOURCE, NO_SPACE_LEFT,
("Shared memory area is too small"),
("Shared memory area of size %" G_GSIZE_FORMAT " is smaller than"
"buffer of size %" G_GSIZE_FORMAT, area_size,
gst_buffer_get_size (buf)));
return GST_FLOW_ERROR;
}
while ((memory =
gst_shm_sink_allocator_alloc_locked (self->allocator,
gst_buffer_get_size (buf), &self->params)) == NULL) {
g_cond_wait (&self->cond, GST_OBJECT_GET_LOCK (self));
if (self->unlock)
goto flushing;
}
while (self->wait_for_connection && !self->clients) {
g_cond_wait (&self->cond, GST_OBJECT_GET_LOCK (self));
if (self->unlock) {
gst_memory_unref (memory);
GST_OBJECT_UNLOCK (self);
return GST_FLOW_FLUSHING;
}
}
gst_memory_map (memory, &map, GST_MAP_WRITE);
gst_buffer_extract (buf, 0, map.data, map.size);
gst_memory_unmap (memory, &map);
sendbuf = gst_buffer_new ();
gst_buffer_copy_into (sendbuf, buf, GST_BUFFER_COPY_METADATA, 0, -1);
gst_buffer_append_memory (sendbuf, memory);
} else {
sendbuf = gst_buffer_ref (buf);
}
gst_buffer_map (sendbuf, &map, GST_MAP_READ);
/* Make the memory readonly as of now as we've sent it to the other side
* We know it's not mapped for writing anywhere as we just mapped it for
* reading
*/
rv = sp_writer_send_buf (self->pipe, (char *) map.data, map.size, sendbuf);
gst_buffer_unmap (sendbuf, &map);
GST_OBJECT_UNLOCK (self);
if (rv == 0) {
GST_DEBUG_OBJECT (self, "No clients connected, unreffing buffer");
gst_buffer_unref (sendbuf);
} else if (rv == -1) {
GST_ELEMENT_ERROR (self, STREAM, FAILED, ("Invalid allocated buffer"),
("The shmpipe library rejects our buffer, this is a bug"));
ret = GST_FLOW_ERROR;
}
//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:gst-plugins-bad,代码行数:101,代码来源:gstshmsink.c
示例4: gst_gl_mixer_sink_query
static gboolean
gst_gl_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad,
GstQuery * query)
{
gboolean ret = FALSE;
GstGLMixer *mix = GST_GL_MIXER (agg);
GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);
GST_TRACE ("QUERY %" GST_PTR_FORMAT, query);
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CAPS:
{
GstCaps *filter, *caps;
gst_query_parse_caps (query, &filter);
caps = gst_gl_mixer_pad_sink_getcaps (GST_PAD (bpad), mix, filter);
gst_query_set_caps_result (query, caps);
gst_caps_unref (caps);
ret = TRUE;
break;
}
case GST_QUERY_ACCEPT_CAPS:
{
GstCaps *caps;
gst_query_parse_accept_caps (query, &caps);
ret = gst_gl_mixer_pad_sink_acceptcaps (GST_PAD (bpad), mix, caps);
gst_query_set_accept_caps_result (query, ret);
ret = TRUE;
break;
}
case GST_QUERY_ALLOCATION:
{
GstQuery *decide_query = NULL;
GST_OBJECT_LOCK (mix);
if (G_UNLIKELY (!mix->priv->negotiated)) {
GST_DEBUG_OBJECT (mix,
"not negotiated yet, can't answer ALLOCATION query");
GST_OBJECT_UNLOCK (mix);
return FALSE;
}
if ((decide_query = mix->priv->query))
gst_query_ref (decide_query);
GST_OBJECT_UNLOCK (mix);
GST_DEBUG_OBJECT (mix,
"calling propose allocation with query %" GST_PTR_FORMAT,
decide_query);
/* pass the query to the propose_allocation vmethod if any */
ret = gst_gl_mixer_propose_allocation (mix, decide_query, query);
if (decide_query)
gst_query_unref (decide_query);
GST_DEBUG_OBJECT (mix, "ALLOCATION ret %d, %" GST_PTR_FORMAT, ret, query);
break;
}
case GST_QUERY_CONTEXT:
{
ret = gst_gl_handle_context_query ((GstElement *) mix, query,
&mix->display, &mix->other_context);
if (mix->display)
gst_gl_display_filter_gl_api (mix->display,
mix_class->supported_gl_api);
break;
}
default:
ret = GST_AGGREGATOR_CLASS (parent_class)->sink_query (agg, bpad, query);
break;
}
return ret;
}
开发者ID:ego5710,项目名称:gst-plugins-bad,代码行数:76,代码来源:gstglmixer.c
示例5: fs_rtp_conference_handle_message
static void
fs_rtp_conference_handle_message (
GstBin * bin,
GstMessage * message)
{
FsRtpConference *self = FS_RTP_CONFERENCE (bin);
if (!self->rtpbin)
goto out;
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ELEMENT:
{
const GstStructure *s = gst_message_get_structure (message);
/* we change the structure name and add the session ID to it */
if (gst_structure_has_name (s, "application/x-rtp-source-sdes") &&
gst_structure_has_field_typed (s, "session", G_TYPE_UINT) &&
gst_structure_has_field_typed (s, "ssrc", G_TYPE_UINT) &&
gst_structure_has_field_typed (s, "cname", G_TYPE_STRING))
{
guint session_id;
guint ssrc;
const GValue *val;
FsRtpSession *session;
const gchar *cname;
val = gst_structure_get_value (s, "session");
session_id = g_value_get_uint (val);
val = gst_structure_get_value (s, "ssrc");
ssrc = g_value_get_uint (val);
cname = gst_structure_get_string (s, "cname");
if (!ssrc || !cname)
{
GST_WARNING_OBJECT (self,
"Got GstRTPBinSDES without a ssrc or a cname (ssrc:%u cname:%p)",
ssrc, cname);
break;
}
session = fs_rtp_conference_get_session_by_id (self, session_id);
if (session) {
fs_rtp_session_associate_ssrc_cname (session, ssrc, cname);
g_object_unref (session);
} else {
GST_WARNING_OBJECT (self,"Our RtpBin announced a new association"
"for non-existent session %u for ssrc: %u and cname %s",
session_id, ssrc, cname);
}
}
else if (gst_structure_has_name (s, "dtmf-event-processed") ||
gst_structure_has_name (s, "dtmf-event-dropped"))
{
GList *item;
guint cookie;
GST_OBJECT_LOCK (self);
restart:
cookie = self->priv->sessions_cookie;
for (item = self->priv->sessions; item; item = item->next)
{
GST_OBJECT_UNLOCK (self);
if (fs_rtp_session_handle_dtmf_event_message (item->data, message))
{
gst_message_unref (message);
message = NULL;
goto out;
}
GST_OBJECT_LOCK (self);
if (cookie != self->priv->sessions_cookie)
goto restart;
}
GST_OBJECT_UNLOCK (self);
}
}
break;
case GST_MESSAGE_STREAM_STATUS:
{
GstStreamStatusType type;
guint i;
gst_message_parse_stream_status (message, &type, NULL);
switch (type)
{
case GST_STREAM_STATUS_TYPE_ENTER:
GST_OBJECT_LOCK (self);
for (i = 0; i < self->priv->threads->len; i++)
{
if (g_ptr_array_index (self->priv->threads, i) ==
g_thread_self ())
goto done;
}
g_ptr_array_add (self->priv->threads, g_thread_self ());
//.........这里部分代码省略.........
开发者ID:kakaroto,项目名称:farstream,代码行数:101,代码来源:fs-rtp-conference.c
示例6: gst_netfilter_set_property
static void gst_netfilter_set_property(GObject *object, guint prop_id, GValue const *value, GParamSpec *pspec)
{
GstNetfilter *netfilter;
GST_OBJECT_LOCK(object);
netfilter = GST_NETFILTER(object);
switch (prop_id)
{
case PROP_FILTER_ADDRESS:
{
/*
The address can be specified in many ways, as hostname, as IPv4 address, as IPv6 address..
getaddrinfo is used to get an IP address out of what has been specified
*/
int error;
struct addrinfo *result;
char const *address_str;
address_str = g_value_get_string(value);
error = getaddrinfo(address_str, NULL, NULL, &result);
if (error != 0)
{
GST_ERROR_OBJECT(netfilter, "Could not set filter address property: %s", gai_strerror(error));
}
else
{
switch (result->ai_family)
{
case AF_INET:
{
struct sockaddr_in const *sockaddr_ipv4 = (struct sockaddr_in const *)(result->ai_addr);
struct in_addr const *addr = &(sockaddr_ipv4->sin_addr);
gst_netaddress_set_ip4_address(&(netfilter->filter_address), addr->s_addr, DUMMY_PORT);
break;
}
case AF_INET6:
{
struct sockaddr_in6 const *sockaddr_ipv6 = (struct sockaddr_in6 const *)(result->ai_addr);
struct in6_addr const *addr = &(sockaddr_ipv6->sin6_addr);
gst_netaddress_set_ip6_address(&(netfilter->filter_address), (guint8 *)(addr->s6_addr), DUMMY_PORT);
break;
}
default:
GST_ERROR_OBJECT(netfilter, "Could not set filter address property: unknown address family %d", result->ai_family);
}
}
freeaddrinfo(result);
break;
}
case PROP_ENABLED:
{
netfilter->filtering_enabled = g_value_get_boolean(value);
GST_DEBUG_OBJECT(netfilter, "Filtering is %s", netfilter->filtering_enabled ? "enabled" : "disabled");
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
GST_OBJECT_UNLOCK(object);
}
开发者ID:dv1,项目名称:gstnetfilter,代码行数:66,代码来源:gstnetfilter.c
示例7: gst_type_find_handle_src_query
static gboolean
gst_type_find_handle_src_query (GstPad * pad, GstObject * parent,
GstQuery * query)
{
GstTypeFindElement *typefind;
gboolean res = FALSE;
typefind = GST_TYPE_FIND_ELEMENT (parent);
GST_DEBUG_OBJECT (typefind, "Handling src query %s",
GST_QUERY_TYPE_NAME (query));
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_SCHEDULING:
/* FIXME, filter out the scheduling modes that we understand */
res = gst_pad_peer_query (typefind->sink, query);
break;
case GST_QUERY_CAPS:
{
GST_DEBUG_OBJECT (typefind,
"Got caps query, our caps are %" GST_PTR_FORMAT, typefind->caps);
/* We can hijack caps query if we typefind already */
if (typefind->caps) {
gst_query_set_caps_result (query, typefind->caps);
res = TRUE;
} else {
res = gst_pad_peer_query (typefind->sink, query);
}
break;
}
case GST_QUERY_POSITION:
{
gint64 peer_pos;
GstFormat format;
if (!(res = gst_pad_peer_query (typefind->sink, query)))
goto out;
gst_query_parse_position (query, &format, &peer_pos);
GST_OBJECT_LOCK (typefind);
/* FIXME: this code assumes that there's no discont in the queue */
switch (format) {
case GST_FORMAT_BYTES:
peer_pos -= gst_adapter_available (typefind->adapter);
if (peer_pos < 0) /* Clamp result to 0 */
peer_pos = 0;
break;
default:
/* FIXME */
break;
}
GST_OBJECT_UNLOCK (typefind);
gst_query_set_position (query, format, peer_pos);
break;
}
default:
res = gst_pad_query_default (pad, parent, query);
break;
}
out:
return res;
}
开发者ID:GrokImageCompression,项目名称:gstreamer,代码行数:63,代码来源:gsttypefindelement.c
示例8: stop_typefinding
static void
stop_typefinding (GstTypeFindElement * typefind)
{
GstState state;
gboolean push_cached_buffers;
gsize avail;
GstBuffer *buffer;
GstClockTime pts, dts;
gst_element_get_state (GST_ELEMENT (typefind), &state, NULL, 0);
push_cached_buffers = (state >= GST_STATE_PAUSED && typefind->caps);
GST_DEBUG_OBJECT (typefind, "stopping typefinding%s",
push_cached_buffers ? " and pushing cached events and buffers" : "");
typefind->mode = MODE_NORMAL;
if (push_cached_buffers)
gst_type_find_element_send_cached_events (typefind);
GST_OBJECT_LOCK (typefind);
avail = gst_adapter_available (typefind->adapter);
if (avail == 0)
goto no_data;
pts = gst_adapter_prev_pts (typefind->adapter, NULL);
dts = gst_adapter_prev_dts (typefind->adapter, NULL);
buffer = gst_adapter_take_buffer (typefind->adapter, avail);
GST_BUFFER_PTS (buffer) = pts;
GST_BUFFER_DTS (buffer) = dts;
GST_BUFFER_OFFSET (buffer) = typefind->initial_offset;
GST_OBJECT_UNLOCK (typefind);
if (!push_cached_buffers) {
gst_buffer_unref (buffer);
} else {
GstPad *peer = gst_pad_get_peer (typefind->src);
/* make sure the user gets a meaningful error message in this case,
* which is not a core bug or bug of any kind (as the default error
* message emitted by gstpad.c otherwise would make you think) */
if (peer && GST_PAD_CHAINFUNC (peer) == NULL) {
GST_DEBUG_OBJECT (typefind, "upstream only supports push mode, while "
"downstream element only works in pull mode, erroring out");
GST_ELEMENT_ERROR (typefind, STREAM, FAILED,
("%s cannot work in push mode. The operation is not supported "
"with this source element or protocol.",
G_OBJECT_TYPE_NAME (GST_PAD_PARENT (peer))),
("Downstream pad %s:%s has no chainfunction, and the upstream "
"element does not support pull mode", GST_DEBUG_PAD_NAME (peer)));
typefind->mode = MODE_ERROR; /* make the chain function error out */
gst_buffer_unref (buffer);
} else {
gst_pad_push (typefind->src, buffer);
}
if (peer)
gst_object_unref (peer);
}
return;
/* ERRORS */
no_data:
{
GST_DEBUG_OBJECT (typefind, "we have no data to typefind");
GST_OBJECT_UNLOCK (typefind);
return;
}
}
开发者ID:GrokImageCompression,项目名称:gstreamer,代码行数:68,代码来源:gsttypefindelement.c
示例9: gst_imx_compositor_aggregate_frames
//.........这里部分代码省略.........
* Sometimes, pads don't deliver data right from the start;
* in these cases, their buffers will be NULL
* Just skip to the next pad in that case */
if (videoaggregator_pad->buffer != NULL)
{
GstVideoCropMeta *video_crop_meta;
if (compositor_pad->input_crop && ((video_crop_meta = gst_buffer_get_video_crop_meta(videoaggregator_pad->buffer)) != NULL))
{
/* Crop metadata present. Reconfigure canvas. */
GstVideoInfo *info = &(videoaggregator_pad->info);
GstImxRegion source_region;
source_region.x1 = video_crop_meta->x;
source_region.y1 = video_crop_meta->y;
source_region.x2 = video_crop_meta->x + video_crop_meta->width;
source_region.y2 = video_crop_meta->y + video_crop_meta->height;
/* Make sure the source region does not exceed valid bounds */
source_region.x1 = MAX(0, source_region.x1);
source_region.y1 = MAX(0, source_region.y1);
source_region.x2 = MIN(GST_VIDEO_INFO_WIDTH(info), source_region.x2);
source_region.y2 = MIN(GST_VIDEO_INFO_HEIGHT(info), source_region.y2);
GST_LOG_OBJECT(compositor, "retrieved crop rectangle %" GST_IMX_REGION_FORMAT, GST_IMX_REGION_ARGS(&source_region));
/* Canvas needs to be updated if either one of these applies:
* - the current frame has crop metadata, the last one didn't
* - the new crop rectangle and the last are different */
if (!(compositor_pad->last_frame_with_cropdata) || !gst_imx_region_equal(&source_region, &(compositor_pad->last_source_region)))
{
GST_LOG_OBJECT(compositor, "using new crop rectangle %" GST_IMX_REGION_FORMAT, GST_IMX_REGION_ARGS(&source_region));
compositor_pad->last_source_region = source_region;
compositor_pad->canvas_needs_update = TRUE;
}
compositor_pad->last_frame_with_cropdata = TRUE;
/* Update canvas and input region if necessary */
if (compositor_pad->canvas_needs_update)
gst_imx_compositor_pad_update_canvas(compositor_pad, &(compositor_pad->last_source_region));
}
else
{
/* Force an update if this frame has no crop metadata but the last one did */
if (compositor_pad->last_frame_with_cropdata)
compositor_pad->canvas_needs_update = TRUE;
compositor_pad->last_frame_with_cropdata = FALSE;
/* Update the pad's canvas if necessary,
* to ensure there is a valid canvas to draw to */
gst_imx_compositor_pad_update_canvas(compositor_pad, NULL);
}
GST_LOG_OBJECT(
compositor,
"pad %p frame %p format: %s width/height: %d/%d regions: outer %" GST_IMX_REGION_FORMAT " inner %" GST_IMX_REGION_FORMAT " source subset %" GST_IMX_REGION_FORMAT,
(gpointer)(videoaggregator_pad),
(gpointer)(videoaggregator_pad->buffer),
gst_video_format_to_string(GST_VIDEO_INFO_FORMAT(&(videoaggregator_pad->info))),
GST_VIDEO_INFO_WIDTH(&(videoaggregator_pad->info)),
GST_VIDEO_INFO_HEIGHT(&(videoaggregator_pad->info)),
GST_IMX_REGION_ARGS(&(compositor_pad->canvas.outer_region)),
GST_IMX_REGION_ARGS(&(compositor_pad->canvas.inner_region)),
GST_IMX_REGION_ARGS(&(compositor_pad->source_subset))
);
if (!klass->draw_frame(
compositor,
&(videoaggregator_pad->info),
&(compositor_pad->source_subset),
&(compositor_pad->canvas),
videoaggregator_pad->buffer,
(guint8)(compositor_pad->alpha * 255.0)
))
{
GST_ERROR_OBJECT(compositor, "error while drawing composition frame");
ret = GST_FLOW_ERROR;
break;
}
}
else
{
GST_LOG_OBJECT(compositor, "pad %p buffer is NULL, no frame to aggregate - skipping to next pad", (gpointer)(videoaggregator_pad));
}
/* Move to next pad */
walk = g_list_next(walk);
}
GST_OBJECT_UNLOCK(compositor);
}
/* Release the output buffer, since we don't need it anymore, and
* there is no reason to retain it */
klass->set_output_frame(compositor, NULL);
return ret;
}
开发者ID:FrankBau,项目名称:gstreamer-imx,代码行数:101,代码来源:compositor.c
示例10: gst_type_find_element_loop
static void
gst_type_find_element_loop (GstPad * pad)
{
GstTypeFindElement *typefind;
GstFlowReturn ret = GST_FLOW_OK;
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->need_stream_start) {
gchar *stream_id;
GstEvent *event;
stream_id = gst_pad_create_stream_id (typefind->src,
GST_ELEMENT_CAST (typefind), NULL);
GST_DEBUG_OBJECT (typefind, "Pushing STREAM_START");
event = gst_event_new_stream_start (stream_id);
gst_event_set_group_id (event, gst_util_group_id_next ());
gst_pad_push_event (typefind->src, event);
typefind->need_stream_start = FALSE;
g_free (stream_id);
}
if (typefind->mode == MODE_TYPEFIND) {
GstPad *peer = NULL;
GstCaps *found_caps = NULL;
GstTypeFindProbability probability = GST_TYPE_FIND_NONE;
GST_DEBUG_OBJECT (typefind, "find type in pull mode");
GST_OBJECT_LOCK (typefind);
if (typefind->force_caps) {
found_caps = gst_caps_ref (typefind->force_caps);
probability = GST_TYPE_FIND_MAXIMUM;
}
GST_OBJECT_UNLOCK (typefind);
if (!found_caps) {
peer = gst_pad_get_peer (pad);
if (peer) {
gint64 size;
gchar *ext;
if (!gst_pad_query_duration (peer, GST_FORMAT_BYTES, &size)) {
GST_WARNING_OBJECT (typefind, "Could not query upstream length!");
gst_object_unref (peer);
ret = GST_FLOW_ERROR;
goto pause;
}
/* the size if 0, we cannot continue */
if (size == 0) {
/* keep message in sync with message in sink event handler */
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND,
(_("Stream contains no data.")), ("Can't typefind empty stream"));
gst_object_unref (peer);
ret = GST_FLOW_ERROR;
goto pause;
}
ext = gst_type_find_get_extension (typefind, pad);
found_caps =
gst_type_find_helper_get_range (GST_OBJECT_CAST (peer),
GST_OBJECT_PARENT (peer),
(GstTypeFindHelperGetRangeFunction) (GST_PAD_GETRANGEFUNC (peer)),
(guint64) size, ext, &probability);
g_free (ext);
GST_DEBUG ("Found caps %" GST_PTR_FORMAT, found_caps);
gst_object_unref (peer);
}
}
if (!found_caps || probability < typefind->min_probability) {
GST_DEBUG ("Trying to guess using extension");
gst_caps_replace (&found_caps, NULL);
found_caps =
gst_type_find_guess_by_extension (typefind, pad, &probability);
}
if (!found_caps || probability < typefind->min_probability) {
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
gst_caps_replace (&found_caps, NULL);
ret = GST_FLOW_ERROR;
goto pause;
}
GST_DEBUG ("Emiting found caps %" GST_PTR_FORMAT, found_caps);
gst_type_find_element_emit_have_type (typefind, probability, found_caps);
typefind->mode = MODE_NORMAL;
gst_caps_unref (found_caps);
} else if (typefind->mode == MODE_NORMAL) {
GstBuffer *outbuf = NULL;
if (typefind->need_segment) {
typefind->need_segment = FALSE;
gst_pad_push_event (typefind->src,
//.........这里部分代码省略.........
开发者ID:GrokImageCompression,项目名称:gstreamer,代码行数:101,代码来源:gsttypefindelement.c
示例11: gst_v4l2_allocator_start
guint
gst_v4l2_allocator_start (GstV4l2Allocator * allocator, guint32 count,
guint32 memory)
{
struct v4l2_requestbuffers breq = { count, allocator->type, memory };
gboolean can_allocate;
gint i;
g_return_val_if_fail (count != 0, 0);
GST_OBJECT_LOCK (allocator);
if (g_atomic_int_get (&allocator->active))
goto already_active;
if (v4l2_ioctl (allocator->video_fd, VIDIOC_REQBUFS, &breq) < 0)
goto reqbufs_failed;
if (breq.count < 1)
goto out_of_memory;
switch (memory) {
case V4L2_MEMORY_MMAP:
can_allocate = GST_V4L2_ALLOCATOR_CAN_ALLOCATE (allocator, MMAP);
break;
case V4L2_MEMORY_USERPTR:
can_allocate = GST_V4L2_ALLOCATOR_CAN_ALLOCATE (allocator, USERPTR);
break;
case V4L2_MEMORY_DMABUF:
can_allocate = GST_V4L2_ALLOCATOR_CAN_ALLOCATE (allocator, DMABUF);
break;
default:
can_allocate = FALSE;
break;
}
GST_DEBUG_OBJECT (allocator, "allocated %u %s buffers out of %u requested",
breq.count, memory_type_to_str (memory), count);
allocator->can_allocate = can_allocate;
allocator->count = breq.count;
allocator->memory = memory;
/* Create memory groups */
for (i = 0; i < allocator->count; i++) {
allocator->groups[i] = gst_v4l2_memory_group_new (allocator, i);
if (allocator->groups[i] == NULL)
goto error;
gst_atomic_queue_push (allocator->free_queue, allocator->groups[i]);
}
g_atomic_int_set (&allocator->active, TRUE);
done:
GST_OBJECT_UNLOCK (allocator);
return breq.count;
already_active:
{
GST_ERROR_OBJECT (allocator, "allocator already active");
goto error;
}
reqbufs_failed:
{
GST_ERROR_OBJECT (allocator,
"error requesting %d buffers: %s", count, g_strerror (errno));
goto error;
}
out_of_memory:
{
GST_ERROR_OBJECT (allocator, "Not enough memory to allocate buffers");
goto error;
}
error:
{
breq.count = 0;
goto done;
}
}
开发者ID:hizukiayaka,项目名称:gst-plugins-good,代码行数:80,代码来源:gstv4l2allocator.c
示例12: gst_dtls_enc_chain
static GstFlowReturn
gst_dtls_enc_chain (GstDtlsBase * base, GstBuffer * buffer)
{
GstDtlsEnc *self = GST_DTLS_ENC (base);
gssize ret;
GstMapInfo map;
GError *error = NULL;
if (gst_buffer_get_size (buffer) == 0) {
gst_buffer_unref (buffer);
return GST_FLOW_OK;
}
if (!gst_buffer_map (buffer, &map, GST_MAP_READ)) {
GST_ELEMENT_ERROR (base, RESOURCE, READ, ("Can't map buffer"),
("Can't map buffer"));
gst_buffer_unref (buffer);
return GST_FLOW_ERROR;
}
GST_OBJECT_LOCK (self);
self->src_buffer = buffer;
self->running_thread = g_thread_self ();
GST_OBJECT_UNLOCK (self);
ret =
g_output_stream_write (g_io_stream_get_output_stream (G_IO_STREAM
(base->conn->conn)), map.data, map.size, NULL, &error);
g_assert (ret < 0 || ret == map.size);
if (ret > 0 && ret != map.size)
ret = -10;
GST_OBJECT_LOCK (self);
self->src_buffer = NULL;
GST_OBJECT_UNLOCK (self);
gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
if (ret > 0) {
return GST_FLOW_OK;
} else {
if (error) {
GstFlowReturn flow = GST_FLOW_ERROR;
if (error->domain == GST_IO_STREAM_FLOW_RETURN) {
flow = error->code;
} else {
GST_ELEMENT_ERROR (base, LIBRARY, FAILED,
("DTLS encoding failed: %s", error->message),
("DTLS encoding failed: %s", error->message));
}
g_clear_error (&error);
return flow;
} else {
GST_ELEMENT_ERROR (base, LIBRARY, FAILED, ("Unknown encoding error"),
("Unknown encoding error"));
return GST_FLOW_ERROR;
}
}
}
开发者ID:KurentoLegacy,项目名称:kms-dtls-plugins,代码行数:63,代码来源:gstdtlsenc.c
示例13: gst_ffmpegauddec_set_format
static gboolean
gst_ffmpegauddec_set_format (GstAudioDecoder * decoder, GstCaps * caps)
{
GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) decoder;
GstFFMpegAudDecClass *oclass;
gboolean ret = TRUE;
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
GST_DEBUG_OBJECT (ffmpegdec, "setcaps called");
GST_OBJECT_LOCK (ffmpegdec);
if (ffmpegdec->last_caps && gst_caps_is_equal (ffmpegdec->last_caps, caps)) {
GST_DEBUG_OBJECT (ffmpegdec, "same caps");
GST_OBJECT_UNLOCK (ffmpegdec);
return TRUE;
}
gst_caps_replace (&ffmpegdec->last_caps, caps);
/* close old session */
if (ffmpegdec->opened) {
GST_OBJECT_UNLOCK (ffmpegdec);
gst_ffmpegauddec_drain (ffmpegdec);
GST_OBJECT_LOCK (ffmpegdec);
gst_ffmpegauddec_close (ffmpegdec);
}
/* get size and so */
gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
oclass->in_plugin->type, caps, ffmpegdec->context);
/* workaround encoder bugs */
ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
ffmpegdec->context->err_recognition = 1;
ffmpegdec->context->opaque = ffmpegdec;
ffmpegdec->context->get_buffer = gst_ffmpegauddec_get_buffer;
ffmpegdec->context->reget_buffer = NULL;
ffmpegdec->context->release_buffer = NULL;
/* open codec - we don't select an output pix_fmt yet,
* simply because we don't know! We only get it
* during playback... */
if (!gst_ffmpegauddec_open (ffmpegdec))
goto open_failed;
done:
GST_OBJECT_UNLOCK (ffmpegdec);
return ret;
/* ERRORS */
open_failed:
{
GST_DEBUG_OBJECT (ffmpegdec, "Failed to open");
ret = FALSE;
goto done;
}
}
开发者ID:cablelabs,项目名称:gst-libav,代码行数:61,代码来源:gstavauddec.c
示例14: gst_video_scale_transform
static GstFlowReturn
gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
GstBuffer * out)
{
GstVideoScale *videoscale = GST_VIDEO_SCALE (trans);
GstFlowReturn ret = GST_FLOW_OK;
VSImage dest = { NULL, };
VSImage src = { NULL, };
VSImage dest_u = { NULL, };
VSImage dest_v = { NULL, };
VSImage src_u = { NULL, };
VSImage src_v = { NULL, };
gint method;
const guint8 *black = _get_black_for_format (videoscale->format);
gboolean add_borders;
GST_OBJECT_LOCK (videoscale);
method = videoscale->method;
add_borders = videoscale->add_borders;
GST_OBJECT_UNLOCK (videoscale);
if (videoscale->from_width == 1) {
method = GST_VIDEO_SCALE_NEAREST;
}
if (method == GST_VIDEO_SCALE_4TAP &&
(videoscale->from_width < 4 || videoscale->from_height < 4)) {
method = GST_VIDEO_SCALE_BILINEAR;
}
gst_video_scale_setup_vs_image (&src, videoscale->format, 0,
videoscale->from_width, videoscale->from_height, 0, 0,
GST_BUFFER_DATA (in));
gst_video_scale_setup_vs_image (&dest, videoscale->format, 0,
videoscale->to_width, videoscale->to_height, videoscale->borders_w,
videoscale->borders_h, GST_BUFFER_DATA (out));
if (videoscale->format == GST_VIDEO_FORMAT_I420
|| videoscale->format == GST_VIDEO_FORMAT_YV12
|| videoscale->format == GST_VIDEO_FORMAT_Y444
|| videoscale->format == GST_VIDEO_FORMAT_Y42B
|| videoscale->format == GST_VIDEO_FORMAT_Y41B) {
gst_video_scale_setup_vs_image (&src_u, videoscale->format, 1,
videoscale->from_width, videoscale->from_height, 0, 0,
GST_BUFFER_DATA (in));
gst_video_scale_setup_vs_image (&src_v, videoscale->format, 2,
videoscale->from_width, videoscale->from_height, 0, 0,
GST_BUFFER_DATA (in));
gst_video_scale_setup_vs_image (&dest_u, videoscale->format, 1,
videoscale->to_width, videoscale->to_height, videoscale->borders_w,
videoscale->borders_h, GST_BUFFER_DATA (out));
gst_video_scale_setup_vs_image (&dest_v, videoscale->format, 2,
videoscale->to_width, videoscale->to_height, videoscale->borders_w,
videoscale->borders_h, GST_BUFFER_DATA (out));
}
switch (videoscale->format) {
case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_xRGB:
case GST_VIDEO_FORMAT_BGRx:
case GST_VIDEO_FORMAT_xBGR:
case GST_VIDEO_FORMAT_RGBA:
case GST_VIDEO_FORMAT_ARGB:
case GST_VIDEO_FORMAT_BGRA:
case GST_VIDEO_FORMAT_ABGR:
case GST_VIDEO_FORMAT_AYUV:
if (add_borders)
vs_fill_borders_RGBA (&dest, black);
switch (method) {
case GST_VIDEO_SCALE_NEAREST:
vs_image_scale_nearest_RGBA (&dest, &src, videoscale->tmp_buf);
break;
case GST_VIDEO_SCALE_BILINEAR:
vs_image_scale_linear_RGBA (&dest, &src, videoscale->tmp_buf);
break;
case GST_VIDEO_SCALE_4TAP:
vs_image_scale_4tap_RGBA (&dest, &src, videoscale->tmp_buf);
break;
default:
goto unknown_mode;
}
break;
case GST_VIDEO_FORMAT_ARGB64:
case GST_VIDEO_FORMAT_AYUV64:
if (add_borders)
vs_fill_borders_AYUV64 (&dest, black);
switch (method) {
case GST_VIDEO_SCALE_NEAREST:
vs_image_scale_nearest_AYUV64 (&dest, &src, videoscale->tmp_buf);
break;
case GST_VIDEO_SCALE_BILINEAR:
vs_image_scale_linear_AYUV64 (&dest, &src, videoscale->tmp_buf);
break;
case GST_VIDEO_SCALE_4TAP:
vs_image_scale_4tap_AYUV64 (&dest, &src, videoscale->tmp_buf);
break;
default:
goto unknown_mode;
}
break;
case GST_VIDEO_FORMAT_RGB:
//.........这里部分代码省略.........
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:101,代码来源:gstvideoscale.c
示例15: gst_type_find_element_sink_event
static gboolean
gst_type_find_element_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event)
{
gboolean res = FALSE;
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (parent);
GST_DEBUG_OBJECT (typefind, "got %s event in mode %d",
GST_EVENT_TYPE_NAME (event), typefind->mode);
switch (typefind->mode) {
case MODE_TYPEFIND:
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CAPS:
{
GstCaps *caps;
/* Parse and push out our caps and data */
gst_event_parse_caps (event, &caps);
res = gst_type_find_element_setcaps (typefind, caps);
gst_event_unref (event);
break;
}
case GST_EVENT_GAP:
{
GST_FIXME_OBJECT (typefind,
"GAP events during typefinding not handled properly");
/* FIXME: These would need to be inserted in the stream at
* the right position between buffers, but we combine all
* buffers with a GstAdapter. Drop the GAP event for now,
* which will only cause an implicit GAP between buffers.
*/
gst_event_unref (event);
res = TRUE;
break;
}
case GST_EVENT_EOS:
{
GST_INFO_OBJECT (typefind, "Got EOS and no type found yet");
gst_type_find_element_chain_do_typefinding (typefind, FALSE, TRUE);
res = gst_pad_push_event (typefind->src, event);
break;
}
case GST_EVENT_FLUSH_STOP:{
GList *l;
GST_OBJECT_LOCK (typefind);
for (l = typefind->cached_events; l; l = l->next) {
if (GST_EVENT_IS_STICKY (l->data) &&
GST_EVENT_TYPE (l->data) != GST_EVENT_SEGMENT &&
GST_EVENT_TYPE (l->data) != GST_EVENT_EOS) {
gst_pad_store_sticky_event (typefind->src, l->data);
}
gst_event_unref (l->data);
}
g_list_free (typefind->cached_events);
typefind->cached_events = NULL;
gst_adapter_clear (typefind->adapter);
GST_OBJECT_UNLOCK (typefind);
/* fall through */
}
case GST_EVENT_FLUSH_START:
res = gst_pad_push_event (typefind->src, event);
break;
default:
/* Forward events that would happen before the caps event
* directly instead of storing them. There's no reason not
* to send them directly and we should only store events
* for later sending that would need to come after the caps
* event */
if (GST_EVENT_TYPE (event) < GST_EVENT_CAPS) {
res = gst_pad_push_event (typefind->src, event);
} else {
GST_DEBUG_OBJECT (typefind, "Saving %s event to send later",
GST_EVENT_TYPE_NAME (event));
GST_OBJECT_LOCK (typefind);
typefind->cached_events =
g_list_append (typefind->cached_events, event);
GST_OBJECT_UNLOCK (typefind);
res = TRUE;
}
break;
}
break;
case MODE_NORMAL:
res = gst_pad_push_event (typefind->src, event);
break;
case MODE_ERROR:
break;
default:
g_assert_not_reached ();
}
return res;
}
开发者ID:GrokImageCompression,项目名称:gstreamer,代码行数:99,代码来源:gsttypefindelement.c
示例16: gst_geometric_transform_transform_frame
static GstFlowReturn
gst_geometric_transform_transform_frame (GstVideoFilter * vfilter,
GstVideoFrame * in_frame, GstVideoFrame * out_frame)
{
GstGeometricTransform *gt;
GstGeometricTransformClass *klass;
gint x, y;
GstFlowReturn ret = GST_FLOW_OK;
gdouble *ptr;
guint8 *in_data;
guint8 *out_data;
gt = GST_GEOMETRIC_TRANSFORM_CAST (vfilter);
klass = GST_GEOMETRIC_TRANSFORM_GET_CLASS (gt);
in_data = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
out_data = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
if (GST_VIDEO_FRAME_FORMAT (out_frame) == GST_VIDEO_FORMAT_AYUV) {
/* in AYUV black is not just all zeros:
* 0x10 is black for Y,
* 0x80 is black for Cr and Cb */
for (int i = 0; i < out_frame->map[0].size; i += 4)
GST_WRITE_UINT32_BE (out_data + i, 0xff108080);
} else {
memset (out_data, 0, out_frame->map[0].size);
}
GST_OBJECT_LOCK (gt);
if (gt->precalc_map) {
if (gt->needs_remap) {
if (klass->prepare_func)
if (!klass->prepare_func (gt)) {
ret = FALSE;
|
请发表评论