本文整理汇总了Java中com.google.android.exoplayer2.util.MimeTypes类的典型用法代码示例。如果您正苦于以下问题:Java MimeTypes类的具体用法?Java MimeTypes怎么用?Java MimeTypes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MimeTypes类属于com.google.android.exoplayer2.util包,在下文中一共展示了MimeTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildTrackName
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
public static String buildTrackName(Format format) {
String trackName;
if (MimeTypes.isVideo(format.sampleMimeType)) {
trackName = joinWithSeparator(
buildResolutionString(format), buildBitrateString(format));
} else if (MimeTypes.isAudio(format.sampleMimeType)) {
trackName = joinWithSeparator(joinWithSeparator(joinWithSeparator(joinWithSeparator(
buildLanguageString(format), buildAudioPropertyString(format)),
buildBitrateString(format)), buildTrackIdString(format)),
buildSampleMimeTypeString(format));
} else {
trackName = joinWithSeparator(joinWithSeparator(joinWithSeparator(buildLanguageString(format),
buildBitrateString(format)), buildTrackIdString(format)),
buildSampleMimeTypeString(format));
}
return trackName.length() == 0 ? "unknown" : trackName;
}
示例2: testWidevineOfflineLicense
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
public void testWidevineOfflineLicense() throws Exception {
if (Util.SDK_INT < 22) {
// Pass.
return;
}
String streamName = "test_widevine_h264_fixed_offline";
DashHostedTestEncParameters parameters = newDashHostedTestEncParameters(
WIDEVINE_H264_MANIFEST_PREFIX, true, MimeTypes.VIDEO_H264);
TestOfflineLicenseHelper helper = new TestOfflineLicenseHelper(parameters);
try {
byte[] keySetId = helper.downloadLicense();
testDashPlayback(getActivity(), streamName, null, true, parameters,
WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, false, keySetId, WIDEVINE_H264_CDD_FIXED);
helper.renewLicense();
} finally {
helper.releaseResources();
}
}
示例3: testWidevineOfflineLicenseExpiresOnPause
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
public void testWidevineOfflineLicenseExpiresOnPause() throws Exception {
if (Util.SDK_INT < 22) {
// Pass.
return;
}
String streamName = "test_widevine_h264_fixed_offline";
DashHostedTestEncParameters parameters = newDashHostedTestEncParameters(
WIDEVINE_H264_MANIFEST_PREFIX, true, MimeTypes.VIDEO_H264);
TestOfflineLicenseHelper helper = new TestOfflineLicenseHelper(parameters);
try {
byte[] keySetId = helper.downloadLicense();
// During playback pause until the license expires then continue playback
Pair<Long, Long> licenseDurationRemainingSec = helper.getLicenseDurationRemainingSec();
long licenseDuration = licenseDurationRemainingSec.first;
assertTrue("License duration should be less than 30 sec. "
+ "Server settings might have changed.", licenseDuration < 30);
ActionSchedule schedule = new ActionSchedule.Builder(TAG)
.delay(3000).pause().delay(licenseDuration * 1000 + 2000).play().build();
// DefaultDrmSessionManager should renew the license and stream play fine
testDashPlayback(getActivity(), streamName, schedule, true, parameters,
WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, false, keySetId, WIDEVINE_H264_CDD_FIXED);
} finally {
helper.releaseResources();
}
}
示例4: deriveFormat
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
/**
* Derives a track format corresponding to a given container format, by combining it with sample
* level information obtained from the samples.
*
* @param containerFormat The container format for which the track format should be derived.
* @param sampleFormat A sample format from which to obtain sample level information.
* @return The derived track format.
*/
private static Format deriveFormat(Format containerFormat, Format sampleFormat) {
if (containerFormat == null) {
return sampleFormat;
}
String codecs = null;
int sampleTrackType = MimeTypes.getTrackType(sampleFormat.sampleMimeType);
if (sampleTrackType == C.TRACK_TYPE_AUDIO) {
codecs = getAudioCodecs(containerFormat.codecs);
} else if (sampleTrackType == C.TRACK_TYPE_VIDEO) {
codecs = getVideoCodecs(containerFormat.codecs);
}
return sampleFormat.copyWithContainerInfo(containerFormat.id, codecs, containerFormat.bitrate,
containerFormat.width, containerFormat.height, containerFormat.selectionFlags,
containerFormat.language);
}
示例5: getCodecsOfType
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
private static String getCodecsOfType(String codecs, int trackType) {
if (TextUtils.isEmpty(codecs)) {
return null;
}
String[] codecArray = codecs.split("(\\s*,\\s*)|(\\s*$)");
StringBuilder builder = new StringBuilder();
for (String codec : codecArray) {
if (trackType == MimeTypes.getTrackTypeOfCodec(codec)) {
if (builder.length() > 0) {
builder.append(",");
}
builder.append(codec);
}
}
return builder.length() > 0 ? builder.toString() : null;
}
示例6: consume
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
@Override
public void consume(ParsableByteArray sectionData) {
if (!formatDeclared) {
if (timestampAdjuster.getTimestampOffsetUs() == C.TIME_UNSET) {
// There is not enough information to initialize the timestamp adjuster.
return;
}
output.format(Format.createSampleFormat(null, MimeTypes.APPLICATION_SCTE35,
timestampAdjuster.getTimestampOffsetUs()));
formatDeclared = true;
}
int sampleSize = sectionData.bytesLeft();
output.sampleData(sectionData, sampleSize);
output.sampleMetadata(timestampAdjuster.getLastAdjustedTimestampUs(), C.BUFFER_FLAG_KEY_FRAME,
sampleSize, 0, null);
}
示例7: readHeaders
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
@Override
protected boolean readHeaders(ParsableByteArray packet, long position, SetupData setupData)
throws IOException, InterruptedException {
if (vorbisSetup != null) {
return false;
}
vorbisSetup = readSetupHeaders(packet);
if (vorbisSetup == null) {
return true;
}
ArrayList<byte[]> codecInitialisationData = new ArrayList<>();
codecInitialisationData.add(vorbisSetup.idHeader.data);
codecInitialisationData.add(vorbisSetup.setupHeaderData);
setupData.format = Format.createAudioSampleFormat(null, MimeTypes.AUDIO_VORBIS, null,
this.vorbisSetup.idHeader.bitrateNominal, Format.NO_VALUE,
this.vorbisSetup.idHeader.channels, (int) this.vorbisSetup.idHeader.sampleRate,
codecInitialisationData, null, 0, null);
return true;
}
示例8: readHeaders
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
@Override
protected boolean readHeaders(ParsableByteArray packet, long position, SetupData setupData)
throws IOException, InterruptedException {
if (!headerRead) {
byte[] metadata = Arrays.copyOf(packet.data, packet.limit());
int channelCount = metadata[9] & 0xFF;
int preskip = ((metadata[11] & 0xFF) << 8) | (metadata[10] & 0xFF);
List<byte[]> initializationData = new ArrayList<>(3);
initializationData.add(metadata);
putNativeOrderLong(initializationData, preskip);
putNativeOrderLong(initializationData, DEFAULT_SEEK_PRE_ROLL_SAMPLES);
setupData.format = Format.createAudioSampleFormat(null, MimeTypes.AUDIO_OPUS, null,
Format.NO_VALUE, Format.NO_VALUE, channelCount, SAMPLE_RATE, initializationData, null, 0,
null);
headerRead = true;
} else {
boolean headerPacket = packet.readInt() == OPUS_CODE;
packet.setPosition(0);
return headerPacket;
}
return true;
}
示例9: getDrmInitDataFromAtoms
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
/** Returns DrmInitData from leaf atoms. */
private static DrmInitData getDrmInitDataFromAtoms(List<Atom.LeafAtom> leafChildren) {
ArrayList<SchemeData> schemeDatas = null;
int leafChildrenSize = leafChildren.size();
for (int i = 0; i < leafChildrenSize; i++) {
LeafAtom child = leafChildren.get(i);
if (child.type == Atom.TYPE_pssh) {
if (schemeDatas == null) {
schemeDatas = new ArrayList<>();
}
byte[] psshData = child.data.data;
UUID uuid = PsshAtomUtil.parseUuid(psshData);
if (uuid == null) {
Log.w(TAG, "Skipped pssh atom (failed to extract uuid)");
} else {
schemeDatas.add(new SchemeData(uuid, MimeTypes.VIDEO_MP4, psshData));
}
}
}
return schemeDatas == null ? null : new DrmInitData(schemeDatas);
}
示例10: Cea608Decoder
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
public Cea608Decoder(String mimeType, int accessibilityChannel) {
ccData = new ParsableByteArray();
cueBuilders = new LinkedList<>();
currentCueBuilder = new CueBuilder(CC_MODE_UNKNOWN, DEFAULT_CAPTIONS_ROW_COUNT);
packetLength = MimeTypes.APPLICATION_MP4CEA608.equals(mimeType) ? 2 : 3;
switch (accessibilityChannel) {
case 3:
case 4:
selectedField = 2;
break;
case 1:
case 2:
case Format.NO_VALUE:
default:
selectedField = 1;
}
setCaptionMode(CC_MODE_UNKNOWN);
resetCueBuilders();
}
示例11: createDecoder
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
@Override
public SubtitleDecoder createDecoder(Format format) {
switch (format.sampleMimeType) {
case MimeTypes.TEXT_VTT:
return new WebvttDecoder();
case MimeTypes.APPLICATION_MP4VTT:
return new Mp4WebvttDecoder();
case MimeTypes.APPLICATION_TTML:
return new TtmlDecoder();
case MimeTypes.APPLICATION_SUBRIP:
return new SubripDecoder();
case MimeTypes.APPLICATION_TX3G:
return new Tx3gDecoder(format.initializationData);
case MimeTypes.APPLICATION_CEA608:
case MimeTypes.APPLICATION_MP4CEA608:
return new Cea608Decoder(format.sampleMimeType, format.accessibilityChannel);
case MimeTypes.APPLICATION_CEA708:
return new Cea708Decoder(format.accessibilityChannel);
case MimeTypes.APPLICATION_DVBSUBS:
return new DvbDecoder(format.initializationData);
default:
throw new IllegalArgumentException("Attempted to create decoder for unsupported format");
}
}
示例12: maxH264DecodableFrameSize
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
/**
* Returns the maximum frame size supported by the default H264 decoder.
*
* @return The maximum frame size for an H264 stream that can be decoded on the device.
*/
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
if (maxH264DecodableFrameSize == -1) {
int result = 0;
MediaCodecInfo decoderInfo = getDecoderInfo(MimeTypes.VIDEO_H264, false);
if (decoderInfo != null) {
for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
}
// We assume support for at least 480p (SDK_INT >= 21) or 360p (SDK_INT < 21), which are
// the levels mandated by the Android CDD.
result = Math.max(result, Util.SDK_INT >= 21 ? (720 * 480) : (480 * 360));
}
maxH264DecodableFrameSize = result;
}
return maxH264DecodableFrameSize;
}
示例13: supportsFormat
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
@Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format)
throws DecoderQueryException {
String mimeType = format.sampleMimeType;
if (!MimeTypes.isAudio(mimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
}
int tunnelingSupport = Util.SDK_INT >= 21 ? TUNNELING_SUPPORTED : TUNNELING_NOT_SUPPORTED;
if (allowPassthrough(mimeType) && mediaCodecSelector.getPassthroughDecoderInfo() != null) {
return ADAPTIVE_NOT_SEAMLESS | tunnelingSupport | FORMAT_HANDLED;
}
MediaCodecInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType, false);
if (decoderInfo == null) {
return FORMAT_UNSUPPORTED_SUBTYPE;
}
// Note: We assume support for unknown sampleRate and channelCount.
boolean decoderCapable = Util.SDK_INT < 21
|| ((format.sampleRate == Format.NO_VALUE
|| decoderInfo.isAudioSampleRateSupportedV21(format.sampleRate))
&& (format.channelCount == Format.NO_VALUE
|| decoderInfo.isAudioChannelCountSupportedV21(format.channelCount)));
int formatSupport = decoderCapable ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
return ADAPTIVE_NOT_SEAMLESS | tunnelingSupport | formatSupport;
}
示例14: onOutputFormatChanged
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
@Override
protected void onOutputFormatChanged(MediaCodec codec, MediaFormat outputFormat)
throws ExoPlaybackException {
boolean passthrough = passthroughMediaFormat != null;
String mimeType = passthrough ? passthroughMediaFormat.getString(MediaFormat.KEY_MIME)
: MimeTypes.AUDIO_RAW;
MediaFormat format = passthrough ? passthroughMediaFormat : outputFormat;
int channelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
int sampleRate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE);
int[] channelMap;
if (codecNeedsDiscardChannelsWorkaround && channelCount == 6 && this.channelCount < 6) {
channelMap = new int[this.channelCount];
for (int i = 0; i < this.channelCount; i++) {
channelMap[i] = i;
}
} else {
channelMap = null;
}
try {
audioTrack.configure(mimeType, channelCount, sampleRate, pcmEncoding, 0, channelMap);
} catch (AudioTrack.ConfigurationException e) {
throw ExoPlaybackException.createForRenderer(e, getIndex());
}
}
示例15: parseEAc3AnnexFFormat
import com.google.android.exoplayer2.util.MimeTypes; //导入依赖的package包/类
/**
* Returns the E-AC-3 format given {@code data} containing the EC3SpecificBox according to
* ETSI TS 102 366 Annex F. The reading position of {@code data} will be modified.
*
* @param data The EC3SpecificBox to parse.
* @param trackId The track identifier to set on the format, or null.
* @param language The language to set on the format.
* @param drmInitData {@link DrmInitData} to be included in the format.
* @return The E-AC-3 format parsed from data in the header.
*/
public static Format parseEAc3AnnexFFormat(ParsableByteArray data, String trackId,
String language, DrmInitData drmInitData) {
data.skipBytes(2); // data_rate, num_ind_sub
// Read only the first substream.
// TODO: Read later substreams?
int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
int sampleRate = SAMPLE_RATE_BY_FSCOD[fscod];
int nextByte = data.readUnsignedByte();
int channelCount = CHANNEL_COUNT_BY_ACMOD[(nextByte & 0x0E) >> 1];
if ((nextByte & 0x01) != 0) { // lfeon
channelCount++;
}
return Format.createAudioSampleFormat(trackId, MimeTypes.AUDIO_E_AC3, null, Format.NO_VALUE,
Format.NO_VALUE, channelCount, sampleRate, null, drmInitData, 0, language);
}