summaryrefslogtreecommitdiffstats
path: root/src/org/codeaurora/gallery3d/ext/MovieUtils.java
blob: 2846ab584975990e3931a4df4dfb7e920746e818 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package org.codeaurora.gallery3d.ext;

import android.net.Uri;
import android.util.Log;

import java.util.Locale;

/**
 * Util class for Movie functions. *
 */
public class MovieUtils {
    private static final String TAG = "MovieUtils";
    private static final boolean LOG = true;

    private MovieUtils() {
    }

    /**
     * Whether current video(Uri) is RTSP streaming or not.
     *
     * @param uri
     * @param mimeType
     * @return
     */
    public static boolean isRtspStreaming(Uri uri, String mimeType) {
        boolean rtsp = false;
        if (uri != null) {
            if ("rtsp".equalsIgnoreCase(uri.getScheme())) {
                rtsp = true;
            }
        }
        if (LOG) {
            Log.v(TAG, "isRtspStreaming(" + uri + ", " + mimeType + ") return " + rtsp);
        }
        return rtsp;
    }

    /**
     * Whether current video(Uri) is HTTP streaming or not.
     *
     * @param uri
     * @param mimeType
     * @return
     */
    public static boolean isHttpStreaming(Uri uri, String mimeType) {
        boolean http = false;
        if (uri != null) {
            if ("http".equalsIgnoreCase(uri.getScheme())) {
                http = true;
            } else if ("https".equalsIgnoreCase(uri.getScheme())) {
                http = true;
            }
        }
        if (LOG) {
            Log.v(TAG, "isHttpStreaming(" + uri + ", " + mimeType + ") return " + http);
        }
        return http;
    }

    /**
     * Whether current video(Uri) is live streaming or not.
     *
     * @param uri
     * @param mimeType
     * @return
     */
    public static boolean isSdpStreaming(Uri uri, String mimeType) {
        boolean sdp = false;
        if (uri != null) {
            if ("application/sdp".equals(mimeType)) {
                sdp = true;
            } else if (uri.toString().toLowerCase(Locale.ENGLISH).endsWith(".sdp")) {
                sdp = true;
            }
        }
        if (LOG) {
            Log.v(TAG, "isSdpStreaming(" + uri + ", " + mimeType + ") return " + sdp);
        }
        return sdp;
    }

    /**
     * Whether current video(Uri) is local file or not.
     *
     * @param uri
     * @param mimeType
     * @return
     */
    public static boolean isLocalFile(Uri uri, String mimeType) {
        boolean local = (!isSdpStreaming(uri, mimeType)
                && !isRtspStreaming(uri, mimeType)
                && !isHttpStreaming(uri, mimeType));
        if (LOG) {
            Log.v(TAG, "isLocalFile(" + uri + ", " + mimeType + ") return " + local);
        }
        return local;
    }
}