Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * 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.
 */

public class Main {
    /**
     * Value returned by {@link #inferContentType(String)} for DASH manifests.
     */
    public static final int TYPE_DASH = 0;
    /**
     * Value returned by {@link #inferContentType(String)} for Smooth Streaming manifests.
     */
    public static final int TYPE_SS = 1;
    /**
     * Value returned by {@link #inferContentType(String)} for HLS manifests.
     */
    public static final int TYPE_HLS = 2;
    /**
     * Value returned by {@link #inferContentType(String)} for files other than DASH, HLS or Smooth
     * Streaming manifests.
     */
    public static final int TYPE_OTHER = 3;

    /**
     * Makes a best guess to infer the type from a file name.
     *
     * @param fileName Name of the file. It can include the path of the file.
     * @return One of {@link #TYPE_DASH}, {@link #TYPE_SS}, {@link #TYPE_HLS} or {@link #TYPE_OTHER}.
     */
    public static int inferContentType(String fileName) {
        if (fileName == null) {
            return TYPE_OTHER;
        } else if (fileName.endsWith(".mpd")) {
            return TYPE_DASH;
        } else if (fileName.endsWith(".ism")) {
            return TYPE_SS;
        } else if (fileName.endsWith(".m3u8")) {
            return TYPE_HLS;
        } else {
            return TYPE_OTHER;
        }
    }
}