How do I set up streaming audio with MediaExtractor and MediaCodec?

I am trying to pass an incoming AMR_NB. I cannot use MediaPlayer directly because it requires a file to search for. I would like to use MediaCodec, but I need to use MediaCodec (I think ... please correct me!) MediaExtractor to give me things like presentationTime. It's true? Can MediaCodec be used without MediaExtractor?

The MediaExtractor requires search files. The documentation only specifically says this for one of the setDataSource operations, but when I tried to use any others it failed due to unsuccessful search attempts.

So what can I do to get the AMR incoming stream? I know of a scheme where you save your input to a file and periodically make a copy of that file to feed to the MediaPlayer, but I'd rather find a real honest streaming solution.

Can MediaCodec be used without using MediaExtractor? If so, how do I find the presentation time and string to pass to MediaCodec.createDecoderByType? The documentation SAYS that "audio / 3gpp" is what I want, but when I try to use that I get the following error:

codec = MediaCodec.createDecoderByType("audio/3gpp");

01-02 03:59:36.980: E/OMXMaster(21605): A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.

      

So, I'm not sure how to get to the MediaCodec.

+3


source to share


1 answer


"I can't use MediaPlayer directly because it requires a file to search for." This is usually not the case. I would like you to try it in your thread and let you know what's going on.

"Can I use MediaCodec without MediaExtractor?" I doubt it: I believe they are meant to be shared.



I used these components to play streams. However, MediaExtractor has limitations that are not documented (as far as I know). So use a small proxy to feed him what he can digest. And I have 1 thread to start MediaExtractor and another one to output from MediaCodec. Then I have to avoid deadlocks and deal with synchronization. But that's not too bad if you just want to play forward. Then the only problem you have is how to stop!

I advise you to try MediaPlayer first. Otherwise, if you are strong enough to give MediaExtractor a try, we can share our discoveries about what it will do and not digest. Don't take anything for granted. For example, it seems that it will play my MP3 files, but cannot detect their duration or search for them!

0


source







All Articles