static void
check_filter_caps (const gchar * name, GstEvent * event, GstCaps * caps,
    gint size, gint num_buffers, const gchar * prop, va_list varargs)
{
  GstElement *filter;
  GstBuffer *inbuffer, *outbuffer;
  gint i;
  GstSegment segment;

  filter = setup_filter (name, prop, varargs);
  fail_unless (gst_element_set_state (filter,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
      "could not set to playing");

  gst_check_setup_events (mysrcpad, filter, caps, GST_FORMAT_TIME);

  /* ensure segment (format) properly setup */
  gst_segment_init (&segment, GST_FORMAT_TIME);
  fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));

  if (event)
    fail_unless (gst_pad_push_event (mysrcpad, event));

  for (i = 0; i < num_buffers; ++i) {
    inbuffer = gst_buffer_new_and_alloc (size);
    /* makes valgrind's memcheck happier */
    gst_buffer_memset (inbuffer, 0, 0, size);
    GST_BUFFER_TIMESTAMP (inbuffer) = 0;
    ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
    fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
  }

  fail_unless (g_list_length (buffers) == num_buffers);

  /* clean up buffers */
  for (i = 0; i < num_buffers; ++i) {
    outbuffer = GST_BUFFER (buffers->data);
    fail_if (outbuffer == NULL);

    switch (i) {
      case 0:
        fail_unless (gst_buffer_get_size (outbuffer) == size);
        /* no check on filter operation itself */
        break;
      default:
        break;
    }
    buffers = g_list_remove (buffers, outbuffer);

    ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
    gst_buffer_unref (outbuffer);
    outbuffer = NULL;
  }

  cleanup_filter (filter);
  g_list_free (buffers);
  buffers = NULL;
}
示例#2
0
void cleanup_filters(struct acl_filter **filters, int count)
{
        int i;
        struct acl_filter *_filters;

        if((filters == NULL) || (*filters == NULL) || (count == 0))
                return;

        _filters = *filters;

        for (i = 0; i < count; i++)
                cleanup_filter(&_filters[i]);

        free(_filters);
        *filters = NULL;
}
示例#3
0
static int parse_acl_filter(xmlNode *fnode, struct acl_filter *filter)
{
        struct acl_rule *rule = NULL;
        char *filter_ref = NULL;
        xmlNode *child = NULL;

        filter->name = get_attr_value(fnode, "name");
        if (filter->name == NULL)
                goto err;

        filter->chain = get_attr_value(fnode, "chain");
        filter->priority = get_attr_value(fnode, "priority");

        for (child = fnode->children; child != NULL; child = child->next) {
                if (XSTREQ(child->name, "uuid")) {
                        STRPROP(filter, uuid, child);
                } else if (XSTREQ(child->name, "rule")) {
                        rule = malloc(sizeof(*rule));
                        if (rule == NULL)
                                goto err;

                        if (parse_acl_rule(child, rule) == 0)
                                goto err;

                        if (append_filter_rule(filter, rule) == 0) {
                                cleanup_rule(rule);
                                goto err;
                        }
                }
                else if (XSTREQ(child->name, "filterref")) {
                        filter_ref = get_attr_value(child, "filter");
                        if (filter_ref == NULL)
                                goto err;

                        if (append_filter_ref(filter, filter_ref) == 0)
                                goto err;
                }
        }

        return 1;

 err:
        cleanup_filter(filter);

        return 0;
}