Skip to content

Commit

Permalink
Make android build again
Browse files Browse the repository at this point in the history
Also include all android code into main repo.
  • Loading branch information
andoma committed Mar 14, 2018
1 parent c1c8da6 commit 499c73b
Show file tree
Hide file tree
Showing 35 changed files with 920 additions and 106 deletions.
57 changes: 21 additions & 36 deletions .doozer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,27 @@
"submodules": ["ext/libav", "ext/vmir", "ext/rtmpdump", "ext/gumbo-parser"],
"targets": {
"android": {
"buildenv": "jessie-i386",
"submodules": ["android"],
"builddeps": {

"debs": [
"openjdk-7-jdk",
"git-core",
"build-essential",
"autoconf",
"bison",
"flex",
"libelf-dev",
"libtool",
"pkg-config",
"texinfo",
"libncurses5-dev",
"libz-dev",
"python-dev",
"libssl-dev",
"libgmp3-dev",
"ccache",
"zip",
"curl",
"wget",
"ant"
],

"android-sdk": [
"platform-tools",
"android-21",
"build-tools-21.1.2"
],

"android-ndk": "http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86.bin"

},
"buildenv": "docker:andoma/movian-android",
"builddeps": [
"git-core",
"build-essential",
"autoconf",
"bison",
"flex",
"libelf-dev",
"libtool",
"pkg-config",
"texinfo",
"libncurses5-dev",
"libz-dev",
"python-dev",
"libssl-dev",
"libgmp3-dev",
"ccache",
"zip",
"curl",
"wget"
],
"buildcmd": "./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR} -v ${VERSION}"
},

Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
[submodule "ext/gumbo-parser"]
path = ext/gumbo-parser
url = https://github.com/google/gumbo-parser
[submodule "android"]
path = android
url = [email protected]:movian-android.git
[submodule "ios/freetype2-ios"]
path = ios/freetype2-ios
url = https://github.com/andoma/freetype2-ios.git
Expand Down
2 changes: 1 addition & 1 deletion Autobuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
#

set -eu
set -e

JARGS=""
TARGET=""
Expand Down
13 changes: 7 additions & 6 deletions Autobuild/android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ fi
${VERSIONARGS} \
--cleanbuild \
${USE_CCACHE} \
--downloadcache="${WORKINGDIR}/downloadcache" \
--sdk=/android/android-sdk-linux \
--ndk=/android/android-ndk-r10e
--downloadcache="${WORKINGDIR}/downloadcache"

APPNAME=movian

make ${JARGS} BUILD=${TARGET} release

artifact android/bin/Movian-release.apk apk application/vnd.android.package-archive ${APPNAME}.apk
if [ -z "${MOVIAN_KEYSTORE_PASS}" ]; then
make ${JARGS} BUILD=${TARGET}
else
make ${JARGS} BUILD=${TARGET} signed-apk
artifact build.${TARGET}/${APPNAME}.apk apk application/vnd.android.package-archive ${APPNAME}.apk
fi
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,8 @@ ${BUILDDIR}/support/dataroot/%.o : CFLAGS = -O2
##############################################################
##############################################################

include support/gitver.mk

include src/arch/${PLATFORM}/${PLATFORM}.mk


Expand Down Expand Up @@ -884,11 +886,7 @@ reconfigure:
showconfig:
@echo $(CONFIGURE_ARGS)

# Create buildversion.h
src/version.c: $(BUILDDIR)/buildversion.h
$(BUILDDIR)/buildversion.h: FORCE
@$(C)/support/version.sh $(C) $@
FORCE:
src/version.c: ${BUILDDIR}/version_git.h

# Include dependency files if they exist.
-include $(DEPS) $(BUNDLE_DEPS)
Expand Down
1 change: 0 additions & 1 deletion android
Submodule android deleted from ccfd17
40 changes: 40 additions & 0 deletions android/AndroidManifest.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lonelycoder.mediaplayer"
android:versionCode="@@VERCODE@@"
android:versionName="@@VERSION@@">

<uses-feature android:name="android.software.leanback"
android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen"
android:required="false"/>

<uses-sdk android:minSdkVersion="15"
android:targetSdkVersion="21"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application android:label="@@APPNAME@@"
android:icon="@drawable/ic_launcher"
android:banner="@drawable/banner">

<service android:name="CoreService"
android:label="@@APPNAME@@"/>

<activity android:name=".GLWActivity"
android:label="@@APPNAME@@"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>

</activity>
</application>
</manifest>
Binary file added android/movian.keystore
Binary file not shown.
Binary file added android/res/drawable-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-ldpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
177 changes: 177 additions & 0 deletions android/src/com/lonelycoder/mediaplayer/Core.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
package com.lonelycoder.mediaplayer;

import java.io.File;

import android.os.Handler;
import android.os.Message;
import android.os.Environment;
import android.content.Context;
import android.util.Log;
import android.graphics.Bitmap;
import android.app.Activity;
import android.view.SurfaceView;
import android.view.SurfaceHolder;
import android.graphics.PixelFormat;
import android.graphics.Canvas;
import android.text.format.DateFormat;
import android.widget.FrameLayout;

import android.media.MediaCodec;
import android.media.MediaFormat;

import android.provider.Settings.Secure;


public class Core {


private static Activity currentActivity;
private static SurfaceView sv;
private static Handler courier;
private static CoreService mService;

static {
System.loadLibrary("avutil");
System.loadLibrary("avresample");
System.loadLibrary("avcodec");
System.loadLibrary("avformat");
System.loadLibrary("swscale");
System.loadLibrary("core");
}

public static native void coreInit(String settingsdir, String cachedir,
String sdcard, String aid,
int clock_24hrs,
String music,
String pictures,
String movies,
int audio_sample_rate,
int audio_frames_per_buffer);

// These two GLW methods should be called on UI thread

public static native int glwCreate(VideoRendererProvider vrp);
public static native void glwDestroy(int id);

// These four GLW methods should be called on OpenGL renderer thread

public static native void glwInit(int id);
public static native void glwFini(int id);
public static native void glwResize(int id, int width, int height);
public static native void glwStep(int id);

// The thread for those are not so important I think...

public static native void glwMotion(int id, int source, int event, int x, int y, long timestamp);
public static native boolean glwKeyDown(int id, int code, int unicode,
boolean shift);
public static native boolean glwKeyUp(int id, int code);

// Create / Destroy subscriptions

public static native int subValue(int prop, String path, ValueSubscription.Callback cb);
public static native int subNodes(int prop, String path, NodeSubscriptionCallback cb);
public static native int unSub(int id);

// Properties

public static native int propRetain(int id);

public static native void propRelease(int id);

// Dispatch a round of property updates, should only be called on UI thread
public static native void pollCourier();

public static native void networkStatusChanged();

public static void init(CoreService svc) {

mService = svc;

courier = new Handler(svc.getMainLooper(), new Handler.Callback() {
public boolean handleMessage(Message msg) {
pollCourier();
return true;
}
});

int clock_24hrs = DateFormat.is24HourFormat(svc) ? 1 : 0;

coreInit(svc.getFilesDir().getPath(),
svc.getCacheDir().getPath(),
Environment.getExternalStorageDirectory().toString(),
Secure.getString(svc.getContentResolver(), Secure.ANDROID_ID),
clock_24hrs,
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).toString(),
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString(),
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).toString(),
svc.getSystemAudioSampleRate(),
svc.getSystemAudioFramesPerBuffer());
}

public static void wakeupMainDispatcher() {
courier.sendEmptyMessage(0);
}


public static Bitmap createBitmap(int width, int height) {
return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
}

public static String GetSysPath(String type) {
return Environment.getExternalStoragePublicDirectory(type).toString();
}

public static void pushBitmap(final Bitmap b) {

currentActivity.runOnUiThread(new Runnable() {
public void run() {

SurfaceHolder sh = sv.getHolder();

sh.setFormat(PixelFormat.RGBA_8888);

Canvas c = sh.lockCanvas();
c.drawBitmap(b, null, sh.getSurfaceFrame(), null);
sh.unlockCanvasAndPost(c);
}
});
}

public static native void vdInputAvailable(int opaque, int buf);
public static native void vdOutputAvailable(int opaque, int buf,
long pts);
public static native void vdOutputFormatChanged(int opaque,
MediaFormat format);
public static native void vdError(int opaque);


public static void setVideoDecoderWrapper(MediaCodec codec,
final int opaque) {

codec.setCallback(new MediaCodec.Callback() {

@Override
public void onInputBufferAvailable(MediaCodec mc, int buf) {
vdInputAvailable(opaque, buf);
}

@Override
public void onOutputBufferAvailable(MediaCodec mc, int buf,
MediaCodec.BufferInfo info) {
vdOutputAvailable(opaque, buf, info.presentationTimeUs);
}

@Override
public void onOutputFormatChanged(MediaCodec mc,
MediaFormat format) {
vdOutputFormatChanged(opaque, format);
}

@Override
public void onError(MediaCodec mc, MediaCodec.CodecException e) {
vdError(opaque);
}
});
}
}
Loading

0 comments on commit 499c73b

Please sign in to comment.