summaryrefslogtreecommitdiff
path: root/prebuilts/gradle/BasicMediaDecoder
diff options
context:
space:
mode:
authorTrevor Johns <trevorjohns@google.com>2014-12-05 12:56:55 -0800
committerTrevor Johns <trevorjohns@google.com>2014-12-05 12:56:55 -0800
commita9a7e8b02c9e69b43362ff73e2cda32a684643c2 (patch)
treebe24ef70e3a6bdbd8ed6d835d66aaaae41992cbf /prebuilts/gradle/BasicMediaDecoder
parent812587d8021399377972b5fbb112f2fae4045a03 (diff)
downloadbuild-a9a7e8b02c9e69b43362ff73e2cda32a684643c2.tar.gz
Update prebuilts for samples (lmp-docs)
Synced to 1fa7b0ca07ecdb63fbc70de661b944e50788401e. Change-Id: I218fa0a1680e8e617e4283be88d19938eb8c4ceb
Diffstat (limited to 'prebuilts/gradle/BasicMediaDecoder')
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/.google/packaging.yaml18
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/Application/build.gradle4
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/CONTRIBUTING.md35
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/NOTICE15
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/README.md63
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties2
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/screenshots/1-launch.pngbin0 -> 31394 bytes
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/screenshots/2-play-video.pngbin0 -> 2019164 bytes
-rw-r--r--prebuilts/gradle/BasicMediaDecoder/screenshots/icon-web.pngbin0 -> 83691 bytes
9 files changed, 128 insertions, 9 deletions
diff --git a/prebuilts/gradle/BasicMediaDecoder/.google/packaging.yaml b/prebuilts/gradle/BasicMediaDecoder/.google/packaging.yaml
new file mode 100644
index 00000000..a602f833
--- /dev/null
+++ b/prebuilts/gradle/BasicMediaDecoder/.google/packaging.yaml
@@ -0,0 +1,18 @@
+# GOOGLE SAMPLE PACKAGING DATA
+#
+# This file is used by Google as part of our samples packaging process.
+# End users may safely ignore this file. It has no relevance to other systems.
+---
+status: PUBLISHED
+technologies: [Android]
+categories: [Media]
+languages: [Java]
+solutions: [Mobile]
+github: android-BasicMediaDecoder
+level: ADVANCED
+icon: screenshots/icon-web.png
+apiRefs:
+ - android:android.media.MediaCodec
+ - android:android.media.MediaExtractor
+ - android:android.animation.TimeAnimator
+license: apache2
diff --git a/prebuilts/gradle/BasicMediaDecoder/Application/build.gradle b/prebuilts/gradle/BasicMediaDecoder/Application/build.gradle
index c71524c1..c03c2540 100644
--- a/prebuilts/gradle/BasicMediaDecoder/Application/build.gradle
+++ b/prebuilts/gradle/BasicMediaDecoder/Application/build.gradle
@@ -4,7 +4,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:0.12.+'
+ classpath 'com.android.tools.build:gradle:1.0.0-rc1'
}
}
@@ -33,7 +33,7 @@ List<String> dirs = [
android {
compileSdkVersion 21
- buildToolsVersion "21.0.0"
+ buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 17
diff --git a/prebuilts/gradle/BasicMediaDecoder/CONTRIBUTING.md b/prebuilts/gradle/BasicMediaDecoder/CONTRIBUTING.md
new file mode 100644
index 00000000..faa8b5c6
--- /dev/null
+++ b/prebuilts/gradle/BasicMediaDecoder/CONTRIBUTING.md
@@ -0,0 +1,35 @@
+# How to become a contributor and submit your own code
+
+## Contributor License Agreements
+
+We'd love to accept your sample apps and patches! Before we can take them, we
+have to jump a couple of legal hurdles.
+
+Please fill out either the individual or corporate Contributor License Agreement (CLA).
+
+ * If you are an individual writing original source code and you're sure you
+ own the intellectual property, then you'll need to sign an [individual CLA]
+ (https://cla.developers.google.com).
+ * If you work for a company that wants to allow you to contribute your work,
+ then you'll need to sign a [corporate CLA]
+ (https://cla.developers.google.com).
+
+Follow either of the two links above to access the appropriate CLA and
+instructions for how to sign and return it. Once we receive it, we'll be able to
+accept your pull requests.
+
+## Contributing A Patch
+
+1. Submit an issue describing your proposed change to the repo in question.
+1. The repo owner will respond to your issue promptly.
+1. If your proposed change is accepted, and you haven't already done so, sign a
+ Contributor License Agreement (see details above).
+1. Fork the desired repo, develop and test your code changes.
+1. Ensure that your code adheres to the existing style in the sample to which
+ you are contributing. Refer to the
+ [Android Code Style Guide]
+ (https://source.android.com/source/code-style.html) for the
+ recommended coding standards for this organization.
+1. Ensure that your code has an appropriate set of unit tests which all pass.
+1. Submit a pull request.
+
diff --git a/prebuilts/gradle/BasicMediaDecoder/NOTICE b/prebuilts/gradle/BasicMediaDecoder/NOTICE
new file mode 100644
index 00000000..7eede3de
--- /dev/null
+++ b/prebuilts/gradle/BasicMediaDecoder/NOTICE
@@ -0,0 +1,15 @@
+This sample uses the following software:
+
+Copyright 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.
diff --git a/prebuilts/gradle/BasicMediaDecoder/README.md b/prebuilts/gradle/BasicMediaDecoder/README.md
index 5663b3ca..1f5ec4a4 100644
--- a/prebuilts/gradle/BasicMediaDecoder/README.md
+++ b/prebuilts/gradle/BasicMediaDecoder/README.md
@@ -1,16 +1,67 @@
Android BasicMediaDecoder Sample
-==============================
+===================================
-This activity uses a TextureView to render the frames of a video decoded using the
-MediaCodec API.
+This sample shows how to use the MediaCoder to decode a video,
+use a TimeAnimator to sync the rendering commands with the system
+display frame rendering and finally render it to a TextureView.
+
+Introduction
+------------
+
+[MediaCodec][1] was introduced in API 16, and can be used for low level (decoding/encoding) operations.
+In the same API was also introduced [TimeAnimator][2], which can be used to synchronise animation frames.
+Finally, [MediaExtractor][3] provides a simple way to extract demuxed media data from a data source.
+
+The main steps are described below:
+
+1. Create a layout with a [TextureView][4] for your activity.
+2. Initialise a MediaExtractor instance with `new MediaExtractor()` and a TimeAnimator instance with
+`new TimeAnimator()`.
+3. To start video playback, call `setDataSource(this, videoUri, null)` on your MediaExtractor instance,
+where `videoUri` is the URI of your video source.
+4. On your MediaExtractor instance, call `getTrackCount()` to know how many tracks you have in your streams.
+They may not all be video tracks. Deselect all tracks by calling `unselectTrack(i)` where `i` is
+the index of the track.
+5. Get the mime type of a track by calling `getTrackFormat(i).getString(MediaFormat.KEY_MIME)`
+on your MediaExtractor instance, where `i` is the index of your selected track.
+If the mime type contains "video/", then this is a video track so you can select it, using `selectTrack(i)`
+on your MediaExtractor instance.
+6. Create a MediaCodec instance by calling `MediaCodec.createDecoderByType(mimeType)`.
+7. Configure your MediaCodec instance with `configure(trackFormat, textureView, null, 0)`,
+where `trackFormat` is obtained by calling `getTrackFormat(i)` on your MediaExtractor instance.
+8. Set a TimeListener on your TimeAnimation instance, and override its `onTimeUpdate(final TimeAnimator animation,
+final long totalTime, final long deltaTime)` method.
+9. In `onTimeUpdate`, check if the media track has reached the end of stream, using `getSampleFlags()`
+on your MediaExtractor instance and looking for `MediaCodec.BUFFER_FLAG_END_OF_STREAM` flag.
+10. Still in `onTimeUpdate`, assuming this isn't the end of the sample, write the media sample to your
+MediaDecoder instance, using `queueInputBuffer(index, 0, size, presentationTimeUs, flags)` method.
+You will need to set up your buffers, refer to [MediaCodec][1] documentation for details.
+11. After writing the media sample, you need to advance the sample, calling `advance()` on your
+TimeExtractor instance (this is a blocking operation and should be done outside the main thread).
+12. Finally, you can release and render the media sample by calling
+`dequeueOutputBuffer(info, timeout)` and `releaseOutputBuffer(i, true)`, refer to [MediaCodec][1]
+documentation for details.
+13. In `onPause()` or if you have reached the end of the stream, call `end()` on your TimeAnimation instance,
+then call `stop()` and `release()` on your MediaCodec instance, and finally, call `release()` on your
+MediaExtractor instance.
+
+[1]: http://developer.android.com/reference/android/media/MediaCodec.html
+[2]: http://developer.android.com/reference/android/animation/TimeAnimator.html
+[3]: http://developer.android.com/reference/android/media/MediaExtractor.html
+[4]: http://developer.android.com/reference/android/view/TextureView.html
Pre-requisites
--------------
-- Android SDK v20
-- Android Build Tools v20
+- Android SDK v21
+- Android Build Tools v21.1.1
- Android Support Repository
+Screenshots
+-------------
+
+<img src="screenshots/1-launch.png" height="400" alt="Screenshot"/> <img src="screenshots/2-play-video.png" height="400" alt="Screenshot"/>
+
Getting Started
---------------
@@ -41,7 +92,7 @@ file to you 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
+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
diff --git a/prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties b/prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties
index d7f03cfe..0c71e760 100644
--- a/prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties
+++ b/prebuilts/gradle/BasicMediaDecoder/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
diff --git a/prebuilts/gradle/BasicMediaDecoder/screenshots/1-launch.png b/prebuilts/gradle/BasicMediaDecoder/screenshots/1-launch.png
new file mode 100644
index 00000000..87c246fc
--- /dev/null
+++ b/prebuilts/gradle/BasicMediaDecoder/screenshots/1-launch.png
Binary files differ
diff --git a/prebuilts/gradle/BasicMediaDecoder/screenshots/2-play-video.png b/prebuilts/gradle/BasicMediaDecoder/screenshots/2-play-video.png
new file mode 100644
index 00000000..17f61fa4
--- /dev/null
+++ b/prebuilts/gradle/BasicMediaDecoder/screenshots/2-play-video.png
Binary files differ
diff --git a/prebuilts/gradle/BasicMediaDecoder/screenshots/icon-web.png b/prebuilts/gradle/BasicMediaDecoder/screenshots/icon-web.png
new file mode 100644
index 00000000..c67722e0
--- /dev/null
+++ b/prebuilts/gradle/BasicMediaDecoder/screenshots/icon-web.png
Binary files differ