--- /dev/null
+#include <gst/gst.h>\r
+ \r
+/* Functions below print the Capabilities in a human-friendly format */\r
+static gboolean print_field (GQuark field, const GValue * value, gpointer pfx) {\r
+ gchar *str = gst_value_serialize (value);\r
+ \r
+ g_print ("%s %15s: %s\n", (gchar *) pfx, g_quark_to_string (field), str);\r
+ g_free (str);\r
+ return TRUE;\r
+}\r
+ \r
+static void print_caps (const GstCaps * caps, const gchar * pfx) {\r
+ guint i;\r
+ \r
+ g_return_if_fail (caps != NULL);\r
+ \r
+ if (gst_caps_is_any (caps)) {\r
+ g_print ("%sANY\n", pfx);\r
+ return;\r
+ }\r
+ if (gst_caps_is_empty (caps)) {\r
+ g_print ("%sEMPTY\n", pfx);\r
+ return;\r
+ }\r
+ \r
+ for (i = 0; i < gst_caps_get_size (caps); i++) {\r
+ GstStructure *structure = gst_caps_get_structure (caps, i);\r
+ \r
+ g_print ("%s%s\n", pfx, gst_structure_get_name (structure));\r
+ gst_structure_foreach (structure, print_field, (gpointer) pfx);\r
+ }\r
+}\r
+ \r
+/* Prints information about a Pad Template, including its Capabilities */\r
+static void print_pad_templates_information (GstElementFactory * factory) {\r
+ const GList *pads;\r
+ GstStaticPadTemplate *padtemplate;\r
+ \r
+ g_print ("Pad Templates for %s:\n", gst_element_factory_get_longname (factory));\r
+ if (!factory->numpadtemplates) {\r
+ g_print (" none\n");\r
+ return;\r
+ }\r
+ \r
+ pads = factory->staticpadtemplates;\r
+ while (pads) {\r
+ padtemplate = (GstStaticPadTemplate *) (pads->data);\r
+ pads = g_list_next (pads);\r
+ \r
+ if (padtemplate->direction == GST_PAD_SRC)\r
+ g_print (" SRC template: '%s'\n", padtemplate->name_template);\r
+ else if (padtemplate->direction == GST_PAD_SINK)\r
+ g_print (" SINK template: '%s'\n", padtemplate->name_template);\r
+ else\r
+ g_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template);\r
+ \r
+ if (padtemplate->presence == GST_PAD_ALWAYS)\r
+ g_print (" Availability: Always\n");\r
+ else if (padtemplate->presence == GST_PAD_SOMETIMES)\r
+ g_print (" Availability: Sometimes\n");\r
+ else if (padtemplate->presence == GST_PAD_REQUEST) {\r
+ g_print (" Availability: On request\n");\r
+ } else\r
+ g_print (" Availability: UNKNOWN!!!\n");\r
+ \r
+ if (padtemplate->static_caps.string) {\r
+ g_print (" Capabilities:\n");\r
+ print_caps (gst_static_caps_get (&padtemplate->static_caps), " ");\r
+ }\r
+ \r
+ g_print ("\n");\r
+ }\r
+}\r
+ \r
+/* Shows the CURRENT capabilities of the requested pad in the given element */\r
+static void print_pad_capabilities (GstElement *element, gchar *pad_name) {\r
+ GstPad *pad = NULL;\r
+ GstCaps *caps = NULL;\r
+ \r
+ /* Retrieve pad */\r
+ pad = gst_element_get_static_pad (element, pad_name);\r
+ if (!pad) {\r
+ g_printerr ("Could not retrieve pad '%s'\n", pad_name);\r
+ return;\r
+ }\r
+ \r
+ /* Retrieve negotiated caps (or acceptable caps if negotiation is not finished yet) */\r
+ caps = gst_pad_get_negotiated_caps (pad);\r
+ if (!caps)\r
+ caps = gst_pad_get_caps_reffed (pad);\r
+ \r
+ /* Print and free */\r
+ g_print ("Caps for the %s pad:\n", pad_name);\r
+ print_caps (caps, " ");\r
+ gst_caps_unref (caps);\r
+ gst_object_unref (pad);\r
+}\r
+ \r
+int main(int argc, char *argv[]) {\r
+ GstElement *pipeline, *source, *sink;\r
+ GstElementFactory *source_factory, *sink_factory;\r
+ GstBus *bus;\r
+ GstMessage *msg;\r
+ GstStateChangeReturn ret;\r
+ gboolean terminate = FALSE;\r
+ \r
+ /* Initialize GStreamer */\r
+ gst_init (&argc, &argv);\r
+ \r
+ /* Create the element factories */\r
+ source_factory = gst_element_factory_find ("audiotestsrc");\r
+ sink_factory = gst_element_factory_find ("autoaudiosink");\r
+ if (!source_factory || !sink_factory) {\r
+ g_printerr ("Not all element factories could be created.\n");\r
+ return -1;\r
+ }\r
+ \r
+ /* Print information about the pad templates of these factories */\r
+ print_pad_templates_information (source_factory);\r
+ print_pad_templates_information (sink_factory);\r
+ \r
+ /* Ask the factories to instantiate actual elements */\r
+ source = gst_element_factory_create (source_factory, "source");\r
+ sink = gst_element_factory_create (sink_factory, "sink");\r
+ \r
+ /* Create the empty pipeline */\r
+ pipeline = gst_pipeline_new ("test-pipeline");\r
+ \r
+ if (!pipeline || !source || !sink) {\r
+ g_printerr ("Not all elements could be created.\n");\r
+ return -1;\r
+ }\r
+ \r
+ /* Build the pipeline */\r
+ gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);\r
+ if (gst_element_link (source, sink) != TRUE) {\r
+ g_printerr ("Elements could not be linked.\n");\r
+ gst_object_unref (pipeline);\r
+ return -1;\r
+ }\r
+ \r
+ /* Print initial negotiated caps (in NULL state) */\r
+ g_print ("In NULL state:\n");\r
+ print_pad_capabilities (sink, "sink");\r
+ \r
+ /* Start playing */\r
+ ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);\r
+ if (ret == GST_STATE_CHANGE_FAILURE) {\r
+ g_printerr ("Unable to set the pipeline to the playing state (check the bus for error messages).\n");\r
+ }\r
+ \r
+ /* Wait until error, EOS or State Change */\r
+ bus = gst_element_get_bus (pipeline);\r
+ do {\r
+ msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS |\r
+ GST_MESSAGE_STATE_CHANGED);\r
+ \r
+ /* Parse message */\r
+ if (msg != NULL) {\r
+ GError *err;\r
+ gchar *debug_info;\r
+ \r
+ switch (GST_MESSAGE_TYPE (msg)) {\r
+ case GST_MESSAGE_ERROR:\r
+ gst_message_parse_error (msg, &err, &debug_info);\r
+ g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);\r
+ g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");\r
+ g_clear_error (&err);\r
+ g_free (debug_info);\r
+ terminate = TRUE;\r
+ break;\r
+ case GST_MESSAGE_EOS:\r
+ g_print ("End-Of-Stream reached.\n");\r
+ terminate = TRUE;\r
+ break;\r
+ case GST_MESSAGE_STATE_CHANGED:\r
+ /* We are only interested in state-changed messages from the pipeline */\r
+ if (GST_MESSAGE_SRC (msg) == GST_OBJECT (pipeline)) {\r
+ GstState old_state, new_state, pending_state;\r
+ gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state);\r
+ g_print ("\nPipeline state changed from %s to %s:\n",\r
+ gst_element_state_get_name (old_state), gst_element_state_get_name (new_state));\r
+ /* Print the current capabilities of the sink element */\r
+ print_pad_capabilities (sink, "sink");\r
+ }\r
+ break;\r
+ default:\r
+ /* We should not reach here because we only asked for ERRORs, EOS and STATE_CHANGED */\r
+ g_printerr ("Unexpected message received.\n");\r
+ break;\r
+ }\r
+ gst_message_unref (msg);\r
+ }\r
+ } while (!terminate);\r
+ \r
+ /* Free resources */\r
+ gst_object_unref (bus);\r
+ gst_element_set_state (pipeline, GST_STATE_NULL);\r
+ gst_object_unref (pipeline);\r
+ gst_object_unref (source_factory);\r
+ gst_object_unref (sink_factory);\r
+ return 0;\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <ItemGroup Label="ProjectConfigurations">\r
+ <ProjectConfiguration Include="Debug|Win32">\r
+ <Configuration>Debug</Configuration>\r
+ <Platform>Win32</Platform>\r
+ </ProjectConfiguration>\r
+ <ProjectConfiguration Include="Release|Win32">\r
+ <Configuration>Release</Configuration>\r
+ <Platform>Win32</Platform>\r
+ </ProjectConfiguration>\r
+ </ItemGroup>\r
+ <PropertyGroup Label="Globals">\r
+ <ProjectGuid>{A2A55F96-F759-4AF6-84EB-96ABD9D82410}</ProjectGuid>\r
+ <Keyword>Win32Proj</Keyword>\r
+ <RootNamespace>basictutorial6</RootNamespace>\r
+ </PropertyGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+ <ConfigurationType>Application</ConfigurationType>\r
+ <UseDebugLibraries>true</UseDebugLibraries>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+ <ConfigurationType>Application</ConfigurationType>\r
+ <UseDebugLibraries>false</UseDebugLibraries>\r
+ <WholeProgramOptimization>true</WholeProgramOptimization>\r
+ <CharacterSet>Unicode</CharacterSet>\r
+ </PropertyGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+ <ImportGroup Label="ExtensionSettings">\r
+ </ImportGroup>\r
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ <Import Project="..\..\libs\gstreamer-0.10.props" />\r
+ <Import Project="..\..\libs\msvc\x86.props" />\r
+ </ImportGroup>\r
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ <Import Project="..\..\libs\gstreamer-0.10.props" />\r
+ <Import Project="..\..\libs\msvc\x86.props" />\r
+ </ImportGroup>\r
+ <PropertyGroup Label="UserMacros" />\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <LinkIncremental>true</LinkIncremental>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <LinkIncremental>false</LinkIncremental>\r
+ </PropertyGroup>\r
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <ClCompile>\r
+ <PrecompiledHeader>\r
+ </PrecompiledHeader>\r
+ <WarningLevel>Level3</WarningLevel>\r
+ <Optimization>Disabled</Optimization>\r
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ </ClCompile>\r
+ <Link>\r
+ <SubSystem>Console</SubSystem>\r
+ <GenerateDebugInformation>true</GenerateDebugInformation>\r
+ </Link>\r
+ </ItemDefinitionGroup>\r
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <ClCompile>\r
+ <WarningLevel>Level3</WarningLevel>\r
+ <PrecompiledHeader>\r
+ </PrecompiledHeader>\r
+ <Optimization>MaxSpeed</Optimization>\r
+ <FunctionLevelLinking>true</FunctionLevelLinking>\r
+ <IntrinsicFunctions>true</IntrinsicFunctions>\r
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ </ClCompile>\r
+ <Link>\r
+ <SubSystem>Console</SubSystem>\r
+ <GenerateDebugInformation>true</GenerateDebugInformation>\r
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+ <OptimizeReferences>true</OptimizeReferences>\r
+ </Link>\r
+ </ItemDefinitionGroup>\r
+ <ItemGroup>\r
+ <ClCompile Include="..\..\..\..\gst-sdk\tutorials\basic-tutorial-6.c" />\r
+ </ItemGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+ <ImportGroup Label="ExtensionTargets">\r
+ </ImportGroup>\r
+</Project>
\ No newline at end of file