Skip to content

Commit

Permalink
Fixed logging, updated javadocs, prepared for maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
ex3ndr committed Sep 29, 2014
1 parent bbc7153 commit 270ed45
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 6 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
93 changes: 90 additions & 3 deletions opus/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ buildscript {
}
}
apply plugin: 'android-library'
apply plugin: 'maven'
apply plugin: 'signing'

group = 'com.droidkit'
version = '1.1'

repositories {
mavenCentral()
Expand All @@ -20,7 +25,7 @@ android {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
versionName "1.1"

ndk {
moduleName "opus"
Expand All @@ -43,7 +48,89 @@ android {
}
}

// Android JavaDocs
android.libraryVariants.all { variant ->
task("${variant.name}Javadoc", type: Javadoc) {
destinationDir = new File("$project.buildDir/javadoc/$variant.name")

source = variant.javaCompile.source
exclude '**/BuildConfig.java'
exclude '**/R.java'

ext.androidJar = "${android.plugin.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
}

task("${variant.name}JavadocJar", type: Jar, dependsOn: "${variant.name}Javadoc") {
classifier 'javadoc'
destinationDir = new File("$project.buildDir/libs/")
from "$project.buildDir/javadoc/$variant.name"
}

task("${variant.name}SourcesJar", type: Jar) {
classifier 'sources'

destinationDir = new File("$project.buildDir/libs/")

from variant.javaCompile.source
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
}

project.afterEvaluate {
artifacts {
archives releaseJavadocJar
archives releaseSourcesJar
}

if (project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")) {

signing {
sign configurations.archives
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
name 'DroidKit-Opus'
packaging 'aar'
description 'DroidKit Opus is OpusLib binding for Android'
url 'https://github.com/actorapp/droidkit-opus'

scm {
url 'scm:git@github.com:actorapp/droidkit-opus.git'
connection 'scm:git@github.com:actorapp/droidkit-opus.git'
developerConnection 'scm:git@github.com:actorapp/droidkit-opus.git'
}

licenses {
license {
name 'The MIT License (MIT)'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
}
}

developers {
developer {
id 'ex3ndr'
name 'Stepan Korshakov'
}
}
}
}
}
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
69 changes: 66 additions & 3 deletions opus/src/main/java/com/droidkit/opus/OpusLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,93 @@
import java.nio.ByteBuffer;

/**
* Created by ex3ndr on 29.09.14.
* OpusLib native binding
*/
public class OpusLib {
/**
* Starting opus recording
*
* @param path path to file
* @return non zero if started player
*/
public native int startRecord(String path);

/**
* Writing audio frame to encoder
*
* @param frame buffer with sound in 16 bit mono PCM 16000 format
* @param len len of data
* @return not null if successful
*/
public native int writeFrame(ByteBuffer frame, int len);

/**
* Stopping record
*/
public native void stopRecord();

/**
* Checking Opus File format
*
* @param path path to file
* @return non zero if opus file
*/
public native int isOpusFile(String path);

/**
* Opening file
*
* @param path path to file
* @return non zero if successful
*/
public native int openOpusFile(String path);

/**
* Seeking in opus file
*
* @param position position in file
* @return non zero if successful
*/
public native int seekOpusFile(float position);

public native int isOpusFile(String path);

/**
* Closing opus file
*/
public native void closeOpusFile();

/**
* Reading from opus file
*
* @param buffer
* @param capacity
*/
public native void readOpusFile(ByteBuffer buffer, int capacity);

/**
* Is playback finished
*
* @return non zero if playback is finished
*/
public native int getFinished();

/**
* Read block size in readOpusFile
*
* @return block size in bytes
*/
public native int getSize();

/**
* Offset of actual sound for playback
*
* @return offset
*/
public native long getPcmOffset();

/**
* Total opus pcm duration
*
* @return pcm duration
*/
public native long getTotalPcmDuration();
}
11 changes: 11 additions & 0 deletions opus/src/main/jni/log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef LOG_INCLUDED
#define LOG_INCLUDED

#include <android/log.h>

#define LOG_TAG "libopus"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)

#endif

0 comments on commit 270ed45

Please sign in to comment.