How do I add media codec support to Crosswalk when using the Cordova plugin?

I am creating a PhoneGap application that needs to play AAC audio. It works well using native WebView

, but I'd like to use Crosswalk for APIs to target build 16-20, because some CSS features in my app don't work at all on Android 4.x.

When I make a copy of the project to add Crosswalk Lite, I can see that the application works, except for the item <audio>

pointing to the AAC file. This is due to the fact that Crosswalk does not come with proprietary codecs by default .

The linked page says:

To build Crosswalk with these codecs, the developer must run the build with the "must accept EULA" switch enabled:

$ xwalk/gyp_xwalk -Dmediacodecs_EULA=1

      

Then build the Crosswalk. The ffmpegsumo.dll or libffmpegsumo.so file in the build output directory will contain proprietary codecs.

See Crosswalk Building Instructions for details .

However, I am adding Crosswalk using the suggested plug-in, so I end up with prebuilt libraries without proprietary codecs:

phonegap plugin add cordova-plugin-crosswalk-webview  --variable XWALK_MODE="lite" --save

      

How can I integrate proprietary codecs into the Cordova Crosswalk plugin?

+3


source to share


1 answer


I managed to figure out the (confusing) process of building everything. This answer is about the process of compiling a custom build of the full Crosswalk (not the lite version).

Actually, I decided to finally use the standard build and replace the AAC audio with MP3, but I thought this answer might be useful for future reference.

Environment

I built Crosswalk in an Ubuntu 16.04 Docker container to avoid polluting my system and to ensure I had the correct Linux version. The stock image is pretty barebones, so I installed some dependencies. I also created a shared folder to access the compiled files:

docker run -it -v /home/andrea/shared:/shared ubuntu:16.04 /bin/bash
apt update
apt install -y python git nano lsb-release sudo wget curl software-properties-common
export EDITOR=nano # life it too short to learn vi

      

Finally, you need to add the multiverse repositories :

apt-add-repository multiverse

      

Note: This procedure requires a lot of space. Make sure you have at least 25 GB of free space before proceeding.

Requirements

Install depot_tools

as stated in the documentation :

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:/path/to/depot_tools

      

Initialize working directory with

mkdir crosswalk-checkout
cd crosswalk-checkout
export XWALK_OS_ANDROID=1
gclient config --name src/xwalk https://github.com/crosswalk-project/crosswalk.git

      

Then edit the config file with nano .gclient

and add the following line:

target_os = ['android']

      

Save the file.

Extract source

Try your first sync with:

gclient sync

      

This command will fail , but that's ok. The instructions say:

Don't worry if gyp_xwalk

it fails due to lack of dependencies; their installation is covered in the next section, after which you can start gyp_xwalk

manually again .

Correct the file install-build-deps.sh

and then run it:

sed -si "s/msttcorefonts/ttf-mscorefonts-installer/g" src/build/install-build-deps.sh
sudo ./src/build/install-build-deps-android.sh

      

Run gclient sync

again and wait until it finishes correctly.

Building



By checking the src/xwalk/build/common.gypi

and files src/tools/mb/mb_config.pyl

, we can see what we need to add ffmpeg_branding="Chrome"

to the build arguments.

To prevent the error later, install the development package associated with libnotify:

sudo apt install libnotify-dev

      

Move to directory src

and open configuration:

cd src/
gn args out/Default

      

Make sure the content looks like this:

import("//xwalk/build/android.gni")
target_os = "android"
is_debug = false
ffmpeg_branding = "Chrome"
use_sysroot = false

      

The options use_sysroot = false

prevent another error. When you save the file, you should see something like this:

Waiting for editor on "/home/utente/crosswalk-checkout/src/out/Default/args.gn"...
Generating files...
Done. Wrote 6060 targets from 1003 files in 2416ms

      

Problem cd ..

and run again gclient sync

.

Finally, to create the main library, run:

cd src/
ninja -C out/Default xwalk_core_library

      

This will create a library for ARM by creating an AAR file located at:

src/out/Default/xwalk_core_library.aar

      

Copy this file to a safe location.

Building for x86

Revert back to the arguments with:

gn args out/Default

      

Add the following line:

target_cpu = "x86"

      

Save the file, run gclient sync

and resubmit the command ninja

. Make a copy of the new AAR file, which now contains the x86 libraries.

Using AAR files

The standard Cordova Crosswalk plugin uses a single AAR file with libraries for both platforms. This post from Raphael Kubo da Costa suggests how to create this single archive:

AAR files are only zip files; given the only difference between ARM and x86 AAR files are different shared libraries, you can use something like zipmerge

or anything that combines zip files
(or even extract everything to some directory and then create one new zip file ) to create one final AAR archive with multiple architectures.

Finally, to use a custom AAR file in the Cordova plugin, see How to change the version of Crosswalk used by the Cordova Crosswalk Webview plugin .

+1


source







All Articles