I need to be able to play an encrypted file in Android.
The file is AAC.
The only way I can see to do this is either:
- decrypt the file to internal private storage and point the player at that file to play, or
- decrypt & decode the file to pcm and feed it to an AudioTr开发者_运维百科ack.
1 isn't great because it takes a long time to do that.
2 isn't great either because I don't know how I can take advantage of the HW decoder to do this.Any ideas?
tia.
If you have an encryption format that can be decrypted on a stream, then you can insert a proxy between the stream source and the media player and read it from there.
The NPR Android News app has an example of a proxy inserted to allow pre-2.2 devices to properly handle Shoutcast streams. See the StreamProxy class in the source code for how this is done and lines 410-418 (as of last update) of the PlaybackService class for an implementation of that. It essentially just changed the URL to run through the local proxy server:
if (stream && Build.VERSION.SDK_INT < 8) {
if (proxy == null) {
proxy = new StreamProxy();
proxy.init();
proxy.start();
}
playUrl = String.format("http://127.0.0.1:%d/%s",
proxy.getPort(), url);
}
If your stream comes from a local file, not the Internet, then you could do something like the HttpRawResourceServer that I wrote as a test harness to interface to the media player.
Well I think Android does not support .AAC format.
3GPP (.3gp) and MPEG-4 (.mp4, .m4a). No support for raw AAC (.aac)
but you could change the file playerdriver.cpp inside the Android OpenCORE the following line::
mDataSource->SetDataSourceFormatType(PVMF_FORMAT_UNKNOWN);
to
mDataSource->SetDataSourceFormatType(PVMF_AACFF);
then you could play your AAC file =)
精彩评论