Commit graph

59 commits

Author SHA1 Message Date
Ursula Maplehurst
236398ee3f androidmedia: when flushing, better handle IllegalStateException received from getOutputBuffer
1. Similar to 880f3d8, don't consider not getting an output buffer as
   an error during flushing. I've seen the following sometimes when
   encoding:

   W GStreamer+amcvideoenc: java.lang.IllegalStateException
   W GStreamer+amcvideoenc:         at android.media.MediaCodec.getBuffer(Native Method)
   W GStreamer+amcvideoenc:         at android.media.MediaCodec.getOutputBuffer(MediaCodec.java:2886)

2. For amcvideodec/enc, call _find_nearest_frame (which grabs a fresh
   reference on a GstVideoCodecFrame) after we have an output buffer,
   so as to not leak the reference, in case getting an output buffer
   fails.

   Otherwise, if we get an error grabbing the output buffer, we leak
   the reference to the frame. This can cause issues with a
   v4l2bufferpool feeding the encoder not being able to clean itself
   up properly due to buffers still being marked as in-use.

https://bugzilla.gnome.org/show_bug.cgi?id=791258
2017-12-06 10:32:02 +02:00
Sebastian Dröge
9988ad9c42 androidmedia: Add support for Opus in the decoder 2017-01-05 15:05:42 +02:00
Sebastian Dröge
3357ddb0e1 amcaudiodec: Set "is-adts" to 1 for ADTS AAC
Otherwise it fails to decode.

https://bugzilla.gnome.org/show_bug.cgi?id=740101
2016-12-15 14:09:25 +02:00
Thibault Saunier
2fb716409c Use the new API to post flow ERROR messages on the bus
https://bugzilla.gnome.org/show_bug.cgi?id=770158
2016-08-26 19:23:31 -03:00
Sebastian Dröge
610705cbb4 amc: Correctly handle NULL input buffers
https://bugzilla.gnome.org/show_bug.cgi?id=763401
2016-03-11 10:46:10 +02:00
Sebastian Dröge
5a3744e86c amc: MediaCodec::getOutputBuffer() can return NULL without exception
Happens when doing zerocopy rendering, or when passing a wrong index to it.
Handle this properly for zerocopy rendering, fail properly for the other
cases.

https://bugzilla.gnome.org/show_bug.cgi?id=760961
2016-01-22 16:13:45 +02:00
Matthieu Bouron
43b63f304d androidmedia: Add support for GL output in amcvideodec
https://bugzilla.gnome.org/show_bug.cgi?id=731204
2015-10-21 04:27:43 +11:00
Sebastian Dröge
a6fb482247 androidmedia: Conditionally use get_{input,output}_buffer() Android 21 APIs
Also properly set limit/position on byte buffer, some codecs prefer to have
correct values there.
2015-05-31 21:27:27 +02:00
Sebastian Dröge
8bacecfb08 amcaudiodec: Add an output adapter for chunking the output into codec frames
Otherwise the base class will be confused.
See https://bugzilla.gnome.org/show_bug.cgi?id=685730
2015-05-19 19:12:41 +03:00
Sebastian Dröge
774866ad62 androidmedia: Handle queue/release errors non-fatal
They can happen sometimes as a transient problem, e.g. if there
is a problem in the stream. Only handle them as fatal if many of
them happen in a row.
2015-04-17 20:11:46 +02:00
Edward Hervey
4b5d3a97ba androidmedia: Remove unused label/variable 2015-03-11 10:17:53 +01:00
Anuj Jaiswal
593f7d520e androidmedia: break statements unnecessary
Code flow never arrives to the break statements due to the goto's. So the
breaks are unecessary. Second part to commit a3958ae65b

https://bugzilla.gnome.org/show_bug.cgi?id=736940
2014-09-24 12:17:41 +01:00
Sebastian Dröge
f5e73d2808 amcaudiodec: Remove hack for Google MP3 decoder
The first buffer does not contain more garbage than any other MP3 decoder
outputs and we don't really know how much we have to drop or not.

After this change the output has the same duration as with mad.
2014-09-01 17:44:04 +03:00
Sebastian Dröge
8f25220b9c androidmedia: Make sure to unblock any thread waiting on the drain condition variable when errors happen 2014-08-14 15:27:21 +03:00
Sebastian Dröge
ca62186797 androidmedia: Fix draining logic to let the base class handle EOS events
https://bugzilla.gnome.org//show_bug.cgi?id=734775
2014-08-14 15:27:21 +03:00
Sebastian Dröge
aee9d12b86 androidmedia: Also don't report warnings for queue/dequeue errors during flushing in error cases
... and fix a case where we released an invalid buffer index.
2014-06-19 18:34:05 +02:00
Sebastian Dröge
880f3d8a18 androidmedia: Don't consider input buffer queueing failures as an error during flushing 2014-06-19 18:34:05 +02:00
Sebastian Dröge
71c0e0e19f androidmedia: Clean up flushing code and don't consider output buffer releasing failures during flushing as an error 2014-06-19 18:34:05 +02:00
Sebastian Dröge
f844af2320 androidmedia: Add exceptions from the Java API to error messages, and post more error/warning messages overall 2014-05-30 16:36:11 +02:00
Jorge Zapata
ad82575693 Release the codec before freeing it
On Samsung Galaxy S4 it is impossible to have more than one
hardware decoder at the same time. If we do not release it
explicitly the GC only releases it whenever the whole application
is finished not whenever the activity is finished and thus a player
will not be able to work correctly
2014-05-30 12:40:59 +02:00
Chen Jie
557d6b974f androidmedia: move create_src|sink_caps to gstamc.c
Some hack logic needs also to be present in create_src|sink_caps, for
working around some broken codecs. These hacks are hidden
in color_format/video_format conversion -- the prototypes of these
functions are also changed to include more args for hack judgement.

Also in case of multi-color_formats mapped to one video_format, then
map that video_format back will not give the original color_format, which
causes gst_amc_codec_configure failed with something like
'does not support color format N'.

The new prototype involves with GstAmcCodecInfo and mime, which
ensures the converted color_format is supported by the codec.

A COLOR_FormatYCbYCr to GST_VIDEO_FORMAT_YUY2 mapping is also added, in
order to work around bugs in OMX.k3.video.decoder.avc(which incorrectly
reports supporting COLOR_FormatYCbYCr, which is actually
COLOR_FormatYUV420SemiPlanar). There are already hacks for this in
gst_amc_video_format_to_color_format, gst_amc_color_format_to_video_format
and gst_amc_color_format_info_set, but the codec will still not work(be
ignored because of "has unknown color formats") without adding this mapping.
2014-05-26 16:29:01 +02:00
Sebastian Dröge
5b23cf694c amcaudiodec: Calculate number of samples per frame for MP3 and use that
Some audio decoders (at least the MP3 decoder on MTK based devices) outputs
raw audio in batches of multiple audio frames. We need to handle that
properly, otherwise the base class will be kind of unhappy.
2014-02-14 12:51:50 +01:00
Sebastian Dröge
aeeeedd7c7 amcaudiodec: Error out if we get an invalid raw audio buffer size 2014-02-14 12:51:50 +01:00
Sebastian Dröge
2476b926b1 amcaudiodec: Release buffer back to Android if allocating output fails 2014-02-14 12:51:50 +01:00
Sebastian Dröge
30d80bf658 androidmedia: Don't handle FLUSHING or NOT_LINKED as error
And also just stop the task for FLUSHING.
2014-01-25 17:41:18 +01:00
Andoni Morales Alastruey
6b49683447 androidmedia: fix access to invalid buffers in the decoding loop
Flushing the decoder invalidates all buffers, so it should be done
after quiting the decoding loop. Otherwise we can jump into
"failed_release" and stop everything

https://bugzilla.gnome.org/show_bug.cgi?id=711156
2013-10-30 16:24:17 +01:00
Sebastian Dröge
e66f097f37 androidmedia: Fix indention 2013-05-20 13:24:07 +02:00
Sebastian Dröge
a887497d18 amcaudiodec: Properly set output format instead of just setting caps 2013-04-16 16:23:46 +02:00
Sebastian Dröge
055154fe78 androidmedia: Set parent class in class_init 2013-04-16 16:17:50 +02:00
Sebastian Dröge
7832b9b43f androidmedia: Handle refcounts of pad templates correctly
gst_pad_template_new() does not take ownership of caps anymore and
gst_element_class_add_pad_template() does take ownership of the
pad template now.
2013-04-16 16:00:30 +02:00
Sebastian Dröge
fd8defc525 amcaudiodec: Use 1.0-style raw audio caps 2013-04-16 15:32:01 +02:00
Sebastian Dröge
75493a7731 androidmedia: Properly set subclasses metadata/pad templates in base_init 2013-04-16 15:31:34 +02:00
Sebastian Dröge
b2e5b9cb67 androidmedia: Update to new GLib thread API 2012-11-12 11:32:44 +01:00
Sebastian Dröge
079c68e4de androidmedia: Port to 1.0 2012-10-25 14:05:48 +02:00
Sebastian Dröge
31f0f163bd Try to handle format changes more gracefully
And make stop() faster and more robust
2012-10-15 16:28:43 +02:00
Sebastian Dröge
b0b642d8ab Add workaround for Google MP3 decoder outputting garbage in first output buffer
And assume one decoded input frame per output buffer to fix timestamp
handling by the base class.
2012-10-15 16:28:43 +02:00
Sebastian Dröge
2f3b2c586f Also add some more output format checks to the audio decoder 2012-10-15 16:28:42 +02:00
Sebastian Dröge
6ed3ea7cad Don't set timestamps, the baseclass handles this for us anyway 2012-10-15 16:28:42 +02:00
Sebastian Dröge
0b0255ed12 Merge structures into caps instead of appending them 2012-10-15 16:28:42 +02:00
Sebastian Dröge
9f7ed3f180 Use orc_memcpy() instead of memcpy() as it should be faster for larger memory areas 2012-10-15 16:28:42 +02:00
Sebastian Dröge
7a53743bfd Add support for audio/mpeg-L2 for the Nexus 7 2012-10-15 16:28:42 +02:00
Sebastian Dröge
cb6f703669 Only mpegversion=4 is supported for AAC 2012-10-15 16:28:41 +02:00
Sebastian Dröge
742816df69 Remove some obsolete FIXMEs 2012-10-15 16:28:41 +02:00
Sebastian Dröge
f839a615a0 Fix flushing logic to unbreak handling of flushing seeks 2012-10-15 16:28:41 +02:00
Sebastian Dröge
7dbef6415f Fix Vorbis decoding 2012-10-15 16:28:41 +02:00
Sebastian Dröge
562b033872 Wait at most 100ms for dequeueing a buffer, and retry after that
Some codecs don't fail the dequeueing if the codec is flushed,
causing deadlocks when shutting down the element.
2012-10-15 16:28:41 +02:00
Sebastian Dröge
9a034f2beb Release output buffers a bit earlier 2012-10-15 16:28:41 +02:00
Sebastian Dröge
4c3617f7f0 Keep another reference of the input buffer in handle_frame()
It might be unreffed in the meantime by the other thread due
to finish_frame().
2012-10-15 16:28:41 +02:00
Sebastian Dröge
613a75ad92 Pass -1 as number of frames to the base class
This will automatically do the right thing if timestamps are good enough
2012-10-15 16:28:41 +02:00
Sebastian Dröge
0143418e0c Use correct buffer variable 2012-10-15 16:28:41 +02:00