Search in sources :

Example 1 with UnstableApi

use of androidx.media3.common.util.UnstableApi in project media by androidx.

the class Format method toBundle.

@UnstableApi
@Override
public Bundle toBundle() {
    Bundle bundle = new Bundle();
    bundle.putString(keyForField(FIELD_ID), id);
    bundle.putString(keyForField(FIELD_LABEL), label);
    bundle.putString(keyForField(FIELD_LANGUAGE), language);
    bundle.putInt(keyForField(FIELD_SELECTION_FLAGS), selectionFlags);
    bundle.putInt(keyForField(FIELD_ROLE_FLAGS), roleFlags);
    bundle.putInt(keyForField(FIELD_AVERAGE_BITRATE), averageBitrate);
    bundle.putInt(keyForField(FIELD_PEAK_BITRATE), peakBitrate);
    bundle.putString(keyForField(FIELD_CODECS), codecs);
    // Metadata is currently not Bundleable because Metadata.Entry is an Interface,
    // which would be difficult to unbundle in a backward compatible way.
    // The entries are additionally of limited usefulness to remote processes.
    bundle.putParcelable(keyForField(FIELD_METADATA), metadata);
    // Container specific.
    bundle.putString(keyForField(FIELD_CONTAINER_MIME_TYPE), containerMimeType);
    // Sample specific.
    bundle.putString(keyForField(FIELD_SAMPLE_MIME_TYPE), sampleMimeType);
    bundle.putInt(keyForField(FIELD_MAX_INPUT_SIZE), maxInputSize);
    for (int i = 0; i < initializationData.size(); i++) {
        bundle.putByteArray(keyForInitializationData(i), initializationData.get(i));
    }
    // DrmInitData doesn't need to be Bundleable as it's only used in the playing process to
    // initialize the decoder.
    bundle.putParcelable(keyForField(FIELD_DRM_INIT_DATA), drmInitData);
    bundle.putLong(keyForField(FIELD_SUBSAMPLE_OFFSET_US), subsampleOffsetUs);
    // Video specific.
    bundle.putInt(keyForField(FIELD_WIDTH), width);
    bundle.putInt(keyForField(FIELD_HEIGHT), height);
    bundle.putFloat(keyForField(FIELD_FRAME_RATE), frameRate);
    bundle.putInt(keyForField(FIELD_ROTATION_DEGREES), rotationDegrees);
    bundle.putFloat(keyForField(FIELD_PIXEL_WIDTH_HEIGHT_RATIO), pixelWidthHeightRatio);
    bundle.putByteArray(keyForField(FIELD_PROJECTION_DATA), projectionData);
    bundle.putInt(keyForField(FIELD_STEREO_MODE), stereoMode);
    bundle.putBundle(keyForField(FIELD_COLOR_INFO), BundleableUtil.toNullableBundle(colorInfo));
    // Audio specific.
    bundle.putInt(keyForField(FIELD_CHANNEL_COUNT), channelCount);
    bundle.putInt(keyForField(FIELD_SAMPLE_RATE), sampleRate);
    bundle.putInt(keyForField(FIELD_PCM_ENCODING), pcmEncoding);
    bundle.putInt(keyForField(FIELD_ENCODER_DELAY), encoderDelay);
    bundle.putInt(keyForField(FIELD_ENCODER_PADDING), encoderPadding);
    // Text specific.
    bundle.putInt(keyForField(FIELD_ACCESSIBILITY_CHANNEL), accessibilityChannel);
    // Source specific.
    bundle.putInt(keyForField(FIELD_CRYPTO_TYPE), cryptoType);
    return bundle;
}
Also used : Bundle(android.os.Bundle) UnstableApi(androidx.media3.common.util.UnstableApi)

Example 2 with UnstableApi

use of androidx.media3.common.util.UnstableApi in project media by androidx.

the class ExoPlaybackException method toBundle.

/**
 * {@inheritDoc}
 *
 * <p>It omits the {@link #mediaPeriodId} field. The {@link #mediaPeriodId} of an instance
 * restored by {@link #CREATOR} will always be {@code null}.
 */
@UnstableApi
@Override
public Bundle toBundle() {
    Bundle bundle = super.toBundle();
    bundle.putInt(keyForField(FIELD_TYPE), type);
    bundle.putString(keyForField(FIELD_RENDERER_NAME), rendererName);
    bundle.putInt(keyForField(FIELD_RENDERER_INDEX), rendererIndex);
    bundle.putBundle(keyForField(FIELD_RENDERER_FORMAT), BundleableUtil.toNullableBundle(rendererFormat));
    bundle.putInt(keyForField(FIELD_RENDERER_FORMAT_SUPPORT), rendererFormatSupport);
    bundle.putBoolean(keyForField(FIELD_IS_RECOVERABLE), isRecoverable);
    return bundle;
}
Also used : Bundle(android.os.Bundle) UnstableApi(androidx.media3.common.util.UnstableApi)

Example 3 with UnstableApi

use of androidx.media3.common.util.UnstableApi in project media by androidx.

the class DefaultMediaSourceFactory method createMediaSource.

@UnstableApi
@Override
public MediaSource createMediaSource(MediaItem mediaItem) {
    Assertions.checkNotNull(mediaItem.localConfiguration);
    @Nullable String scheme = mediaItem.localConfiguration.uri.getScheme();
    if (scheme != null && scheme.equals(C.SSAI_SCHEME)) {
        return checkNotNull(serverSideAdInsertionMediaSourceFactory).createMediaSource(mediaItem);
    }
    @C.ContentType int type = Util.inferContentTypeForUriAndMimeType(mediaItem.localConfiguration.uri, mediaItem.localConfiguration.mimeType);
    @Nullable MediaSource.Factory mediaSourceFactory = delegateFactoryLoader.getMediaSourceFactory(type);
    checkStateNotNull(mediaSourceFactory, "No suitable media source factory found for content type: " + type);
    MediaItem.LiveConfiguration.Builder liveConfigurationBuilder = mediaItem.liveConfiguration.buildUpon();
    if (mediaItem.liveConfiguration.targetOffsetMs == C.TIME_UNSET) {
        liveConfigurationBuilder.setTargetOffsetMs(liveTargetOffsetMs);
    }
    if (mediaItem.liveConfiguration.minPlaybackSpeed == C.RATE_UNSET) {
        liveConfigurationBuilder.setMinPlaybackSpeed(liveMinSpeed);
    }
    if (mediaItem.liveConfiguration.maxPlaybackSpeed == C.RATE_UNSET) {
        liveConfigurationBuilder.setMaxPlaybackSpeed(liveMaxSpeed);
    }
    if (mediaItem.liveConfiguration.minOffsetMs == C.TIME_UNSET) {
        liveConfigurationBuilder.setMinOffsetMs(liveMinOffsetMs);
    }
    if (mediaItem.liveConfiguration.maxOffsetMs == C.TIME_UNSET) {
        liveConfigurationBuilder.setMaxOffsetMs(liveMaxOffsetMs);
    }
    MediaItem.LiveConfiguration liveConfiguration = liveConfigurationBuilder.build();
    // Make sure to retain the very same media item instance, if no value needs to be overridden.
    if (!liveConfiguration.equals(mediaItem.liveConfiguration)) {
        mediaItem = mediaItem.buildUpon().setLiveConfiguration(liveConfiguration).build();
    }
    MediaSource mediaSource = mediaSourceFactory.createMediaSource(mediaItem);
    List<MediaItem.SubtitleConfiguration> subtitleConfigurations = castNonNull(mediaItem.localConfiguration).subtitleConfigurations;
    if (!subtitleConfigurations.isEmpty()) {
        MediaSource[] mediaSources = new MediaSource[subtitleConfigurations.size() + 1];
        mediaSources[0] = mediaSource;
        for (int i = 0; i < subtitleConfigurations.size(); i++) {
            if (useProgressiveMediaSourceForSubtitles) {
                Format format = new Format.Builder().setSampleMimeType(subtitleConfigurations.get(i).mimeType).setLanguage(subtitleConfigurations.get(i).language).setSelectionFlags(subtitleConfigurations.get(i).selectionFlags).setRoleFlags(subtitleConfigurations.get(i).roleFlags).setLabel(subtitleConfigurations.get(i).label).setId(subtitleConfigurations.get(i).id).build();
                ExtractorsFactory extractorsFactory = () -> new Extractor[] { SubtitleDecoderFactory.DEFAULT.supportsFormat(format) ? new SubtitleExtractor(SubtitleDecoderFactory.DEFAULT.createDecoder(format), format) : new UnknownSubtitlesExtractor(format) };
                mediaSources[i + 1] = new ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory).setLoadErrorHandlingPolicy(loadErrorHandlingPolicy).createMediaSource(MediaItem.fromUri(subtitleConfigurations.get(i).uri.toString()));
            } else {
                mediaSources[i + 1] = new SingleSampleMediaSource.Factory(dataSourceFactory).setLoadErrorHandlingPolicy(loadErrorHandlingPolicy).createMediaSource(subtitleConfigurations.get(i), /* durationUs= */
                C.TIME_UNSET);
            }
        }
        mediaSource = new MergingMediaSource(mediaSources);
    }
    return maybeWrapWithAdsMediaSource(mediaItem, maybeClipMediaSource(mediaItem, mediaSource));
}
Also used : SubtitleExtractor(androidx.media3.extractor.text.SubtitleExtractor) Format(androidx.media3.common.Format) AdsMediaSource(androidx.media3.exoplayer.source.ads.AdsMediaSource) DefaultExtractorsFactory(androidx.media3.extractor.DefaultExtractorsFactory) ExtractorsFactory(androidx.media3.extractor.ExtractorsFactory) MediaItem(androidx.media3.common.MediaItem) Extractor(androidx.media3.extractor.Extractor) SubtitleExtractor(androidx.media3.extractor.text.SubtitleExtractor) Nullable(androidx.annotation.Nullable) UnstableApi(androidx.media3.common.util.UnstableApi)

Example 4 with UnstableApi

use of androidx.media3.common.util.UnstableApi in project media by androidx.

the class CommandButton method toBundle.

@UnstableApi
@Override
public Bundle toBundle() {
    Bundle bundle = new Bundle();
    bundle.putBundle(keyForField(FIELD_SESSION_COMMAND), BundleableUtil.toNullableBundle(sessionCommand));
    bundle.putInt(keyForField(FIELD_PLAYER_COMMAND), playerCommand);
    bundle.putInt(keyForField(FIELD_ICON_RES_ID), iconResId);
    bundle.putCharSequence(keyForField(FIELD_DISPLAY_NAME), displayName);
    bundle.putBundle(keyForField(FIELD_EXTRAS), extras);
    bundle.putBoolean(keyForField(FIELD_ENABLED), isEnabled);
    return bundle;
}
Also used : Bundle(android.os.Bundle) UnstableApi(androidx.media3.common.util.UnstableApi)

Example 5 with UnstableApi

use of androidx.media3.common.util.UnstableApi in project media by androidx.

the class SessionCommands method toBundle.

@UnstableApi
@Override
public Bundle toBundle() {
    Bundle bundle = new Bundle();
    ArrayList<Bundle> sessionCommandBundleList = new ArrayList<>();
    for (SessionCommand command : commands) {
        sessionCommandBundleList.add(command.toBundle());
    }
    bundle.putParcelableArrayList(keyForField(FIELD_SESSION_COMMANDS), sessionCommandBundleList);
    return bundle;
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) UnstableApi(androidx.media3.common.util.UnstableApi)

Aggregations

UnstableApi (androidx.media3.common.util.UnstableApi)29 Bundle (android.os.Bundle)26 Nullable (androidx.annotation.Nullable)3 ArrayList (java.util.ArrayList)3 MediaItem (androidx.media3.common.MediaItem)2 BundleableUtil.fromNullableBundle (androidx.media3.common.util.BundleableUtil.fromNullableBundle)2 Handler (android.os.Handler)1 HandlerThread (android.os.HandlerThread)1 ResultReceiver (android.os.ResultReceiver)1 MediaControllerCompat (android.support.v4.media.session.MediaControllerCompat)1 MediaSessionCompat (android.support.v4.media.session.MediaSessionCompat)1 CallSuper (androidx.annotation.CallSuper)1 BundleListRetriever (androidx.media3.common.BundleListRetriever)1 Format (androidx.media3.common.Format)1 Player (androidx.media3.common.Player)1 AdsMediaSource (androidx.media3.exoplayer.source.ads.AdsMediaSource)1 DefaultExtractorsFactory (androidx.media3.extractor.DefaultExtractorsFactory)1 Extractor (androidx.media3.extractor.Extractor)1 ExtractorsFactory (androidx.media3.extractor.ExtractorsFactory)1 SubtitleExtractor (androidx.media3.extractor.text.SubtitleExtractor)1