Chromium Code Reviews| 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.media; | 5 package org.chromium.media; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.media.AudioFormat; | 8 import android.media.AudioFormat; |
| 9 import android.media.MediaCodec; | 9 import android.media.MediaCodec; |
| 10 import android.media.MediaCrypto; | 10 import android.media.MediaCrypto; |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 break; | 613 break; |
| 614 default: | 614 default: |
| 615 name = null; | 615 name = null; |
| 616 break; | 616 break; |
| 617 } | 617 } |
| 618 if (name != null) { | 618 if (name != null) { |
| 619 format.setByteBuffer(name, ByteBuffer.wrap(bytes)); | 619 format.setByteBuffer(name, ByteBuffer.wrap(bytes)); |
| 620 } | 620 } |
| 621 } | 621 } |
| 622 | 622 |
| 623 @TargetApi(Build.VERSION_CODES.M) | |
| 624 @CalledByNative | |
| 625 private void setSurface(Surface surface) { | |
| 626 try { | |
| 627 mMediaCodec.setOutputSurface(surface); | |
| 628 } catch (IllegalArgumentException | IllegalStateException e) { | |
| 629 Log.e(TAG, "Cannot set output surface", e); | |
| 630 } | |
|
watk
2016/11/08 22:59:03
Seems like this should return an error? If we fail
DaleCurtis
2016/11/08 23:50:10
Done.
| |
| 631 } | |
| 632 | |
| 623 @CalledByNative | 633 @CalledByNative |
| 624 private static void setFrameHasADTSHeader(MediaFormat format) { | 634 private static void setFrameHasADTSHeader(MediaFormat format) { |
| 625 format.setInteger(MediaFormat.KEY_IS_ADTS, 1); | 635 format.setInteger(MediaFormat.KEY_IS_ADTS, 1); |
| 626 } | 636 } |
| 627 | 637 |
| 628 @CalledByNative | 638 @CalledByNative |
| 629 private boolean configureAudio(MediaFormat format, MediaCrypto crypto, int f lags) { | 639 private boolean configureAudio(MediaFormat format, MediaCrypto crypto, int f lags) { |
| 630 try { | 640 try { |
| 631 mMediaCodec.configure(format, null, crypto, flags); | 641 mMediaCodec.configure(format, null, crypto, flags); |
| 632 return true; | 642 return true; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | 675 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
| 666 return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND; | 676 return AudioFormat.CHANNEL_OUT_7POINT1_SURROUND; |
| 667 } else { | 677 } else { |
| 668 return AudioFormat.CHANNEL_OUT_7POINT1; | 678 return AudioFormat.CHANNEL_OUT_7POINT1; |
| 669 } | 679 } |
| 670 default: | 680 default: |
| 671 return AudioFormat.CHANNEL_OUT_DEFAULT; | 681 return AudioFormat.CHANNEL_OUT_DEFAULT; |
| 672 } | 682 } |
| 673 } | 683 } |
| 674 } | 684 } |
| OLD | NEW |