AAC samples number and pp::MediaStreamAudioTrack

60 views
Skip to first unread message

giovanni...@gmail.com

unread,
Oct 4, 2016, 6:41:51 AM10/4/16
to Native-Client-Discuss
Hi guys,

I am using pepper 47

I am developing a pepper api to stream audio/video upon network. The audio codec is AAC . In general, all standard  AAC codecs, use  512, 1024, 2048 samples to code a frame.

When I call the method configure of the class pp::MediaStreamAudioTrack, I realized that I can set only the  PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, and I cannot set the values for sample rate, sample size and channels number. It seems they are fix, respectively, to 48000, 2, 1.

Here is my code

int32_t attribs[] = {

    PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS, 1,
    /**
     * The duration of an audio buffer in milliseconds.
     * Valid range: 10 to 10000
     */
    PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, 10,
    PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE
  };

  audio_track_.Configure(attribs, callback_factory_.NewCallback(&stream::OnConfigure));

In such situation I cannot retrieve just 512 samples, in fact when I set
PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION = 10 I recover 480 samples and when I set PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION = 11 I recover 528. So I am around to 512.

Right now my work around was to truncate the number of sample from 528 to 512 and fill the decoder with 512 samples.

What am I doing wrong ?
What I did not understand ?


Thanks in advance,

Giovanni

Bill Budge

unread,
Oct 5, 2016, 6:24:50 PM10/5/16
to Native-Client-Discuss
Why not use a queue as a buffer? When you receive samples from the media stream, push them onto the queue. Whenever the queue has at least 512 samples, pull that many, encode them and send.

giovanni...@gmail.com

unread,
Oct 19, 2016, 11:24:59 AM10/19/16
to Native-Client-Discuss
Sorry for the delay of the answers, I have been out of office for a while.
The reason is due to the presentation time provided by the HW. As you know for each bunch of samples we have a specific presentation time, then if we mix two groups of samples with differents presentation times, we think that we fall in a more complicated scenario.
Anyway we solved the problem because we have integrated the fraunhofer libfdkaac and we are using the AAC_LD profile, which requires, as input, 480 samples.

Bye

Giovanni
Reply all
Reply to author
Forward
0 new messages