| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.pm.PackageManager; | 8 import android.content.pm.PackageManager; |
| 9 import android.media.MediaMetadataRetriever; | 9 import android.media.MediaMetadataRetriever; |
| 10 import android.net.ConnectivityManager; | 10 import android.net.ConnectivityManager; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 import java.util.List; | 26 import java.util.List; |
| 27 import java.util.Map; | 27 import java.util.Map; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Java counterpart of android MediaResourceGetter. | 30 * Java counterpart of android MediaResourceGetter. |
| 31 */ | 31 */ |
| 32 @JNINamespace("content") | 32 @JNINamespace("content") |
| 33 class MediaResourceGetter { | 33 class MediaResourceGetter { |
| 34 | 34 |
| 35 private static final String TAG = "MediaResourceGetter"; | 35 private static final String TAG = "MediaResourceGetter"; |
| 36 private static final MediaMetadata EMPTY_METADATA = new MediaMetadata(0,0,0,
false); | 36 private static final MediaMetadata EMPTY_METADATA = new MediaMetadata(0, 0,
0, false); |
| 37 | 37 |
| 38 private final MediaMetadataRetriever mRetriever = new MediaMetadataRetriever
(); | 38 private final MediaMetadataRetriever mRetriever = new MediaMetadataRetriever
(); |
| 39 | 39 |
| 40 @VisibleForTesting | 40 @VisibleForTesting |
| 41 static class MediaMetadata { | 41 static class MediaMetadata { |
| 42 private final int mDurationInMilliseconds; | 42 private final int mDurationInMilliseconds; |
| 43 private final int mWidth; | 43 private final int mWidth; |
| 44 private final int mHeight; | 44 private final int mHeight; |
| 45 private final boolean mSuccess; | 45 private final boolean mSuccess; |
| 46 | 46 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 @Override | 90 @Override |
| 91 public boolean equals(Object obj) { | 91 public boolean equals(Object obj) { |
| 92 if (this == obj) | 92 if (this == obj) |
| 93 return true; | 93 return true; |
| 94 if (obj == null) | 94 if (obj == null) |
| 95 return false; | 95 return false; |
| 96 if (getClass() != obj.getClass()) | 96 if (getClass() != obj.getClass()) |
| 97 return false; | 97 return false; |
| 98 MediaMetadata other = (MediaMetadata)obj; | 98 MediaMetadata other = (MediaMetadata) obj; |
| 99 if (mDurationInMilliseconds != other.mDurationInMilliseconds) | 99 if (mDurationInMilliseconds != other.mDurationInMilliseconds) |
| 100 return false; | 100 return false; |
| 101 if (mHeight != other.mHeight) | 101 if (mHeight != other.mHeight) |
| 102 return false; | 102 return false; |
| 103 if (mSuccess != other.mSuccess) | 103 if (mSuccess != other.mSuccess) |
| 104 return false; | 104 return false; |
| 105 if (mWidth != other.mWidth) | 105 if (mWidth != other.mWidth) |
| 106 return false; | 106 return false; |
| 107 return true; | 107 return true; |
| 108 } | 108 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } finally { | 396 } finally { |
| 397 try { | 397 try { |
| 398 parcelFd.close(); | 398 parcelFd.close(); |
| 399 } catch (IOException e) { | 399 } catch (IOException e) { |
| 400 Log.e(TAG, "Failed to close file descriptor: " + e); | 400 Log.e(TAG, "Failed to close file descriptor: " + e); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 } | 403 } |
| 404 | 404 |
| 405 @VisibleForTesting | 405 @VisibleForTesting |
| 406 void configure(String url, Map<String,String> headers) { | 406 void configure(String url, Map<String, String> headers) { |
| 407 mRetriever.setDataSource(url, headers); | 407 mRetriever.setDataSource(url, headers); |
| 408 } | 408 } |
| 409 | 409 |
| 410 @VisibleForTesting | 410 @VisibleForTesting |
| 411 void configure(String path) { | 411 void configure(String path) { |
| 412 mRetriever.setDataSource(path); | 412 mRetriever.setDataSource(path); |
| 413 } | 413 } |
| 414 | 414 |
| 415 @VisibleForTesting | 415 @VisibleForTesting |
| 416 String extractMetadata(int key) { | 416 String extractMetadata(int key) { |
| 417 return mRetriever.extractMetadata(key); | 417 return mRetriever.extractMetadata(key); |
| 418 } | 418 } |
| 419 } | 419 } |
| OLD | NEW |