mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
Added playback-tutorial-6.
This commit is contained in:
parent
989e16d366
commit
9e05d50a5f
4 changed files with 195 additions and 0 deletions
84
gst-sdk/tutorials/playback-tutorial-6.c
Normal file
84
gst-sdk/tutorials/playback-tutorial-6.c
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
/* playbin2 flags */
|
||||||
|
typedef enum {
|
||||||
|
GST_PLAY_FLAG_VIS = (1 << 3) /* Enable rendering of visualisations when there is no video stream. */
|
||||||
|
} GstPlayFlags;
|
||||||
|
|
||||||
|
/* Return TRUE if this is a Visualization element */
|
||||||
|
static gboolean filter_vis_features (GstPluginFeature *feature, gpointer data) {
|
||||||
|
GstElementFactory *factory;
|
||||||
|
|
||||||
|
if (!GST_IS_ELEMENT_FACTORY (feature))
|
||||||
|
return FALSE;
|
||||||
|
factory = GST_ELEMENT_FACTORY (feature);
|
||||||
|
if (!g_strrstr (gst_element_factory_get_klass (factory), "Visualization"))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
GstElement *pipeline, *vis_plugin;
|
||||||
|
GstBus *bus;
|
||||||
|
GstMessage *msg;
|
||||||
|
GList *list, *walk;
|
||||||
|
GstElementFactory *factory = NULL;
|
||||||
|
guint flags;
|
||||||
|
|
||||||
|
/* Initialize GStreamer */
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
/* Get a list of all visualization plugins */
|
||||||
|
list = gst_registry_feature_filter (gst_registry_get_default (), filter_vis_features, FALSE, NULL);
|
||||||
|
|
||||||
|
/* Print their names */
|
||||||
|
g_print("Available visualization plugins:\n");
|
||||||
|
for (walk = list; walk != NULL; walk = g_list_next (walk)) {
|
||||||
|
const gchar *name;
|
||||||
|
|
||||||
|
factory = GST_ELEMENT_FACTORY (walk->data);
|
||||||
|
name = gst_element_factory_get_longname (factory);
|
||||||
|
|
||||||
|
g_print(" %s\n", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Don't use the factory if it's still empty */
|
||||||
|
/* e.g. no visualization plugins found */
|
||||||
|
if (!factory) {
|
||||||
|
g_print ("No visualization plugins found!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We now have factory pointing to the last Visualization plugin found */
|
||||||
|
vis_plugin = gst_element_factory_create (factory, NULL);
|
||||||
|
if (!vis_plugin)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Build the pipeline */
|
||||||
|
pipeline = gst_parse_launch ("playbin2 uri=http://radio.goha.ru:8000/grindfm.ogg", NULL);
|
||||||
|
|
||||||
|
/* Set the visualization flag */
|
||||||
|
g_object_get (pipeline, "flags", &flags, NULL);
|
||||||
|
flags |= GST_PLAY_FLAG_VIS;
|
||||||
|
g_object_set (pipeline, "flags", flags, NULL);
|
||||||
|
|
||||||
|
/* set vis plugin for playbin2 */
|
||||||
|
g_object_set (pipeline, "vis-plugin", vis_plugin, NULL);
|
||||||
|
|
||||||
|
/* Start playing */
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
|
||||||
|
/* Wait until error or EOS */
|
||||||
|
bus = gst_element_get_bus (pipeline);
|
||||||
|
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
|
||||||
|
|
||||||
|
/* Free resources */
|
||||||
|
if (msg != NULL)
|
||||||
|
gst_message_unref (msg);
|
||||||
|
gst_plugin_feature_list_free (list);
|
||||||
|
gst_object_unref (bus);
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
gst_object_unref (pipeline);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\playback-tutorial-6.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}</ProjectGuid>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Platform)'=='Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(GSTREAMER_SDK_ROOT_X86)\share\vs\2010\libs\gstreamer-0.10.props" Condition="exists('$(GSTREAMER_SDK_ROOT_X86)\share\vs\2010\libs\gstreamer-0.10.props')" />
|
||||||
|
<Import Project="$(GSTREAMER_SDK_ROOT_X86)\share\vs\2010\msvc\x86.props" Condition="exists('$(GSTREAMER_SDK_ROOT_X86)\share\vs\2010\msvc\x86.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Platform)'=='x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(GSTREAMER_SDK_ROOT_X86_64)\share\vs\2010\libs\gstreamer-0.10.props" Condition="exists('$(GSTREAMER_SDK_ROOT_X86_64)\share\vs\2010\libs\gstreamer-0.10.props')" />
|
||||||
|
<Import Project="$(GSTREAMER_SDK_ROOT_X86_64)\share\vs\2010\msvc\x86_64.props" Condition="exists('$(GSTREAMER_SDK_ROOT_X86_64)\share\vs\2010\msvc\x86_64.props')" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\playback-tutorial-6.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -31,6 +31,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "playback-tutorial-3", "play
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "playback-tutorial-5", "playback-tutorial-5\playback-tutorial-5.vcxproj", "{57F94395-E9A1-430E-AF28-165FD9BE0872}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "playback-tutorial-5", "playback-tutorial-5\playback-tutorial-5.vcxproj", "{57F94395-E9A1-430E-AF28-165FD9BE0872}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "playback-tutorial-6", "playback-tutorial-6\playback-tutorial-6.vcxproj", "{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
|
@ -159,6 +161,14 @@ Global
|
||||||
{57F94395-E9A1-430E-AF28-165FD9BE0872}.Release|Win32.Build.0 = Release|Win32
|
{57F94395-E9A1-430E-AF28-165FD9BE0872}.Release|Win32.Build.0 = Release|Win32
|
||||||
{57F94395-E9A1-430E-AF28-165FD9BE0872}.Release|x64.ActiveCfg = Release|x64
|
{57F94395-E9A1-430E-AF28-165FD9BE0872}.Release|x64.ActiveCfg = Release|x64
|
||||||
{57F94395-E9A1-430E-AF28-165FD9BE0872}.Release|x64.Build.0 = Release|x64
|
{57F94395-E9A1-430E-AF28-165FD9BE0872}.Release|x64.Build.0 = Release|x64
|
||||||
|
{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{D6293AFD-41DA-44B6-AE57-F1EEE74338AC}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
Loading…
Reference in a new issue