2017年3月14日 星期二

Class.forName, asSubclass, getConstructor(), newInstance()

/*
 * Copyright (C) 2016 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.extractor;

import java.util.ArrayList;
import java.util.List;

/**
 * An {@link ExtractorsFactory} that provides an array of extractors for the following formats:
 *
 * <ul>
 * <li>MP4, including M4A ({@link com.google.android.exoplayer2.extractor.mp4.Mp4Extractor})</li>
 * <li>fMP4 ({@link com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor})</li>
 * <li>Matroska and WebM ({@link com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor})
 * </li>
 * <li>Ogg Vorbis/FLAC ({@link com.google.android.exoplayer2.extractor.ogg.OggExtractor}</li>
 * <li>MP3 ({@link com.google.android.exoplayer2.extractor.mp3.Mp3Extractor})</li>
 * <li>AAC ({@link com.google.android.exoplayer2.extractor.ts.AdtsExtractor})</li>
 * <li>MPEG TS ({@link com.google.android.exoplayer2.extractor.ts.TsExtractor})</li>
 * <li>MPEG PS ({@link com.google.android.exoplayer2.extractor.ts.PsExtractor})</li>
 * <li>FLV ({@link com.google.android.exoplayer2.extractor.flv.FlvExtractor})</li>
 * <li>WAV ({@link com.google.android.exoplayer2.extractor.wav.WavExtractor})</li>
 * <li>FLAC (only available if the FLAC extension is built and included)</li>
 * </ul>
 */
public final class DefaultExtractorsFactory implements ExtractorsFactory {

  // Lazily initialized default extractor classes in priority order.
  private static List<Class<? extends Extractor>> defaultExtractorClasses;

  /**
   * Creates a new factory for the default extractors.
   */
  public DefaultExtractorsFactory() {
    synchronized (DefaultExtractorsFactory.class) {
      if (defaultExtractorClasses == null) {
        // Lazily initialize defaultExtractorClasses.
        List<Class<? extends Extractor>> extractorClasses = new ArrayList<>();
        // We reference extractors using reflection so that they can be deleted cleanly.
        // Class.forName is used so that automated tools like proguard can detect the use of
        // reflection (see http://proguard.sourceforge.net/FAQ.html#forname).
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.mp4.Mp4Extractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.mp3.Mp3Extractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.ts.AdtsExtractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.ts.Ac3Extractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.ts.TsExtractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.flv.FlvExtractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.ogg.OggExtractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.ts.PsExtractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.extractor.wav.WavExtractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        try {
          extractorClasses.add(
              Class.forName("com.google.android.exoplayer2.ext.flac.FlacExtractor")
                  .asSubclass(Extractor.class));
        } catch (ClassNotFoundException e) {
          // Extractor not found.
        }
        defaultExtractorClasses = extractorClasses;
      }
    }
  }

  @Override
  public Extractor[] createExtractors() {
    Extractor[] extractors = new Extractor[defaultExtractorClasses.size()];
    for (int i = 0; i < extractors.length; i++) {
      try {
        extractors[i] = defaultExtractorClasses.get(i).getConstructor().newInstance();
      } catch (Exception e) {
        // Should never happen.
        throw new IllegalStateException("Unexpected error creating default extractor", e);
      }
    }
    return extractors;
  }

}

Class.forName
asSubclass
getConstructor
https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getConstructor(java.lang.Class...)

newInstance
https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#newInstance()

Github markdown tool

https://jbt.github.io/markdown-editor/#

http://dillinger.io/

2017年1月17日 星期二

shaka player

https://shaka-player-demo.appspot.com/docs/api/index.html

What does "tunnelled video" mean for Andorid

To summarize, when Tunneled video playback is active,
  • OMX Component has advertised the support for the same
  • Complete feature is a vendor specific implementation and framework doesn't come into picture for resource allocation or synchronization
  • A/V Sync is handled at the hardware level - Support is required in Audio HAL to retrieve the references for the same
  • Video Decoder pushes the current frame directly to the display hardware
  • The Display hardware "probably" composes this picture on top of current picture being displayed and directly outputs to the screen
  • If the underlying HW is unable to support, a solid color is displayed

Ref:

2017年1月11日 星期三

Contribute steps to Github


[How to clone a specific Git branch? ]:

git clone -b <branch> <remote_repo>


[recursively delete directory]:

rmdir c:\test /s /q


[To rollback to a specific commit]:

git reset --hard commit_sha


[Undo current modification]

git checkout -- .

Use "git checkout -- ..." to discard changes in working directory


[Update your fork]

Steps:
1. git clone your fork.
2. git remote -v
should be like:
E:\source code\EXO_fork_John\ExoPlayer>git remote -v
origin  https://github.com/WeiChungChang/ExoPlayer.git (fetch)
origin  https://github.com/WeiChungChang/ExoPlayer.git (push)
3. git remote add upstream https://github.com/google/ExoPlayer.git
should be like:
E:\source code\EXO_fork_John\ExoPlayer>git remote -v
origin  https://github.com/WeiChungChang/ExoPlayer.git (fetch)
origin  https://github.com/WeiChungChang/ExoPlayer.git (push)
upstream        https://github.com/google/ExoPlayer.git (fetch)
upstream        https://github.com/google/ExoPlayer.git (push)
4. git checkout dev-v2 (branch name)
5. git pull upstream dev-v2 (branch name)
6. git push origin dev-v2 (branch name)


[Contribute to GitHub]

Steps:
1. git checkout -b "新名稱"
2. git commit -a -m 'message'
3. git push origin (branch name)

update a pull request


http://stackoverflow.com/questions/9790448/how-to-update-a-pull-request


Monkey (猴子)

https://backlogtool.com/git-guide/tw/stepup/stepup2_4.html





[Contribute to Gstreamer]

https://gstreamer.freedesktop.org/documentation/contribute/index.html#how-to-submit-patches

create a commit and attach a 'git format-patch' style patch like so

git add files/to/commit
git commit
<enter commit message>
git format-patch -1

Add --help or the search the git documentation for specifics on what these functions do.




[After deleting remote branch & would like to sync the status]

https://git-scm.com/docs/git-fetch

git fetch --all --prune


--all


Fetch all remotes.
--prune



Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning.


[Develop with Git to develop new feature locally]


1. git commit -a -m 'three seconds is better'

2. git reset --hard ID


[Github README.md]


https://read01.com/J848LL.html