Access to opencore audio decoders from application layer.

by sandy8531 » Thu, 16 Jul 2009 07:24:44 GMT


Sponsored Links
 My application needs to extract a 10 second portion of a audio file in
PCM format and store it.

On other platforms I have been doing this in Java using Jlayer
decoder, but once I ported that to Android, it ran extremely slowly.
It takes almost 50 seconds to decode a 10 second sample !

Since the opencore libraries are already available, I would like to be
to use them as an alternative. I have been looking at it for a couple
of days now. I would like to understand what options are available to
me to be able to do this.

My first approach was to develop a JNI stub and try and make a call
out to the codec in the opencore shipped library, but it appears that
those interfaces are subject to change and there is no guaranty of
backward compatibility in a future release.

The other approach I can think of is to take the opencore source and
compile the codecs into a separate standalone jni library private to
my application, and that way I avoid the backward compatibility
issue.

Before I go too far down any path I would like to run this by the
experts and figure out what is the best approach.

One more question - I saw in the opencore code that the decoding
thread is run at a higher priority. Since my decoder would be running
at normal application priority am I going to see a significant
performance drop off ala Jlayer ?

-thanks,
Sandeep



--~--~---------~--~----~------------~-------~--~----~



Access to opencore audio decoders from application layer.

by sesha giri » Thu, 16 Jul 2009 08:36:27 GMT


 Hi Sandeep,

You can put the if condition in the parser to read only till 10 sec
and take the PCM samples from decoder output to a file

-Giri




________________________________
From: sandy8531 <mathur...@gmail.com>
To: android-framework <android-framework@googlegroups.com>
Sent: Thursday, 16 July, 2009 12:46:10 PM
Subject: Access to opencore audio decoders from application layer.


My application needs to extract a 10 second portion of a audio file in
PCM format and store it.

On other platforms I have been doing this in Java using Jlayer
decoder, but once I ported that to Android, it ran extremely slowly.
It takes almost 50 seconds to decode a 10 second sample !

Since the opencore libraries are already available, I would like to be
to use them as an alternative. I have been looking at it for a couple
of days now. I would like to understand what options are available to
me to be able to do this.

My first approach was to develop a JNI stub and try and make a call
out to the codec in the opencore shipped library, but it appears that
those interfaces are subject to change and there is no guaranty of
backward compatibility in a future release.

The other approach I can think of is to take the opencore source and
compile the codecs into a separate standalone jni library private to
my application, and that way I avoid the backward compatibility
issue.

Before I go too far down any path I would like to run this by the
experts and figure out what is the best approach.

One more question - I saw in the opencore code that the decoding
thread is run at a higher priority. Since my decoder would be running
at normal application priority am I going to see a significant
performance drop off ala Jlayer ?

-thanks,
Sandeep





      See the Web&#39;s breaking stories, chosen by people like you. Check out 
Yahoo! Buzz.  http://in.buzz.yahoo.com/ 
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Access to opencore audio decoders from application layer.

by Jean-Baptiste Queru » Thu, 16 Jul 2009 12:26:33 GMT


 Can you be more precise about what your application does? On quite a
few devices (and especially on the Dream/G1) Android fits tightly with
little room to spare, so it's unclear that we'd be accepting
contributions for entirely new applications.

JBQ






-- 
Jean-Baptiste M. "JBQ" Queru
Android Engineer, Google.

Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.

--~--~---------~--~----~------------~-------~--~----~



Access to opencore audio decoders from application layer.

by Freepine » Thu, 16 Jul 2009 12:53:04 GMT


 You might want to take a look at SoundPool class and its corresponding
implementation in native layer, which could be a good reference if the class
itself doesn't satisfy your needs:)
 http://developer.android.com/reference/android/media/SoundPool.html 





--~--~---------~--~----~------------~-------~--~----~



Access to opencore audio decoders from application layer.

by sandy8531 » Thu, 16 Jul 2009 17:03:39 GMT


 Freepine,

I have looked at Soundpool, it does not solve my problem. To further
clarify, I need to implement the following (pseudo code) api for my
application. I do not need to play the sound.

public short[] getPcmData(String audioFilename, int
seekPositionInSeconds, int durationInSeconds);

Where for example:
   audioFileName = "/sdcard/somefile.mp3" ; // If I can implement this
for mp3 files only that would be a good start, but if i can also do
the same for AAC and other formats that would be great
   seekPositionInSeconds = 15 ; // The offset inside the audio file to
start decoding
   durationInSeconds = 5;           //  Number of seconds of audio
data starting at seekPosition to return the data for

What I need is a way to invoke the opencore decoder code from my
application and get the raw PCM data back.

-thanks,
Sandeep




--~--~---------~--~----~------------~-------~--~----~



Access to opencore audio decoders from application layer.

by Freepine » Fri, 17 Jul 2009 10:10:20 GMT


 andeep,
SoundPool leverages MediaPlayer service to decode the compressed audio into
a raw 16-bit PCM stream, which I thought you could refer to its
implementation.
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=media/jni/soundpool/SoundPool.cpp;h=02731825e08794a17132caed973b6f46486e632a;hb=8ecb36eec61f119f500a805b82438aadb3396a19
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=media/libmediaplayerservice/MediaPlayerService.cpp;h=8ef0dc6c42c43735d7778874f4b8cfcbc502e79b;hb=8ecb36eec61f119f500a805b82438aadb3396a19#l837

Besides, based on your requirements, I don't think it can be achieved by
calling Opencore decoder node directly. You'll need to to call the file
parser first, then feed the decoder node with parsed frames, and if you want
to support more codecs other than mp3, you'll need to call file recognizers
by yourself, too. That is going to be a lot of work:)

-Freepine

On Fri, Jul 17, 2009 at 1:03 AM, sandy8531 <mathur...@gmail.com> wrote:


--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. samples\android-11\ContactManager Document Sample Code Not Working

Hi List,

I am trying Android SDK 3, API 11.  I was trying to learn Content
Provider with the example given in Samples.

While running ContactManager I am getting NullPointerException -

04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
com.sanoop.ContactAdder.createContactEntry(ContactAdder.java:170)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
com.sanoop.ContactAdder.onSaveButtonClicked(ContactAdder.java:146)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
com.sanoop.ContactAdder.access$1(ContactAdder.java:144)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
com.sanoop.ContactAdder$2.onClick(ContactAdder.java:135)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
android.view.View.performClick(View.java:3100)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at android.view.View
$PerformClick.run(View.java:11644)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
android.os.Handler.handleCallback(Handler.java:587)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
android.os.Handler.dispatchMessage(Handler.java:92)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
android.os.Looper.loop(Looper.java:126)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
android.app.ActivityThread.main(ActivityThread.java:3997)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
java.lang.reflect.Method.invokeNative(Native Method)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
java.lang.reflect.Method.invoke(Method.java:491)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-12 00:25:07.379: ERROR/AndroidRuntime(541):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)


Line number 170 code is -

ArrayList<ContentProviderOperation> ops = new
ArrayList<ContentProviderOperation>();
 
ops.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
                .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE,
mSelectedAccount.getType())
                .withValue(ContactsContract.RawContacts.ACCOUNT_NAME,
mSelectedAccount.getName()).build());



And all the code lines are simply copied from the samples
\android-11\ContactManager.



please help me out.


Thanks,
Sanoop

-- 

2. How to add scrollbar...

- i have placed 3 table layouts on absolute view having height (height/
3) for each filled horizontally one after other.
- i want to make one of the layout scrollable (horizontally and
vertically too).
- So for that i have placed scroll view on the above table layout and
add another table layout on the scroll view which having number of
rows and columns....
- but on the display i got only vertical scrollbar but not
horizontal.....

i didn't get what is the problem....

-- 

3. HTML5 canvas element highlights on click

4. FragmentBreadCrumbs

5. My first app

6. Add breadcrumbs for navigating backward through fragments

7. Android simulator and telnet