Commit graph

272 commits

Author SHA1 Message Date
Martin Kelly
ddebf1ff66 ahc: correct error message
The error message is specific to only one of the failure cases and is
misleading in the others. Correct it to be more generic and cover all
the failure cases.

https://bugzilla.gnome.org/show_bug.cgi?id=763065
2016-03-04 09:42:14 +02:00
Martin Kelly
e337918a06 ahc: remove unneeded #include <stdio.h>
https://bugzilla.gnome.org/show_bug.cgi?id=763065
2016-03-04 09:42:14 +02:00
Martin Kelly
21d1eaa6c8 ahc: typo fix
https://bugzilla.gnome.org/show_bug.cgi?id=763065
2016-03-04 09:42:14 +02:00
Sebastian Dröge
476d5b6940 amcvideodec: When outputting on a surface, accept all color formats
We don't have to understand them, we handle them as a GL texture.

https://bugzilla.gnome.org/show_bug.cgi?id=762792
2016-02-28 11:10:39 +02:00
Matthew Waters
cd4a93da3b glsyncmeta: separate out gpu/cpu waits.
CPU waits are more expensive and are only required if the CPU is ever going to
access the data. GPU waits perform inter-context synchronisation and are cheaper
as they don't require CPU intervention.
2016-02-09 12:30:25 +11:00
Matthew Waters
9efdfb1a29 amcvideodec: pass the correct time value to wait_for_sync
When we are not waiting, we need to pass -1 to signal that we just want to check
that the frame was/n't rendered.  Avoids waiting for frames that will never be
rendered.

https://bugzilla.gnome.org/show_bug.cgi?id=761014
2016-02-04 15:46:22 +11:00
Matthew Waters
3c29dcaddb amcvideodec: advance the ready counter ourselves when render=FALSE
When not rendering the video frame, e.g. when freeing an unreleased sync frame,
we will not receive a frame listener callback.

Reduces the amount of 'on_frame_available miss detected' messages when dropping
frames.

https://bugzilla.gnome.org/show_bug.cgi?id=761014
2016-02-04 15:46:22 +11:00
Matthew Waters
b276de7827 amcvideodec: guard against not finding a valid frame in loop
Fixes sporadic crashes on finishing decoding a video.

https://bugzilla.gnome.org/show_bug.cgi?id=761014
2016-01-29 23:52:15 +11:00
Matthew Waters
1fceac8122 amcvideodec: set our data pointer in java to NULL on close
The frame available callback can be called after deconfiguring the amc codec.
Guard against this by setting the back pointer to NULL on close() and ignoring
any NULL data pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=761014
2016-01-29 23:52:15 +11:00
Sebastian Dröge
c9d9042aff ahc: Fail gracefully if our callback class can't be found
Instead of just ignoring that error and then calling JNI functions with NULL,
which will kill the virtual machine.

The error handling here needs some further improvements though, errors in more
places are just ignored.
2016-01-22 17:25:28 +02:00
Sebastian Dröge
551b0a5f28 ahc: Initialize GError pointer with NULL
Otherwise there will be assertions.
2016-01-22 17:22:47 +02:00
Sebastian Dröge
f585a66bd1 amcvideodec: Only free GstAmcBuffer if it's not NULL
And also free it on GL errors.
2016-01-22 17:19:29 +02:00
Sebastian Dröge
8c57341241 amc: Add an assertion for NULL GErrors
Should never happen! But an assertion is better than a NULL pointer
dereference.
2016-01-22 16:22:25 +02:00
Sebastian Dröge
31e1b7ceeb ahc: Fix indentation 2016-01-22 16:14:46 +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
Nicolas Dufresne
09dbc5b298 ahcsrc: Fix latency reporting
Currently it was wrongly reporting min/max as being the shortest and
longest possible frame duration. This is not how latency works in
GStreamer.

Fix by reporting min latency as being the longest possible duration of
one frame. As we don't know how many buffers the stack can accumulate, we
simply assume that max latency is the same (the usual default behaviour).
2016-01-21 13:49:18 -05:00
George Kiagiadakis
9a53d79876 ahcsrc: fix deadlock when flushing
_data_queue_item_free() calls gst_buffer_unref(), which
calls gst_ahc_src_buffer_free_func(), which calls
g_mutex_lock() on self->mutex and there you go... deadlock!
2016-01-21 13:49:18 -05:00
Justin Kim
f1809c4d93 ahcsrc: porting from 0.10 to 1.0 2016-01-21 13:49:17 -05:00
Justin Kim
becaf2852d move androidcamera into androidmedia
This commit is a part of portng android hardware camera from 0.10 implementation.
To preserve history and get diff clearly, the interesting files are moved to
deployment directory and the remaining files are removed.
2016-01-21 13:49:17 -05:00
Youness Alaoui
c84878ad4b androidmedia: Fix get_level and get_profile exception checking by not using return 2016-01-21 13:49:17 -05:00
Youness Alaoui
86f2535c41 androidmedia: Add extern gint declarations 2016-01-21 13:49:16 -05:00
Sebastian Dröge
64b869ea40 dvm: Rename gst-dvm.[ch] to gstdvm.[ch] for consistency with other GStreamer code 2016-01-21 13:49:15 -05:00
Sebastian Dröge
e3801c041f androidmedia: Make everything compile with the new wrappers 2016-01-21 13:49:15 -05:00
Sebastian Dröge
ade8590778 androidmedia: Add remaining bits of the Java wrappers using libgstdvm 2016-01-21 13:49:15 -05:00
Sebastian Dröge
ea43e42ca5 androidmedia: Remove g_return_if_fails()
This is not public API so it has no advantage to have them here.
2016-01-21 13:49:14 -05:00
Youness Alaoui
3ac90867ac androidmedia: Use gst-dvm and refactor java wrappers (WIP)
Moved the java wrapper API into its own files and made use of the
gst-dvm macros. Also renamed the API to have the proper naming
convention and coding style in order to match the one in androidcamera.
This is a work in progress! "android/media/MediaCodecList" is still missing
and the actual elements have not been ported to use the new function names.
2016-01-21 13:49:14 -05:00
Matthew Waters
650e5c4fe5 glmemory: implement GstGLBaseMemory::alloc
- Create GstGLVideoAllocationParams which is a GstGLAllocationParams subclass.
- Make it possible to allocate glmemory objects directly if no frills are
  needed.
2015-12-17 13:49:55 +11:00
Matthew Waters
fd3203cfeb amcvideodec: update for GLMemory API changes 2015-12-14 19:15:14 +11:00
Mathias Hasselmann
d387bfd188 androidmedia: Don't add metadata to locked buffer
The video decoders tried calling gst_buffer_add_*meta() on non-writable
buffer resulting in warnings of this kind:

  gstamcvideodec.c:921 (_gl_sync_render_unlocked): WARNING: amcvideodec
  Failed to create the transformation meta for the gl_sync 0xabc03848
  buffer 0xabb01b40 (0)

https://bugzilla.gnome.org/show_bug.cgi?id=758694
2015-11-26 22:24:26 +11:00
Matthew Waters
ab3fd36d64 amcvideodec: move release_output_buffer into the sync meta
Some devices only ever keep one buffer available in the GL queue resulting in
multiple calls to release_output_buffer only causing one frame to be rendered.
If there is a queue after amcvideodec (even playsink's small one), then
multiple buffers are pushed but only a small fraction of them are actually
rendered on time.  The rest will either render some number of frames ahead of
where they are meant to be or timeout waiting for a frame that's already been
rendered.

Solved by moving the release_output_buffer into the sync_meta the is pushed
downstream.  When downstream renders, the custom sync implementation attempts
to release the current buffer (if not already released) and render. Once the
frame has been rendered to the screen, the next frame is released and is
hopefully available by the time the next frame is to be rendered.

This fixes a perceived frame jitter in the output.
2015-11-19 19:25:48 +11:00
Sebastian Dröge
96eb5ef33c amcvideodec: Don't require a non-zero buffer size when doing decoding to a surface
At least on some devices/Android versions the buffer size will always be zero
in these cases.

https://bugzilla.gnome.org/show_bug.cgi?id=758228
2015-11-18 09:23:49 +02:00
Sebastian Dröge
be7f4d6cd6 amcvideodec: Fix indentation 2015-11-17 16:21:10 +02:00
Matthew Waters
3bf7430411 glimagesink: wait on the correct sync meta when rendering 2015-11-17 15:27:26 +11:00
Matthew Waters
f2ca0eaf27 amcviddec: output external-oes textures
This provides a performance and power usage improvement by removing
the texture copy from an OES texture to 2D texture.

The flow is as follows
1. Generate the output buffer with the required sync meta with the incrementing
   push counter and OES GL memory
1.1 release_output_buffer (buf, render=true) and push downstream
2. Downstream waits for on the sync meta (timed wait) or drops the frame (no wait)
2.1 Timed wait for the frame number to reach the number of frame callbacks fired
2.2 Unconditionally update the image when the wait completes (success or fail).
    Sets the affine transformation matrix meta on the buffer.
3. Downstream renders as usual.

At *some* point through this the on_frame_callback may or may not fire.  If it
does fire, we can finish waiting early and render. Otherwise we have to
wait for a timeout to occur which may cause more buffers to be pused into the
internal GL queue which siginificantly decreases the chances of the
on_frame_callback to fire again.  This is because the frame callback only occurs
when the internal GL queue changes state from empty to non-empty.

Because there is no way to reliably correlate between the number of buffers
pushed and the number of frame callbacks received, there are a number of
workarounds in place.
1. We self-increment the ready counter when it falls behind the push counter
2. Time based waits as the frame callback may not be fired for a certain frame.
3. It is assumed that the device can render at speed or performs some QoS of
   the interal GL queue (which may not match the GStreamer QoS).

It holds that we call SurfaceTexture::updateTexImage for each buffer pushed
downstream however there's no guarentee that updateTexImage will result in
the exact next frame (it could skip or duplicate) so synchronization is not
guaranteed to be accurate although it seems to be close enough to be unable
to discern visually.  This has not changed from before this patch.  The current
requirement for synchronization is that updateTexImage is called at the point in
time when the buffers is to be rendered.

https://bugzilla.gnome.org/show_bug.cgi?id=757285
2015-11-17 15:27:26 +11:00
Luis de Bethencourt
1ba4d63d6a amcvideodec: use GST_STIME_ARGS for GstClockTimeDiff
No need to manually handle negative value of deadline, GST_STIME_ARGS does
exactly this.
2015-11-03 15:00:28 +00:00
Matthew Waters
c6f2426a7a androidmedia: fix build errors
printf %lld instead of G_GINT64_FORMAT.
Double ret variable declaration.
2015-10-21 05:33:13 +11:00
Matthew Waters
c322806227 amcviddec: use gstcontext to retreive the OpenGL context 2015-10-21 04:27:43 +11:00
Matthieu Bouron
7dbb6681a3 androidmedia: Only allow GL output if the decoder has unknown color formats
If GST_AMC_IGNORE_UNKNOWN_COLOR_FORMATS is set to yes, non-GL output
is still allowed.

https://bugzilla.gnome.org/show_bug.cgi?id=731204
2015-10-21 04:27:43 +11: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
Matthieu Bouron
45e287840d androidmedia: Do not flush codec if it is not started 2015-10-21 04:27:43 +11:00
Matthieu Bouron
6ca0be038a androidmedia: Allow object to be NULL in gst_amc_jni_*unref functions 2015-10-21 04:27:43 +11:00
Edward Hervey
88cd44fbd8 androidmedia: Fix debug statement (%d for a gsize argument) 2015-10-21 04:27:43 +11:00
Matthieu Bouron
4ab1e66b2e androidmedia: Improve color format debug messages 2015-10-21 04:27:43 +11:00
Matthieu Bouron
8c46a7704a androidmedia: Improve debug messages 2015-10-21 04:27:43 +11:00
Matthieu Bouron
a038478f1b androidmedia: Do not warn we do not support COLOR_FormatSurface 2015-10-21 04:27:43 +11:00
Sebastian Dröge
f441b9d5d2 amcvideodec: Properly forward the return value of gst_video_decoder_negotiate()
https://bugzilla.gnome.org/show_bug.cgi?id=756578
2015-10-16 09:12:35 +03:00
Sebastian Dröge
b48524c357 amcvideodec: Implement support for COLOR_QCOM_FormatYVU420SemiPlanar32mMultiView for decoding
https://bugzilla.gnome.org/show_bug.cgi?id=756578
2015-10-16 09:12:35 +03:00
Sebastian Dröge
431c4b5e84 amcvideoenc: Always set i-frame-interval setting
Most encoders fail to initialize if we don't set it at all.
2015-07-29 10:13:17 +01:00
Sebastian Dröge
42a1a95f3e androidmedia: Add support for H265/HEVC 2015-07-08 11:42:48 +03:00
Vineeth TM
96d691694a amc: fix check whether we managed to acquire a buffer
https://bugzilla.gnome.org/show_bug.cgi?id=751821
2015-07-02 09:14:45 +01:00
Sebastian Dröge
d5a676aec8 androidmedia: Call initialize_classes() also when we got the Java VM from the app
https://bugzilla.gnome.org/show_bug.cgi?id=751664
2015-06-29 18:51:04 +02:00
Sebastian Dröge
6b2800e324 androidmedia: Allow the application to provide the Java VM
In JNI_OnLoad() we will already get the Java VM passed and could
just directly use that. gstreamer_android-1.0.c will now provide
this to us.

Reason for this is that apparently not all Android system are
providing the JNI functions to get the currently running Java VMs, so
we would fail to get. With this we will always be able to get the Java
VM on such systems.
2015-06-18 14:38:04 +02:00
Sebastian Dröge
c51b012991 androidmedia: Prefer software codecs over hardware codecs for audio
Hardware codecs don't make sense for audio and are generally less reliable on
Android than the software codecs.
2015-06-18 14:31:39 +02:00
Sebastian Dröge
26396bfac2 androidmedia: Failing to detach a thread is not that much of a problem
Someone else might have detached it before us, so make this just normal debug
output instead of a GST_ERROR()
2015-06-18 14:29:33 +02:00
Sebastian Dröge
ade625111e androidmedia: Don't fail if JNI_CreateJavaVM can't be found
We only need that if no Java VM is running yet, and all usual cases,
i.e. when calling GStreamer from an actual Android app, there will already
be a Java VM we can just use.

It seems like some phones come without that symbol, let's hope they come
with the other symbol but for now don't make a missing JNI_CreateJavaVM fatal.
2015-06-18 10:45:24 +02:00
Sebastian Dröge
6be20ffb79 androidmedia: Move variables into the scope where they are needed 2015-06-15 14:22:00 +02:00
Sebastian Dröge
90c4a6ecd0 androidmedia: Don't query supported color formats for non-video codecs 2015-06-15 12:20:24 +02:00
Sebastian Dröge
d221108857 amc: Only lower ranks of OMX.Exynos. audio codecs, the video codecs are actually working 2015-06-01 20:03:22 +02:00
Sebastian Dröge
bf07b52477 amc: Give marginal rank to codecs that start with OMX.Exynos.
OMX.Exynos. codecs are existing on some devices like the
Galaxy S5 mini, and cause random crashes (of the device,
not the app!) and generally misbehave. That specific device
has other codecs that work with a different name, but let's
just give them marginal rank in case there are devices that
have no other codecs and these are actually the only working
ones
2015-06-01 19:41:21 +02:00
Sebastian Dröge
2e0395aa59 androidmedia: Give lower ranks to codecs not starting with OMX.
On some devices there are codecs that don't start with OMX., while
there are also some that do. And on some of these devices the ones
that don't start with OMX. just crash during initialization while
the others work. To make things even more complicated other devices
have codecs with the same name that work and no alternatives.
So just give a lower rank to these non-OMX codecs and hope that
there's an alternative with a higher rank.

Also stagefright gives codecs starting with OMX. a higher rank too and
considers other codecs that don't start with OMX. as software codecs.
2015-06-01 19:41:21 +02: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
Matthieu Bouron
3c77fbda87 androidmedia: Add suport for COLOR_FormatYV12
Reference: http://developer.android.com/reference/android/graphics/ImageFormat.html#YV12

https://bugzilla.gnome.org/show_bug.cgi?id=747126
2015-05-04 12:45:12 +02:00
Matthieu Bouron
bd21df1056 androidmedia: Declare QOMX_COLOR_FORMATYVU420PackedSemiPlanar32mMultiView constant
This color format is the same as QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m
but stores two images one after the other in a top-bottom layout.

https://bugzilla.gnome.org/show_bug.cgi?id=747126
2015-05-04 12:44:56 +02:00
Matthieu Bouron
21ff3ae0b0 androidmedia: Fix slice-height for Tegra 3 devices
https://bugzilla.gnome.org/show_bug.cgi?id=748867
2015-05-04 10:39:38 +02:00
Edward Hervey
8d41c3e393 androidmedia: Add support for COLOR_FormatYUV420Flexible
https://bugzilla.gnome.org/show_bug.cgi?id=747126
2015-05-04 09:34:29 +02:00
Edward Hervey
0654442c8f androidmedia: Add suport for Intel color formats
https://bugzilla.gnome.org/show_bug.cgi?id=747126
2015-05-04 09:34:15 +02:00
Tim-Philipp Müller
699452ef31 Remove obsolete Android build cruft
This is not needed any longer.
2015-04-26 18:59:32 +01: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
Sebastian Dröge
265538ac6e amc: Use new JNI utils almost everywhere 2015-04-11 19:44:34 +02:00
Sebastian Dröge
7fb0fafed2 amc: Allow creating global and local references of objects 2015-04-11 19:37:34 +02:00
Sebastian Dröge
6c7b64f90c amc: Make GError argument order more consistent 2015-04-11 19:37:34 +02:00
Sebastian Dröge
448867f0aa amc: Add helper function for getting a direct buffer array 2015-04-11 19:37:20 +02:00
Sebastian Dröge
0dbf5d322f amc: Java longs are gint64s 2015-04-11 19:37:20 +02:00
Sebastian Dröge
0914ee4a07 amc: Improve JNI utilities and add some missing ones
We now fill GErrors for everything that could throw an exception, and method
calls now always return a gboolean and their value in an out-parameter to
distinguish failures from other values.
2015-04-11 19:37:20 +02:00
Sebastian Dröge
35ef602b7d androidmedia: Add helpers for calling static methods 2015-03-15 16:59:25 +00:00
Sebastian Dröge
1580336152 androidmedia: Fix indention 2015-03-15 16:41:12 +00:00
Matthieu Bouron
66f315d6a6 androidmedia: Add more JNI helper functions 2015-03-15 16:28:03 +00:00
Matthieu Bouron
be2378a071 androidmedia: Split jni code to gstjniutils.c 2015-03-15 16:28:03 +00:00
Edward Hervey
4b5d3a97ba androidmedia: Remove unused label/variable 2015-03-11 10:17:53 +01:00
Sebastian Dröge
66a4572c12 androidmedia: Fix calculation of the frame size for COLOR_FormatYUV420Planar
https://bugzilla.gnome.org/show_bug.cgi?id=734156
2014-10-02 10:26:43 +03: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
Anuj Jaiswal
a3958ae65b androidmedia: break statement unnecessary
Code flow never arrives to the break statements due to the goto's. So the
breaks are unecessary.

https://bugzilla.gnome.org/show_bug.cgi?id=736942
2014-09-24 12:12:16 +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 Rasmussen
c1d5aa3da5 amcvideoenc: Avoid leaking copy of caps object
gst_pad_get_pad_template_caps() returns a reference which is unreferenced,
so creating a copy using gst_caps_copy() results in a reference leak.
Also remove the incorrect comment to avoid confusion in the future.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=734533
2014-08-10 12:11:10 +01:00
Sebastian Dröge
74c2e64d5d amc: Properly integrate COLOR_QCOM_FormatYVU420SemiPlanar32m again
https://bugzilla.gnome.org/show_bug.cgi?id=732683
2014-07-03 17:53:33 +02:00
Sebastian Dröge
93bce7aeb7 amcaudiodec: audio/mpeg is always MPEG 1 layer 3
Configuring e.g. layer 2 on such a decoder usually fails unless
it additionally also accepts audio/mpeg-L2.
2014-07-03 15:07:23 +02:00
Sebastian Dröge
337bc06de1 androidmedia: Clear exceptions also when we did not provide a GError 2014-06-20 14:59:12 +02: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
b44724f662 androidmedia: Actually print the stacktrace into the error string 2014-06-02 12:39:49 +02:00
Sebastian Dröge
40fb09544f androidmedia: Clear the exception before trying to call Java methods to convert it to a string 2014-06-02 11:28:43 +02:00
Sebastian Dröge
0c93a82861 androidmedia: Fix crashes when loading the plugin in a standalone application on Android >= 4.4
Check if libnativehelper is loaded in the process and if
it has these awful wrappers for JNI_CreateJavaVM and
JNI_GetCreatedJavaVMs that crash the app if you don't
create a JniInvocation instance first. If it isn't we
just fail here and don't initialize anything.

See this code for reference:
https://android.googlesource.com/platform/libnativehelper/+/master/JniInvocation.cpp
2014-06-02 11:18:38 +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
Sebastian Dröge
440574d963 androidmedia: Add a GError argument to all amc methods and catch exceptions there 2014-05-30 15:25:25 +02:00
Sebastian Dröge
22b5abf86c androidmedia: Describe exceptions happening when scanning all codecs 2014-05-30 15:25:21 +02:00
Sebastian Dröge
3cf4c8cad1 androidmedia: Add API to convert an exception into a string 2014-05-30 15:25:21 +02:00