Problem with Vorbis and Theora file on Android

doon don-prog at mail.ru
Mon Apr 25 01:19:31 UTC 2016


I try to play audio from the video and audio file, but have strange problem
with the pads linking. Here is my code: 

G_BEGIN_DECLS
GST_PLUGIN_STATIC_DECLARE(coreelements);
GST_PLUGIN_STATIC_DECLARE(soup);
GST_PLUGIN_STATIC_DECLARE(opensles);
GST_PLUGIN_STATIC_DECLARE(playback);
GST_PLUGIN_STATIC_DECLARE(ogg);
GST_PLUGIN_STATIC_DECLARE(vorbis);
GST_PLUGIN_STATIC_DECLARE(audioconvert);
GST_PLUGIN_STATIC_DECLARE(theora);
GST_PLUGIN_STATIC_DECLARE(videoconvert);
GST_PLUGIN_STATIC_DECLARE(videotestsrc);
GST_PLUGIN_STATIC_DECLARE(opengl);
G_END_DECLS

void MainWindow::play(){
    GST_PLUGIN_STATIC_REGISTER(coreelements);
    GST_PLUGIN_STATIC_REGISTER(soup);
    GST_PLUGIN_STATIC_REGISTER(opensles);
    GST_PLUGIN_STATIC_REGISTER(playback);
    GST_PLUGIN_STATIC_REGISTER(ogg);
    GST_PLUGIN_STATIC_REGISTER(vorbis);
    GST_PLUGIN_STATIC_REGISTER(audioconvert);
    GST_PLUGIN_STATIC_REGISTER(theora);
    GST_PLUGIN_STATIC_REGISTER(videoconvert);
    GST_PLUGIN_STATIC_REGISTER(videotestsrc);
    GST_PLUGIN_STATIC_REGISTER(opengl);

    gst_init(NULL, NULL);
    play_vorbis_audio();
}

GstElement *pipeline;
void on_pad_added(GstElement *element, GstPad *pad, gpointer data) {

    GstElement* audioelem = ((GstElement **)data)[0];

    GstCaps *caps = gst_pad_get_current_caps(pad);
    GstStructure* str = gst_caps_get_structure(caps, 0);

    if (g_strrstr(gst_structure_get_name(str), "audio")) {
        gst_caps_unref(caps);

        GstPad* sinkpad = gst_element_get_static_pad(audioelem, "sink");
        if (gst_pad_link(pad, sinkpad) != 0)
        {
            qDebug("link audio error: \n");
        }

        gst_object_unref(sinkpad);

        gst_element_set_state(pipeline, GST_STATE_PLAYING);
    }

}
void play_vorbis_audio() {

    GstElement *httpsrc, *demux, *dec, *audioconvert, *audiosink;
    GMainLoop *loop = g_main_loop_new(NULL, FALSE);

    pipeline = gst_pipeline_new("pipeline");

    httpsrc = gst_element_factory_make("souphttpsrc", "httpsrc");
    demux = gst_element_factory_make("oggdemux", "demux");
    dec = gst_element_factory_make("vorbisdec", "dec");
    audioconvert = gst_element_factory_make("audioconvert", "audioconvert");
    audiosink = gst_element_factory_make("openslessink", "audiosink");

    g_object_set(G_OBJECT(httpsrc), "location",
"http://docs.gstreamer.com/media/sintel_trailer-368p.ogv", NULL);
    GstCaps *caps1 = gst_caps_new_simple("application/ogg", NULL);

    gst_bin_add_many(GST_BIN(pipeline), httpsrc, demux, dec, audioconvert,
audiosink, NULL);
    gst_element_link_filtered(httpsrc, demux, caps1);
    gst_element_link_many(dec, audioconvert, audiosink, NULL);

    GstElement *convert_array[2];
    convert_array[0] = dec;

    g_signal_connect(demux, "pad-added", G_CALLBACK(on_pad_added),
convert_array);

    gst_element_set_state(pipeline, GST_STATE_PLAYING);
    g_main_loop_run(loop);
}

This pipeline works fine on Ubuntu, problem occurs on Android.
If I use uri with ogv video(Theora) and audio(Vorbis) than I get this
GST_DEBUG without audio playback(of course now I need only audio, without
Theora):

//...
W libOpenSLES: Leaving Object::GetInterface (SL_RESULT_FEATURE_UNSUPPORTED)
//...
  creating caps event application/ogg
  Starting with first granule 0
  Starting with first granule 0
  creating segment event time segment start=0:00:00.000000000,
offset=0:00:00.000000000, stop=99:99:99.999999999, rate=1.000000,
applied_rate=1.000000, flags=0x00, time=0:00:00.000000000,
base=0:00:00.000000000, position 0:00:00.000000000, duration
99:99:99.999999999
  found pad demux:sink
  creating caps event video/x-theora, width=(int)854, height=(int)366,
framerate=(fraction)24/1, pixel-aspect-ratio=(fraction)1/1,
streamheader=(buffer)<
807468656f72610302010036001700035600016e0002000000180000000100000100000100000000c0c0,
817468656f72612b000000586970682e4f7267206c69627468656f726120312e312032303039303832322028546875736e656c64612900000000,
827468656f7261becd28f7b9cd6b18b5a9494a10739ce6318c5294a42108318c62108421084000000000000000000011f4e1642e5549b47612f570b4986b95a2a9409648a1d047d399b8d66430174b2552912c94462210078391c0d06431168b05628130944621100783a1c0c8602c1509848220f0683014fb9917d69555541412d2d19190504f0f0dcdcc8c8b4b4b4a0a0a08c8c8c787878786464646450505050503c3c3c3c3c3c3c28282828282828281414141414141402100b0a101828333d0c0c0e131a3a3c370e0d1018283945380e11161d3357503e1216253a446d674d182337405168715c31404e
  adding pad 'src_38a00248'
  found pad demux:sink
  creating caps event audio/x-vorbis, rate=(int)48000, channels=(int)2,
streamheader=(buffer)<
01766f72626973000000000280bb0000000000008038010000000000b801,
03766f726269731d000000586970682e4f7267206c6962566f726269732049203230303930373039010000001a000000454e434f4445523d66666d706567327468656f72612d302e323401,
05766f7262697321424356010000010018635429469952d24a8919739431469962924a89a5841642489d731453a939d79c6bacb9b52084101a5350290599528e526919639029059952104b492574123a279d63105b49c1d6986b8b41b61c840d9a524c29c494528a420819538c29c594524a420725740e3ae61c538e4a2841b89c73abb59696638ba974924ae724644c42482985924a07a5534e42483596d652291d7352526a41e820841042b620840d82d0905500000100c040101ab20a00500000108aa1188a028486ac020032000004a0288ee2288e233992634916101ab20a00000200100000c07014499114c9b1244bd22c4bd34451557dd5365555f6755dd7755dd7
  adding pad 'src_0a053d9b'
  found pad dec:sink
  trying to link demux:src_0a053d9b and dec:sink
  Expected field 'channel-mask' in structure: audio/x-raw, rate=(int){ 8000,
11025, 12000, 16000, 22050, 24000, 32000, 44100 }, channels=(int)[ 1, 2 ],
layout=(string)interleaved;
  caps are incompatible
  link between demux:src_0a053d9b and dec:sink failed: no common format
D libandroid_test.so: ../android_test/player.cpp:16 (void
on_pad_added(GstElement*, GstPad*, gpointer)): link audio error:
04-25 04:38:47.594  6992  7090 D libandroid_test.so:
//...

But if I use uri with only audio(Vorbis) all works fine. 
So, what is the problem and how can I solve it? 



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Problem-with-Vorbis-and-Theora-file-on-Android-tp4677085.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list