本文整理汇总了Java中com.google.android.exoplayer2.drm.DrmSession类的典型用法代码示例。如果您正苦于以下问题:Java DrmSession类的具体用法?Java DrmSession怎么用?Java DrmSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrmSession类属于com.google.android.exoplayer2.drm包,在下文中一共展示了DrmSession类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: acquireSession
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
@SuppressWarnings("PMD.AvoidCatchingGenericException") // We are forced to catch Exception as ResourceBusyException is minSdk 19
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
public DrmSession<FrameworkMediaCrypto> acquireSession(Looper playbackLooper, DrmInitData drmInitData) {
DrmSession<FrameworkMediaCrypto> drmSession;
try {
SessionId sessionId = SessionId.of(mediaDrm.openSession());
FrameworkMediaCrypto mediaCrypto = mediaDrm.createMediaCrypto(sessionId.asBytes());
mediaDrm.restoreKeys(sessionId.asBytes(), keySetIdToRestore.asBytes());
drmSession = new LocalDrmSession(mediaCrypto, keySetIdToRestore, sessionId);
} catch (Exception exception) {
drmSession = new InvalidDrmSession(new DrmSession.DrmSessionException(exception));
notifyErrorListener(drmSession);
}
return drmSession;
}
开发者ID:novoda,项目名称:no-player,代码行数:20,代码来源:LocalDrmSessionManager.java
示例2: shouldWaitForKeys
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException {
if (drmSession == null) {
return false;
}
@DrmSession.State int drmSessionState = drmSession.getState();
if (drmSessionState == DrmSession.STATE_ERROR) {
throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
}
return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS
&& (bufferEncrypted || !playClearSamplesWithoutKeys);
}
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:12,代码来源:MediaCodecRenderer.java
示例3: maybeInitDecoder
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
private void maybeInitDecoder() throws ExoPlaybackException {
if (decoder != null) {
return;
}
drmSession = pendingDrmSession;
ExoMediaCrypto mediaCrypto = null;
if (drmSession != null) {
@DrmSession.State int drmSessionState = drmSession.getState();
if (drmSessionState == DrmSession.STATE_ERROR) {
throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
} else if (drmSessionState == DrmSession.STATE_OPENED
|| drmSessionState == DrmSession.STATE_OPENED_WITH_KEYS) {
mediaCrypto = drmSession.getMediaCrypto();
} else {
// The drm session isn't open yet.
return;
}
}
try {
long codecInitializingTimestamp = SystemClock.elapsedRealtime();
TraceUtil.beginSection("createAudioDecoder");
decoder = createDecoder(inputFormat, mediaCrypto);
TraceUtil.endSection();
long codecInitializedTimestamp = SystemClock.elapsedRealtime();
eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
codecInitializedTimestamp - codecInitializingTimestamp);
decoderCounters.decoderInitCount++;
} catch (AudioDecoderException e) {
throw ExoPlaybackException.createForRenderer(e, getIndex());
}
}
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:34,代码来源:SimpleDecoderAudioRenderer.java
示例4: notifyErrorListener
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
private void notifyErrorListener(DrmSession<FrameworkMediaCrypto> drmSession) {
final DrmSession.DrmSessionException error = drmSession.getError();
handler.post(new Runnable() {
@Override
public void run() {
eventListener.onDrmSessionManagerError(error);
}
});
}
开发者ID:novoda,项目名称:no-player,代码行数:10,代码来源:LocalDrmSessionManager.java
示例5: givenValidMediaDrm_whenAcquiringSession_thenReturnsLocalDrmSession
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
@Test
public void givenValidMediaDrm_whenAcquiringSession_thenReturnsLocalDrmSession() throws MediaCryptoException {
given(mediaDrm.createMediaCrypto(SESSION_ID.asBytes())).willReturn(frameworkMediaCrypto);
DrmSession<FrameworkMediaCrypto> drmSession = localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA);
LocalDrmSession localDrmSession = new LocalDrmSession(frameworkMediaCrypto, KEY_SET_ID_TO_RESTORE, SESSION_ID);
assertThat(drmSession).isEqualTo(localDrmSession);
}
开发者ID:novoda,项目名称:no-player,代码行数:10,代码来源:LocalDrmSessionManagerTest.java
示例6: givenOpeningSessionError_whenAcquiringSession_thenNotifiesErrorEventListenerOnHandler
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Test
public void givenOpeningSessionError_whenAcquiringSession_thenNotifiesErrorEventListenerOnHandler() throws MediaDrmException {
given(mediaDrm.openSession()).willThrow(new ResourceBusyException("resource is busy"));
localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA);
ArgumentCaptor<Runnable> argumentCaptor = ArgumentCaptor.forClass(Runnable.class);
verify(handler).post(argumentCaptor.capture());
argumentCaptor.getValue().run();
verify(eventListener).onDrmSessionManagerError(any(DrmSession.DrmSessionException.class));
}
开发者ID:novoda,项目名称:no-player,代码行数:13,代码来源:LocalDrmSessionManagerTest.java
示例7: givenOpeningSessionError_whenAcquiringSession_thenReturnsInvalidDrmSession
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Test
public void givenOpeningSessionError_whenAcquiringSession_thenReturnsInvalidDrmSession() throws MediaDrmException {
ResourceBusyException resourceBusyException = new ResourceBusyException("resource is busy");
given(mediaDrm.openSession()).willThrow(resourceBusyException);
DrmSession<FrameworkMediaCrypto> drmSession = localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA);
assertThat(drmSession).isInstanceOf(InvalidDrmSession.class);
assertThat(drmSession.getError().getCause()).isEqualTo(resourceBusyException);
}
开发者ID:novoda,项目名称:no-player,代码行数:12,代码来源:LocalDrmSessionManagerTest.java
示例8: givenAcquiredSession_whenReleasingSession_thenClosesCurrentSession
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
@Test
public void givenAcquiredSession_whenReleasingSession_thenClosesCurrentSession() {
DrmSession<FrameworkMediaCrypto> drmSession = new LocalDrmSession(frameworkMediaCrypto, KEY_SET_ID_TO_RESTORE, SESSION_ID);
localDrmSessionManager.releaseSession(drmSession);
verify(mediaDrm).closeSession(SESSION_ID.asBytes());
}
开发者ID:novoda,项目名称:no-player,代码行数:9,代码来源:LocalDrmSessionManagerTest.java
示例9: shouldWaitForKeys
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException {
if (drmSession == null) {
return false;
}
int drmSessionState = drmSession.getState();
if (drmSessionState == DrmSession.STATE_ERROR) {
throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
}
return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS
&& (bufferEncrypted || !playClearSamplesWithoutKeys);
}
开发者ID:TakumaMochizuki,项目名称:Komica,代码行数:12,代码来源:LibvpxVideoRenderer.java
示例10: shouldWaitForKeys
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException {
if (drmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) {
return false;
}
@DrmSession.State int drmSessionState = drmSession.getState();
if (drmSessionState == DrmSession.STATE_ERROR) {
throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
}
return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS;
}
开发者ID:y20k,项目名称:transistor,代码行数:11,代码来源:LibvpxVideoRenderer.java
示例11: buildOfflineDrmSessionManager
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
private DrmSessionManager<FrameworkMediaCrypto> buildOfflineDrmSessionManager(UUID uuid,
String licenseUrl, Map<String, String> keyRequestProperties) throws UnsupportedDrmException, IOException, DrmSession.DrmSessionException, InterruptedException {
if (Util.SDK_INT < 18) {
return null;
}
customDrmCallback = new CustomDrmCallback(
DemoApplication.getAppInstance().buildHttpDataSourceFactory(new DefaultBandwidthMeter()),
licenseUrl
);
DefaultDrmSessionManager<FrameworkMediaCrypto> drmSessionManager = new DefaultDrmSessionManager<>(uuid,
FrameworkMediaDrm.newInstance(uuid), customDrmCallback, null, mainHandler, eventLogger);
String offlineAssetKeyIdStr = DemoApplication.getAppInstance().
getSharedPreferences().getString(DemoApplication.KEY_OFFLINE_OFFSET_ID,DemoApplication.EMPTY);
byte[] offlineAssetKeyId = Base64.decode(offlineAssetKeyIdStr, Base64.DEFAULT);
this.offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(customDrmCallback, null);
Pair<Long, Long> remainingSecPair = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineAssetKeyId);
Log.e(TAG," License remaining Play time : "+remainingSecPair.first+", Purchase time : "+remainingSecPair.second);
if(DemoApplication.EMPTY.equals(offlineAssetKeyIdStr) || ( remainingSecPair.first == 0 || remainingSecPair.second == 0)) {
String path = getIntent().getStringExtra(EXTRA_OFFLINE_URI);
File file = getUriForManifest(path);
Uri uri = Uri.fromFile(file);
InputStream is = new FileInputStream(file);
Log.e(TAG, "will start download now");
offlineAssetKeyId = offlineLicenseHelper.download(
DemoApplication.getAppInstance().buildHttpDataSourceFactory(new DefaultBandwidthMeter()).createDataSource(),
new DashManifestParser().parse(uri, is));
Pair<Long, Long> p = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineAssetKeyId);
Log.e(TAG, "download done : " + p.toString());
SharedPreferences sharedPreferences = DemoApplication.getAppInstance().getSharedPreferences();
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(DemoApplication.KEY_OFFLINE_OFFSET_ID,
Base64.encodeToString(offlineAssetKeyId, Base64.DEFAULT));
editor.commit();
}
drmSessionManager.setMode(DefaultDrmSessionManager.MODE_QUERY,offlineAssetKeyId);
return drmSessionManager;
}
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:44,代码来源:PlayerActivity.java
示例12: releaseSession
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
@Override
public void releaseSession(DrmSession<FrameworkMediaCrypto> drmSession) {
FrameworkDrmSession frameworkDrmSession = (FrameworkDrmSession) drmSession;
SessionId sessionId = frameworkDrmSession.getSessionId();
mediaDrm.closeSession(sessionId.asBytes());
}
开发者ID:novoda,项目名称:no-player,代码行数:7,代码来源:LocalDrmSessionManager.java
示例13: getState
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
@Override
public int getState() {
return DrmSession.STATE_ERROR;
}
开发者ID:novoda,项目名称:no-player,代码行数:5,代码来源:InvalidDrmSession.java
示例14: render
import com.google.android.exoplayer2.drm.DrmSession; //导入依赖的package包/类
@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
if (outputStreamEnded) {
return;
}
// Try and read a format if we don't have one already.
if (format == null && !readFormat()) {
// We can't make progress without one.
return;
}
if (isRendererAvailable()) {
drmSession = pendingDrmSession;
ExoMediaCrypto mediaCrypto = null;
if (drmSession != null) {
int drmSessionState = drmSession.getState();
if (drmSessionState == DrmSession.STATE_ERROR) {
throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
} else if (drmSessionState == DrmSession.STATE_OPENED
|| drmSessionState == DrmSession.STATE_OPENED_WITH_KEYS) {
mediaCrypto = drmSession.getMediaCrypto();
} else {
// The drm session isn't open yet.
return;
}
}
try {
if (decoder == null) {
// If we don't have a decoder yet, we need to instantiate one.
long codecInitializingTimestamp = SystemClock.elapsedRealtime();
TraceUtil.beginSection("createVpxDecoder");
decoder = new VpxDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
mediaCrypto);
decoder.setOutputMode(outputMode);
TraceUtil.endSection();
long codecInitializedTimestamp = SystemClock.elapsedRealtime();
eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
codecInitializedTimestamp - codecInitializingTimestamp);
decoderCounters.decoderInitCount++;
}
TraceUtil.beginSection("drainAndFeed");
while (drainOutputBuffer(positionUs)) {}
while (feedInputBuffer()) {}
TraceUtil.endSection();
} catch (VpxDecoderException e) {
throw ExoPlaybackException.createForRenderer(e, getIndex());
}
} else {
skipToKeyframeBefore(positionUs);
}
decoderCounters.ensureUpdated();
}
开发者ID:TakumaMochizuki,项目名称:Komica,代码行数:54,代码来源:LibvpxVideoRenderer.java
注:本文中的com.google.android.exoplayer2.drm.DrmSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论