⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gstevent.c

📁 gnash 在pc和嵌入式下开发需要的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* GStreamer * Copyright (C) 2005 Jan Schmidt <thaytan@mad.scientist.com> * * gstevent.c: Unit test for event handling * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */#include <gst/check/gstcheck.h>GST_START_TEST (create_custom_events){  GstEvent *event, *event2;  GstStructure *structure;  /* FLUSH_START */  {    event = gst_event_new_flush_start ();    fail_if (event == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_START);    fail_unless (GST_EVENT_IS_UPSTREAM (event));    fail_unless (GST_EVENT_IS_DOWNSTREAM (event));    fail_if (GST_EVENT_IS_SERIALIZED (event));    gst_event_unref (event);  }  /* FLUSH_STOP */  {    event = gst_event_new_flush_stop ();    fail_if (event == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP);    fail_unless (GST_EVENT_IS_UPSTREAM (event));    fail_unless (GST_EVENT_IS_DOWNSTREAM (event));    fail_unless (GST_EVENT_IS_SERIALIZED (event));    gst_event_unref (event);  }  /* EOS */  {    event = gst_event_new_eos ();    fail_if (event == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_EOS);    fail_if (GST_EVENT_IS_UPSTREAM (event));    fail_unless (GST_EVENT_IS_DOWNSTREAM (event));    fail_unless (GST_EVENT_IS_SERIALIZED (event));    gst_event_unref (event);  }  /* NEWSEGMENT */  {    gdouble rate, applied_rate;    GstFormat format;    gint64 start, end, base;    gboolean update;    event =        gst_event_new_new_segment (FALSE, 0.5, GST_FORMAT_TIME, 1, G_MAXINT64,        0xdeadbeef);    fail_if (event == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT);    fail_if (GST_EVENT_IS_UPSTREAM (event));    fail_unless (GST_EVENT_IS_DOWNSTREAM (event));    fail_unless (GST_EVENT_IS_SERIALIZED (event));    gst_event_parse_new_segment (event, &update, &rate, &format, &start, &end,        &base);    fail_unless (update == FALSE);    fail_unless (rate == 0.5);    fail_unless (format == GST_FORMAT_TIME);    fail_unless (start == 1);    fail_unless (end == G_MAXINT64);    fail_unless (base == 0xdeadbeef);    /* Check that the new segment was created with applied_rate of 1.0 */    gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate,        &format, &start, &end, &base);    fail_unless (update == FALSE);    fail_unless (rate == 0.5);    fail_unless (applied_rate == 1.0);    fail_unless (format == GST_FORMAT_TIME);    fail_unless (start == 1);    fail_unless (end == G_MAXINT64);    gst_event_unref (event);    event =        gst_event_new_new_segment_full (TRUE, 0.75, 0.5, GST_FORMAT_BYTES, 0,        G_MAXINT64 - 1, 0xdeadbeef);    fail_if (event == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT);    fail_if (GST_EVENT_IS_UPSTREAM (event));    fail_unless (GST_EVENT_IS_DOWNSTREAM (event));    fail_unless (GST_EVENT_IS_SERIALIZED (event));    gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate,        &format, &start, &end, &base);    fail_unless (update == TRUE);    fail_unless (rate == 0.75);    fail_unless (applied_rate == 0.5);    fail_unless (format == GST_FORMAT_BYTES);    fail_unless (start == 0);    fail_unless (end == (G_MAXINT64 - 1));    gst_event_unref (event);  }  /* TAGS */  {    GstTagList *taglist = gst_tag_list_new ();    GstTagList *tl2 = NULL;    event = gst_event_new_tag (taglist);    fail_if (taglist == NULL);    fail_if (event == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_TAG);    fail_if (GST_EVENT_IS_UPSTREAM (event));    fail_unless (GST_EVENT_IS_DOWNSTREAM (event));    fail_unless (GST_EVENT_IS_SERIALIZED (event));    gst_event_parse_tag (event, &tl2);    fail_unless (taglist == tl2);    gst_event_unref (event);  }  /* FIXME: Add tests for QOS when it is implemented. */  /* SEEK */  {    gdouble rate;    GstFormat format;    GstSeekFlags flags;    GstSeekType cur_type, stop_type;    gint64 cur, stop;    event = gst_event_new_seek (0.5, GST_FORMAT_BYTES,        GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,        GST_SEEK_TYPE_SET, 1, GST_SEEK_TYPE_NONE, 0xdeadbeef);    fail_if (event == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_SEEK);    fail_unless (GST_EVENT_IS_UPSTREAM (event));    fail_if (GST_EVENT_IS_DOWNSTREAM (event));    fail_if (GST_EVENT_IS_SERIALIZED (event));    gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur,        &stop_type, &stop);    fail_unless (rate == 0.5);    fail_unless (format == GST_FORMAT_BYTES);    fail_unless (flags == (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE));    fail_unless (cur_type == GST_SEEK_TYPE_SET);    fail_unless (cur == 1);    fail_unless (stop_type == GST_SEEK_TYPE_NONE);    fail_unless (stop == 0xdeadbeef);    gst_event_unref (event);  }  /* NAVIGATION */  {    structure = gst_structure_new ("application/x-gst-navigation", "event",        G_TYPE_STRING, "key-press", "key", G_TYPE_STRING, "mon", NULL);    fail_if (structure == NULL);    event = gst_event_new_navigation (structure);    fail_if (event == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION);    fail_unless (GST_EVENT_IS_UPSTREAM (event));    fail_if (GST_EVENT_IS_DOWNSTREAM (event));    fail_if (GST_EVENT_IS_SERIALIZED (event));    fail_unless (gst_event_get_structure (event) == structure);    gst_event_unref (event);  }  /* Custom event types */  {    structure = gst_structure_empty_new ("application/x-custom");    fail_if (structure == NULL);    event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, structure);    fail_if (event == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_UPSTREAM);    fail_unless (GST_EVENT_IS_UPSTREAM (event));    fail_if (GST_EVENT_IS_DOWNSTREAM (event));    fail_if (GST_EVENT_IS_SERIALIZED (event));    fail_unless (gst_event_get_structure (event) == structure);    gst_event_unref (event);    /* Decided not to test the other custom enum types, as they     * only differ by the value of the enum passed to gst_event_new_custom     */  }  /* Event copying */  {    structure = gst_structure_empty_new ("application/x-custom");    fail_if (structure == NULL);    event = gst_event_new_custom (GST_EVENT_CUSTOM_BOTH, structure);    fail_if (event == NULL);    event2 = gst_event_copy (event);    fail_if (event2 == NULL);    fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_TYPE (event2));    /* The structure should have been duplicated */    fail_if (gst_event_get_structure (event) ==        gst_event_get_structure (event2));    gst_event_unref (event);    gst_event_unref (event2);  }  /* Make events writable */  {    structure = gst_structure_empty_new ("application/x-custom");    fail_if (structure == NULL);    event = gst_event_new_custom (GST_EVENT_CUSTOM_BOTH, structure);    /* ref the event so that it becomes non-writable */    gst_event_ref (event);    gst_event_ref (event);    /* this should fail if the structure isn't writable */    ASSERT_CRITICAL (gst_structure_remove_all_fields ((GstStructure *)            gst_event_get_structure (event)));    /* now make writable */    event2 =        GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -