diff --git a/extensions/cronet/README.md b/extensions/cronet/README.md new file mode 100644 index 0000000000..be79ac7d3e --- /dev/null +++ b/extensions/cronet/README.md @@ -0,0 +1,31 @@ +# ExoPlayer Cronet Extension # + +## Description ## + +[Cronet][] is Chromium's Networking stack packaged as a library. + +The Cronet Extension is an [HttpDataSource][] implementation using [Cronet][]. + +[HttpDataSource]: https://google.github.io/ExoPlayer/doc/reference/com/google/android/exoplayer/upstream/HttpDataSource.html +[Cronet]: https://chromium.googlesource.com/chromium/src/+/master/components/cronet?autodive=0%2F%2F + +## Build Instructions ## + +* Checkout ExoPlayer along with Extensions: + +``` +git clone https://github.com/google/ExoPlayer.git +``` + +* Get the Cronet libraries: + +1. Find the latest Cronet release [here][] and navigate to its `Release/cronet` + directory +1. Download `cronet.jar`, `cronet_api.jar` and the `libs` directory +1. Copy the two jar files into the `libs` directory of this extension +1. Copy the content of the downloaded `libs` directory into the `jniLibs` + directory of this extension + +* In ExoPlayer's `settings.gradle` file, uncomment the Cronet extension + +[here]: https://console.cloud.google.com/storage/browser/chromium-cronet/android diff --git a/extensions/cronet/build.gradle b/extensions/cronet/build.gradle new file mode 100644 index 0000000000..0b75639d73 --- /dev/null +++ b/extensions/cronet/build.gradle @@ -0,0 +1,51 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +apply plugin: 'com.android.library' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.1" + + defaultConfig { + minSdkVersion 9 + targetSdkVersion 23 + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } + + lintOptions { + abortOnError false + } + + sourceSets.main { + jniLibs.srcDirs = ['jniLibs'] + } +} + +dependencies { + compile project(':library') + compile files('libs/cronet_api.jar') + compile files('libs/cronet.jar') + androidTestCompile 'com.google.dexmaker:dexmaker:1.2' + androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2' + androidTestCompile 'org.mockito:mockito-core:1.9.5' + androidTestCompile project(':library') + androidTestCompile 'com.android.support.test:runner:0.4' +} diff --git a/extensions/cronet/jniLibs/README.md b/extensions/cronet/jniLibs/README.md new file mode 100644 index 0000000000..e9f0717ae6 --- /dev/null +++ b/extensions/cronet/jniLibs/README.md @@ -0,0 +1 @@ +Copy folders containing architecture specific .so files here. diff --git a/extensions/cronet/libs/README.md b/extensions/cronet/libs/README.md new file mode 100644 index 0000000000..641a80db18 --- /dev/null +++ b/extensions/cronet/libs/README.md @@ -0,0 +1 @@ +Copy cronet.jar and cronet_api.jar here. diff --git a/library/src/main/java/com/google/android/exoplayer2/util/Clock.java b/library/src/main/java/com/google/android/exoplayer2/util/Clock.java new file mode 100644 index 0000000000..01f667ed86 --- /dev/null +++ b/library/src/main/java/com/google/android/exoplayer2/util/Clock.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.android.exoplayer2.util; + +/** + * An interface through which system clocks can be read. The {@link SystemClock} implementation + * must be used for all non-test cases. + */ +public interface Clock { + + /** + * Returns {@link android.os.SystemClock#elapsedRealtime}. + * + * @return Elapsed milliseconds since boot. + */ + long elapsedRealtime(); + +} diff --git a/library/src/main/java/com/google/android/exoplayer2/util/SystemClock.java b/library/src/main/java/com/google/android/exoplayer2/util/SystemClock.java new file mode 100644 index 0000000000..b05675f647 --- /dev/null +++ b/library/src/main/java/com/google/android/exoplayer2/util/SystemClock.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.android.exoplayer2.util; + +/** + * The standard implementation of {@link Clock}. + */ +public final class SystemClock implements Clock { + + @Override + public long elapsedRealtime() { + return android.os.SystemClock.elapsedRealtime(); + } + +} diff --git a/settings.gradle b/settings.gradle index ad16f1d324..8500dc6af7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -20,10 +20,15 @@ include ':extension-vp9' include ':extension-okhttp' include ':extension-flac' include ':extension-ffmpeg' +// Uncomment the following line to use the Cronet Extension. +// include ':extension-cronet' + project(':extension-opus').projectDir = new File(settingsDir, 'extensions/opus') project(':extension-vp9').projectDir = new File(settingsDir, 'extensions/vp9') project(':extension-okhttp').projectDir = new File(settingsDir, 'extensions/okhttp') project(':extension-flac').projectDir = new File(settingsDir, 'extensions/flac') project(':extension-ffmpeg').projectDir = new File(settingsDir, 'extensions/ffmpeg') - +// Uncomment the following line to use the Cronet Extension. +// See extensions/cronet/README.md for details. +// project(':extension-cronet').projectDir = new File(settingsDir, 'extensions/cronet')