2015-09-04 02:15:03 +02:00
|
|
|
package org.schabi.newpipe;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Christian Schabesberger on 26.08.15.
|
|
|
|
*
|
|
|
|
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
|
|
|
* VideoInfo.java is part of NewPipe.
|
|
|
|
*
|
|
|
|
* NewPipe is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* NewPipe is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import android.graphics.Bitmap;
|
2015-09-21 21:12:48 +02:00
|
|
|
import android.util.Log;
|
2015-09-04 02:15:03 +02:00
|
|
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
public class VideoInfo {
|
|
|
|
|
2015-09-21 21:12:48 +02:00
|
|
|
private static final String TAG = VideoInfo.class.toString();
|
|
|
|
|
|
|
|
// format identifier
|
|
|
|
public static final int I_MPEG_4 = 0x0;
|
|
|
|
public static final int I_3GPP = 0x1;
|
|
|
|
public static final int I_WEBM = 0x2;
|
|
|
|
public static final int I_M4A = 0x3;
|
|
|
|
public static final int I_WEBMA = 0x4;
|
|
|
|
|
|
|
|
// format name
|
2015-09-04 02:15:03 +02:00
|
|
|
public static final String F_MPEG_4 = "MPEG-4";
|
|
|
|
public static final String F_3GPP = "3GPP";
|
|
|
|
public static final String F_WEBM = "WebM";
|
2015-09-21 13:32:11 +02:00
|
|
|
public static final String F_M4A = "m4a";
|
2015-09-21 21:12:48 +02:00
|
|
|
public static final String F_WEBMA = "WebM";
|
|
|
|
|
|
|
|
// file suffix
|
|
|
|
public static final String C_MPEG_4 = "mp4";
|
|
|
|
public static final String C_3GPP = "3gp";
|
|
|
|
public static final String C_WEBM = "webm";
|
|
|
|
public static final String C_M4A = "m4a";
|
|
|
|
public static final String C_WEBMA = "webm";
|
|
|
|
|
|
|
|
// mimeType
|
|
|
|
public static final String M_MPEG_4 = "video/mp4";
|
|
|
|
public static final String M_3GPP = "video/3gpp";
|
|
|
|
public static final String M_WEBM = "video/webm";
|
|
|
|
public static final String M_M4A = "audio/mp4";
|
|
|
|
public static final String M_WEBMA = "audio/webm";
|
2015-09-04 02:15:03 +02:00
|
|
|
|
|
|
|
public static final int VIDEO_AVAILABLE = 0x00;
|
|
|
|
public static final int VIDEO_UNAVAILABLE = 0x01;
|
2015-11-02 15:03:11 +00:00
|
|
|
public static final int VIDEO_UNAVAILABLE_GEMA = 0x02;//German DRM organisation; sound pretty draconian
|
2015-09-04 02:15:03 +02:00
|
|
|
|
2015-09-21 21:12:48 +02:00
|
|
|
public static String getNameById(int id) {
|
|
|
|
switch(id) {
|
|
|
|
case I_MPEG_4: return F_MPEG_4;
|
|
|
|
case I_3GPP: return F_3GPP;
|
|
|
|
case I_WEBM: return F_WEBM;
|
|
|
|
case I_M4A: return F_M4A;
|
|
|
|
case I_WEBMA: return F_WEBMA;
|
2015-11-02 15:03:11 +00:00
|
|
|
default: formatNotKnown(id);
|
2015-09-21 21:12:48 +02:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getSuffixById(int id) {
|
|
|
|
switch(id) {
|
|
|
|
case I_MPEG_4: return C_MPEG_4;
|
|
|
|
case I_3GPP: return C_3GPP;
|
|
|
|
case I_WEBM: return C_WEBM;
|
|
|
|
case I_M4A: return C_M4A;
|
|
|
|
case I_WEBMA: return C_WEBMA;
|
2015-11-02 15:03:11 +00:00
|
|
|
default: formatNotKnown(id);
|
2015-09-21 21:12:48 +02:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getMimeById(int id) {
|
|
|
|
switch(id) {
|
|
|
|
case I_MPEG_4: return M_MPEG_4;
|
|
|
|
case I_3GPP: return M_3GPP;
|
|
|
|
case I_WEBM: return M_WEBM;
|
|
|
|
case I_M4A: return M_M4A;
|
|
|
|
case I_WEBMA: return M_WEBMA;
|
2015-11-02 15:03:11 +00:00
|
|
|
default: formatNotKnown(id);
|
2015-09-21 21:12:48 +02:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-09-21 13:32:11 +02:00
|
|
|
public static class VideoStream {
|
2015-09-21 21:12:48 +02:00
|
|
|
public VideoStream(String url, int format, String res) {
|
2015-09-21 13:32:11 +02:00
|
|
|
this.url = url; this.format = format; resolution = res;
|
2015-09-04 02:15:03 +02:00
|
|
|
}
|
|
|
|
public String url = ""; //url of the stream
|
2015-09-21 21:12:48 +02:00
|
|
|
public int format = -1;
|
2015-09-04 02:15:03 +02:00
|
|
|
public String resolution = "";
|
|
|
|
}
|
|
|
|
|
2015-11-02 15:03:11 +00:00
|
|
|
protected static void formatNotKnown(int id)
|
|
|
|
{
|
|
|
|
Log.e(TAG, "format not known: \"" +
|
|
|
|
Integer.toString(id) + "\". Call the programmer, he messed it up!");
|
|
|
|
}
|
|
|
|
|
2015-09-21 13:32:11 +02:00
|
|
|
public static class AudioStream {
|
2015-10-15 23:25:53 +02:00
|
|
|
public AudioStream(String url, int format, int bandwidth, int samplingRate) {
|
2015-09-21 13:32:11 +02:00
|
|
|
this.url = url; this.format = format;
|
2015-10-15 23:25:53 +02:00
|
|
|
this.bandwidth = bandwidth; this.samplingRate = samplingRate;
|
2015-09-21 13:32:11 +02:00
|
|
|
}
|
|
|
|
public String url = "";
|
2015-09-21 21:12:48 +02:00
|
|
|
public int format = -1;
|
2015-10-15 23:25:53 +02:00
|
|
|
public int bandwidth = -1;
|
2015-09-21 21:12:48 +02:00
|
|
|
public int samplingRate = -1;
|
|
|
|
|
2015-09-21 13:32:11 +02:00
|
|
|
}
|
|
|
|
|
2015-09-04 02:15:03 +02:00
|
|
|
public String id = "";
|
|
|
|
public String uploader = "";
|
|
|
|
public String upload_date = "";
|
|
|
|
public String uploader_thumbnail_url = "";
|
|
|
|
public Bitmap uploader_thumbnail = null;
|
|
|
|
public String title = "";
|
|
|
|
public String thumbnail_url = "";
|
|
|
|
public Bitmap thumbnail = null;
|
|
|
|
public String description = "";
|
|
|
|
public int duration = -1;
|
|
|
|
public int age_limit = 0;
|
|
|
|
public String webpage_url = "";
|
|
|
|
public String view_count = "";
|
|
|
|
public String like_count = "";
|
|
|
|
public String dislike_count = "";
|
|
|
|
public String average_rating = "";
|
2015-09-21 13:32:11 +02:00
|
|
|
public VideoStream[] videoStreams = null;
|
|
|
|
public AudioStream[] audioStreams = null;
|
2015-09-04 02:15:03 +02:00
|
|
|
public VideoInfoItem nextVideo = null;
|
2015-11-02 19:57:47 +01:00
|
|
|
public VideoInfoItem[] relatedVideos = null;
|
2015-09-04 02:15:03 +02:00
|
|
|
public int videoAvailableStatus = VIDEO_AVAILABLE;
|
|
|
|
}
|