Debian Codegraph @

examples/typefind/main.cc

raw symbols SCIP
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2009 The gstreamermm Development Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 #include <gstreamermm.h>cxx . . $ `<file>/gstreamer/gstreamermm.h`/
20 #include <glibmm/main.h>
21 #include <glibmm/exceptionhandler.h>
22 #include <iostream>
23
24 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Glibcxx . . $ Glib/::MainLoopcxx . . $ Glib/MainLoop#> mainloopcxx . . $ mainloop.;
25 bool have_typecxx . . $ have_type. = false;
26
27 static bool on_structure_foreachcxx . . $ on_structure_foreach(4ffcc159750c0a6).(const Glibcxx . . $ Glib/::QueryQuarkcxx . . $ Glib/QueryQuark#& id, const Glibcxx . . $ Glib/::ValueBasecxx . . $ Glib/ValueBase#& value)
28 {
29 const Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring# str_idcxx . . $ Glib/ustring#ustring(9ff8f5cb794dfdbf). = id;
30 gchar* str_value = g_strdup_value_contents(value.gobjcxx . . $ Glib/ValueBase#gobj(2653be92411ed030).());
31 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Structure field: id=" <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). str_id <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ", value=" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). str_value <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
32 g_free(str_value);
33
34 return true;
35 }
36
37 static void on_typefind_have_typecxx . . $ on_typefind_have_type(9937f6758da92a73).(guint probability, const Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Capscxx . . $ Gst/Caps#>& caps)
38 {
39 have_typecxx . . $ have_type. = true;
40
41 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "have-type: probability=" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). probability <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
42
43 if(!caps)
44 {
45 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "on_typefind_have_type(): caps is null" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
46 return;
47 }
48
49 if(!caps->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).sizecxx . . $ Gst/Caps#size(ddd8539a2fcdd4ce).())
50 {
51 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "on_typefind_have_type(): caps is empty" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
52 return;
53 }
54
55 Gstcxx . . $ Gst/::Structurecxx . . $ Gst/Structure# structure = capscxx . . $ Gst/Structure#Structure(d8c6d4e94c9eb7a4).->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_structurecxx . . $ Gst/Caps#get_structure(1c73294166a8b10b).(0);
56 const Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring# mime_type = structurecxx . . $ Glib/ustring#ustring(9ff8f5cb794dfdbf)..get_namecxx . . $ Gst/Structure#get_name(fff0f585954e56f3).();
57 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "have-type: mime_type=" <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). mime_type <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
58
59 structure.foreachcxx . . $ Gst/Structure#foreach(ef3ca79e6c36fc0b).( sigccxx . . $ sigc/slot#slot(edcd8b2679e9bd1a).::ptr_funcxx . . $ sigc/ptr_fun(1a86a404afb7766).(&on_structure_foreachcxx . . $ on_structure_foreach(4ffcc159750c0a6).) );
60
61 if(mainloopcxx . . $ mainloop.)
62 mainloopcxx . . $ mainloop.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).quitcxx . . $ Glib/MainLoop#quit(49f6e7a06ebc5aa8).();
63 else
64 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "on_typefind_have_type(): mainloop is null" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
65 }
66
67 #ifdef GSTREAMERMM_DISABLE_DEPRECATED
68
69 #include <gst/gsttypefind.h>
70
71 static void TypeFindElement_signal_have_type_callback(struct _GstTypeFindElement* self, guint p0,GstCaps* p1,void* data)
72 {
73 using SlotType = sigc::slot< void,guint,const Glib::RefPtr<Gst::Caps>& >;
74
75 auto obj = dynamic_cast<Gst::Element*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
76 if(obj)
77 {
78 try
79 {
80 if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
81 (*static_cast<SlotType*>(slot))(p0, Glib::wrap(p1, true));
82 }
83 catch(...)
84 {
85 Glib::exception_handlers_invoke();
86 }
87 }
88 }
89
90
91 static const Glib::SignalProxyInfo TypeFindElement_signal_have_type_info =
92 {
93 "have-type",
94 (GCallback) &TypeFindElement_signal_have_type_callback,
95 (GCallback) &TypeFindElement_signal_have_type_callback
96 };
97 #endif
98
99 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char** argv)
100 {
101 // Initialize Gstreamermm:
102 Gstcxx . . $ Gst/::initcxx . . $ Gst/init(22930d6ef54703eb).(argc, argv);
103
104 //Check input arguments:
105 if(argc < 2)
106 {
107 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Usage: " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). argv[0] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " <filename>" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
108 return 1;
109 }
110
111 const stdcxx . . $ std/::stringcxx . . $ std/string# filenamecxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f). = argvcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).[1];
112
113 // Create pipeline:
114 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Pipelinecxx . . $ Gst/Pipeline#> pipeline = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::Pipelinecxx . . $ Gst/Pipeline#::createcxx . . $ Gst/Pipeline#create(4db98da4abd65927).("my-pipeline"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
115
116 // Create elements:
117 #ifndef GSTREAMERMM_DISABLE_DEPRECATED
118 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::FileSrccxx . . $ Gst/FileSrc#> element_source = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::FileSrccxx . . $ Gst/FileSrc#::createcxx . . $ Gst/FileSrc#create(c38e35eb3f591174).();
119 element_source->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).property_locationcxx . . $ Gst/FileSrc#property_location(ee255b09b2ef680a).() =cxx . . $ Glib/PropertyProxy#`operator=`(96d6f65396a143d8). filenamecxx . . $ Glib/ustring#ustring(9c546c94e5fcce4e).;
120 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::FakeSinkcxx . . $ Gst/FakeSink#> element_sink = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::FakeSinkcxx . . $ Gst/FakeSink#::createcxx . . $ Gst/FakeSink#create(fe9d6d7d604dde37).();
121 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::TypeFindElementcxx . . $ Gst/TypeFindElement#> element_typefind = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::TypeFindElementcxx . . $ Gst/TypeFindElement#::createcxx . . $ Gst/TypeFindElement#create(97edd473e190b9a0).();
122 element_typefind->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).signal_have_typecxx . . $ Gst/TypeFindElement#signal_have_type(e34c12719eac8017).().connectcxx . . $ Glib/SignalProxy#connect(23e07d4a2c0735e0).(
123 sigccxx . . $ sigc/slot#slot(edcd8b2679e9bd1a).::ptr_funcxx . . $ sigc/ptr_fun(1a86a404afb7766).(&on_typefind_have_typecxx . . $ on_typefind_have_type(9937f6758da92a73).) );
124
125 #else
126 Glib::RefPtr<Gst::Element> element_source = Gst::ElementFactory::create_element("filesrc");
127 element_source->set_property("location", filename);
128 Glib::RefPtr<Gst::Element> element_sink = Gst::ElementFactory::create_element("fakesink");
129 Glib::RefPtr<Gst::Element> element_typefind = Gst::ElementFactory::create_element("typefind");
130
131 Glib::SignalProxy< void,guint,const Glib::RefPtr<Gst::Caps>& > proxy(element_typefind.operator->(), &TypeFindElement_signal_have_type_info);
132 proxy.connect(sigc::ptr_fun(&on_typefind_have_type));
133 #endif
134
135 //If using an MP3 file, this should provide more Caps information from typefind.
136 //Glib::RefPtr<Gst::Element> element_id3demux = Gst::ElementFactory::create_element("id3demux");
137 //g_assert(element_id3demux);
138
139 // We must add the elements to the pipeline before linking them:
140 try
141 {
142 pipeline->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(element_sourcecxx . . $ Glib/RefPtr#RefPtr(11a1ac667024f826).)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(element_typefindcxx . . $ Glib/RefPtr#RefPtr(11a1ac667024f826).)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(element_sinkcxx . . $ Glib/RefPtr#RefPtr(11a1ac667024f826).);
143 //pipeline->add(element_source)->add(element_id3demux)->add(element_typefind)->add(element_sink);
144 }
145 catch (stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#& ex)
146 {
147 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Exception while adding: " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ex.whatcxx . . $ std/runtime_error#what(a9f41ea0e82d88cf).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
148 return 1;
149 }
150
151 // Link the elements together:
152 try
153 {
154 //element_source->link(element_id3demux)->link(element_typefind)->link(element_sink);
155 element_source->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(element_typefindcxx . . $ Glib/RefPtr#RefPtr(11a1ac667024f826).)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(element_sinkcxx . . $ Glib/RefPtr#RefPtr(11a1ac667024f826).);
156 }
157 catch(const stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#& error)
158 {
159 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Exception while linking: " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). error.whatcxx . . $ std/runtime_error#what(a9f41ea0e82d88cf).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
160 return 1;
161 }
162
163 // Now set the whole pipeline to playing and start the main loop:
164 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Setting pipeline to PLAYING." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
165 mainloopcxx . . $ mainloop. =cxx . . $ Glib/RefPtr#`operator=`(b66de19e2ab7ce1f). Glibcxx . . $ Glib/::MainLoopcxx . . $ Glib/MainLoop#::createcxx . . $ Glib/MainLoop#create(748caac81bf5da26).();
166 pipeline->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).set_statecxx . . $ Gst/Element#set_state(17bf573d41f9253f).(Gstcxx . . $ Gst/::STATE_PLAYINGcxx . . $ Gst/STATE_PLAYING.);
167 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Pipeline is playing." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
168 if(!have_typecxx . . $ have_type.)
169 mainloopcxx . . $ mainloop.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).runcxx . . $ Glib/MainLoop#run(49f6e7a06ebc5aa8).();
170
171 // Clean up nicely:
172 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Returned. Stopping pipeline." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
173 pipeline->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).set_statecxx . . $ Gst/Element#set_state(17bf573d41f9253f).(Gstcxx . . $ Gst/::STATE_NULLcxx . . $ Gst/STATE_NULL.);
174
175 return 0;
176 }