Skip to content

Commit dcddf15

Browse files
Merge pull request #1 from AlexTrotsenko/2020_04_noaudiostreamfix
Merge with latest master (as of 07.04.2020)
2 parents 74dbf9b + aa7dc58 commit dcddf15

File tree

18 files changed

+183
-46
lines changed

18 files changed

+183
-46
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## 0.3.0
2+
- Fix cancel() sometimes not working. (Thanks @strayerM and @PinkFloyded)
3+
- Geolocation support on API>=19. (Thanks @hkurokawa)
4+
5+
## 0.2.0
6+
- Experimental audio transcoding support. (Thanks @aaron112)
7+
- Fix transcode does not run on Huawei Ascend P7. (Thanks @spiritedRunning)
8+
- Fix race condition caused by not closing output before callback. (Thanks @ryanwilliams83)
9+
10+
## 0.1.10
11+
- `Future` support. (Thanks @MaiKambayashi)
12+
13+
## 0.1.X
14+
- Stability updates. (Thanks @ozyozyo)
15+
16+
## 0.1.0
17+
- First release.

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ repositories {
6767
```
6868

6969
```groovy
70-
compile 'net.ypresto.androidtranscoder:android-transcoder:0.1.10'
70+
compile 'net.ypresto.androidtranscoder:android-transcoder:0.2.0'
7171
```
7272

7373
## Note (PLEASE READ FIRST)
@@ -78,6 +78,20 @@ Use [qtfaststart-java](https://github.com/ypresto/qtfaststart-java) to place moo
7878
- Android does not gurantees that all devices have bug-free codecs/accelerators for your codec parameters (especially, resolution). Refer [supported media formats](http://developer.android.com/guide/appendix/media-formats.html) for parameters guaranteed by [CTS](https://source.android.com/compatibility/cts-intro.html).
7979
- This library does not support video files recorded by other device like digital cameras, iOS (mov files, including non-baseline profile h.264), etc.
8080

81+
82+
## More information about internals
83+
84+
There is a blog post about this library written in Japanese.
85+
http://qiita.com/yuya_presto/items/d48e29c89109b746d000
86+
87+
While it is Japanese, diagrams would be useful for understanding internals of this library.
88+
89+
## References for Android Low-Level Media APIs
90+
91+
- http://bigflake.com/mediacodec/
92+
- https://github.com/google/grafika
93+
- https://android.googlesource.com/platform/frameworks/av/+/lollipop-release/media/libstagefright
94+
8195
## License
8296

8397
```
@@ -95,9 +109,3 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95109
See the License for the specific language governing permissions and
96110
limitations under the License.
97111
```
98-
99-
## References for Android Low-Level Media APIs
100-
101-
- http://bigflake.com/mediacodec/
102-
- https://github.com/google/grafika
103-
- https://android.googlesource.com/platform/frameworks/av/+/lollipop-release/media/libstagefright

build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
maven {
7+
url 'https://maven.google.com/'
8+
name 'Google'
9+
}
610
}
711
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.1.2'
12+
classpath 'com.android.tools.build:gradle:2.3.3'
913

1014
// NOTE: Do not place your application dependencies here; they belong
1115
// in the individual module build.gradle files
@@ -15,5 +19,9 @@ buildscript {
1519
allprojects {
1620
repositories {
1721
jcenter()
22+
maven {
23+
url 'https://maven.google.com/'
24+
name 'Google'
25+
}
1826
}
1927
}

example/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 24
5-
buildToolsVersion "24.0.1"
5+
buildToolsVersion '25.0.0'
66

77
defaultConfig {
88
applicationId "net.ypresto.androidtranscoder.example"
@@ -21,4 +21,5 @@ android {
2121

2222
dependencies {
2323
compile project(':lib')
24+
compile 'com.android.support:support-core-utils:24.2.0'
2425
}

example/src/main/AndroidManifest.xml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="net.ypresto.androidtranscoder.example" >
3+
package="net.ypresto.androidtranscoder.example">
4+
5+
<uses-permission
6+
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
7+
android:maxSdkVersion="18" />
48

59
<application
610
android:allowBackup="true"
711
android:icon="@drawable/ic_launcher"
812
android:label="@string/app_name"
9-
android:theme="@style/AppTheme" >
13+
android:theme="@style/AppTheme">
1014
<activity
1115
android:name=".TranscoderActivity"
12-
android:label="@string/app_name" >
16+
android:label="@string/app_name">
1317
<intent-filter>
1418
<action android:name="android.intent.action.MAIN" />
1519

1620
<category android:name="android.intent.category.LAUNCHER" />
1721
</intent-filter>
1822
</activity>
23+
24+
<provider
25+
android:name="android.support.v4.content.FileProvider"
26+
android:authorities="net.ypresto.androidtranscoder.example.fileprovider"
27+
android:exported="false"
28+
android:grantUriPermissions="true">
29+
<meta-data
30+
android:name="android.support.FILE_PROVIDER_PATHS"
31+
android:resource="@xml/file_paths" />
32+
</provider>
1933
</application>
2034

2135
</manifest>

example/src/main/java/net/ypresto/androidtranscoder/example/TranscoderActivity.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.os.Bundle;
88
import android.os.ParcelFileDescriptor;
99
import android.os.SystemClock;
10+
import android.support.v4.content.FileProvider;
1011
import android.util.Log;
1112
import android.view.Menu;
1213
import android.view.MenuItem;
@@ -26,6 +27,7 @@
2627

2728
public class TranscoderActivity extends Activity {
2829
private static final String TAG = "TranscoderActivity";
30+
private static final String FILE_PROVIDER_AUTHORITY = "net.ypresto.androidtranscoder.example.fileprovider";
2931
private static final int REQUEST_CODE_PICK = 1;
3032
private static final int PROGRESS_BAR_MAX = 1000;
3133
private Future<Void> mFuture;
@@ -55,7 +57,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
5557
final File file;
5658
if (resultCode == RESULT_OK) {
5759
try {
58-
file = File.createTempFile("transcode_test", ".mp4", getExternalFilesDir(null));
60+
File outputDir = new File(getExternalFilesDir(null), "outputs");
61+
//noinspection ResultOfMethodCallIgnored
62+
outputDir.mkdir();
63+
file = File.createTempFile("transcode_test", ".mp4", outputDir);
5964
} catch (IOException e) {
6065
Log.e(TAG, "Failed to create temporary file.", e);
6166
Toast.makeText(this, "Failed to create temporary file.", Toast.LENGTH_LONG).show();
@@ -89,7 +94,10 @@ public void onTranscodeProgress(double progress) {
8994
public void onTranscodeCompleted() {
9095
Log.d(TAG, "transcoding took " + (SystemClock.uptimeMillis() - startTime) + "ms");
9196
onTranscodeFinished(true, "transcoded file placed on " + file, parcelFileDescriptor);
92-
startActivity(new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.fromFile(file), "video/mp4"));
97+
Uri uri = FileProvider.getUriForFile(TranscoderActivity.this, FILE_PROVIDER_AUTHORITY, file);
98+
startActivity(new Intent(Intent.ACTION_VIEW)
99+
.setDataAndType(uri, "video/mp4")
100+
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION));
93101
}
94102

95103
@Override
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<paths>
3+
<external-path
4+
name="output_videos"
5+
path="Android/data/net.ypresto.androidtranscoder.example/files/outputs" />
6+
</paths>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Mar 09 14:43:12 JST 2015
1+
#Thu Jun 08 12:40:11 IST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

lib/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ apply plugin: 'bintray-release'
1212

1313
android {
1414
compileSdkVersion 24
15-
buildToolsVersion "24.0.1"
15+
buildToolsVersion '25.0.2'
1616

1717
defaultConfig {
1818
minSdkVersion 18
@@ -32,7 +32,7 @@ android {
3232
publish {
3333
groupId = 'net.ypresto.androidtranscoder'
3434
artifactId = 'android-transcoder'
35-
version = '0.1.10-SNAPSHOT'
35+
version = '0.3.0'
3636
licences = ['Apache-2.0']
3737
website = 'https://github.com/ypresto/android-transcoder'
3838
autoPublish = false
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package net.ypresto.androidtranscoder.utils;
2+
3+
import junit.framework.TestCase;
4+
5+
public class ISO6709LocationParserTest extends TestCase {
6+
public void testParse() {
7+
ISO6709LocationParser parser = new ISO6709LocationParser();
8+
assertEquals(new float[]{35.658632f, 139.745411f}, parser.parse("+35.658632+139.745411/"));
9+
assertEquals(new float[]{40.75f, -074.00f}, parser.parse("+40.75-074.00/"));
10+
// with Altitude
11+
assertEquals(new float[]{-90f, +0f}, parser.parse("-90+000+2800/"));
12+
assertEquals(new float[]{27.5916f, 086.5640f}, parser.parse("+27.5916+086.5640+8850/"));
13+
// ranged data
14+
assertEquals(new float[]{35.331f, 134.224f}, parser.parse("+35.331+134.224/+35.336+134.228/"));
15+
assertEquals(new float[]{35.331f, 134.224f}, parser.parse("+35.331+134.224/+35.336+134.228/+35.333+134.229/+35.333+134.227/"));
16+
}
17+
18+
public void testParseFailure() {
19+
ISO6709LocationParser parser = new ISO6709LocationParser();
20+
assertNull(parser.parse(null));
21+
assertNull(parser.parse(""));
22+
assertNull(parser.parse("35 deg 65' 86.32\" N, 139 deg 74' 54.11\" E"));
23+
assertNull(parser.parse("+35.658632"));
24+
assertNull(parser.parse("+35.658632-"));
25+
assertNull(parser.parse("40.75-074.00"));
26+
assertNull(parser.parse("+40.75-074.00.00"));
27+
}
28+
29+
private static void assertEquals(float[] expected, float[] actual) {
30+
assertEquals(expected.length, actual.length);
31+
for (int i = 0; i < expected.length; i++) {
32+
assertTrue(Float.compare(expected[i], actual[i]) == 0);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)