| 1 | /* |
| 2 | * main.cc |
| 3 | * |
| 4 | * Created on: Aug 14, 2013 |
| 5 | * Author: m.kolny |
| 6 | */ |
| 7 | |
| 8 | #include <gstreamermm.h>cxx . . $ `<file>/gstreamer/gstreamermm.h`/ |
| 9 | #include <iostream> |
| 10 | #include <glibmm/main.h> |
| 11 | |
| 12 | using namespace Gst; |
| 13 | using Glibcxx . . $ Glib/::RefPtrcxx . . $ RefPtr#; |
| 14 | |
| 15 | RefPtrcxx . . $ RefPtr#<Elementcxx . . $ Gst/Element#> video_parsercxx . . $ video_parser., audio_parsercxx . . $ audio_parser.; |
| 16 | RefPtrcxx . . $ RefPtr#<Glibcxx . . $ Glib/::MainLoopcxx . . $ Glib/MainLoop#> main_loopcxx . . $ main_loop.; |
| 17 | |
| 18 | bool on_bus_messagecxx . . $ on_bus_message(f80753751e77bf04).(const RefPtrcxx . . $ RefPtr#<Gstcxx . . $ Gst/::Buscxx . . $ Gst/Bus#>&, const RefPtrcxx . . $ RefPtr#<Messagecxx . . $ Gst/Message#>& message) |
| 19 | { |
| 20 | switch(message->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_message_typecxx . . $ Gst/Message#get_message_type(97914d44a9bd21bb).()) |
| 21 | { |
| 22 | case Gstcxx . . $ Gst/::MESSAGE_EOScxx . . $ Gst/MESSAGE_EOS.: |
| 23 | 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).; |
| 24 | main_loopcxx . . $ main_loop.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).quitcxx . . $ Glib/MainLoop#quit(49f6e7a06ebc5aa8).(); |
| 25 | return false; |
| 26 | case Gstcxx . . $ Gst/::MESSAGE_ERRORcxx . . $ Gst/MESSAGE_ERROR.: |
| 27 | { |
| 28 | Glibcxx . . $ Glib/::Errorcxx . . $ Glib/Error# errorcxx . . $ Glib/Error#Error(49f6e7a06ebc5aa8).; |
| 29 | stdcxx . . $ std/::stringcxx . . $ std/string# debug_messagecxx . . $ std/__cxx11/basic_string#basic_string(49f6e7a06ebc5aa8).; |
| 30 | RefPtrcxx . . $ Glib/RefPtr#<MessageError>::cast_staticcxx . . $ Glib/RefPtr#cast_static(18212fa50966cf79).(message)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).parsecxx . . $ Gst/MessageError#parse(e2e4a293156aa5db).(error, debug_message); |
| 31 | stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Error: " <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). error.whatcxx . . $ Glib/Error#what(fff0f585954e56f3).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9). <<cxx . . $ std/`operator<<`(88df5bef833f7f83). debug_message <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 32 | main_loopcxx . . $ main_loop.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).quitcxx . . $ Glib/MainLoop#quit(49f6e7a06ebc5aa8).(); |
| 33 | return false; |
| 34 | } |
| 35 | default: |
| 36 | break; |
| 37 | } |
| 38 | |
| 39 | return true; |
| 40 | } |
| 41 | |
| 42 | void on_demux_pad_addedcxx . . $ on_demux_pad_added(6d8541f3277dd441).(const RefPtrcxx . . $ RefPtr#<Padcxx . . $ Gst/Pad#>& newPad) |
| 43 | { |
| 44 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Dynamic pad created. Linking demuxer/decoder." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 45 | RefPtrcxx . . $ RefPtr#<Padcxx . . $ Gst/Pad#> sinkPad = video_parsercxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_static_padcxx . . $ Gst/Element#get_static_pad(d41a58e7b5052139).("sink"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 46 | PadLinkReturncxx . . $ Gst/PadLinkReturn# ret = newPad->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Pad#link(ca9408873a0c7209).(sinkPad); |
| 47 | |
| 48 | if (ret != PAD_LINK_OKcxx . . $ Gst/PAD_LINK_OK. && ret != PAD_LINK_WAS_LINKEDcxx . . $ Gst/PAD_LINK_WAS_LINKED.) |
| 49 | { |
| 50 | 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). |
| 51 | 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).; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char** argv) |
| 56 | { |
| 57 | if (argc < 3) |
| 58 | { |
| 59 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Usage: " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). argv[0] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " <Ogg/Vorbis filename>" |
| 60 | " <mp3 filename> <mkv output filename>" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 61 | return 1; |
| 62 | } |
| 63 | |
| 64 | initcxx . . $ Gst/init(22930d6ef54703eb).(argc, argv); |
| 65 | |
| 66 | RefPtrcxx . . $ RefPtr#<Pipelinecxx . . $ Gst/Pipeline#> pipeline = Pipelinecxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::createcxx . . $ Gst/Pipeline#create(4db98da4abd65927).("play-pipeline"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 67 | main_loopcxx . . $ main_loop. =cxx . . $ Glib/RefPtr#`operator=`(b66de19e2ab7ce1f). Glibcxx . . $ Glib/::MainLoopcxx . . $ Glib/MainLoop#::createcxx . . $ Glib/MainLoop#create(748caac81bf5da26).(); |
| 68 | RefPtrcxx . . $ RefPtr#<Buscxx . . $ Gst/Bus#> bus = pipelinecxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_buscxx . . $ Gst/Pipeline#get_bus(ada66d6ded80d30d).(); |
| 69 | 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 . . $ on_bus_message(f80753751e77bf04).)); |
| 70 | |
| 71 | #ifndef GSTREAMERMM_DISABLE_DEPRECATED |
| 72 | RefPtrcxx . . $ RefPtr#<FileSrccxx . . $ Gst/FileSrc#> video_source = FileSrccxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::createcxx . . $ Gst/FileSrc#create(c38e35eb3f591174).(), |
| 73 | audio_source = FileSrccxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::createcxx . . $ Gst/FileSrc#create(c38e35eb3f591174).(); |
| 74 | RefPtrcxx . . $ RefPtr#<FileSinkcxx . . $ Gst/FileSink#> filesink = FileSinkcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::createcxx . . $ Gst/FileSink#create(31d78999cef96de9).(); |
| 75 | #else |
| 76 | RefPtr<Element> video_source = ElementFactory::create_element("filesrc"), |
| 77 | audio_source = ElementFactory::create_element("filesrc"), |
| 78 | filesink = ElementFactory::create_element("filesink"); |
| 79 | #endif |
| 80 | |
| 81 | RefPtrcxx . . $ RefPtr#<Elementcxx . . $ Gst/Element#> ogg_demuxer = ElementFactorycxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("oggdemux"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 82 | audio_parsercxx . . $ audio_parser. =cxx . . $ Glib/RefPtr#`operator=`(b66de19e2ab7ce1f). ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("mad"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 83 | |
| 84 | RefPtrcxx . . $ RefPtr#<Elementcxx . . $ Gst/Element#> audiosink = ElementFactorycxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("autoaudiosink"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).), |
| 85 | videosink = ElementFactorycxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("autovideosink"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 86 | |
| 87 | RefPtrcxx . . $ RefPtr#<Elementcxx . . $ Gst/Element#> muxer = ElementFactorycxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("matroskamux"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 88 | |
| 89 | |
| 90 | video_parsercxx . . $ video_parser. =cxx . . $ Glib/RefPtr#`operator=`(b66de19e2ab7ce1f). ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("theoraparse"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 91 | |
| 92 | if (!video_source || !ogg_demuxer || !video_parsercxx . . $ video_parser. || !videosink || !pipeline || !audio_parsercxx . . $ audio_parser. || !audio_source) |
| 93 | { |
| 94 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "One element could not be created." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 95 | return 1; |
| 96 | } |
| 97 | |
| 98 | #ifndef GSTREAMERMM_DISABLE_DEPRECATED |
| 99 | video_source->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).property_locationcxx . . $ Gst/FileSrc#property_location(ee255b09b2ef680a).() =cxx . . $ Glib/PropertyProxy#`operator=`(96d6f65396a143d8). argvcxx . . $ Glib/ustring#ustring(85c52e162fed56f9).[1]; |
| 100 | audio_source->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).property_locationcxx . . $ Gst/FileSrc#property_location(ee255b09b2ef680a).() =cxx . . $ Glib/PropertyProxy#`operator=`(96d6f65396a143d8). argvcxx . . $ Glib/ustring#ustring(85c52e162fed56f9).[2]; |
| 101 | filesink->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).property_locationcxx . . $ Gst/FileSink#property_location(ee255b09b2ef680a).() =cxx . . $ Glib/PropertyProxy#`operator=`(96d6f65396a143d8). argvcxx . . $ Glib/ustring#ustring(85c52e162fed56f9).[3]; |
| 102 | #else |
| 103 | video_source->set_property<Glib::ustring>("location", argv[1]); |
| 104 | audio_source->set_property<Glib::ustring>("location", argv[2]); |
| 105 | filesink->set_property<Glib::ustring>("location", argv[3]); |
| 106 | #endif |
| 107 | |
| 108 | pipeline->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(video_sourcecxx . . $ Glib/RefPtr#RefPtr(11a1ac667024f826).)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8). |
| 109 | addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(ogg_demuxer)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8). |
| 110 | addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(video_parsercxx . . $ video_parser.)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8). |
| 111 | addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(audio_sourcecxx . . $ Glib/RefPtr#RefPtr(11a1ac667024f826).)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8). |
| 112 | addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(audio_parsercxx . . $ audio_parser.)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8). |
| 113 | addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(muxer)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8). |
| 114 | addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(filesinkcxx . . $ Glib/RefPtr#RefPtr(11a1ac667024f826).); |
| 115 | |
| 116 | ogg_demuxer->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_demux_pad_addedcxx . . $ on_demux_pad_added(6d8541f3277dd441).)); |
| 117 | |
| 118 | video_source->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(ogg_demuxer); |
| 119 | video_parsercxx . . $ video_parser.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(muxer); |
| 120 | audio_source->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(audio_parsercxx . . $ audio_parser.)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(muxer); |
| 121 | muxer->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).linkcxx . . $ Gst/Element#link(52e71ea9673343b3).(filesinkcxx . . $ Glib/RefPtr#RefPtr(11a1ac667024f826).); |
| 122 | |
| 123 | pipeline->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).set_statecxx . . $ Gst/Element#set_state(17bf573d41f9253f).(STATE_PLAYINGcxx . . $ Gst/STATE_PLAYING.); |
| 124 | |
| 125 | main_loopcxx . . $ main_loop.->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).runcxx . . $ Glib/MainLoop#run(49f6e7a06ebc5aa8).(); |
| 126 | |
| 127 | pipeline->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).set_statecxx . . $ Gst/Element#set_state(17bf573d41f9253f).(STATE_NULLcxx . . $ Gst/STATE_NULL.); |
| 128 | |
| 129 | return 0; |
| 130 | } |