void test_from_string() { GstCaps *caps; GstCaps *caps2; gchar *to_str; int i; //xmlfile = "test_from_string"; std_log(LOG_FILENAME_LINE, "Test Started test_from_string"); for (i = 0; i < G_N_ELEMENTS (caps_list); i++) { caps = gst_caps_from_string (caps_list[i]); fail_if (caps == NULL, "Could not create caps from string %s\n", caps_list[i]); to_str = gst_caps_to_string (caps); fail_if (to_str == NULL, "Could not convert caps back to string %s\n", caps_list[i]); caps2 = gst_caps_from_string (caps_list[i]); fail_if (caps2 == NULL, "Could not create caps from string %s\n", to_str); fail_unless (gst_caps_is_equal (caps, caps)); fail_unless (gst_caps_is_equal (caps, caps2)); gst_caps_unref (caps); gst_caps_unref (caps2); g_free (to_str); } std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
static gboolean audioresample_transform_size (GstBaseTransform * base, GstPadDirection direction, GstCaps * caps, guint size, GstCaps * othercaps, guint * othersize) { GstAudioresample *audioresample = GST_AUDIORESAMPLE (base); ResampleState *state; GstCaps *srccaps, *sinkcaps; gboolean use_internal = FALSE; /* whether we use the internal state */ gboolean ret = TRUE; GST_LOG_OBJECT (base, "asked to transform size %d in direction %s", size, direction == GST_PAD_SINK ? "SINK" : "SRC"); if (direction == GST_PAD_SINK) { sinkcaps = caps; srccaps = othercaps; } else { sinkcaps = othercaps; srccaps = caps; } /* if the caps are the ones that _set_caps got called with; we can use * our own state; otherwise we'll have to create a state */ if (gst_caps_is_equal (sinkcaps, audioresample->sinkcaps) && gst_caps_is_equal (srccaps, audioresample->srccaps)) { use_internal = TRUE; state = audioresample->resample; } else { GST_DEBUG_OBJECT (audioresample, "caps are not the set caps, creating state"); state = resample_new (); resample_set_filter_length (state, audioresample->filter_length); resample_set_state_from_caps (state, sinkcaps, srccaps, NULL, NULL, NULL); } if (direction == GST_PAD_SINK) { /* asked to convert size of an incoming buffer */ *othersize = resample_get_output_size_for_input (state, size); } else { /* asked to convert size of an outgoing buffer */ *othersize = resample_get_input_size_for_output (state, size); } g_assert (*othersize % state->sample_size == 0); /* we make room for one extra sample, given that the resampling filter * can output an extra one for non-integral i_rate/o_rate */ GST_LOG_OBJECT (base, "transformed size %d to %d", size, *othersize); if (!use_internal) { resample_free (state); } return ret; }
static gboolean gst_v4l2_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps, GstCaps * outcaps) { GstV4l2Transform *self = GST_V4L2_TRANSFORM (trans); if (self->incaps && self->outcaps) { if (gst_caps_is_equal (incaps, self->incaps) && gst_caps_is_equal (outcaps, self->outcaps)) { GST_DEBUG_OBJECT (trans, "Caps did not changed"); return TRUE; } } /* TODO Add renegotiation support */ g_return_val_if_fail (!GST_V4L2_IS_ACTIVE (self->v4l2output), FALSE); g_return_val_if_fail (!GST_V4L2_IS_ACTIVE (self->v4l2capture), FALSE); gst_caps_replace (&self->incaps, incaps); gst_caps_replace (&self->outcaps, outcaps); if (!gst_v4l2_object_set_format (self->v4l2output, incaps)) goto incaps_failed; if (!gst_v4l2_object_set_format (self->v4l2capture, outcaps)) goto outcaps_failed; /* FIXME implement fallback if crop not supported */ if (!gst_v4l2_object_set_crop (self->v4l2output)) goto failed; if (!gst_v4l2_object_set_crop (self->v4l2capture)) goto failed; return TRUE; incaps_failed: { GST_ERROR_OBJECT (self, "failed to set input caps: %" GST_PTR_FORMAT, incaps); goto failed; } outcaps_failed: { gst_v4l2_object_stop (self->v4l2output); GST_ERROR_OBJECT (self, "failed to set output caps: %" GST_PTR_FORMAT, outcaps); goto failed; } failed: return FALSE; }
static gboolean gst_hls_demux_get_next_fragment (GstHLSDemux * demux) { GstBuffer *buf; guint avail; const gchar *next_fragment_uri; GstClockTime duration; GstClockTime timestamp; gboolean discont; if (!gst_m3u8_client_get_next_fragment (demux->client, &discont, &next_fragment_uri, &duration, ×tamp)) { GST_INFO_OBJECT (demux, "This playlist doesn't contain more fragments"); demux->end_of_playlist = TRUE; gst_task_start (demux->task); return FALSE; } GST_INFO_OBJECT (demux, "Fetching next fragment %s", next_fragment_uri); if (!gst_hls_demux_fetch_location (demux, next_fragment_uri)) { /* FIXME: The gst_m3u8_get_next_fragment increments the sequence number but another thread might call get_next_fragment and this decrement will not redownload the failed fragment, but might duplicate the download of a succeeded fragment */ g_atomic_int_add (&demux->client->sequence, -1); return FALSE; } avail = gst_adapter_available (demux->download); buf = gst_adapter_take_buffer (demux->download, avail); GST_BUFFER_DURATION (buf) = duration; GST_BUFFER_TIMESTAMP (buf) = timestamp; /* We actually need to do this every time we switch bitrate */ if (G_UNLIKELY (demux->do_typefind)) { GstCaps *caps = gst_type_find_helper_for_buffer (NULL, buf, NULL); if (!demux->input_caps || !gst_caps_is_equal (caps, demux->input_caps)) { gst_caps_replace (&demux->input_caps, caps); /* gst_pad_set_caps (demux->srcpad, demux->input_caps); */ GST_INFO_OBJECT (demux, "Input source caps: %" GST_PTR_FORMAT, demux->input_caps); demux->do_typefind = FALSE; } else gst_caps_unref (caps); } gst_buffer_set_caps (buf, demux->input_caps); if (discont) { GST_DEBUG_OBJECT (demux, "Marking fragment as discontinuous"); GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT); } g_queue_push_tail (demux->queue, buf); gst_task_start (demux->task); gst_adapter_clear (demux->download); return TRUE; }
/* * Sets the caps on deinterlace sinkpad and validates the * caps that is set on the srcpad */ static void deinterlace_set_caps_and_check (GstCaps * input, gboolean must_deinterlace) { GstCaps *othercaps = NULL; fail_unless (gst_pad_set_caps (sinkpad, input)); g_object_get (srcpad, "caps", &othercaps, NULL); if (must_deinterlace) { fail_if (gst_caps_is_interlaced (othercaps)); } else { GstStructure *s; fail_unless (gst_caps_is_interlaced (input) == gst_caps_is_interlaced (othercaps)); othercaps = gst_caps_make_writable (othercaps); s = gst_caps_get_structure (othercaps, 0); gst_structure_remove_field (s, "interlace-mode"); input = gst_caps_make_writable (input); s = gst_caps_get_structure (input, 0); gst_structure_remove_field (s, "interlace-mode"); fail_unless (gst_caps_is_equal (input, othercaps)); } gst_caps_unref (input); gst_caps_unref (othercaps); }
static gboolean gst_frei0r_mixer_set_caps (GstFrei0rMixer * self, GstPad * pad, GstCaps * caps) { gboolean ret = TRUE; if (!self->caps) { gst_caps_replace (&self->caps, caps); ret = gst_pad_set_caps (self->src, caps); if (ret) { GstVideoInfo info; gst_video_info_init (&info); if (!gst_video_info_from_caps (&self->info, caps)) { ret = FALSE; } } } else if (!gst_caps_is_equal (caps, self->caps)) { if (gst_pad_peer_query_accept_caps (pad, self->caps)) gst_pad_push_event (pad, gst_event_new_reconfigure ()); ret = FALSE; } return ret; }
static gboolean gst_v4l2sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) { GstV4l2Sink *v4l2sink = GST_V4L2SINK (bsink); GstV4l2Object *obj = v4l2sink->v4l2object; GstBufferPool *pool; guint size = 0; GstCaps *caps; gboolean need_pool; gst_query_parse_allocation (query, &caps, &need_pool); if (caps == NULL) goto no_caps; if ((pool = obj->pool)) gst_object_ref (pool); if (pool != NULL) { GstCaps *pcaps; GstStructure *config; /* we had a pool, check caps */ config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_get_params (config, &pcaps, &size, NULL, NULL); GST_DEBUG_OBJECT (v4l2sink, "we had a pool with caps %" GST_PTR_FORMAT, pcaps); if (!gst_caps_is_equal (caps, pcaps)) { gst_structure_free (config); gst_object_unref (pool); goto different_caps; } gst_structure_free (config); } /* we need at least 2 buffers to operate */ gst_query_add_allocation_pool (query, pool, size, 2, 0); /* we also support various metadata */ gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); gst_query_add_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE, NULL); if (pool) gst_object_unref (pool); return TRUE; /* ERRORS */ no_caps: { GST_DEBUG_OBJECT (v4l2sink, "no caps specified"); return FALSE; } different_caps: { /* different caps, we can't use this pool */ GST_DEBUG_OBJECT (v4l2sink, "pool has different caps"); return FALSE; } }
/* Removes duplicate codecs that have the same RTP expression */ static GList * remove_duplicates (GList *list) { GList *walk1, *walk2; for (walk1 = list; walk1; walk1 = g_list_next (walk1)) { CodecCap *codec_cap1 = walk1->data; again: for (walk2 = walk1->next; walk2; walk2 = g_list_next (walk2)) { CodecCap *codec_cap2 = walk2->data; if (gst_caps_is_equal (codec_cap1->rtp_caps, codec_cap2->rtp_caps)) { codec_cap_free (codec_cap2); walk1 = g_list_delete_link (walk1, walk2); goto again; } } } return list; }
/* * Read a buffer from the client socket * * @return GST_FLOW_OK if the send operation was successful, GST_FLOW_ERROR otherwise. */ static GstFlowReturn gst_dccp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf) { GstDCCPClientSrc *src; GstFlowReturn ret = GST_FLOW_OK; src = GST_DCCP_CLIENT_SRC (psrc); GST_LOG_OBJECT (src, "reading a buffer"); ret = gst_dccp_read_buffer (GST_ELEMENT (src), src->sock_fd, outbuf); if (ret == GST_FLOW_OK) { GST_LOG_OBJECT (src, "Returning buffer from _get of size %d, ts %" GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT ", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT, GST_BUFFER_SIZE (*outbuf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*outbuf)), GST_TIME_ARGS (GST_BUFFER_DURATION (*outbuf)), GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf)); if (!gst_caps_is_equal (src->caps, GST_CAPS_ANY)) { gst_buffer_set_caps (*outbuf, src->caps); } } return ret; }
/** * ensure_sinkpad_buffer_pool: * @plugin: a #GstVaapiPluginBase * @caps: the initial #GstCaps for the resulting buffer pool * * Makes sure the sink pad video buffer pool is created with the * appropriate @caps. * * Returns: %TRUE if successful, %FALSE otherwise. */ static gboolean ensure_sinkpad_buffer_pool (GstVaapiPluginBase * plugin, GstCaps * caps) { GstBufferPool *pool; GstCaps *pool_caps; GstStructure *config; GstVideoInfo vi; gboolean need_pool; if (!gst_vaapi_plugin_base_ensure_display (plugin)) return FALSE; if (plugin->sinkpad_buffer_pool) { config = gst_buffer_pool_get_config (plugin->sinkpad_buffer_pool); gst_buffer_pool_config_get_params (config, &pool_caps, NULL, NULL, NULL); need_pool = !gst_caps_is_equal (caps, pool_caps); gst_structure_free (config); if (!need_pool) return TRUE; g_clear_object (&plugin->sinkpad_buffer_pool); plugin->sinkpad_buffer_size = 0; } pool = gst_vaapi_video_buffer_pool_new (plugin->display); if (!pool) goto error_create_pool; gst_video_info_init (&vi); gst_video_info_from_caps (&vi, caps); if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED) { GST_DEBUG ("assume video buffer pool format is NV12"); gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12, GST_VIDEO_INFO_WIDTH (&vi), GST_VIDEO_INFO_HEIGHT (&vi)); } plugin->sinkpad_buffer_size = vi.size; config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_set_params (config, caps, plugin->sinkpad_buffer_size, 0, 0); gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META); gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); if (!gst_buffer_pool_set_config (pool, config)) goto error_pool_config; plugin->sinkpad_buffer_pool = pool; return TRUE; /* ERRORS */ error_create_pool: { GST_ERROR ("failed to create buffer pool"); return FALSE; } error_pool_config: { GST_ERROR ("failed to reset buffer pool config"); gst_object_unref (pool); return FALSE; } }
gboolean gst_media_descriptor_parser_add_stream (GstMediaDescriptorParser * parser, GstPad * pad) { GList *tmp; gboolean ret = FALSE; GstCaps *caps; g_return_val_if_fail (GST_IS_MEDIA_DESCRIPTOR_PARSER (parser), FALSE); g_return_val_if_fail (((GstMediaDescriptor *) parser)->filenode, FALSE); caps = gst_pad_query_caps (pad, NULL); for (tmp = ((GstMediaDescriptor *) parser)->filenode->streams; tmp; tmp = tmp->next) { StreamNode *streamnode = (StreamNode *) tmp->data; if (streamnode->pad == NULL && gst_caps_is_equal (streamnode->caps, caps)) { ret = TRUE; streamnode->pad = gst_object_ref (pad); goto done; } } done: if (caps != NULL) gst_caps_unref (caps); return ret; }
/* * Sets the caps on deinterlace sinkpad and validates the * caps that is set on the srcpad */ static void deinterlace_set_caps_and_check (GstCaps * input, gboolean must_deinterlace) { GstCaps *othercaps = NULL; GstSegment segment; gst_pad_send_event (sinkpad, gst_event_new_stream_start ("test")); fail_unless (gst_pad_set_caps (sinkpad, input)); gst_segment_init (&segment, GST_FORMAT_TIME); gst_pad_send_event (sinkpad, gst_event_new_segment (&segment)); g_object_get (srcpad, "caps", &othercaps, NULL); if (must_deinterlace) { fail_if (gst_caps_is_interlaced (othercaps)); } else { GstStructure *s; fail_unless (gst_caps_is_interlaced (input) == gst_caps_is_interlaced (othercaps)); othercaps = gst_caps_make_writable (othercaps); s = gst_caps_get_structure (othercaps, 0); gst_structure_remove_field (s, "interlace-mode"); input = gst_caps_make_writable (input); s = gst_caps_get_structure (input, 0); gst_structure_remove_field (s, "interlace-mode"); fail_unless (gst_caps_is_equal (input, othercaps)); } gst_caps_unref (input); gst_caps_unref (othercaps); }
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); if (!gst_ffmpegauddec_close (ffmpegdec, TRUE)) { GST_OBJECT_UNLOCK (ffmpegdec); return FALSE; } } /* 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; /* 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; } }
static void sink_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad, gpointer user_data) { gint i; GstMapInfo map; gfloat *data; GstCaps *caps, *ccaps; gint n = GPOINTER_TO_INT (user_data); guint64 mask; fail_unless (GST_IS_BUFFER (buffer)); gst_buffer_map (buffer, &map, GST_MAP_READ); data = (gfloat *) map.data; fail_unless_equals_int (map.size, 48000 * 2 * sizeof (gfloat)); fail_unless_equals_int (GST_BUFFER_DURATION (buffer), GST_SECOND); if (n == 0) { GstAudioChannelPosition pos[2] = { GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE }; gst_audio_channel_positions_to_mask (pos, 2, FALSE, &mask); } else if (n == 1) { GstAudioChannelPosition pos[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT }; gst_audio_channel_positions_to_mask (pos, 2, FALSE, &mask); } else if (n == 2) { GstAudioChannelPosition pos[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER }; gst_audio_channel_positions_to_mask (pos, 2, FALSE, &mask); } else { g_assert_not_reached (); } caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, GST_AUDIO_NE (F32), "channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 48000, "layout", G_TYPE_STRING, "interleaved", "channel-mask", GST_TYPE_BITMASK, mask, NULL); ccaps = gst_pad_get_current_caps (pad); fail_unless (gst_caps_is_equal (caps, ccaps)); gst_caps_unref (ccaps); gst_caps_unref (caps); #ifdef HAVE_VALGRIND if (!(RUNNING_ON_VALGRIND)) #endif for (i = 0; i < 48000 * 2; i += 2) { fail_unless_equals_float (data[i], -1.0); fail_unless_equals_float (data[i + 1], 1.0); } gst_buffer_unmap (buffer, &map); have_data++; }
static gboolean set_caps_1 (GstBaseTransform * trans, GstCaps * incaps, GstCaps * outcaps) { GstCaps *caps; GST_DEBUG_OBJECT (trans, "set_caps called"); set_caps_1_called = TRUE; caps = gst_caps_new_empty_simple ("foo/x-bar"); fail_unless (gst_caps_is_equal (incaps, caps)); fail_unless (gst_caps_is_equal (outcaps, caps)); gst_caps_unref (caps); return TRUE; }
static inline gboolean _gst_caps_is_equal_safe (GstCaps * a, GstCaps * b) { if (a == b) return TRUE; if ((a == NULL) || (b == NULL)) return FALSE; return gst_caps_is_equal (a, b); }
static void gst_base_camera_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstBaseCameraSrc *self = GST_BASE_CAMERA_SRC (object); switch (prop_id) { case PROP_MODE: gst_base_camera_src_set_mode (GST_BASE_CAMERA_SRC (self), g_value_get_enum (value)); break; case PROP_ZOOM:{ self->zoom = g_value_get_float (value); /* limit to max-zoom */ if (self->zoom > self->max_zoom) { GST_DEBUG_OBJECT (self, "Clipping zoom %f to max-zoom %f", self->zoom, self->max_zoom); self->zoom = self->max_zoom; } /* does not set it if in NULL, the src is not created yet */ if (GST_STATE (self) != GST_STATE_NULL) gst_base_camera_src_setup_zoom (self); break; } case PROP_POST_PREVIEW: self->post_preview = g_value_get_boolean (value); break; case PROP_PREVIEW_CAPS:{ GstCaps *new_caps = NULL; new_caps = (GstCaps *) gst_value_get_caps (value); if (!gst_caps_is_equal (self->preview_caps, new_caps)) { gst_caps_replace (&self->preview_caps, new_caps); gst_base_camera_src_setup_preview (self, new_caps); } else { GST_DEBUG_OBJECT (self, "New preview caps equal current preview caps"); } } break; case PROP_PREVIEW_FILTER: if (self->preview_filter) gst_object_unref (self->preview_filter); self->preview_filter = g_value_dup_object (value); if (!gst_camerabin_preview_set_filter (self->preview_pipeline, self->preview_filter)) { GST_WARNING_OBJECT (self, "Cannot change preview filter, is element in NULL state?"); } break; case PROP_AUTO_START: self->auto_start = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec); break; } }
static gboolean rsn_parsetter_check_caps (RsnParSetter * parset, GstCaps * caps) { GstStructure *s; gint width, height; gint par_n, par_d; guint dar_n, dar_d; gboolean ret = FALSE; g_mutex_lock (parset->caps_lock); if (caps == parset->in_caps_last || gst_caps_is_equal (caps, parset->in_caps_last)) { ret = parset->in_caps_was_ok; goto out; } /* Calculate the DAR from the incoming caps, and return TRUE if it matches * the required DAR, FALSE if not */ s = gst_caps_get_structure (caps, 0); if (s == NULL) goto out; if (!gst_structure_get_int (s, "width", &width) || !gst_structure_get_int (s, "height", &height)) goto out; if (!gst_structure_get_fraction (s, "pixel-aspect-ratio", &par_n, &par_d)) par_n = par_d = 1; if (!gst_video_calculate_display_ratio (&dar_n, &dar_d, width, height, par_n, par_d, 1, 1)) goto out; GST_DEBUG_OBJECT (parset, "Incoming video caps now: w %d h %d PAR %d/%d = DAR %d/%d", width, height, par_n, par_d, dar_n, dar_d); if (parset->is_widescreen) { if (dar_n == 16 && dar_d == 9) ret = TRUE; } else { if (dar_n == 4 && dar_d == 3) ret = TRUE; } gst_caps_replace (&parset->in_caps_last, caps); gst_caps_replace (&parset->in_caps_converted, NULL); parset->in_caps_was_ok = ret; out: g_mutex_unlock (parset->caps_lock); return ret; }
static gboolean set_caps_pt2 (GstBaseTransform * trans, GstCaps * incaps, GstCaps * outcaps) { GST_DEBUG_OBJECT (trans, "set_caps called"); set_caps_pt2_called = TRUE; fail_unless (gst_caps_is_equal (incaps, outcaps)); return TRUE; }
static gboolean setcaps_func (GstPad * pad, GstCaps * caps) { GstCaps **caps2 = g_object_get_data (G_OBJECT (pad), "caps"); fail_unless (caps2 != NULL && *caps2 != NULL); fail_unless (gst_caps_is_equal (caps, *caps2)); return TRUE; }
static void caps_notify_cb (GObject * obj, GObject * child, GParamSpec * pspec, Helper * h) { GstCaps *caps = NULL; g_object_get (child, "caps", &caps, NULL); if (caps) { GST_LOG_OBJECT (child, "expected caps: %" GST_PTR_FORMAT, h->expected_caps); GST_LOG_OBJECT (child, "caps set to : %" GST_PTR_FORMAT, caps); fail_unless (gst_caps_is_equal (caps, h->expected_caps)); gst_caps_unref (caps); } }
/** * img_capture_prepared: * @data: camerasrc object * @caps: caps describing the prepared image format * * Callback which is called after image capture has been prepared. */ static void img_capture_prepared (gpointer data, GstCaps * caps) { GstWrapperCameraBinSrc *self = GST_WRAPPER_CAMERA_BIN_SRC (data); GST_INFO_OBJECT (self, "image capture prepared"); /* It is possible we are about to get something else that we requested */ if (!gst_caps_is_equal (self->image_capture_caps, caps)) { adapt_image_capture (self, caps); } else { set_capsfilter_caps (self, self->image_capture_caps); } }
static gboolean set_caps_ct2 (GstBaseTransform * trans, GstCaps * incaps, GstCaps * outcaps) { GstCaps *caps1, *caps2; GST_DEBUG_OBJECT (trans, "set_caps called"); caps1 = gst_caps_new_empty_simple ("foo/x-bar"); if (set_caps_ct2_case == 1) caps2 = gst_caps_copy (caps1); else caps2 = gst_caps_new_empty_simple ("baz/x-foo"); fail_unless (gst_caps_is_equal (incaps, caps1)); fail_unless (gst_caps_is_equal (outcaps, caps2)); set_caps_ct2_called = TRUE; gst_caps_unref (caps1); gst_caps_unref (caps2); return TRUE; }
static gboolean gst_au_parse_add_srcpad (GstAuParse * auparse, GstCaps * new_caps) { GstPad *srcpad = NULL; if (auparse->src_caps && gst_caps_is_equal (new_caps, auparse->src_caps)) { GST_LOG_OBJECT (auparse, "same caps, nothing to do"); return TRUE; } gst_caps_replace (&auparse->src_caps, new_caps); if (auparse->srcpad != NULL) { GST_DEBUG_OBJECT (auparse, "Changing src pad caps to %" GST_PTR_FORMAT, auparse->src_caps); gst_pad_set_caps (auparse->srcpad, auparse->src_caps); } if (auparse->srcpad == NULL) { srcpad = auparse->srcpad = gst_pad_new_from_static_template (&src_template, "src"); g_return_val_if_fail (auparse->srcpad != NULL, FALSE); #if 0 gst_pad_set_query_type_function (auparse->srcpad, GST_DEBUG_FUNCPTR (gst_au_parse_src_get_query_types)); #endif gst_pad_set_query_function (auparse->srcpad, GST_DEBUG_FUNCPTR (gst_au_parse_src_query)); gst_pad_set_event_function (auparse->srcpad, GST_DEBUG_FUNCPTR (gst_au_parse_src_event)); gst_pad_use_fixed_caps (auparse->srcpad); gst_pad_set_active (auparse->srcpad, TRUE); if (auparse->src_caps) gst_pad_set_caps (auparse->srcpad, auparse->src_caps); GST_DEBUG_OBJECT (auparse, "Adding src pad with caps %" GST_PTR_FORMAT, auparse->src_caps); gst_object_ref (auparse->srcpad); if (!gst_element_add_pad (GST_ELEMENT (auparse), auparse->srcpad)) return FALSE; gst_element_no_more_pads (GST_ELEMENT (auparse)); } return TRUE; }
/** * gst_stream_set_caps: * @stream: a #GstStream * @caps: (transfer none) (allow-none): a #GstCaps * * Set the caps for the #GstStream * * Since: 1.10 */ void gst_stream_set_caps (GstStream * stream, GstCaps * caps) { gboolean notify = FALSE; GST_OBJECT_LOCK (stream); if (stream->priv->caps == NULL || (caps && !gst_caps_is_equal (stream->priv->caps, caps))) { gst_caps_replace (&stream->priv->caps, caps); notify = TRUE; } GST_OBJECT_UNLOCK (stream); if (notify) g_object_notify_by_pspec (G_OBJECT (stream), gst_stream_pspecs[PROP_CAPS]); }
static gboolean transform_size_ct2 (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps, gsize size, GstCaps * othercaps, gsize * othersize) { if (gst_caps_is_equal (caps, othercaps)) { *othersize = size; } else { if (direction == GST_PAD_SINK) { *othersize = size * 2; } else { *othersize = size / 2; } } return TRUE; }
static gboolean gst_vaapi_buffer_pool_caps_is_equal (GstBufferPool * pool, GstCaps * newcaps) { GstStructure *config; GstCaps *caps; gboolean ret; caps = NULL; ret = FALSE; config = gst_buffer_pool_get_config (pool); if (gst_buffer_pool_config_get_params (config, &caps, NULL, NULL, NULL)) ret = gst_caps_is_equal (newcaps, caps); gst_structure_free (config); return ret; }
/* * Verify that given buffer contains predefined ADTS frame. */ static void buffer_verify_data (void *buffer, void *user_data) { buffer_verify_data_s *vdata; if (!user_data) { return; } vdata = (buffer_verify_data_s *) user_data; GST_DEBUG ("discard: %d", vdata->discard); if (vdata->discard) { buffer_counter++; if (buffer_counter == vdata->discard) { buffer_counter = 0; vdata->discard = 0; } return; } fail_unless (GST_BUFFER_SIZE (buffer) == vdata->data_to_verify_size); fail_unless (memcmp (GST_BUFFER_DATA (buffer), vdata->data_to_verify, vdata->data_to_verify_size) == 0); if (vdata->buffers_before_offset_skip) { /* This is for skipping the garbage in some test cases */ if (buffer_counter == vdata->buffers_before_offset_skip) { offset_counter += vdata->offset_skip_amount; } } if (!vdata->no_metadata) { fail_unless (GST_BUFFER_TIMESTAMP (buffer) == ts_counter); fail_unless (GST_BUFFER_DURATION (buffer) != 0); fail_unless (GST_BUFFER_OFFSET (buffer) == offset_counter); } if (vdata->caps) { GST_LOG ("%" GST_PTR_FORMAT " = %" GST_PTR_FORMAT " ?", GST_BUFFER_CAPS (buffer), vdata->caps); fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), vdata->caps)); } ts_counter += GST_BUFFER_DURATION (buffer); offset_counter += GST_BUFFER_SIZE (buffer); buffer_counter++; }
static void sink_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad, gpointer user_data) { gint i; gfloat *data; GstCaps *caps; gint n = GPOINTER_TO_INT (user_data); fail_unless (GST_IS_BUFFER (buffer)); fail_unless_equals_int (GST_BUFFER_SIZE (buffer), 48000 * 2 * sizeof (gfloat)); fail_unless_equals_int (GST_BUFFER_DURATION (buffer), GST_SECOND); caps = gst_caps_new_simple ("audio/x-raw-float", "width", G_TYPE_INT, 32, "channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 48000, "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL); if (n == 0) { GstAudioChannelPosition pos[2] = { GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE }; gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos); } else if (n == 1) { GstAudioChannelPosition pos[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT }; gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos); } else if (n == 2) { GstAudioChannelPosition pos[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER }; gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos); } fail_unless (gst_caps_is_equal (caps, GST_BUFFER_CAPS (buffer))); gst_caps_unref (caps); data = (gfloat *) GST_BUFFER_DATA (buffer); for (i = 0; i < 48000 * 2; i += 2) { fail_unless_equals_float (data[i], -1.0); fail_unless_equals_float (data[i + 1], 1.0); } have_data++; }
static gboolean gst_render_bridge_set_caps (GstBaseSink * bsink, GstCaps * caps) { GstBufferClassSink *bcsink = GST_BCSINK (bsink); g_return_val_if_fail (caps, FALSE); g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); if (G_UNLIKELY (bcsink->pool)) { GstCaps *current_caps = gst_buffer_manager_get_caps (bcsink->pool); GST_DEBUG_OBJECT (bcsink, "already have caps: %" GST_PTR_FORMAT, current_caps); if (gst_caps_is_equal (current_caps, caps)) { GST_DEBUG_OBJECT (bcsink, "they are equal!"); gst_caps_unref (current_caps); return TRUE; } gst_caps_unref (current_caps); GST_DEBUG_OBJECT (bcsink, "new caps are different: %" GST_PTR_FORMAT, caps); // TODO GST_DEBUG_OBJECT (bsink, "reallocating buffers not implemented yet"); g_return_val_if_fail (0, FALSE); } GST_DEBUG_OBJECT (bcsink, "constructing bufferpool with caps: %" GST_PTR_FORMAT, caps); bcsink->pool = gst_buffer_manager_new (GST_ELEMENT (bcsink), /*bcsink->fd*/ -1, bcsink->num_buffers, caps); if (!bcsink->pool) { return FALSE; } if (bcsink->num_buffers != bcsink->pool->num_buffers) { GST_DEBUG_OBJECT (bcsink, "asked for %d buffers, got %d instead", bcsink->num_buffers, bcsink->pool->num_buffers); bcsink->num_buffers = bcsink->pool->num_buffers; g_object_notify (G_OBJECT (bcsink), "queue-size"); } g_signal_emit (bcsink, signals[SIG_INIT], 0, bcsink->num_buffers); return TRUE; }