From f257300d8e770b57a22cc4a9cbf1120943be7e91 Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Tue, 12 Sep 2017 06:18:03 -0700 Subject: [PATCH] Add tv module for USB tuner support + demo app ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=168366847 --- .gitignore | 1 + demos/tv/README.md | 4 ++ demos/tv/build.gradle | 49 +++++++++++++++++++ extensions/tv/README.md | 41 ++++++++++++++++ extensions/tv/build.gradle | 39 +++++++++++++++ .../exoplayer2/util/ParsableBitArray.java | 11 +++++ 6 files changed, 145 insertions(+) create mode 100644 demos/tv/README.md create mode 100644 demos/tv/build.gradle create mode 100644 extensions/tv/README.md create mode 100644 extensions/tv/build.gradle diff --git a/.gitignore b/.gitignore index 1146c06456..1a946e2ade 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ proguard-project.txt # Other .DS_Store +cmake-build-debug dist tmp diff --git a/demos/tv/README.md b/demos/tv/README.md new file mode 100644 index 0000000000..8a1ab807a0 --- /dev/null +++ b/demos/tv/README.md @@ -0,0 +1,4 @@ +# TV tuner demo application # + +This folder contains a demo application that uses ExoPlayer to play broadcast +TV from USB tuners. diff --git a/demos/tv/build.gradle b/demos/tv/build.gradle new file mode 100644 index 0000000000..9e87d5e06b --- /dev/null +++ b/demos/tv/build.gradle @@ -0,0 +1,49 @@ +// Copyright (C) 2017 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 from: '../../constants.gradle' +apply plugin: 'com.android.application' + +android { + compileSdkVersion project.ext.compileSdkVersion + buildToolsVersion project.ext.buildToolsVersion + + defaultConfig { + minSdkVersion 21 + targetSdkVersion project.ext.targetSdkVersion + } + + buildTypes { + release { + shrinkResources true + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt') + } + debug { + jniDebuggable = true + } + } + + lintOptions { + // The demo app does not have translations. + disable 'MissingTranslation' + } + +} + +dependencies { + compile project(modulePrefix + 'library-core') + compile project(modulePrefix + 'library-ui') + compile project(modulePrefix + 'internal-extension-tv') + compile project(modulePrefix + 'extension-ffmpeg') +} diff --git a/extensions/tv/README.md b/extensions/tv/README.md new file mode 100644 index 0000000000..0deb33794f --- /dev/null +++ b/extensions/tv/README.md @@ -0,0 +1,41 @@ +# ExoPlayer TV tuner extension # + +Provides components for broadcast TV playback with ExoPlayer. + +## Links ## + +* [Javadoc][]: Classes matching `com.google.android.exoplayer2.ext.tv.*` + belong to this extension. + +[Javadoc]: https://google.github.io/ExoPlayer/doc/reference/index.html + +## Build Instructions ## + +* Checkout ExoPlayer: + +``` +git clone https://github.com/google/ExoPlayer.git +``` + +* Set the following environment variables: + +``` +cd "" +EXOPLAYER_ROOT="$(pwd)" +TV_MODULE_PATH="${EXOPLAYER_ROOT}/extensions/tv/src/main" +``` + +* Download the [Android NDK][] and set its location in an environment variable: + +[Android NDK]: https://developer.android.com/tools/sdk/ndk/index.html + +``` +NDK_PATH="" +``` + +* Build the JNI native libraries from the command line: + +``` +cd "${TV_MODULE_PATH}"/jni && \ +${NDK_PATH}/ndk-build APP_ABI=all -j +``` diff --git a/extensions/tv/build.gradle b/extensions/tv/build.gradle new file mode 100644 index 0000000000..ee54926650 --- /dev/null +++ b/extensions/tv/build.gradle @@ -0,0 +1,39 @@ +// Copyright (C) 2017 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 from: '../../constants.gradle' +apply plugin: 'com.android.library' + +android { + compileSdkVersion project.ext.compileSdkVersion + buildToolsVersion project.ext.buildToolsVersion + + defaultConfig { + minSdkVersion 21 + targetSdkVersion project.ext.targetSdkVersion + } + + sourceSets.main { + jniLibs.srcDir 'src/main/libs' + jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio. + } +} + +dependencies { + compile project(modulePrefix + 'library-core') +} + +ext { + javadocTitle = 'TV tuner extension' +} +apply from: '../../javadoc_library.gradle' diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/ParsableBitArray.java b/library/core/src/main/java/com/google/android/exoplayer2/util/ParsableBitArray.java index fdee7fb5e6..19b303484f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/ParsableBitArray.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/ParsableBitArray.java @@ -62,6 +62,17 @@ public final class ParsableBitArray { reset(data, data.length); } + /** + * Sets this instance's data, position and limit to match the provided {@code parsableByteArray}. + * Any modifications to the underlying data array will be visible in both instances + * + * @param parsableByteArray The {@link ParsableByteArray}. + */ + public void reset(ParsableByteArray parsableByteArray) { + reset(parsableByteArray.data, parsableByteArray.limit()); + setPosition(parsableByteArray.getPosition() * 8); + } + /** * Updates the instance to wrap {@code data}, and resets the position to zero. *