1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.google.android.exoplayer2.ext.cast; 17 18 import android.content.Context; 19 import com.google.android.gms.cast.CastMediaControlIntent; 20 import com.google.android.gms.cast.framework.CastOptions; 21 import com.google.android.gms.cast.framework.OptionsProvider; 22 import com.google.android.gms.cast.framework.SessionProvider; 23 import java.util.Collections; 24 import java.util.List; 25 26 /** 27 * A convenience {@link OptionsProvider} to target the default cast receiver app. 28 */ 29 public final class DefaultCastOptionsProvider implements OptionsProvider { 30 31 /** 32 * App id of the Default Media Receiver app. Apps that do not require DRM support may use this 33 * receiver receiver app ID. 34 * 35 * <p>See https://developers.google.com/cast/docs/caf_receiver/#default_media_receiver. 36 */ 37 public static final String APP_ID_DEFAULT_RECEIVER = 38 CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID; 39 40 /** 41 * App id for receiver app with rudimentary support for DRM. 42 * 43 * <p>This app id is only suitable for ExoPlayer's Cast Demo app, and it is not intended for 44 * production use. In order to use DRM, custom receiver apps should be used. For environments that 45 * do not require DRM, the default receiver app should be used (see {@link 46 * #APP_ID_DEFAULT_RECEIVER}). 47 */ 48 // TODO: Add a documentation resource link for DRM support in the receiver app [Internal ref: 49 // b/128603245]. 50 public static final String APP_ID_DEFAULT_RECEIVER_WITH_DRM = "A12D4273"; 51 52 @Override getCastOptions(Context context)53 public CastOptions getCastOptions(Context context) { 54 return new CastOptions.Builder() 55 .setReceiverApplicationId(APP_ID_DEFAULT_RECEIVER_WITH_DRM) 56 .setStopReceiverApplicationWhenEndingSession(true) 57 .build(); 58 } 59 60 @Override getAdditionalSessionProviders(Context context)61 public List<SessionProvider> getAdditionalSessionProviders(Context context) { 62 return Collections.emptyList(); 63 } 64 65 } 66