mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-07 23:12:42 +00:00
Added basic tutorial 7
This commit is contained in:
parent
5e2462c9ae
commit
2c2daae387
4 changed files with 185 additions and 0 deletions
87
gst-sdk/tutorials/basic-tutorial-7.c
Normal file
87
gst-sdk/tutorials/basic-tutorial-7.c
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
GstElement *pipeline, *audio_source, *tee, *audio_queue, *audio_convert, *audio_sink;
|
||||||
|
GstElement *video_queue, *visual, *video_convert, *video_sink;
|
||||||
|
GstBus *bus;
|
||||||
|
GstMessage *msg;
|
||||||
|
GstPadTemplate *tee_src_pad_template;
|
||||||
|
GstPad *tee_audio_pad, *tee_video_pad;
|
||||||
|
GstPad *queue_audio_pad, *queue_video_pad;
|
||||||
|
|
||||||
|
/* Initialize GStreamer */
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
/* Create the elements */
|
||||||
|
audio_source = gst_element_factory_make ("audiotestsrc", "audio_source");
|
||||||
|
tee = gst_element_factory_make ("tee", "tee");
|
||||||
|
audio_queue = gst_element_factory_make ("queue", "audio_queue");
|
||||||
|
audio_convert = gst_element_factory_make ("audioconvert", "audio_convert");
|
||||||
|
audio_sink = gst_element_factory_make ("autoaudiosink", "audio_sink");
|
||||||
|
video_queue = gst_element_factory_make ("queue", "video_queue");
|
||||||
|
visual = gst_element_factory_make ("wavescope", "visual");
|
||||||
|
video_convert = gst_element_factory_make ("ffmpegcolorspace", "csp");
|
||||||
|
video_sink = gst_element_factory_make ("autovideosink", "video_sink");
|
||||||
|
|
||||||
|
/* Create the empty pipeline */
|
||||||
|
pipeline = gst_pipeline_new ("test-pipeline");
|
||||||
|
|
||||||
|
if (!pipeline || !audio_source || !tee || !audio_queue || !audio_convert || !audio_sink ||
|
||||||
|
!video_queue || !visual || !video_convert || !video_sink) {
|
||||||
|
g_printerr ("Not all elements could be created.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Configure elements */
|
||||||
|
g_object_set (visual, "shader", 0, NULL);
|
||||||
|
|
||||||
|
/* Link all elements that can be automatically linked because they have "Always" pads */
|
||||||
|
gst_bin_add_many (GST_BIN (pipeline), audio_source, tee, audio_queue, audio_convert, audio_sink,
|
||||||
|
video_queue, visual, video_convert, video_sink, NULL);
|
||||||
|
if (gst_element_link_many (audio_source, tee, NULL) != TRUE ||
|
||||||
|
gst_element_link_many (audio_queue, audio_convert, audio_sink, NULL) != TRUE ||
|
||||||
|
gst_element_link_many (video_queue, visual, video_convert, video_sink, NULL) != TRUE) {
|
||||||
|
g_printerr ("Elements could not be linked.\n");
|
||||||
|
gst_object_unref (pipeline);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Manually link the Tee, which has "Request" pads */
|
||||||
|
tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (tee), "src%d");
|
||||||
|
tee_audio_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
|
||||||
|
g_print ("Obtained request pad %s for audio branch.\n", gst_pad_get_name (tee_audio_pad));
|
||||||
|
queue_audio_pad = gst_element_get_static_pad (audio_queue, "sink");
|
||||||
|
tee_video_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
|
||||||
|
g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name (tee_video_pad));
|
||||||
|
queue_video_pad = gst_element_get_static_pad (video_queue, "sink");
|
||||||
|
if (gst_pad_link (tee_audio_pad, queue_audio_pad) != GST_PAD_LINK_OK ||
|
||||||
|
gst_pad_link (tee_video_pad, queue_video_pad) != GST_PAD_LINK_OK) {
|
||||||
|
g_printerr ("Tee could not be linked.\n");
|
||||||
|
gst_object_unref (pipeline);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
gst_object_unref (queue_audio_pad);
|
||||||
|
gst_object_unref (queue_video_pad);
|
||||||
|
|
||||||
|
/* Start playing the pipeline */
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* Release the request pads from the Tee, and unref them */
|
||||||
|
gst_element_release_request_pad (tee, tee_audio_pad);
|
||||||
|
gst_element_release_request_pad (tee, tee_video_pad);
|
||||||
|
gst_object_unref (tee_audio_pad);
|
||||||
|
gst_object_unref (tee_video_pad);
|
||||||
|
|
||||||
|
/* Free resources */
|
||||||
|
if (msg != NULL)
|
||||||
|
gst_message_unref (msg);
|
||||||
|
gst_object_unref (bus);
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
|
||||||
|
gst_object_unref (pipeline);
|
||||||
|
return 0;
|
||||||
|
}
|
86
vs/2010/tutorials/basic-tutorial-7/basic-tutorial-7.vcxproj
Normal file
86
vs/2010/tutorials/basic-tutorial-7/basic-tutorial-7.vcxproj
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
<?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="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{B1666543-AE05-46BF-9528-95916A02A9D4}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>basictutorial7</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" 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="'$(Configuration)|$(Platform)'=='Debug|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" />
|
||||||
|
<Import Project="$(GSTREAMER_SDK_ROOT_X86)\share\vs\2010\msvc\x86.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|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" />
|
||||||
|
<Import Project="$(GSTREAMER_SDK_ROOT_X86)\share\vs\2010\msvc\x86.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<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>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\..\gst-sdk\tutorials\basic-tutorial-7.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<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="..\..\..\..\gst-sdk\tutorials\basic-tutorial-7.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "playback-tutorial-2", "play
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-tutorial-6", "basic-tutorial-6\basic-tutorial-6.vcxproj", "{A2A55F96-F759-4AF6-84EB-96ABD9D82410}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-tutorial-6", "basic-tutorial-6\basic-tutorial-6.vcxproj", "{A2A55F96-F759-4AF6-84EB-96ABD9D82410}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-tutorial-7", "basic-tutorial-7\basic-tutorial-7.vcxproj", "{B1666543-AE05-46BF-9528-95916A02A9D4}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
|
@ -55,6 +57,10 @@ Global
|
||||||
{A2A55F96-F759-4AF6-84EB-96ABD9D82410}.Debug|Win32.Build.0 = Debug|Win32
|
{A2A55F96-F759-4AF6-84EB-96ABD9D82410}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{A2A55F96-F759-4AF6-84EB-96ABD9D82410}.Release|Win32.ActiveCfg = Release|Win32
|
{A2A55F96-F759-4AF6-84EB-96ABD9D82410}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{A2A55F96-F759-4AF6-84EB-96ABD9D82410}.Release|Win32.Build.0 = Release|Win32
|
{A2A55F96-F759-4AF6-84EB-96ABD9D82410}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{B1666543-AE05-46BF-9528-95916A02A9D4}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{B1666543-AE05-46BF-9528-95916A02A9D4}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{B1666543-AE05-46BF-9528-95916A02A9D4}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{B1666543-AE05-46BF-9528-95916A02A9D4}.Release|Win32.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
Loading…
Reference in a new issue