|
31 | 31 | #include <assert.h>
|
32 | 32 | #include <pthread.h>
|
33 | 33 |
|
34 |
| -#include <android.h> |
| 34 | +#include <utils/android.h> |
35 | 35 |
|
36 | 36 | // Non-standard 'stdint' implementation
|
37 | 37 | #pragma clang diagnostic push
|
@@ -223,58 +223,12 @@ JNIEXPORT jint JNICALL naOpenFile(JNIEnv *env, jobject instance, jstring filenam
|
223 | 223 | JNIEXPORT void JNICALL naDecodeAudioFromPacket( // Decoding audio packets
|
224 | 224 | JNIEnv* env, jobject instance, int aBuffLength
|
225 | 225 | ) {
|
226 |
| - AVPacket avPkt; |
227 |
| - AVFrame *pFrame = av_frame_alloc(); |
228 |
| - int AUDIO_INBUF_SIZE = 4096; |
229 |
| - int decodedDataSize = 0, |
230 |
| - packetSize = avPkt.size, |
231 |
| - status = 0, |
232 |
| - tAudioFrames = 0; |
233 |
| - jclass jmPlay = env->GetObjectClass(instance); |
234 |
| - jmethodID renderAudioMid = env->GetMethodID(jmPlay, "renderAudio", "([BI)V"); |
235 |
| - short* buffer = (short*)malloc(aBuffLength); |
236 |
| - jbyteArray jBuffer = env->NewByteArray(aBuffLength); |
237 |
| - |
238 |
| - pFrame = av_frame_alloc(); |
239 | 226 |
|
240 |
| - if (debug_mode) { |
241 |
| - LOGD(10, "[DEBUG] Starting audio decoder..."); |
242 |
| - } |
243 |
| - |
244 |
| - while (gPlaybackState == FFMPEG_PLAYBACK_PLAYING && |
245 |
| - (status = av_read_frame(gFormatCtx, &avPkt)) >= 0) { |
246 |
| - int len = avcodec_decode_audio4( |
247 |
| - gAudioCodecCtx, |
248 |
| - pFrame, |
249 |
| - &status, |
250 |
| - &avPkt |
251 |
| - ); |
252 |
| - |
253 |
| - if (status) { |
254 |
| - int dataSize = av_samples_get_buffer_size(NULL, |
255 |
| - gAudioCodecCtx->channels, |
256 |
| - pFrame->nb_samples, |
257 |
| - gAudioCodecCtx->sample_fmt, |
258 |
| - 1); |
259 |
| - |
260 |
| - if (debug_mode) { |
261 |
| - LOGD(10, "[DEBUG] Decoding audio frame #%d... | Length: %d of %d", |
262 |
| - tAudioFrames + 1, dataSize, aBuffLength |
263 |
| - ); |
264 |
| - } |
265 |
| - |
266 |
| - buffer = (short *) pFrame->data[0]; |
267 |
| - env->SetByteArrayRegion(jBuffer, 0, (jsize) dataSize / gAudioCodecCtx->channels, (jbyte *) buffer); |
268 |
| - env->CallVoidMethod(instance, renderAudioMid, jBuffer, dataSize / gAudioCodecCtx->channels); |
269 |
| - } |
270 |
| - |
271 |
| - tAudioFrames++; |
272 |
| - |
273 |
| - av_free_packet(&avPkt); |
274 |
| - av_packet_unref(&avPkt); |
275 |
| - } |
276 | 227 | }
|
277 | 228 |
|
| 229 | +/*env->SetByteArrayRegion(jBuffer, 0, (jsize) dataSize / gAudioCodecCtx->channels, (jbyte *) buffer); |
| 230 | + env->CallVoidMethod(instance, renderAudioMid, jBuffer, dataSize / gAudioCodecCtx->channels);*/ |
| 231 | + |
278 | 232 |
|
279 | 233 | JNIEXPORT uint8_t* JNICALL convertYuv2Rgb(AVPixelFormat pxf, AVFrame* frame, int length) {
|
280 | 234 | uint8_t *buffer = (uint8_t*) malloc((size_t)length);
|
@@ -328,7 +282,7 @@ JNIEXPORT void JNICALL naDecodeVideoFromPacket(
|
328 | 282 | LOGD(10, "[DEBUG] Starting video decoder...");
|
329 | 283 | }
|
330 | 284 |
|
331 |
| - while (gPlaybackState == FFMPEG_PLAYBACK_PLAYING && |
| 285 | + /*while (gPlaybackState == FFMPEG_PLAYBACK_PLAYING && |
332 | 286 | (status = av_read_frame(gFormatCtx, &avPkt)) >= 0) {
|
333 | 287 | if (avPkt.stream_index == gVideoStreamIndex) {
|
334 | 288 | AVFrame *pFrame = av_frame_alloc(),
|
@@ -385,6 +339,7 @@ JNIEXPORT void JNICALL naDecodeVideoFromPacket(
|
385 | 339 | av_free_packet(&avPkt);
|
386 | 340 | av_packet_unref(&avPkt);
|
387 | 341 | }
|
| 342 | + */ |
388 | 343 | }
|
389 | 344 |
|
390 | 345 | JNIEXPORT void JNICALL naPlay(JNIEnv *env, jobject instance) {
|
|
0 commit comments