tools/gst-typefind.c: Update, add copyright block.

Original commit message from CVS:
2005-07-15  Andy Wingo  <wingo@pobox.com>

* tools/gst-typefind.c: Update, add copyright block.

* gst/base/gstbasesrc.c (gst_base_src_default_negotiate):
Normalize and truncate caps before fixation.

* gst/gstcaps.h:
* gst/gstcaps.c (gst_caps_truncate): New function, destructively
discards all but the first structure from its argument.
This commit is contained in:
Andy Wingo 2005-07-15 11:04:18 +00:00
parent 7f4581d977
commit ad1970eae2
73 changed files with 304 additions and 31 deletions

View file

@ -1,3 +1,14 @@
2005-07-15 Andy Wingo <wingo@pobox.com>
* tools/gst-typefind.c: Update, add copyright block.
* gst/base/gstbasesrc.c (gst_base_src_default_negotiate):
Normalize and truncate caps before fixation.
* gst/gstcaps.h:
* gst/gstcaps.c (gst_caps_truncate): New function, destructively
discards all but the first structure from its argument.
2005-07-15 Wim Taymans <wim@fluendo.com>
* gst/base/gstbasetransform.c: (gst_base_transform_init),

View file

@ -87,6 +87,9 @@ Check out both <ulink url="http://www.cse.ogi.edu/sysl/">OGI's
pipeline</ulink> and Microsoft's DirectShow for some background.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### FUNCTION gst_init ##### -->
<para>

View file

@ -14,6 +14,9 @@ GstBaseSink
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstBaseSink ##### -->
<para>

View file

@ -14,6 +14,9 @@ GstBaseSrc
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstBaseSrc ##### -->
<para>

View file

@ -14,6 +14,9 @@ GstBaseTransform
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstBaseTransform ##### -->
<para>
@ -28,8 +31,10 @@ GstBaseTransform
@parent_class:
@transform_caps:
@set_caps:
@get_size:
@start:
@stop:
@event:
@transform:
@transform_ip:

View file

@ -55,6 +55,9 @@ clock providers in the bin.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstBin ##### -->
<para>

View file

@ -85,6 +85,9 @@ Last reviewed on August 12th, 2004 (0.8.5)
#GstPad, #GstMiniObject
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstBuffer ##### -->
<para>
The basic structure of a buffer.

View file

@ -14,6 +14,9 @@ Structure describing sets of media formats
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstCaps ##### -->
<para>

View file

@ -22,6 +22,9 @@ a good measure of the current playback time in the pipeline.
#GstSystemClock
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstClock ##### -->
<para>

View file

@ -16,3 +16,6 @@ This can be done in CFLAGS for compiling old code.
</para>
<!-- ##### SECTION Stability_Level ##### -->

View file

@ -37,6 +37,9 @@ If a subsystem is disabled in GStreamer, a value is defined in
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### MACRO GST_DISABLE_LOADSAVE_REGISTRY ##### -->
<para>

View file

@ -65,6 +65,9 @@ and gst_element_set_clock(). You can wait for the clock to reach a given
<!-- basic object functions -->
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstElement ##### -->
<para>

View file

@ -14,6 +14,9 @@ Defines public information about a #GstElement
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstElementDetails ##### -->
<para>
This struct is used to define public information about the element. It

View file

@ -54,6 +54,9 @@ so that the autopluggers can select a plugin more appropriatly
#GstElement, #GstPlugin, #GstPluginFeature, #GstPadTemplate.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstElementFactory ##### -->
<para>

View file

@ -14,3 +14,6 @@ all gstreamer core related enumerations
</para>
<!-- ##### SECTION Stability_Level ##### -->

View file

@ -14,6 +14,9 @@ Categorized error messages
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### ENUM GstCoreError ##### -->
<para>
@ -82,6 +85,7 @@ Categorized error messages
@GST_STREAM_ERROR_DEMUX:
@GST_STREAM_ERROR_MUX:
@GST_STREAM_ERROR_FORMAT:
@GST_STREAM_ERROR_STOPPED:
@GST_STREAM_ERROR_NUM_ERRORS:
<!-- ##### MACRO GST_CORE_ERROR ##### -->

View file

@ -27,6 +27,9 @@ gst_event_new_flush() creates a new flush event.
#GstPad, #GstElement
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstEvent ##### -->
<para>

View file

@ -14,6 +14,9 @@ GstFakeSink
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstFakeSink ##### -->
<para>

View file

@ -14,6 +14,9 @@ GstFakeSrc
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstFakeSrc ##### -->
<para>

View file

@ -14,6 +14,9 @@ GstFileSink
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstFileSink ##### -->
<para>

View file

@ -14,6 +14,9 @@ GstFileSrc
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstFileSrc ##### -->
<para>

View file

@ -17,6 +17,9 @@ on its own.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### USER_FUNCTION GstFilterFunc ##### -->
<para>

View file

@ -15,6 +15,9 @@ formats can be used to perform seeking or conversions/query operations.
#GstPad, #GstElement
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### ENUM GstFormat ##### -->
<para>
Standard predefined formats

View file

@ -14,6 +14,9 @@ Pseudo link pads
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstGhostPad ##### -->
<para>

View file

@ -14,6 +14,9 @@ Core interface implemented by #GstElements that allows runtime querying of inter
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstImplementsInterface ##### -->
<para>

View file

@ -15,6 +15,9 @@ in a pipeline.
#GstIndexFactory
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstIndex ##### -->
<para>

View file

@ -14,6 +14,9 @@ GstIndexFactory is used to dynamically create GstIndex implementations.
#GstIndex
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstIndexFactory ##### -->
<para>
The GstIndexFactory object

View file

@ -68,6 +68,9 @@ categories. These are explained at GST_DEBUG_CATEGORY_INIT().
and environment variables that affect the debugging output.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### ENUM GstDebugLevel ##### -->
<para>
The level defines the importance of a debugging message. The more important a

View file

@ -14,6 +14,9 @@ GstIterator
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstIterator ##### -->
<para>

View file

@ -14,3 +14,6 @@ various portabillity helper macros
</para>
<!-- ##### SECTION Stability_Level ##### -->

View file

@ -21,6 +21,9 @@ The GstMemChunk is used to allocate critical resources for #GstBuffer and
#GstBuffer, #GstEvent, #GstData
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstMemChunk ##### -->
<para>
The memchunk structure

View file

@ -14,6 +14,9 @@ GstMiniObject
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstMiniObject ##### -->
<para>

View file

@ -67,6 +67,9 @@ object.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstObject ##### -->
<para>

View file

@ -57,6 +57,9 @@ Last reviewed on December 13th, 2002 (0.5.0.1)
#GstPadTemplate, #GstElement, #GstEvent
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstPad ##### -->
<para>

View file

@ -73,6 +73,9 @@ The following example shows you how to add the padtemplate to an elementfactory:
#GstPad, #GstElementFactory
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstPadTemplate ##### -->
<para>
The padtemplate object.

View file

@ -14,6 +14,9 @@ get a pipeline from a text pipeline description
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### FUNCTION gst_parse_error_quark ##### -->
<para>

View file

@ -21,6 +21,9 @@ the pipeline, use gst_object_unref() to free its resources.
#GstBin
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstPipeline ##### -->
<para>

View file

@ -35,6 +35,9 @@ to bring the plugin into memory.
#GstPluginFeature, #GstType, #GstAutoplug, #GstElementFactory
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### FUNCTION gst_plugin_error_quark ##### -->
<para>
Get the error quark

View file

@ -14,6 +14,9 @@ This is a base class for anything that can be added to a #GstPlugin.
#GstPlugin
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstPluginFeature ##### -->
<para>

View file

@ -15,6 +15,9 @@ Query types can be used to perform queries on pads and elements.
#GstPad, #GstElement
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### ENUM GstQueryType ##### -->
<para>
Standard predefined Query types

View file

@ -25,6 +25,9 @@ The queue blocks by default.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstQueue ##### -->
<para>

View file

@ -15,3 +15,6 @@ All registries build the #GstRegistryPool.
#GstPlugin, #GstPluginFeature
</para>
<!-- ##### SECTION Stability_Level ##### -->

View file

@ -15,6 +15,9 @@ the system.
GstRegistry
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### FUNCTION gst_registry_pool_list ##### -->
<para>

View file

@ -14,6 +14,9 @@ This is a base class for custom schedulers.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstScheduler ##### -->
<para>

View file

@ -31,6 +31,9 @@ Use gst_scheduler_factory_destroy() to remove the factory from the global list.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstSchedulerFactory ##### -->
<para>

View file

@ -14,6 +14,9 @@ Generic structure containing fields of names and values
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstStructure ##### -->
<para>

View file

@ -15,6 +15,9 @@ system time.
#GstClock
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstSystemClock ##### -->
<para>

View file

@ -14,6 +14,9 @@ List of tags and values used to describe media metadata
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### TYPEDEF GstTagList ##### -->
<para>

View file

@ -14,6 +14,9 @@ Element interface that allows setting and retrieval of media metadata
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstTagSetter ##### -->
<para>

View file

@ -14,6 +14,9 @@ Tracing functionality
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstTrace ##### -->
<para>

View file

@ -14,6 +14,9 @@ gsttrashstack
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstTrashStack ##### -->
<para>

View file

@ -14,6 +14,9 @@ typefinding subsystem
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstTypeFind ##### -->
<para>

View file

@ -67,6 +67,9 @@ the given data. You can get quite a bit more complicated than that though.
<link linkend="gstreamer-Writing-typefind-functions">Writing typefind functions</link>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstTypeFindFactory ##### -->
<para>
Object that stores information about a typefind function

View file

@ -14,6 +14,9 @@ various global enums and constants
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### ENUM GstElementState ##### -->
<para>
These contants describe the state a #GstElement is in and transition scheduled for the #GstElement (the pending state).

View file

@ -15,6 +15,9 @@ and the element property that can handle a given URI.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstURIHandler ##### -->
<para>

View file

@ -14,6 +14,9 @@ describes URI types
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### ENUM GstURIType ##### -->
<para>

View file

@ -14,6 +14,9 @@ various utility functions
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### FUNCTION gst_util_set_value_from_string ##### -->
<para>

View file

@ -14,6 +14,9 @@ GValue implementations specific to GStreamer
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### MACRO GST_MAKE_FOURCC ##### -->
<para>
will transform four characters into a host-endiannness guint32 fourcc:

View file

@ -15,6 +15,9 @@ The version macros get defined by including "gst/gst.h".
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### MACRO GST_VERSION_MAJOR ##### -->
<para>
The major version of GStreamer at compile time

View file

@ -14,6 +14,9 @@ XML save/restore operations of pipelines
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstXML ##### -->
<para>

View file

@ -73,6 +73,9 @@ This allows the manager to interupt processing to apply new control values.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### FUNCTION gst_control_init ##### -->
<para>

View file

@ -27,6 +27,9 @@ network connections also need a protocol to do this.
#GstBuffer, #GstCaps, #GstEvent
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### ENUM GstDPHeaderFlag ##### -->
<para>

View file

@ -15,6 +15,9 @@ Subclasses of this do more advanced updates like smoothing parameter changes.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstDParam ##### -->
<para>

View file

@ -14,6 +14,9 @@ linear interpolation dynamic parameter
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstDParamLinInterp ##### -->
<para>

View file

@ -20,6 +20,9 @@ are for applications that use elements with dparams.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstDParamManager ##### -->
<para>

View file

@ -14,6 +14,9 @@ realtime smoothed dynamic parameter
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstDParamSmooth ##### -->
<para>

View file

@ -14,6 +14,9 @@ accelerated routines for getting bits from a data stream.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT gst_getbits_t ##### -->
<para>

View file

@ -14,6 +14,9 @@ conversion between units of measurement
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstUnitConvert ##### -->
<para>

View file

@ -785,7 +785,13 @@ gst_base_src_default_negotiate (GstBaseSrc * basesrc)
caps = thiscaps;
}
if (caps) {
caps = gst_caps_make_writable (caps);
GstCaps *normalized;
normalized = gst_caps_make_writable (caps);
gst_caps_unref (caps);
caps = normalized;
gst_caps_truncate (caps);
gst_pad_fixate_caps (GST_BASE_SRC_PAD (basesrc), caps);
GST_DEBUG ("fixated to: %" GST_PTR_FORMAT, caps);

View file

@ -568,6 +568,27 @@ gst_caps_copy_nth (const GstCaps * caps, gint nth)
return newcaps;
}
/**
* gst_caps_truncate:
* @caps: the @GstCaps to truncate
*
* Destructively discard all but the first structure from @caps. Useful when
* fixating. @caps must be writable.
*/
void
gst_caps_truncate (GstCaps * caps)
{
gint i;
g_return_if_fail (GST_IS_CAPS (caps));
g_return_if_fail (IS_WRITABLE (caps));
i = caps->structs->len - 1;
while (i > 0)
gst_caps_remove_structure (caps, i--);
}
/**
* gst_caps_set_simple:
* @caps: the @GstCaps to set

View file

@ -109,6 +109,7 @@ int gst_caps_get_size (const G
GstStructure * gst_caps_get_structure (const GstCaps *caps,
int index);
GstCaps * gst_caps_copy_nth (const GstCaps * caps, gint nth);
void gst_caps_truncate (GstCaps * caps);
void gst_caps_set_simple (GstCaps *caps,
char *field, ...);
void gst_caps_set_simple_valist (GstCaps *caps,

View file

@ -785,7 +785,13 @@ gst_base_src_default_negotiate (GstBaseSrc * basesrc)
caps = thiscaps;
}
if (caps) {
caps = gst_caps_make_writable (caps);
GstCaps *normalized;
normalized = gst_caps_make_writable (caps);
gst_caps_unref (caps);
caps = normalized;
gst_caps_truncate (caps);
gst_pad_fixate_caps (GST_BASE_SRC_PAD (basesrc), caps);
GST_DEBUG ("fixated to: %" GST_PTR_FORMAT, caps);

View file

@ -1,3 +1,27 @@
/* GStreamer
* Copyright (C) 2003 Thomas Vander Stichele <thomas@apestaart.org>
* 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
* 2005 Andy Wingo <wingo@pobox.com>
*
* gst-typefind.c: Use GStreamer to find the type of a file
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
@ -7,28 +31,19 @@
#include <locale.h>
#include <gst/gst.h>
/*
* find the type of a media file and display it's properties
**/
gboolean FOUND = FALSE;
gchar *filename = NULL;
char *filename = NULL;
void
gst_caps_print (const char *filename, const GstCaps * caps)
{
gchar *caps_str = gst_caps_to_string (caps);
g_print ("%s - %s\n", filename, caps_str);
g_free (caps_str);
}
void
have_type_handler (GstElement * typefind, guint probability,
const GstCaps * caps, gpointer unused)
{
gst_caps_print (filename, caps);
FOUND = TRUE;
gchar *caps_str;
caps_str = gst_caps_to_string (caps);
g_print ("%s - %s\n", filename, caps_str);
g_free (caps_str);
}
int
@ -36,7 +51,7 @@ main (int argc, char *argv[])
{
guint i = 1;
GstElement *pipeline;
GstElement *source, *typefind;
GstElement *source, *typefind, *fakesink;
setlocale (LC_ALL, "");
@ -48,32 +63,41 @@ main (int argc, char *argv[])
}
pipeline = gst_pipeline_new (NULL);
/* don't hang too long trying to preroll */
g_object_set (pipeline, "play-timeout", (gint64) 0.25 * GST_SECOND, NULL);
source = gst_element_factory_make ("filesrc", "source");
g_assert (GST_IS_ELEMENT (source));
typefind = gst_element_factory_make ("typefind", "typefind");
g_assert (GST_IS_ELEMENT (typefind));
gst_bin_add (GST_BIN (pipeline), source);
gst_bin_add (GST_BIN (pipeline), typefind);
gst_pad_link (gst_element_get_pad (source, "src"),
gst_element_get_pad (typefind, "sink"));
fakesink = gst_element_factory_make ("fakesink", "fakesink");
g_assert (GST_IS_ELEMENT (typefind));
gst_bin_add_many (GST_BIN (pipeline), source, typefind, fakesink, NULL);
gst_element_link_many (source, typefind, fakesink, NULL);
g_signal_connect (G_OBJECT (typefind), "have-type",
G_CALLBACK (have_type_handler), NULL);
while (i < argc) {
FOUND = FALSE;
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
GstElementStateReturn sret;
filename = argv[i];
g_object_set (source, "location", filename, NULL);
/* set to play */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
while (!FOUND) {
}
if (!FOUND) {
/* typefind will only commit to PAUSED if it actually finds a type;
* otherwise the state change fails */
sret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
if (sret != GST_STATE_SUCCESS)
g_print ("%s - No type found\n", argv[i]);
}
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
i++;
}
g_object_unref (pipeline);
gst_object_unref (pipeline);
return 0;
}