当前位置: 首页>>代码示例>>Java>>正文


Java Format类代码示例

本文整理汇总了Java中com.google.android.exoplayer2.Format的典型用法代码示例。如果您正苦于以下问题:Java Format类的具体用法?Java Format怎么用?Java Format使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Format类属于com.google.android.exoplayer2包,在下文中一共展示了Format类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseDtsFormat

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
/**
 * Returns the DTS format given {@code data} containing the DTS frame according to ETSI TS 102 114
 * subsections 5.3/5.4.
 *
 * @param frame The DTS frame 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 DTS format parsed from data in the header.
 */
public static Format parseDtsFormat(byte[] frame, String trackId, String language,
    DrmInitData drmInitData) {
  ParsableBitArray frameBits = new ParsableBitArray(frame);
  frameBits.skipBits(4 * 8 + 1 + 5 + 1 + 7 + 14); // SYNC, FTYPE, SHORT, CPF, NBLKS, FSIZE
  int amode = frameBits.readBits(6);
  int channelCount = CHANNELS_BY_AMODE[amode];
  int sfreq = frameBits.readBits(4);
  int sampleRate = SAMPLE_RATE_BY_SFREQ[sfreq];
  int rate = frameBits.readBits(5);
  int bitrate = rate >= TWICE_BITRATE_KBPS_BY_RATE.length ? Format.NO_VALUE
      : TWICE_BITRATE_KBPS_BY_RATE[rate] * 1000 / 2;
  frameBits.skipBits(10); // MIX, DYNF, TIMEF, AUXF, HDCD, EXT_AUDIO_ID, EXT_AUDIO, ASPF
  channelCount += frameBits.readBits(2) > 0 ? 1 : 0; // LFF
  return Format.createAudioSampleFormat(trackId, MimeTypes.AUDIO_DTS, null, bitrate,
      Format.NO_VALUE, channelCount, sampleRate, null, drmInitData, 0, language);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:27,代码来源:DtsUtil.java

示例2: determineIdealSelectedIndex

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
/**
 * Computes the ideal selected index ignoring buffer health.
 *
 * @param nowMs The current time in the timebase of {@link SystemClock#elapsedRealtime()}, or
 *     {@link Long#MIN_VALUE} to ignore blacklisting.
 */
private int determineIdealSelectedIndex(long nowMs) {
  long bitrateEstimate = bandwidthMeter.getBitrateEstimate();
  long effectiveBitrate = bitrateEstimate == BandwidthMeter.NO_ESTIMATE
      ? maxInitialBitrate : (long) (bitrateEstimate * bandwidthFraction);
  int lowestBitrateNonBlacklistedIndex = 0;
  for (int i = 0; i < length; i++) {
    if (nowMs == Long.MIN_VALUE || !isBlacklisted(i, nowMs)) {
      Format format = getFormat(i);
      if (format.bitrate <= effectiveBitrate) {
        return i;
      } else {
        lowestBitrateNonBlacklistedIndex = i;
      }
    }
  }
  return lowestBitrateNonBlacklistedIndex;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:24,代码来源:AdaptiveTrackSelection.java

示例3: getAudioTrackScore

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
private static int getAudioTrackScore(int formatSupport, String preferredLanguage,
    Format format) {
  boolean isDefault = (format.selectionFlags & C.SELECTION_FLAG_DEFAULT) != 0;
  int trackScore;
  if (formatHasLanguage(format, preferredLanguage)) {
    if (isDefault) {
      trackScore = 4;
    } else {
      trackScore = 3;
    }
  } else if (isDefault) {
    trackScore = 2;
  } else {
    trackScore = 1;
  }
  if (isSupported(formatSupport, false)) {
    trackScore += WITHIN_RENDERER_CAPABILITIES_BONUS;
  }
  return trackScore;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:21,代码来源:DefaultTrackSelector.java

示例4: MediaCodecVideoRenderer

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
/**
 * @param context A context.
 * @param mediaCodecSelector A decoder selector.
 * @param allowedJoiningTimeMs The maximum duration in milliseconds for which this video renderer
 *     can attempt to seamlessly join an ongoing playback.
 * @param drmSessionManager For use with encrypted content. May be null if support for encrypted
 *     content is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param maxDroppedFramesToNotify The maximum number of frames that can be dropped between
 *     invocations of {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
 */
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
    long allowedJoiningTimeMs, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys, Handler eventHandler,
    VideoRendererEventListener eventListener, int maxDroppedFramesToNotify) {
  super(C.TRACK_TYPE_VIDEO, mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys);
  this.allowedJoiningTimeMs = allowedJoiningTimeMs;
  this.maxDroppedFramesToNotify = maxDroppedFramesToNotify;
  frameReleaseTimeHelper = new VideoFrameReleaseTimeHelper(context);
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  deviceNeedsAutoFrcWorkaround = deviceNeedsAutoFrcWorkaround();
  joiningDeadlineMs = C.TIME_UNSET;
  currentWidth = Format.NO_VALUE;
  currentHeight = Format.NO_VALUE;
  currentPixelWidthHeightRatio = Format.NO_VALUE;
  pendingPixelWidthHeightRatio = Format.NO_VALUE;
  scalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
  clearReportedVideoSize();
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:37,代码来源:MediaCodecVideoRenderer.java

示例5: readData

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
int readData(int group, FormatHolder formatHolder, DecoderInputBuffer buffer,
    boolean requireFormat) {
  if (isPendingReset()) {
    return C.RESULT_NOTHING_READ;
  }

  while (mediaChunks.size() > 1 && finishedReadingChunk(mediaChunks.getFirst())) {
    mediaChunks.removeFirst();
  }
  HlsMediaChunk currentChunk = mediaChunks.getFirst();
  Format trackFormat = currentChunk.trackFormat;
  if (!trackFormat.equals(downstreamTrackFormat)) {
    eventDispatcher.downstreamFormatChanged(trackType, trackFormat,
        currentChunk.trackSelectionReason, currentChunk.trackSelectionData,
        currentChunk.startTimeUs);
  }
  downstreamTrackFormat = trackFormat;

  return sampleQueues.valueAt(group).readData(formatHolder, buffer, requireFormat,
      loadingFinished, lastSeekPositionUs);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:22,代码来源:HlsSampleStreamWrapper.java

示例6: parseEAc3AnnexFFormat

import com.google.android.exoplayer2.Format; //导入依赖的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);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:27,代码来源:Ac3Util.java

示例7: parseHeader

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
/**
 * Parses the sample header.
 */
@SuppressWarnings("ReferenceEquality")
private void parseHeader() {
  headerScratchBits.setPosition(0);
  Ac3Util.Ac3SyncFrameInfo frameInfo = Ac3Util.parseAc3SyncframeInfo(headerScratchBits);
  if (format == null || frameInfo.channelCount != format.channelCount
      || frameInfo.sampleRate != format.sampleRate
      || frameInfo.mimeType != format.sampleMimeType) {
    format = Format.createAudioSampleFormat(trackFormatId, frameInfo.mimeType, null,
        Format.NO_VALUE, Format.NO_VALUE, frameInfo.channelCount, frameInfo.sampleRate, null,
        null, 0, language);
    output.format(format);
  }
  sampleSize = frameInfo.frameSize;
  // In this class a sample is an access unit (syncframe in AC-3), but the MediaFormat sample rate
  // specifies the number of PCM audio samples per second.
  sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:21,代码来源:Ac3Reader.java

示例8: consume

import com.google.android.exoplayer2.Format; //导入依赖的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);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:17,代码来源:SpliceInfoSectionReader.java

示例9: readHeaders

import com.google.android.exoplayer2.Format; //导入依赖的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;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:OpusReader.java

示例10: Track

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
public Track(int id, int type, long timescale, long movieTimescale, long durationUs,
    Format format, @Transformation int sampleTransformation,
    TrackEncryptionBox[] sampleDescriptionEncryptionBoxes, int nalUnitLengthFieldLength,
    long[] editListDurations, long[] editListMediaTimes) {
  this.id = id;
  this.type = type;
  this.timescale = timescale;
  this.movieTimescale = movieTimescale;
  this.durationUs = durationUs;
  this.format = format;
  this.sampleTransformation = sampleTransformation;
  this.sampleDescriptionEncryptionBoxes = sampleDescriptionEncryptionBoxes;
  this.nalUnitLengthFieldLength = nalUnitLengthFieldLength;
  this.editListDurations = editListDurations;
  this.editListMediaTimes = editListMediaTimes;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:17,代码来源:Track.java

示例11: createDecoder

import com.google.android.exoplayer2.Format; //导入依赖的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");
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:SubtitleDecoderFactory.java

示例12: videoLoaded

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
private void videoLoaded() {
    if (loadVideoStarted) {
        loadVideoStarted = false;
        Format videoFormat = player.getVideoFormat();
        int width = videoFormat != null ? videoFormat.width : 0;
        int height = videoFormat != null ? videoFormat.height : 0;
        eventEmitter.load(player.getDuration(), player.getCurrentPosition(), width, height);
    }
}
 
开发者ID:12d,项目名称:react-native-videoplayer,代码行数:10,代码来源:ReactExoplayerView.java

示例13: canReconfigureCodec

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
@Override
protected boolean canReconfigureCodec(MediaCodec codec, boolean codecIsAdaptive,
    Format oldFormat, Format newFormat) {
  return areAdaptationCompatible(codecIsAdaptive, oldFormat, newFormat)
      && newFormat.width <= codecMaxValues.width && newFormat.height <= codecMaxValues.height
      && newFormat.maxInputSize <= codecMaxValues.inputSize;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:8,代码来源:MediaCodecVideoRenderer.java

示例14: onInputFormatChanged

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
@Override
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException {
  super.onInputFormatChanged(newFormat);
  eventDispatcher.inputFormatChanged(newFormat);
  // If the input format is anything other than PCM then we assume that the audio decoder will
  // output 16-bit PCM.
  pcmEncoding = MimeTypes.AUDIO_RAW.equals(newFormat.sampleMimeType) ? newFormat.pcmEncoding
      : C.ENCODING_PCM_16BIT;
  channelCount = newFormat.channelCount;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:11,代码来源:MediaCodecAudioRenderer.java

示例15: isSupportedAdaptiveAudioTrack

import com.google.android.exoplayer2.Format; //导入依赖的package包/类
private static boolean isSupportedAdaptiveAudioTrack(Format format, int formatSupport,
    AudioConfigurationTuple configuration) {
  return isSupported(formatSupport, false) && format.channelCount == configuration.channelCount
      && format.sampleRate == configuration.sampleRate
      && (configuration.mimeType == null
          || TextUtils.equals(configuration.mimeType, format.sampleMimeType));
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:8,代码来源:DefaultTrackSelector.java


注:本文中的com.google.android.exoplayer2.Format类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。