How to: test GStreamer-droid based camera support in Ubuntu Touch (for Halium 7.1 based port)
-
As you might already know, I'm currently making GStreamer-droid works properly in Ubuntu Touch as a replacement for qtubuntu-camera. This will make video recording works for Halium 7.1 based port, as otherwise a set of custom patches on the Android side (which isn't easy to forward-port) is required.
How can you test this out?
If you're interested in testing this out, please follow these instructions:
Halium side preparation
Due to breaking API change in droidmedia, you'll need to make sure you have a recently-built Halium image. If you build your own Android image, make sure your Halium tree is recently synced as of 8 June 2020. Otherwise, please make sure you have the latest image built on or after that date.
Install GStreamer-droid
- Make sure you're running the latest
devel
oredge
channel image. If you're interested in testing video recording too, please make sure that audio for your port works correctly. - Run
sudo umount /lib/udev/rules.d/70-android.rules
. This prevents failure in the following step. - Run
sudo ubports-qa install xenial_-_gst-droid
to add the repository containing the packages. UBports-qa will upgrade the already installed packages to the latest version and install the new packages.- If you encountered
unable to make backup link of '<a path>' before installing new version: Invalid cross-device link
error, unmount it by runningsudo umount <path without the prepending dot>
it and try again. - The error
ERROR:ubports-qa:Failed to remount root filesystem read-only.
is normal and expected. Proceed to the next step.
- If you encountered
- Reboot your phone to make sure everything is in place.
Install updated camera-app
You'll also need the updated camera-app. To install, grab the correct binary for armhf or arm64, then install with
pkcon install-local --allow-untrusted <file name>
. UPDATED to version 3.1.3.If you're interested in the changes I've made, take a look here.
How to debug
If things don't go as it should, you can add additional debug information by running the camera-app from the command line.
(cd /opt/click.ubuntu.com/com.ubuntu.camera/current && GST_DEBUG=droidcamsrc:4 ./camera-app --desktop_file_hint=com.ubuntu.camera_camera)
About the upgrading
Please note that by installing packages via
ubports-qa
orapt
, you should not install system updates via the system settings app anymore (you'll overwrite this change otherwise). Instead, you'll need to usesudo apt update
andsudo apt upgrade
like on the desktop. This is temporary, and won't be required after this is merged into the proper xenial branch.Also, even though this procedure works on devices on the stable channel, note that following this procedure essentially upgrades the entire device to devel channel. Please test responsibly and don't use it on your daily driver. This will be merged to the xenial branch soon and testing should be easier when that happens.
- Make sure you're running the latest
-
@peat_psuwit i tested it and video record not work got this error
ServiceManager: Waiting for service android.media.IMediaRecorderFactory...
-
I tried this patch on the Galaxy Note 4, works very well, even with flash, video however doesnt play back but I believe that is a mediahub or contenthub issue. I wanted to ask if there was a plan to get this merged into the halium repos or do we have to merge this patch intou our specific device repos? if we have to merge it to our device, what would be the best way to do so?
-
Hello,
I lost the camera access, see log : https://paste.ubuntu.com/p/q549BYtZ9C/Seems that it doesn't find the device and display multicolor squared image. I'm running a OP3 on edge which has a camera working.
-
@walidham Which device are you working on and based on Halium 5.1 or 7.1? IIRC,
android.media.IMediaRecorderFactory
is something I've seen only in Halium 5.1 port by Canonical's custom patch. In case I recalled it wrong, could you also share the result ofps ax -H
too?@ernest Could you please follow the instruction in "How to debug" and share the result with me? It will produce more debug information that could be useful for me.
-
@peat_psuwit said in How to: test GStreamer-droid based camera support in Ubuntu Touch (for Halium 7.1 based port):
ps ax -H
The device is LG V20 tmo h918 based on halium-7.1 and i used stock kernel for nogat 7.0
ps ax -H : https://paste.ubuntu.com/p/bF2t6MgwQZ/
Also i added camera_service in init.qcom.rc to force start media record
service camera_service /system/bin/camera_service
class main
user media
group audio cameraThis is error in logcat
https://paste.ubuntu.com/p/7rdQg83CbP/ -
@walidham Could you please try without
camera_service
?camera_service
comes from libhybris and contains some camera services. However, they're designed for 4.4 devices. The waygstreamer-droid
works should not require this service anymore.Not to be confused with
cameraserver
.cameraserver
is an Android service which splits frommediaserver
starting from 7.0 and is required for camera to work. -
@peat_psuwit Thankyou very much for your reply
First note is camera.msm8996 driver can't load without added libjnigraphics.so, libandroid-runtime.so and 17 others blobs files. I extracted them from cm-14.1 rom and added it to my system.img to make driver HAL camera happy and load.
I tried remove dependencies with patchelf but not work (got methods unknown errors).Second note :i tested camera with gst-inspect-1.0 got this error
** ERROR:gstamchybris.c:1286:scan_codecs: code should not be reached ** ERROR:gstamchybris.c:1286:scan_codecs: code should not be reached No such element or plugin 'androidmedia'
With droidmedia logcat show me this
ServiceManager: add_service('SurfaceFlinger',9) uid=1000 - ALREADY REGISTERED, OVERRIDE ServiceManager: service 'SurfaceFlinger' died ServiceManager: add_service('media.player',10) uid=1013 - ALREADY REGISTERED, OVERRIDE ServiceManager: service 'media.player' died
Thats why i used old camera_service with no hope to make video record work.
-
@peat_psuwit sorry to bother, but could you maybe provide an arm64 version of the updated camera app? or provide the source code so i can compile it myself?
-
@walidham said in How to: test GStreamer-droid based camera support in Ubuntu Touch (for Halium 7.1 based port):
First note is camera.msm8996 driver can't load without added libjnigraphics.so, libandroid-runtime.so and 17 others blobs files. I extracted them from cm-14.1 rom and added it to my system.img to make driver HAL camera happy and load.
I tried remove dependencies with patchelf but not work (got methods unknown errors).Notice that
libandroid-runtime.so
= ART i.e. the Java language runtime. It's unusual for a HAL library to link into it. What method does it say is missing when you tried patchelf it (and what library do you patchelf out)?Second note :i tested camera with gst-inspect-1.0 got this error
** ERROR:gstamchybris.c:1286:scan_codecs: code should not be reached ** ERROR:gstamchybris.c:1286:scan_codecs: code should not be reached No such element or plugin 'androidmedia'
How did you test camera with
gst-inspect-1.0
? Do you meangst-launch-1.0
? Also, that error doesn't come from gst-droid.With droidmedia logcat show me this
ServiceManager: add_service('SurfaceFlinger',9) uid=1000 - ALREADY REGISTERED, OVERRIDE ServiceManager: service 'SurfaceFlinger' died ServiceManager: add_service('media.player',10) uid=1013 - ALREADY REGISTERED, OVERRIDE ServiceManager: service 'media.player' died
Did you also add
minimediaservice
andminisfservice
? It seems likeminisfservice
conflicts with built in minisf in Mir andminimediaservice
conflicts with normalmediaserver
. Please remove both of them. If not, then what do you mean by "with droidmedia"? -
@ComLarsic I've updated the instruction to include the arm64 binary and the link to my modification. Thank you for raising that up!
-
I tried following the steps but the camera doesnt work anymore, i tried undo-ing all the commands but still no luck. is thereany way to bring it back go normal or would i have to reinstall UBTouch?
-
@peat_psuwit
i'm tried to remove the dependcies i ran this commandpatchelf --remove-needed "libjnigraphics.so" vendor/lge/v20-common/proprietary/lib/libfilm_emulation.so
got this error
E HAL : dlopen failed: cannot locate symbol "android_getCpuFeatures" referenced by "/system/lib/libbwfocuspeaking.so"...
This method android_getCpuFeatures i think its part from android NDK
Edit : i found it in libskia.so extracted from stock romnm -D libskia.so |grep android_getCpuFeatures 002ffca8 T android_getCpuFeatures
-
@ComLarsic It's hard to revert changes made by
lxc-android-config
, one of the packages updated. It's cleaner to just re-install Ubuntu Touch. You can do that by using the UBports Installer or by runningsudo system-image-cli -b 0 --progress dots
from an ADB or SSH session (not in the terminal app though).What device are you testing with?
-
@walidham Hmm, according to my research,
android_getCpuFeatures
is supposed to be compiled into the binary using it. If you can make it link tolibskia.so
(which seems to be available on normal Halium installation), then it might work. Also, seem like you'll have to removelibandroid.so
too. -
@peat_psuwit
Yes, android_getCpuFeatures i fount it builded in halium (libskia.so)
and i added libskia.so to libbwfocuspeaking.sopatchelf --add-needed "libskia.so" lib/libbwfocuspeaking.so
Also i updated camera libs , got camera work.
BUTTT
Make photo work , not very good, but i can take photo.
Video record no. I will investigate it more and return to you for HELLP
Best Regards and thankouy -
@peat_psuwit i am testing with the oneplus3t, i guess i'll have to reinstall then.
thanks for the help! -
I removed both minimediaservice & miniafservice, camera don't work, got "Camera service not found", but the driver is loaded correctly and system detect 3 cameras.
I think there is problem in sensor or sound, because got many errors in logcat.
Also why /data/misc/media is empty, there is no media_codecs_profiling_results.xml. -
Fixes video recording on garlic ,halium-7.1 with/without minimedia, miniaf and minisf services. For initial few shots from front camera were purple .
-
@pbt100 interesting, does your device have a delayed wake from sleep as a result of no mediaservice? Somewhere along the line an update broke video recording on my device