Debian Codegraph @

examples/ogg_player/main.cc

raw symbols SCIP
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2008 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 <iostream>
22 #include <iomanip>
23
24 namespacecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/
25 {
26
27 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Glibcxx . . $ Glib/::MainLoopcxx . . $ Glib/MainLoop#> mainloopcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/mainloop.;
28 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Pipelinecxx . . $ Gst/Pipeline#> pipelinecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/pipeline.;
29 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#> decodercxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/decoder.;
30 gulong data_probe_idcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/data_probe_id. = 0;
31
32 bool on_timeoutcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/on_timeout(c9857a73d68e59ba).()
33 {
34 Gstcxx . . $ Gst/::Formatcxx . . $ Gst/Format# fmt = Gstcxx . . $ Gst/::FORMAT_TIMEcxx . . $ Gst/FORMAT_TIME.;
35 gint64 pos = 0;
36 gint64 len = 0;
37
38 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Querycxx . . $ Gst/Query#> querycxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439). = Gstcxx . . $ Glib/RefPtr#RefPtr(5d20f00e530d62cc).::QueryPositioncxx . . $ Gst/QueryPosition#::createcxx . . $ Gst/QueryPosition#create(468db319d6979253).(fmt);
39
40 if(pipelinecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/pipeline.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).querycxx . . $ Gst/Element#query(49f3f197415ffc07).(query)
41 && pipelinecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/pipeline.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).query_durationcxx . . $ Gst/Element#query_duration(8ddfbfb863f611fe).(fmt, len))
42 {
43 // Cast query's RefPtr to RefPtr<Gst::QueryPosition> to parse the
44 // pipeline's position query with the Gst::QueryPosition::parse() method
45 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::QueryPositioncxx . . $ Gst/QueryPosition#> query_pos =
46 Glibcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::RefPtrcxx . . $ Glib/RefPtr#<Gst::QueryPosition>::cast_staticcxx . . $ Glib/RefPtr#cast_static(c0896b3c286bd779).(query);
47 if(query_pos)
48 pos = query_pos->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).parsecxx . . $ Gst/QueryPosition#parse(57a65ae535d7db84).();
49
50 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/basic_ostream#`operator<<`(d90e0e305b0e25c2). stdcxx . . $ std/::rightcxx . . $ std/right(cf36cc481190cd1f). <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Time: " <<cxx . . $ std/`operator<<`(47f1cf32aeb3f1a2). stdcxx . . $ std/::setfillcxx . . $ std/setfill(ade351e831a1374a).('0') <<cxx . . $ std/`operator<<`(fe9a269018418773).
51 stdcxx . . $ std/::setwcxx . . $ std/setw(f06ce2e9220601fb).(3) <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Gstcxx . . $ Gst/::get_hourscxx . . $ Gst/get_hours(ea88b852781e8a38).(pos) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ":" <<cxx . . $ std/`operator<<`(fe9a269018418773).
52 stdcxx . . $ std/::setwcxx . . $ std/setw(f06ce2e9220601fb).(2) <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Gstcxx . . $ Gst/::get_minutescxx . . $ Gst/get_minutes(ea88b852781e8a38).(pos) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ":" <<cxx . . $ std/`operator<<`(fe9a269018418773).
53 stdcxx . . $ std/::setwcxx . . $ std/setw(f06ce2e9220601fb).(2) <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Gstcxx . . $ Gst/::get_secondscxx . . $ Gst/get_seconds(ea88b852781e8a38).(pos) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "." <<cxx . . $ std/`operator<<`(fe9a269018418773).
54 stdcxx . . $ std/::setwcxx . . $ std/setw(f06ce2e9220601fb).(9) <<cxx . . $ std/basic_ostream#`operator<<`(d90e0e305b0e25c2). stdcxx . . $ std/::leftcxx . . $ std/left(cf36cc481190cd1f). <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Gstcxx . . $ Gst/::get_fractional_secondscxx . . $ Gst/get_fractional_seconds(ea88b852781e8a38).(pos);
55
56 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/basic_ostream#`operator<<`(d90e0e305b0e25c2). stdcxx . . $ std/::rightcxx . . $ std/right(cf36cc481190cd1f). <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "/" <<cxx . . $ std/`operator<<`(fe9a269018418773).
57 stdcxx . . $ std/::setwcxx . . $ std/setw(f06ce2e9220601fb).(3) <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Gstcxx . . $ Gst/::get_hourscxx . . $ Gst/get_hours(ea88b852781e8a38).(len) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ":" <<cxx . . $ std/`operator<<`(fe9a269018418773).
58 stdcxx . . $ std/::setwcxx . . $ std/setw(f06ce2e9220601fb).(2) <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Gstcxx . . $ Gst/::get_minutescxx . . $ Gst/get_minutes(ea88b852781e8a38).(len) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ":" <<cxx . . $ std/`operator<<`(fe9a269018418773).
59 stdcxx . . $ std/::setwcxx . . $ std/setw(f06ce2e9220601fb).(2) <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Gstcxx . . $ Gst/::get_secondscxx . . $ Gst/get_seconds(ea88b852781e8a38).(len) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "." <<cxx . . $ std/`operator<<`(fe9a269018418773).
60 stdcxx . . $ std/::setwcxx . . $ std/setw(f06ce2e9220601fb).(9) <<cxx . . $ std/basic_ostream#`operator<<`(d90e0e305b0e25c2). stdcxx . . $ std/::leftcxx . . $ std/left(cf36cc481190cd1f). <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). Gstcxx . . $ Gst/::get_fractional_secondscxx . . $ Gst/get_fractional_seconds(ea88b852781e8a38).(len) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a).
61 stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9). <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::flushcxx . . $ std/flush(345bf97a19cc83a9).;
62 }
63
64 return true;
65 }
66
67 // This function is used to receive asynchronous messages in the main loop.
68 bool on_bus_messagecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/on_bus_message(f80753751e77bf04).(const Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Buscxx . . $ Gst/Bus#>& /* bus */, const Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Messagecxx . . $ Gst/Message#>& message)
69 {
70 switch(message->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_message_typecxx . . $ Gst/Message#get_message_type(97914d44a9bd21bb).()) {
71 case Gstcxx . . $ Gst/::MESSAGE_EOScxx . . $ Gst/MESSAGE_EOS.:
72 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9). <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "End of stream" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
73 mainloopcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/mainloop.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).quitcxx . . $ Glib/MainLoop#quit(49f6e7a06ebc5aa8).();
74 return false;
75 case Gstcxx . . $ Gst/::MESSAGE_ERRORcxx . . $ Gst/MESSAGE_ERROR.:
76 {
77 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::MessageErrorcxx . . $ Gst/MessageError#> msgError = Glibcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::RefPtrcxx . . $ Glib/RefPtr#<Gst::MessageError>::cast_staticcxx . . $ Glib/RefPtr#cast_static(18212fa50966cf79).(message);
78 if(msgError)
79 {
80 Glibcxx . . $ Glib/::Errorcxx . . $ Glib/Error# errcxx . . $ Glib/Error#Error(49f6e7a06ebc5aa8).;
81 err =cxx . . $ Glib/Error#`operator=`(43eb97e7ea8857bc). msgError->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).parse_errorcxx . . $ Gst/MessageError#parse_error(565d2be64918d679).();
82 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Error: " <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). err.whatcxx . . $ Glib/Error#what(fff0f585954e56f3).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
83 }
84 else
85 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Error." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
86
87 mainloopcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/mainloop.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).quitcxx . . $ Glib/MainLoop#quit(49f6e7a06ebc5aa8).();
88 return false;
89 }
90 default:
91 {
92 //std::cout << "debug: on_bus_message: unhandled message=" << G_OBJECT_TYPE_NAME(message->gobj()) << std::endl;
93 }
94 break;
95 }
96
97 return true;
98 }
99
100 void on_parser_pad_addedcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/on_parser_pad_added(6d8541f3277dd441).(const Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Padcxx . . $ Gst/Pad#>& newPad)
101 {
102 // We can now link this pad with the audio decoder
103 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Dynamic pad created. Linking parser/decoder." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
104 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Padcxx . . $ Gst/Pad#> sinkPad = decodercxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_static_padcxx . . $ Gst/Element#get_static_pad(d41a58e7b5052139).("sink"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
105 Gstcxx . . $ Gst/::PadLinkReturncxx . . $ Gst/PadLinkReturn# ret = newPad->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Pad#link(ca9408873a0c7209).(sinkPad);
106
107 if (ret != Gstcxx . . $ Gst/::PAD_LINK_OKcxx . . $ Gst/PAD_LINK_OK. && ret != Gstcxx . . $ Gst/::PAD_LINK_WAS_LINKEDcxx . . $ Gst/PAD_LINK_WAS_LINKED.)
108 {
109 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Linking of pads " <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). newPad->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_namecxx . . $ Gst/Object#get_name(fff0f585954e56f3).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " and " <<cxx . . $ Glib/`operator<<`(d3a65685b7328161).
110 sinkPad->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_namecxx . . $ Gst/Object#get_name(fff0f585954e56f3).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " failed." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
111 }
112 }
113
114 Gstcxx . . $ Gst/::PadProbeReturncxx . . $ Gst/PadProbeReturn# on_sink_pad_have_datacxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/on_sink_pad_have_data(8c6c12be51149d36).(const Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Padcxx . . $ Gst/Pad#>& pad, const Gstcxx . . $ Gst/::PadProbeInfocxx . . $ Gst/PadProbeInfo#&)
115 {
116 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Sink pad '" <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). pad->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_namecxx . . $ Gst/Object#get_name(fff0f585954e56f3).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "' has received data;";
117 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " will now remove sink data probe id: " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). data_probe_idcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/data_probe_id. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
118 pad->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).remove_probecxx . . $ Gst/Pad#remove_probe(2c44cd906ae4e829).(data_probe_idcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/data_probe_id.);
119 return Gstcxx . . $ Gst/::PAD_PROBE_OKcxx . . $ Gst/PAD_PROBE_OK.;
120 }
121
122 } // anonymous namespace
123
124 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char** argv)
125 {
126 // Initialize Gstreamermm:
127 Gstcxx . . $ Gst/::initcxx . . $ Gst/init(22930d6ef54703eb).(argc, argv);
128
129 // Check input arguments:
130 if(argc < 2)
131 {
132 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Usage: " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). argv[0] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " <Ogg/Vorbis filename>" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
133 return 1;
134 }
135
136 const stdcxx . . $ std/::stringcxx . . $ std/string# filenamecxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f). = argvcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).[1];
137
138 mainloopcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/mainloop. =cxx . . $ Glib/RefPtr#`operator=`(b66de19e2ab7ce1f). Glibcxx . . $ Glib/::MainLoopcxx . . $ Glib/MainLoop#::createcxx . . $ Glib/MainLoop#create(748caac81bf5da26).();
139
140 // Create the pipeline:
141 pipelinecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/pipeline. =cxx . . $ Glib/RefPtr#`operator=`(b66de19e2ab7ce1f). Gstcxx . . $ Gst/::Pipelinecxx . . $ Gst/Pipeline#::createcxx . . $ Gst/Pipeline#create(4db98da4abd65927).("audio-player"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
142
143 // Create the elements:
144
145 // filsrc reads the file from disk:
146 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#> source = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("filesrc"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
147 if(!source)
148 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "filesrc element could not be created." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
149
150 // oggdemux parses the ogg streams into elementary streams (audio and video):
151 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#> parser = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("oggdemux"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
152 if(!parser)
153 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "oggdemux element could not be created." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
154
155 // vorbisdec decodes a vorbis (audio) stream:
156 decodercxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/decoder. =cxx . . $ Glib/RefPtr#`operator=`(b66de19e2ab7ce1f). Gstcxx . . $ Gst/::ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("vorbisdec"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
157 if(!decodercxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/decoder.)
158 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "vorbisdec element could not be created." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
159
160 // audioconvert converts raw audio to a format which can be used by the next element
161 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#> conv = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("audioconvert"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
162 if(!conv)
163 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "audioconvert element could not be created." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
164
165 // Outputs sound to an ALSA audio device
166 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#> sink = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("alsasink"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
167 if(!sink)
168 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "alsasink element could not be created." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
169
170 //Check that the elements were created:
171 if(!pipelinecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/pipeline. || !source || !parser || !decodercxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/decoder. || !conv || !sink)
172 {
173 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "One element could not be created" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
174 return 1;
175 }
176
177 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Padcxx . . $ Gst/Pad#> pad = sinkcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_static_padcxx . . $ Gst/Element#get_static_pad(d41a58e7b5052139).("sink"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
178 if(pad)
179 data_probe_idcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/data_probe_id. = pad->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).add_probecxx . . $ Gst/Pad#add_probe(ae80ce1fbdc3b914).(Gstcxx . . $ Gst/::PAD_PROBE_TYPE_DATA_DOWNSTREAMcxx . . $ Gst/PAD_PROBE_TYPE_DATA_DOWNSTREAM., sigccxx . . $ sigc/slot#slot(edcd8b2679e9bd1a).::ptr_funcxx . . $ sigc/ptr_fun(1a86a404afb7766).(&on_sink_pad_have_datacxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/on_sink_pad_have_data(8c6c12be51149d36).));
180
181 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "sink data probe id = " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). data_probe_idcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/data_probe_id. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
182
183 source->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).set_propertycxx . . $ Glib/ObjectBase#set_property(29831774a8731cb).("location"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9)., filename);
184
185 // Get the bus from the pipeline,
186 // and add a bus watch to the default main context with the default priority:
187 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Buscxx . . $ Gst/Bus#> bus = pipelinecxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_buscxx . . $ Gst/Pipeline#get_bus(ada66d6ded80d30d).();
188 bus->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).add_watchcxx . . $ Gst/Bus#add_watch(125cf56d22b1e63d).( sigccxx . . $ sigc/slot#slot(edcd8b2679e9bd1a).::ptr_funcxx . . $ sigc/ptr_fun(1a86a404afb7766).(&on_bus_messagecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/on_bus_message(f80753751e77bf04).) );
189
190
191 // Put all the elements in a pipeline:
192 try
193 {
194 pipelinecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/pipeline.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(source)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(parser)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(decodercxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/decoder.)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(conv)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(sink);
195 }
196 catch(const Glibcxx . . $ Glib/::Errorcxx . . $ Glib/Error#& ex)
197 {
198 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Error while adding elements to the pipeline: " <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). ex.whatcxx . . $ Glib/Error#what(fff0f585954e56f3).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
199 return 1;
200 }
201
202 // Link the elements together:
203 try
204 {
205 source->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(parser);
206
207 // We cannot link the parser and decoder yet,
208 // because the parser uses dynamic pads.
209 // So we do it later in a pad-added signal handler:
210 parser->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).signal_pad_addedcxx . . $ Gst/Element#signal_pad_added(b8ac1dfc5db9f846).().connectcxx . . $ Glib/SignalProxy#connect(23e07d4a2c0735e0).( sigccxx . . $ sigc/slot#slot(edcd8b2679e9bd1a).::ptr_funcxx . . $ sigc/ptr_fun(674d5d33d5bfc9bc).(&on_parser_pad_addedcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/on_parser_pad_added(6d8541f3277dd441).) );
211
212 decodercxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/decoder.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(conv)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(sink);
213 }
214 catch(const stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#& ex)
215 {
216 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Exception while linking elements: " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ex.whatcxx . . $ std/runtime_error#what(a9f41ea0e82d88cf).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
217 }
218
219 // Call on_timeout function at a 200ms
220 // interval to regularly print the position of the stream
221 Glibcxx . . $ Glib/::signal_timeoutcxx . . $ Glib/signal_timeout(66f5cf45299e0490).().connectcxx . . $ Glib/SignalTimeout#connect(c26b6904efe464be).(sigccxx . . $ sigc/slot#slot(edcd8b2679e9bd1a).::ptr_funcxx . . $ sigc/ptr_fun(9a3273562c8d4a7e).(&on_timeoutcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/on_timeout(c9857a73d68e59ba).), 200);
222
223 // Now set the whole pipeline to playing and start the main loop:
224 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Setting to PLAYING." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
225 pipelinecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/pipeline.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).set_statecxx . . $ Gst/Element#set_state(17bf573d41f9253f).(Gstcxx . . $ Gst/::STATE_PLAYINGcxx . . $ Gst/STATE_PLAYING.);
226 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Running." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
227 mainloopcxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/mainloop.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).runcxx . . $ Glib/MainLoop#run(49f6e7a06ebc5aa8).();
228
229 // Clean up nicely:
230 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Returned. Stopping playback." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
231 pipelinecxx . . $ `$anonymous_namespace_examples/ogg_player/main.cc`/pipeline.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).set_statecxx . . $ Gst/Element#set_state(17bf573d41f9253f).(Gstcxx . . $ Gst/::STATE_NULLcxx . . $ Gst/STATE_NULL.);
232
233 return 0;
234 }