2017-06-28 6 views
0

こんにちは私はExoplayer 1.xからExoplayer 2.xに自分のDRM実装を切り替えていますが、いくつかの例外があり、DRMライセンスされたビデオを再生できません。私のDRMセッションマネージャ:Exoplayer2 DRM例外shouldWaitForKeys

protected DrmSessionManager<FrameworkMediaCrypto> generateDrmSessionManager() { 
     // DRM is only supported on API 18 + in the ExoPlayer 
     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { 
      return null; 
     } 

     // Widevine will capture the majority of use cases however playready is supported on all AndroidTV devices 
     UUID uuid = C.WIDEVINE_UUID; 
     final String licenseURL = "http://video.aaa"; 

     HttpMediaDrmCallback drmCallback = 
       new HttpMediaDrmCallback(
         licenseURL, buildHttpDataSourceFactory(false), KEY_REQUEST_PROPERTIES); 

     try { 
      return new DefaultDrmSessionManager<>(
        uuid, FrameworkMediaDrm.newInstance(uuid), drmCallback, null, mainHandler, capabilitiesListener); 
     } catch (Exception e) { 
      Log.d(TAG, "Unable to create a DrmSessionManager due to an exception", e); 
      return null; 
     } 
    } 

は私がdrmSessionを持っているし、呼び出すときにHttpMediaDrmCallbackは

executePost(dataSourceFactory, url, request.getData(), requestProperties); 

実行したときに内部onDrmSessionManagerError(java.lang.IllegalArgumentExceptionが)を引き起こす呼び出しがあります:

HttpDataSource dataSource = dataSourceFactory.createDataSource(); 

at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.shouldWaitForKeys(MediaCodecRenderer.java:735) com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:676) at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:511) at com.google.android android.os.Handler.dispatchMessageでcom.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:308) (Handler.java:98)で.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:479) android.os.Looper.loop(Looper.java:135) (android.os.HandlerThread.run(HandlerThread.java:61)) 原因:com.googl e.android.exoplayer2.drm.DrmSession $ DrmSessionException:java.lang.IllegalArgumentException at com.google.android.exoplayer2.drm.DefaultDrmSessionManager.onError(DefaultDrmSessionManager.java:604) at com.google.android.exoplayer2.drm .DefaultDrmSessionManager.onKeysError(DefaultDrmSessionManager.java:599) com.google.android.exoplayer2.drm.DefaultDrmSessionManager.onKeyResponse(DefaultDrmSessionManager.java:559) com.google.android.exoplayer2.drm.DefaultDrmSessionManager.access $ 900( DefaultDrmSessionManager.java:50) com.google.android.exoplayer2.drm.DefaultDrmSessionManager $ PostResponseHandler.handleMessage(DefaultDrmSessionManager.java:679) at android.os.Handler.dispatchMessage(Handler.java:102) とandroid.os.Looper.loop(Looper.java:135) とandroid.os.HandlerThread.run(HandlerThread.java:61) 原因: java.lang.IllegalArgumentException at com.google.android.exoplayer2.util.Assertions.checkNotEmpty(Assertions.java:138) at com.google.android.exstream.upstream.DefaultHttpDataSource(DefaultHttpDataSource.java:148) at com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory.createDataSourceInternal(DefaultHttpDataSourceFactory.java:81) at com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory.createDataSourc eInternal(DefaultHttpDataSourceFactory.java:22) com.google.android.exoplayer2.upstream.HttpDataSource $ BaseFactory.createDataSource(HttpDataSource.java:176) com.google.android.exoplayer2.drm.HttpMediaDrmCallback.executePost(HttpMediaDrmCallback。 java:139) com.google.android.exoplayer2.drm.HttpMediaDrmCallback.executeKeyRequest(HttpMediaDrmCallback.java:134) at com.google.android.exoplayer2.drm.DefaultDrmSessionManager $ PostRequestHandler.handleMessage(DefaultDrmSessionManager。java:702) (android.os.Handler.dispatchMessage(Handler.java:102)) (android.os.Looper.loop(Looper.java:135)) (android.os.HandlerThread.run(HandlerThread.java: 61)

私のExoplayer 1.xの実装がうまくいき、なぜクラッシュするのか分かりません。

答えて

1

例外がUserAgent文字列がnullまたはここで長さがゼロであることに起因している:

public DefaultHttpDataSource(String userAgent, Predicate<String> contentTypePredicate, 
     TransferListener<? super DefaultHttpDataSource> listener, int connectTimeoutMillis, 
     int readTimeoutMillis, boolean allowCrossProtocolRedirects, 
     RequestProperties defaultRequestProperties) { 
    this.userAgent = Assertions.checkNotEmpty(userAgent); <---- Exception is here 
    this.contentTypePredicate = contentTypePredicate; 
    this.listener = listener; 
    this.requestProperties = new RequestProperties(); 
    this.connectTimeoutMillis = connectTimeoutMillis; 
    this.readTimeoutMillis = readTimeoutMillis; 
    this.allowCrossProtocolRedirects = allowCrossProtocolRedirects; 
    this.defaultRequestProperties = defaultRequestProperties; 
    } 

userAgentには、アプリケーション名とExoPlayerライブラリのバージョンの組み合わせです:

/** 
    * Returns a user agent string based on the given application name and the library version. 
    * 
    * @param context A valid context of the calling application. 
    * @param applicationName String that will be prefix'ed to the generated user agent. 
    * @return A user agent string generated using the applicationName and the library version. 
    */ 
    public static String getUserAgent(Context context, String applicationName) { 
    String versionName; 
    try { 
     String packageName = context.getPackageName(); 
     PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); 
     versionName = info.versionName; 
    } catch (NameNotFoundException e) { 
     versionName = "?"; 
    } 
    return applicationName + "/" + versionName + " (Linux;Android " + Build.VERSION.RELEASE 
     + ") " + ExoPlayerLibraryInfo.VERSION_SLASHY; 
    } 

することができますデモアプリケーションで使用および設定されている例を参照してください。https://github.com/google/ExoPlayer/tree/release-v2/demo

MediaPlayeの設定に関する情報もありますuserAgentには設定されている示すこの例を含んドキュメント(https://google.github.io/ExoPlayer/guide.html)におけるR:

// Measures bandwidth during playback. Can be null if not required. 
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); 
// Produces DataSource instances through which media data is loaded. 
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, 
    Util.getUserAgent(context, "yourApplicationName"), bandwidthMeter); 
// Produces Extractor instances for parsing the media data. 
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); 
// This is the MediaSource representing the media to be played. 
MediaSource videoSource = new ExtractorMediaSource(mp4VideoUri, 
    dataSourceFactory, extractorsFactory, null, null); 
// Prepare the player with the source. 
player.prepare(videoSource); 
+0

causes..currently私が適切にユーザーエージェントを設定していているように見えるわけではありません。 – Billyjoker

+1

@Billyjoker - Stacktraceを見れば例外がスローされていることがわかります '原因:com.google.android.exoplayer2.util.Assertions.checkNotEmpty(Assertions.java:138)at comでjava.lang.IllegalArgumentExceptionが発生しました。 .google.android.exoplayer2.upstream.DefaultHttpDataSource 'あなたがそれを設定しているかもしれませんが、あなたがそれを使う前にリセットされるか、または間違った変数が間違って渡されるかもしれません。 – Mick

+0

あなたは正しかった!問題は、ユーザーエージェントが空の値でDefaultHttpDataSourceFactoryを作成したが、DefaultDataSourceFactoryを作成したときにユーザーエージェントが正しくても、shouldWaitForKeys例外が発生したということでした。だから、私は空のユーザーエージェントを満たし、魅力のように動作します!どうもありがとう – Billyjoker