Camera2 API development

I tried with make clean when i switched the branch. And i think libdroidmedia is the correct make target.

For the xa2 i needed additionally libncurses5, python2 and LC_ALL=C is required. (that is at least as far as i got). I am currently trying to build a dockerfile that includes all the requirements i needed.

3 Likes

I got the libdroidmedia.so now for the XA2:

build with this script in ./makelib

#!/bin/bash
# have jdk8 and the repo tool from android installed
export VENDOR=sony
export DEVICE=h4113
export HABUILD_DEVICE=pioneer
export FAMILY=nile
export BRANCH=8.1.0_r52
export HAVERSION="hybris-sony-aosp-"$BRANCH"_20190206"
export PORT_ARCH=aarch64
export LC_ALL=C

cd build
source build/envsetup.sh
export USE_CCACHE=1
lunch aosp_h4113-eng
make -j$(nproc --all) droidmedia

on this docker image in docker/Dockerfile

FROM python:2.7-buster
ENTRYPOINT [ "/bin/bash" ]
RUN apt-get update && apt-get install -y \
  software-properties-common  build-essential gcc-multilib make ccache libncurses5 \
  && wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | apt-key add - \
  && add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ \
  && apt-get update && apt-get install -y adoptopenjdk-8-hotspot \
  && rm -rf /var/cache/apk/*

Instructions

  • Setup the repositories with repo and clone droidmedia into build/
# have jdk8 and the repo tool from android installed
cd build
export VENDOR=sony
export DEVICE=h4113
export HABUILD_DEVICE=pioneer
export FAMILY=nile
export BRANCH=8.1.0_r52
export HAVERSION="hybris-sony-aosp-"$BRANCH"_20190206"
export PORT_ARCH=aarch64
repo init -u https://github.com/mer-hybris/android.git -b $HAVERSION -m tagged-manifest.xml
repo sync -c --fetch-submodules
git clone https://github.com/mer-hybris/droid-src-sony-nile droid-src
git clone https://github.com/sailfishos/droidmedia external/droidmedia
  • write the build script to makelib and the dockerfile to docker/
  • run docker build docker/ and get the image hash
  • run docker run -it -v(pwd):/camera2api -w /camera2api <imagehash> to get into the image
  • execute bash makelib
  • find libdroidmedia in build/out/target/product/pioneer/system/lib/ (or maybe lib64 if you are on another device)
  • if this works run cd build && make clean && cd ..
  • now you can switch the branch for droidmedia and rebuild with the camera2 api
  • deploy it to /usr/libexec/droid-hybris/system/lib/libdroidmedia.so on your phone (maybe lib64 on other devices.make sure you do not mix lib and lib64 :wink:
6 Likes

I don’t why make droidmedia did not include the libdroidmedia target but now I was able to successfully build the lib. Thanks @thigg !

I can confirm the inverted viewfinder colors, looks fancy actually. Photos have correct color and are taken as fast as in OpenCamera :+1:

@mal A list with known open todos would be super useful or maybe even an issue for each. Feel free to dump a list here and have the community turn it into proper issues. I assume we then open PRs against the camera2 branch and merge to master once ready?

5 Likes

The inverted color issue sounds like a wrong pixel format, but if it was just that, it would already be corrected… Let’s hope that’s not a firmware issue that needs to be worked around…

I’m excited about the progress! I wish I had more hours in a day so I could participate in this, but unfortunately I don’t…

3 Likes

We can certainly create new issues on the droidmedia project, maybe prefix them all with [Camera2]. What we miss is something of a milestone or label created for that, but that’s details.

We have esr91 milestone in Issues · sailfishos/sailfish-browser · GitHub and that looks very clear to me. Maybe having milestone “camera2” for each camera2 related issue. Some food for thought.

2 Likes

Hi @rainemak, I fully agree that a milestone/label with “camera2” would help, however I don’t think any of us can create it. Can you or @mal create this and we’ll just use it? Thanks!

4 Likes

Hi @vlagged ! Created camera2 label (for colored issues) and milestone

Please use flag both camera2 label and milestone when going forward.

10 Likes

So, if released, Camera API 2.0 will affect all SailfishOS-Units also the Ports?

1 Like

A small status update on Camera2 support. I managed to find a fix for the viewfinder color issue. I also have almost working video recording support which does record the video and I can see the first frame of the video when playing it but because of some issue with frame timestamps all later frames are skipped. These changes are not yet in the camera2 branch because I need to cleanup the code again after the a bit ugly code that was created during debugging of the issues.

As for the question in previous comment: current plan is that Camera2 support would be available for all devices which are built on Android 7 or newer base. Community ports need to have their adaptation packages updated to get the support so schedule of that depends on each porter when they will do that after the support is finalized and merged.

50 Likes

I just tried the camera2 branch on my xperia 10-iii. The nice thing is, that camera usage does not interfere anymore with android. I can use android and sfos applications using the camera and it just works :slight_smile:

although the quality seems to be better in sfos…

24 Likes

by any chance, does anyone have camera2 libdroidmedia.so built for 10iii?
i would love to not have OpenCamera and jolla-camera crash each other all the time, but not quiiite enough to undertake that build procedure

Unfortunately none of us had time to work on it the last few months so it is still not super functional (no video, no torch, no creative modes, strange exposure settings, …)

3 Likes

thanks. i know it’s not ready, and i was still interested in trying out the camera2 lib, to test it out, and see if it fixed the crashes in android OpenCamera.

however, after reading the issue you wrote more carefully, i see that the torch doesn’t work even outside the camera app, and you’re correct, i rely on the torch too much to use it as-is.

anyway, thanks so much for the work you folks have been doing on this!

no commits since november. has this hit an insurmountable block, or is everyone just too busy on 4.6/etc?

1 Like

As i understood it it was a private effort and not done by jolla, but maybe that changed now

2 Likes

I have been too busy with other work to focus on camera 2 API development. Hopefully I’ll manage to find time soon to continue with the missing pieces. There is are some a bit difficult issues to solve but nothing that couldn’t be figured out.

31 Likes

Thank you for the instructions @dcaliste and @thigg .

I was unable to build droidmedia on recent Ubuntu (24.04), because of newer version ncurses. So, I created docker image based on older Ubuntu and it works pretty fine! You can find it on github if you want to play with droidmedia too.

Just run (in my docker branch):

docker build -t droidmedia docker

Then you may switch the branch of droidmedia, prepare your own changes and build it in container:

docker run --name droidmedia-devel -v $(pwd):/workdir/external/droidmedia -it droidmedia

# in the container:
source build/envsetup.sh
lunch aosp_$DEVICE-user
make libdroidmedia
7 Likes