com.google.android.exoplayer.util.MimeTypes Java Examples
The following examples show how to use
com.google.android.exoplayer.util.MimeTypes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerActivity.java From Android-Example-HLS-ExoPlayer with Apache License 2.0 | 6 votes |
private static String buildTrackName(MediaFormat format) { if (format.adaptive) { return "auto"; } String trackName; if (MimeTypes.isVideo(format.mimeType)) { trackName = joinWithSeparator(joinWithSeparator(buildResolutionString(format), buildBitrateString(format)), buildTrackIdString(format)); } else if (MimeTypes.isAudio(format.mimeType)) { trackName = joinWithSeparator(joinWithSeparator(joinWithSeparator(buildLanguageString(format), buildAudioPropertyString(format)), buildBitrateString(format)), buildTrackIdString(format)); } else { trackName = joinWithSeparator(joinWithSeparator(buildLanguageString(format), buildBitrateString(format)), buildTrackIdString(format)); } return trackName.length() == 0 ? "unknown" : trackName; }
Example #2
Source File: MediaCodecUtil.java From Exoplayer_VLC with Apache License 2.0 | 6 votes |
/** * @param profile An AVC profile constant from {@link CodecProfileLevel}. * @param level An AVC profile level from {@link CodecProfileLevel}. * @return Whether the specified profile is supported at the specified level. */ public static boolean isH264ProfileSupported(int profile, int level) throws DecoderQueryException { Pair<String, CodecCapabilities> info = getMediaCodecInfo(MimeTypes.VIDEO_H264, false); if (info == null) { return false; } CodecCapabilities capabilities = info.second; for (int i = 0; i < capabilities.profileLevels.length; i++) { CodecProfileLevel profileLevel = capabilities.profileLevels[i]; if (profileLevel.profile == profile && profileLevel.level >= level) { return true; } } return false; }
Example #3
Source File: WebmExtractor.java From Exoplayer_VLC with Apache License 2.0 | 6 votes |
/** * Build an audio {@link MediaFormat} containing recently gathered Audio information, if needed. * * <p>Replaces the previous {@link #format} only if audio channel count/sample rate have changed. * {@link #format} is guaranteed to not be null after calling this method. * * @throws ParserException If an error occurs when parsing codec's private data or if the format * can't be built. */ private void buildAudioFormat() throws ParserException { if (channelCount != UNKNOWN && sampleRate != UNKNOWN && (format == null || format.channelCount != channelCount || format.sampleRate != sampleRate)) { if (CODEC_ID_VORBIS.equals(codecId)) { format = MediaFormat.createAudioFormat( MimeTypes.AUDIO_VORBIS, VORBIS_MAX_INPUT_SIZE, channelCount, sampleRate, parseVorbisCodecPrivate()); } else if (CODEC_ID_OPUS.equals(codecId)) { ArrayList<byte[]> opusInitializationData = new ArrayList<byte[]>(3); opusInitializationData.add(codecPrivate); opusInitializationData.add(ByteBuffer.allocate(Long.SIZE).putLong(codecDelayNs).array()); opusInitializationData.add(ByteBuffer.allocate(Long.SIZE).putLong(seekPreRollNs).array()); format = MediaFormat.createAudioFormat( MimeTypes.AUDIO_OPUS, OPUS_MAX_INPUT_SIZE, channelCount, sampleRate, opusInitializationData); } readResults |= RESULT_READ_INIT; } else if (format == null) { throw new ParserException("Unable to build format"); } }
Example #4
Source File: SmoothStreamingManifestParser.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
private static String fourCCToMimeType(String fourCC) { if (fourCC.equalsIgnoreCase("H264") || fourCC.equalsIgnoreCase("X264") || fourCC.equalsIgnoreCase("AVC1") || fourCC.equalsIgnoreCase("DAVC")) { return MimeTypes.VIDEO_H264; } else if (fourCC.equalsIgnoreCase("AAC") || fourCC.equalsIgnoreCase("AACL") || fourCC.equalsIgnoreCase("AACH") || fourCC.equalsIgnoreCase("AACP")) { return MimeTypes.AUDIO_AAC; } else if (fourCC.equalsIgnoreCase("TTML")) { return MimeTypes.APPLICATION_TTML; } return null; }
Example #5
Source File: ExVidPlayerImp.java From ExVidPlayer with Apache License 2.0 | 5 votes |
@Override public void setQuality(View v) { PopupMenu popup = new PopupMenu(activity, v); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { player.setSelectedTrack(0, (item.getItemId() - 1)); return false; } }); ArrayList<Integer> formats = new ArrayList<>(); Menu menu = popup.getMenu(); menu.add(Menu.NONE, 0, 0, "Bitrate"); for (int i = 0; i < player.getTrackCount(0); i++) { MediaFormat format = player.getTrackFormat(0, i); if (MimeTypes.isVideo(format.mimeType)) { Log.e("dsa", format.bitrate + ""); if (format.adaptive) { menu.add(1, (i + 1), (i + 1), "Auto"); } else { if (!formats.contains(format.bitrate)) { menu.add(1, (i + 1), (i + 1), (format.bitrate) / 1000 + " kbps"); formats.add(format.bitrate); } } } } menu.setGroupCheckable(1, true, true); menu.findItem((player.getSelectedTrack(0) + 1)).setChecked(true); popup.show(); }
Example #6
Source File: AdtsReader.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
/** * Parses the sample header. */ private void parseHeader() { adtsScratch.setPosition(0); if (!hasMediaFormat()) { int audioObjectType = adtsScratch.readBits(2) + 1; int sampleRateIndex = adtsScratch.readBits(4); adtsScratch.skipBits(1); int channelConfig = adtsScratch.readBits(3); byte[] audioSpecificConfig = CodecSpecificDataUtil.buildAudioSpecificConfig( audioObjectType, sampleRateIndex, channelConfig); Pair<Integer, Integer> audioParams = CodecSpecificDataUtil.parseAudioSpecificConfig( audioSpecificConfig); MediaFormat mediaFormat = MediaFormat.createAudioFormat(MimeTypes.AUDIO_AAC, MediaFormat.NO_VALUE, audioParams.second, audioParams.first, Collections.singletonList(audioSpecificConfig)); frameDurationUs = (C.MICROS_PER_SECOND * 1024L) / mediaFormat.sampleRate; setMediaFormat(mediaFormat); } else { adtsScratch.skipBits(10); } adtsScratch.skipBits(4); sampleSize = adtsScratch.readBits(13) - 2 /* the sync word */ - HEADER_SIZE; if (hasCrc) { sampleSize -= CRC_SIZE; } }
Example #7
Source File: DashChunkSource.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
private Chunk newMediaChunk(RepresentationHolder representationHolder, DataSource dataSource, int segmentNum, int trigger) { Representation representation = representationHolder.representation; DashSegmentIndex segmentIndex = representationHolder.segmentIndex; long startTimeUs = segmentIndex.getTimeUs(segmentNum); long endTimeUs = startTimeUs + segmentIndex.getDurationUs(segmentNum); boolean isLastSegment = !currentManifest.dynamic && segmentNum == segmentIndex.getLastSegmentNum(); int nextAbsoluteSegmentNum = isLastSegment ? -1 : (representationHolder.segmentNumShift + segmentNum + 1); RangedUri segmentUri = segmentIndex.getSegmentUrl(segmentNum); DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length, representation.getCacheKey()); long presentationTimeOffsetUs = representation.presentationTimeOffsetUs; if (representation.format.mimeType.equals(MimeTypes.TEXT_VTT)) { if (representationHolder.vttHeaderOffsetUs != presentationTimeOffsetUs) { // Update the VTT header. headerBuilder.setLength(0); headerBuilder.append(WebvttParser.EXO_HEADER).append("=") .append(WebvttParser.OFFSET).append(presentationTimeOffsetUs).append("\n"); representationHolder.vttHeader = headerBuilder.toString().getBytes(); representationHolder.vttHeaderOffsetUs = presentationTimeOffsetUs; } return new SingleSampleMediaChunk(dataSource, dataSpec, representation.format, 0, startTimeUs, endTimeUs, nextAbsoluteSegmentNum, null, representationHolder.vttHeader); } else { return new ContainerMediaChunk(dataSource, dataSpec, representation.format, trigger, startTimeUs, endTimeUs, nextAbsoluteSegmentNum, representationHolder.extractor, psshInfo, false, presentationTimeOffsetUs); } }
Example #8
Source File: MediaPresentationDescriptionParser.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
protected int parseAdaptationSetTypeFromMimeType(String mimeType) { return TextUtils.isEmpty(mimeType) ? AdaptationSet.TYPE_UNKNOWN : MimeTypes.isAudio(mimeType) ? AdaptationSet.TYPE_AUDIO : MimeTypes.isVideo(mimeType) ? AdaptationSet.TYPE_VIDEO : MimeTypes.isText(mimeType) || MimeTypes.isTtml(mimeType) ? AdaptationSet.TYPE_TEXT : AdaptationSet.TYPE_UNKNOWN; }
Example #9
Source File: MediaPresentationDescriptionParser.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
protected int parseAdaptationSetType(String contentType) { return TextUtils.isEmpty(contentType) ? AdaptationSet.TYPE_UNKNOWN : MimeTypes.BASE_TYPE_AUDIO.equals(contentType) ? AdaptationSet.TYPE_AUDIO : MimeTypes.BASE_TYPE_VIDEO.equals(contentType) ? AdaptationSet.TYPE_VIDEO : MimeTypes.BASE_TYPE_TEXT.equals(contentType) ? AdaptationSet.TYPE_TEXT : AdaptationSet.TYPE_UNKNOWN; }
Example #10
Source File: WebmExtractor.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
/** * Build a video {@link MediaFormat} containing recently gathered Video information, if needed. * * <p>Replaces the previous {@link #format} only if video width/height have changed. * {@link #format} is guaranteed to not be null after calling this method. In * the event that it can't be built, an {@link ParserException} will be thrown. */ private void buildVideoFormat() throws ParserException { if (pixelWidth != UNKNOWN && pixelHeight != UNKNOWN && (format == null || format.width != pixelWidth || format.height != pixelHeight)) { format = MediaFormat.createVideoFormat( MimeTypes.VIDEO_VP9, MediaFormat.NO_VALUE, pixelWidth, pixelHeight, null); readResults |= RESULT_READ_INIT; } else if (format == null) { throw new ParserException("Unable to build format"); } }
Example #11
Source File: AdtsReader.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
/** * Parses the sample header. */ private void parseHeader() { adtsScratch.setPosition(0); if (!hasMediaFormat()) { int audioObjectType = adtsScratch.readBits(2) + 1; int sampleRateIndex = adtsScratch.readBits(4); adtsScratch.skipBits(1); int channelConfig = adtsScratch.readBits(3); byte[] audioSpecificConfig = CodecSpecificDataUtil.buildAudioSpecificConfig( audioObjectType, sampleRateIndex, channelConfig); Pair<Integer, Integer> audioParams = CodecSpecificDataUtil.parseAudioSpecificConfig( audioSpecificConfig); MediaFormat mediaFormat = MediaFormat.createAudioFormat(MimeTypes.AUDIO_AAC, MediaFormat.NO_VALUE, audioParams.second, audioParams.first, Collections.singletonList(audioSpecificConfig)); frameDurationUs = (C.MICROS_PER_SECOND * 1024L) / mediaFormat.sampleRate; setMediaFormat(mediaFormat); } else { adtsScratch.skipBits(10); } adtsScratch.skipBits(4); sampleSize = adtsScratch.readBits(13) - 2 /* the sync word */ - HEADER_SIZE; if (hasCrc) { sampleSize -= CRC_SIZE; } }
Example #12
Source File: CommonMp4AtomParsers.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
/** Returns the media format for an avc1 box. */ private static Pair<MediaFormat, TrackEncryptionBox> parseAvcFromParent(ParsableByteArray parent, int position, int size) { parent.setPosition(position + Mp4Util.ATOM_HEADER_SIZE); parent.skip(24); int width = parent.readUnsignedShort(); int height = parent.readUnsignedShort(); float pixelWidthHeightRatio = 1; parent.skip(50); List<byte[]> initializationData = null; TrackEncryptionBox trackEncryptionBox = null; int childPosition = parent.getPosition(); while (childPosition - position < size) { parent.setPosition(childPosition); int childStartPosition = parent.getPosition(); int childAtomSize = parent.readInt(); if (childAtomSize == 0 && parent.getPosition() - position == size) { // Handle optional terminating four zero bytes in MOV files. break; } Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive"); int childAtomType = parent.readInt(); if (childAtomType == Atom.TYPE_avcC) { initializationData = parseAvcCFromParent(parent, childStartPosition); } else if (childAtomType == Atom.TYPE_sinf) { trackEncryptionBox = parseSinfFromParent(parent, childStartPosition, childAtomSize); } else if (childAtomType == Atom.TYPE_pasp) { pixelWidthHeightRatio = parsePaspFromParent(parent, childStartPosition); } childPosition += childAtomSize; } MediaFormat format = MediaFormat.createVideoFormat(MimeTypes.VIDEO_H264, MediaFormat.NO_VALUE, width, height, pixelWidthHeightRatio, initializationData); return Pair.create(format, trackEncryptionBox); }
Example #13
Source File: CommonMp4AtomParsers.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
/** Returns the media format for an mp4v box. */ private static MediaFormat parseMp4vFromParent(ParsableByteArray parent, int position, int size) { parent.setPosition(position + Mp4Util.ATOM_HEADER_SIZE); parent.skip(24); int width = parent.readUnsignedShort(); int height = parent.readUnsignedShort(); parent.skip(50); List<byte[]> initializationData = new ArrayList<byte[]>(1); int childPosition = parent.getPosition(); while (childPosition - position < size) { parent.setPosition(childPosition); int childStartPosition = parent.getPosition(); int childAtomSize = parent.readInt(); Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive"); int childAtomType = parent.readInt(); if (childAtomType == Atom.TYPE_esds) { initializationData.add(parseEsdsFromParent(parent, childStartPosition)); } childPosition += childAtomSize; } return MediaFormat.createVideoFormat( MimeTypes.VIDEO_MP4V, MediaFormat.NO_VALUE, width, height, initializationData); }
Example #14
Source File: WebvttParser.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
@Override public boolean canParse(String mimeType) { return MimeTypes.TEXT_VTT.equals(mimeType); }
Example #15
Source File: H264Reader.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
private void parseMediaFormat(NalUnitTargetBuffer sps, NalUnitTargetBuffer pps) { byte[] spsData = new byte[sps.nalLength]; byte[] ppsData = new byte[pps.nalLength]; System.arraycopy(sps.nalData, 0, spsData, 0, sps.nalLength); System.arraycopy(pps.nalData, 0, ppsData, 0, pps.nalLength); List<byte[]> initializationData = new ArrayList<byte[]>(); initializationData.add(spsData); initializationData.add(ppsData); // Unescape and then parse the SPS unit. unescapeStream(sps.nalData, sps.nalLength); ParsableBitArray bitArray = new ParsableBitArray(sps.nalData); bitArray.skipBits(32); // NAL header int profileIdc = bitArray.readBits(8); bitArray.skipBits(16); // constraint bits (6), reserved (2) and level_idc (8) bitArray.readUnsignedExpGolombCodedInt(); // seq_parameter_set_id int chromaFormatIdc = 1; // Default is 4:2:0 if (profileIdc == 100 || profileIdc == 110 || profileIdc == 122 || profileIdc == 244 || profileIdc == 44 || profileIdc == 83 || profileIdc == 86 || profileIdc == 118 || profileIdc == 128 || profileIdc == 138) { chromaFormatIdc = bitArray.readUnsignedExpGolombCodedInt(); if (chromaFormatIdc == 3) { bitArray.skipBits(1); // separate_colour_plane_flag } bitArray.readUnsignedExpGolombCodedInt(); // bit_depth_luma_minus8 bitArray.readUnsignedExpGolombCodedInt(); // bit_depth_chroma_minus8 bitArray.skipBits(1); // qpprime_y_zero_transform_bypass_flag boolean seqScalingMatrixPresentFlag = bitArray.readBit(); if (seqScalingMatrixPresentFlag) { int limit = (chromaFormatIdc != 3) ? 8 : 12; for (int i = 0; i < limit; i++) { boolean seqScalingListPresentFlag = bitArray.readBit(); if (seqScalingListPresentFlag) { skipScalingList(bitArray, i < 6 ? 16 : 64); } } } } bitArray.readUnsignedExpGolombCodedInt(); // log2_max_frame_num_minus4 long picOrderCntType = bitArray.readUnsignedExpGolombCodedInt(); if (picOrderCntType == 0) { bitArray.readUnsignedExpGolombCodedInt(); // log2_max_pic_order_cnt_lsb_minus4 } else if (picOrderCntType == 1) { bitArray.skipBits(1); // delta_pic_order_always_zero_flag bitArray.readSignedExpGolombCodedInt(); // offset_for_non_ref_pic bitArray.readSignedExpGolombCodedInt(); // offset_for_top_to_bottom_field long numRefFramesInPicOrderCntCycle = bitArray.readUnsignedExpGolombCodedInt(); for (int i = 0; i < numRefFramesInPicOrderCntCycle; i++) { bitArray.readUnsignedExpGolombCodedInt(); // offset_for_ref_frame[i] } } bitArray.readUnsignedExpGolombCodedInt(); // max_num_ref_frames bitArray.skipBits(1); // gaps_in_frame_num_value_allowed_flag int picWidthInMbs = bitArray.readUnsignedExpGolombCodedInt() + 1; int picHeightInMapUnits = bitArray.readUnsignedExpGolombCodedInt() + 1; boolean frameMbsOnlyFlag = bitArray.readBit(); int frameHeightInMbs = (2 - (frameMbsOnlyFlag ? 1 : 0)) * picHeightInMapUnits; if (!frameMbsOnlyFlag) { bitArray.skipBits(1); // mb_adaptive_frame_field_flag } bitArray.skipBits(1); // direct_8x8_inference_flag int frameWidth = picWidthInMbs * 16; int frameHeight = frameHeightInMbs * 16; boolean frameCroppingFlag = bitArray.readBit(); if (frameCroppingFlag) { int frameCropLeftOffset = bitArray.readUnsignedExpGolombCodedInt(); int frameCropRightOffset = bitArray.readUnsignedExpGolombCodedInt(); int frameCropTopOffset = bitArray.readUnsignedExpGolombCodedInt(); int frameCropBottomOffset = bitArray.readUnsignedExpGolombCodedInt(); int cropUnitX, cropUnitY; if (chromaFormatIdc == 0) { cropUnitX = 1; cropUnitY = 2 - (frameMbsOnlyFlag ? 1 : 0); } else { int subWidthC = (chromaFormatIdc == 3) ? 1 : 2; int subHeightC = (chromaFormatIdc == 1) ? 2 : 1; cropUnitX = subWidthC; cropUnitY = subHeightC * (2 - (frameMbsOnlyFlag ? 1 : 0)); } frameWidth -= (frameCropLeftOffset + frameCropRightOffset) * cropUnitX; frameHeight -= (frameCropTopOffset + frameCropBottomOffset) * cropUnitY; } // Set the format. setMediaFormat(MediaFormat.createVideoFormat(MimeTypes.VIDEO_H264, MediaFormat.NO_VALUE, frameWidth, frameHeight, initializationData)); }
Example #16
Source File: SmoothStreamingManifestParser.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
@Override public void parseStartTag(XmlPullParser parser) throws ParserException { int type = (Integer) getNormalizedAttribute(KEY_TYPE); content = null; String value; index = parseInt(parser, KEY_INDEX, -1); bitrate = parseRequiredInt(parser, KEY_BITRATE); nalUnitLengthField = parseInt(parser, KEY_NAL_UNIT_LENGTH_FIELD, 4); if (type == StreamElement.TYPE_VIDEO) { maxHeight = parseRequiredInt(parser, KEY_MAX_HEIGHT); maxWidth = parseRequiredInt(parser, KEY_MAX_WIDTH); mimeType = fourCCToMimeType(parseRequiredString(parser, KEY_FOUR_CC)); } else { maxHeight = -1; maxWidth = -1; String fourCC = parser.getAttributeValue(null, KEY_FOUR_CC); // If fourCC is missing and the stream type is audio, we assume AAC. mimeType = fourCC != null ? fourCCToMimeType(fourCC) : type == StreamElement.TYPE_AUDIO ? MimeTypes.AUDIO_AAC : null; } if (type == StreamElement.TYPE_AUDIO) { samplingRate = parseRequiredInt(parser, KEY_SAMPLING_RATE); channels = parseRequiredInt(parser, KEY_CHANNELS); bitPerSample = parseRequiredInt(parser, KEY_BITS_PER_SAMPLE); packetSize = parseRequiredInt(parser, KEY_PACKET_SIZE); audioTag = parseRequiredInt(parser, KEY_AUDIO_TAG); } else { samplingRate = -1; channels = -1; bitPerSample = -1; packetSize = -1; audioTag = -1; } value = parser.getAttributeValue(null, KEY_CODEC_PRIVATE_DATA); if (value != null && value.length() > 0) { byte[] codecPrivateData = hexStringToByteArray(value); byte[][] split = CodecSpecificDataUtil.splitNalUnits(codecPrivateData); if (split == null) { csd.add(codecPrivateData); } else { for (int i = 0; i < split.length; i++) { Pair<Integer, Integer> spsParameters = CodecSpecificDataUtil.parseSpsNalUnit(split[i]); if (spsParameters != null) { profile = spsParameters.first; level = spsParameters.second; } csd.add(split[i]); } } } }
Example #17
Source File: MediaCodecUtil.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
@Override public boolean isSecurePlaybackSupported(String mimeType, CodecCapabilities capabilities) { // Secure decoders weren't explicitly listed prior to API level 21. We assume that a secure // H264 decoder exists. return MimeTypes.VIDEO_H264.equals(mimeType); }
Example #18
Source File: H264Reader.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
private void parseMediaFormat(NalUnitTargetBuffer sps, NalUnitTargetBuffer pps) { Log.d("H264Reader", "#####parseMediaFormat(): --> <--"); byte[] spsData = new byte[sps.nalLength]; byte[] ppsData = new byte[pps.nalLength]; System.arraycopy(sps.nalData, 0, spsData, 0, sps.nalLength); System.arraycopy(pps.nalData, 0, ppsData, 0, pps.nalLength); List<byte[]> initializationData = new ArrayList<byte[]>(); initializationData.add(spsData); initializationData.add(ppsData); // Unescape and then parse the SPS unit. unescapeStream(sps.nalData, sps.nalLength); ParsableBitArray bitArray = new ParsableBitArray(sps.nalData); bitArray.skipBits(32); // NAL header int profileIdc = bitArray.readBits(8); bitArray.skipBits(16); // constraint bits (6), reserved (2) and level_idc (8) bitArray.readUnsignedExpGolombCodedInt(); // seq_parameter_set_id int chromaFormatIdc = 1; // Default is 4:2:0 if (profileIdc == 100 || profileIdc == 110 || profileIdc == 122 || profileIdc == 244 || profileIdc == 44 || profileIdc == 83 || profileIdc == 86 || profileIdc == 118 || profileIdc == 128 || profileIdc == 138) { chromaFormatIdc = bitArray.readUnsignedExpGolombCodedInt(); if (chromaFormatIdc == 3) { bitArray.skipBits(1); // separate_colour_plane_flag } bitArray.readUnsignedExpGolombCodedInt(); // bit_depth_luma_minus8 bitArray.readUnsignedExpGolombCodedInt(); // bit_depth_chroma_minus8 bitArray.skipBits(1); // qpprime_y_zero_transform_bypass_flag boolean seqScalingMatrixPresentFlag = bitArray.readBit(); if (seqScalingMatrixPresentFlag) { int limit = (chromaFormatIdc != 3) ? 8 : 12; for (int i = 0; i < limit; i++) { boolean seqScalingListPresentFlag = bitArray.readBit(); if (seqScalingListPresentFlag) { skipScalingList(bitArray, i < 6 ? 16 : 64); } } } } bitArray.readUnsignedExpGolombCodedInt(); // log2_max_frame_num_minus4 long picOrderCntType = bitArray.readUnsignedExpGolombCodedInt(); if (picOrderCntType == 0) { bitArray.readUnsignedExpGolombCodedInt(); // log2_max_pic_order_cnt_lsb_minus4 } else if (picOrderCntType == 1) { bitArray.skipBits(1); // delta_pic_order_always_zero_flag bitArray.readSignedExpGolombCodedInt(); // offset_for_non_ref_pic bitArray.readSignedExpGolombCodedInt(); // offset_for_top_to_bottom_field long numRefFramesInPicOrderCntCycle = bitArray.readUnsignedExpGolombCodedInt(); for (int i = 0; i < numRefFramesInPicOrderCntCycle; i++) { bitArray.readUnsignedExpGolombCodedInt(); // offset_for_ref_frame[i] } } bitArray.readUnsignedExpGolombCodedInt(); // max_num_ref_frames bitArray.skipBits(1); // gaps_in_frame_num_value_allowed_flag int picWidthInMbs = bitArray.readUnsignedExpGolombCodedInt() + 1; int picHeightInMapUnits = bitArray.readUnsignedExpGolombCodedInt() + 1; boolean frameMbsOnlyFlag = bitArray.readBit(); int frameHeightInMbs = (2 - (frameMbsOnlyFlag ? 1 : 0)) * picHeightInMapUnits; if (!frameMbsOnlyFlag) { bitArray.skipBits(1); // mb_adaptive_frame_field_flag } bitArray.skipBits(1); // direct_8x8_inference_flag int frameWidth = picWidthInMbs * 16; int frameHeight = frameHeightInMbs * 16; boolean frameCroppingFlag = bitArray.readBit(); if (frameCroppingFlag) { int frameCropLeftOffset = bitArray.readUnsignedExpGolombCodedInt(); int frameCropRightOffset = bitArray.readUnsignedExpGolombCodedInt(); int frameCropTopOffset = bitArray.readUnsignedExpGolombCodedInt(); int frameCropBottomOffset = bitArray.readUnsignedExpGolombCodedInt(); int cropUnitX, cropUnitY; if (chromaFormatIdc == 0) { cropUnitX = 1; cropUnitY = 2 - (frameMbsOnlyFlag ? 1 : 0); } else { int subWidthC = (chromaFormatIdc == 3) ? 1 : 2; int subHeightC = (chromaFormatIdc == 1) ? 2 : 1; cropUnitX = subWidthC; cropUnitY = subHeightC * (2 - (frameMbsOnlyFlag ? 1 : 0)); } frameWidth -= (frameCropLeftOffset + frameCropRightOffset) * cropUnitX; frameHeight -= (frameCropTopOffset + frameCropBottomOffset) * cropUnitY; } // Set the format. setMediaFormat(MediaFormat.createVideoFormat(MimeTypes.VIDEO_H264, MediaFormat.NO_VALUE, frameWidth, frameHeight, initializationData)); }
Example #19
Source File: DashChunkSource.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
private boolean mimeTypeIsWebm(String mimeType) { return mimeType.startsWith(MimeTypes.VIDEO_WEBM) || mimeType.startsWith(MimeTypes.AUDIO_WEBM); }
Example #20
Source File: CommonMp4AtomParsers.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
private static Pair<MediaFormat, TrackEncryptionBox> parseAudioSampleEntry( ParsableByteArray parent, int atomType, int position, int size) { parent.setPosition(position + Mp4Util.ATOM_HEADER_SIZE); parent.skip(16); int channelCount = parent.readUnsignedShort(); int sampleSize = parent.readUnsignedShort(); parent.skip(4); int sampleRate = parent.readUnsignedFixedPoint1616(); int bitrate = MediaFormat.NO_VALUE; byte[] initializationData = null; TrackEncryptionBox trackEncryptionBox = null; int childPosition = parent.getPosition(); while (childPosition - position < size) { parent.setPosition(childPosition); int childStartPosition = parent.getPosition(); int childAtomSize = parent.readInt(); Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive"); int childAtomType = parent.readInt(); if (atomType == Atom.TYPE_mp4a || atomType == Atom.TYPE_enca) { if (childAtomType == Atom.TYPE_esds) { initializationData = parseEsdsFromParent(parent, childStartPosition); // TODO: Do we really need to do this? See [Internal: b/10903778] // Update sampleRate and channelCount from the AudioSpecificConfig initialization data. Pair<Integer, Integer> audioSpecificConfig = CodecSpecificDataUtil.parseAudioSpecificConfig(initializationData); sampleRate = audioSpecificConfig.first; channelCount = audioSpecificConfig.second; } else if (childAtomType == Atom.TYPE_sinf) { trackEncryptionBox = parseSinfFromParent(parent, childStartPosition, childAtomSize); } } else if (atomType == Atom.TYPE_ac_3 && childAtomType == Atom.TYPE_dac3) { // TODO: Choose the right AC-3 track based on the contents of dac3/dec3. Ac3Format ac3Format = parseAc3SpecificBoxFromParent(parent, childStartPosition); if (ac3Format != null) { sampleRate = ac3Format.sampleRate; channelCount = ac3Format.channelCount; bitrate = ac3Format.bitrate; } // TODO: Add support for encrypted AC-3. trackEncryptionBox = null; } else if (atomType == Atom.TYPE_ec_3 && childAtomType == Atom.TYPE_dec3) { sampleRate = parseEc3SpecificBoxFromParent(parent, childStartPosition); trackEncryptionBox = null; } childPosition += childAtomSize; } String mimeType; if (atomType == Atom.TYPE_ac_3) { mimeType = MimeTypes.AUDIO_AC3; } else if (atomType == Atom.TYPE_ec_3) { mimeType = MimeTypes.AUDIO_EC3; } else { mimeType = MimeTypes.AUDIO_AAC; } MediaFormat format = MediaFormat.createAudioFormat( mimeType, sampleSize, channelCount, sampleRate, bitrate, initializationData == null ? null : Collections.singletonList(initializationData)); return Pair.create(format, trackEncryptionBox); }
Example #21
Source File: Id3Parser.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
@Override public boolean canParse(String mimeType) { return mimeType.equals(MimeTypes.APPLICATION_ID3); }
Example #22
Source File: MediaCodecAudioTrackRenderer.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
@Override protected boolean handlesMimeType(String mimeType) { return MimeTypes.isAudio(mimeType) && super.handlesMimeType(mimeType); }
Example #23
Source File: MediaFormat.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
public static MediaFormat createTtmlFormat() { return createFormatForMimeType(MimeTypes.APPLICATION_TTML); }
Example #24
Source File: MediaFormat.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
public static MediaFormat createEia608Format() { return createFormatForMimeType(MimeTypes.APPLICATION_EIA608); }
Example #25
Source File: MediaFormat.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
public static MediaFormat createMp2vFormat() { return createFormatForMimeType(MimeTypes.VIDEO_MP2V); }
Example #26
Source File: MediaFormat.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
public static MediaFormat createId3Format() { return createFormatForMimeType(MimeTypes.APPLICATION_ID3); }
Example #27
Source File: MediaCodecVideoTrackRenderer.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
@Override protected boolean handlesMimeType(String mimeType) { return MimeTypes.isVideo(mimeType) && super.handlesMimeType(mimeType); }
Example #28
Source File: Eia608Parser.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
boolean canParse(String mimeType) { return mimeType.equals(MimeTypes.APPLICATION_EIA608); }
Example #29
Source File: TtmlParser.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
@Override public boolean canParse(String mimeType) { return MimeTypes.APPLICATION_TTML.equals(mimeType); }