| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
| 12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
| 13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
| 14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
| 15 * | 15 * |
| 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 package org.webrtc; | 28 package org.webrtc; |
| 29 | 29 |
| 30 import android.graphics.SurfaceTexture; |
| 30 import android.media.MediaCodec; | 31 import android.media.MediaCodec; |
| 31 import android.media.MediaCodecInfo; | 32 import android.media.MediaCodecInfo; |
| 32 import android.media.MediaCodecInfo.CodecCapabilities; | 33 import android.media.MediaCodecInfo.CodecCapabilities; |
| 33 import android.media.MediaCodecList; | 34 import android.media.MediaCodecList; |
| 34 import android.media.MediaFormat; | 35 import android.media.MediaFormat; |
| 35 import android.os.Build; | 36 import android.os.Build; |
| 36 import android.os.SystemClock; | 37 import android.os.SystemClock; |
| 37 import android.view.Surface; | 38 import android.view.Surface; |
| 38 | 39 |
| 39 import org.webrtc.Logging; | 40 import org.webrtc.Logging; |
| 40 | 41 |
| 41 import java.nio.ByteBuffer; | 42 import java.nio.ByteBuffer; |
| 42 import java.util.Arrays; | 43 import java.util.Arrays; |
| 43 import java.util.LinkedList; | 44 import java.util.LinkedList; |
| 44 import java.util.List; | 45 import java.util.List; |
| 45 import java.util.concurrent.CountDownLatch; | 46 import java.util.concurrent.CountDownLatch; |
| 46 import java.util.Queue; | 47 import java.util.Queue; |
| 47 import java.util.concurrent.TimeUnit; | 48 import java.util.concurrent.TimeUnit; |
| 48 | 49 |
| 49 // Java-side of peerconnection_jni.cc:MediaCodecVideoDecoder. | 50 // Java-side of peerconnection_jni.cc:MediaCodecVideoDecoder. |
| 50 // This class is an implementation detail of the Java PeerConnection API. | 51 // This class is an implementation detail of the Java PeerConnection API. |
| 52 @SuppressWarnings("deprecation") |
| 51 public class MediaCodecVideoDecoder { | 53 public class MediaCodecVideoDecoder { |
| 52 // This class is constructed, operated, and destroyed by its C++ incarnation, | 54 // This class is constructed, operated, and destroyed by its C++ incarnation, |
| 53 // so the class and its methods have non-public visibility. The API this | 55 // so the class and its methods have non-public visibility. The API this |
| 54 // class exposes aims to mimic the webrtc::VideoDecoder API as closely as | 56 // class exposes aims to mimic the webrtc::VideoDecoder API as closely as |
| 55 // possibly to minimize the amount of translation work necessary. | 57 // possibly to minimize the amount of translation work necessary. |
| 56 | 58 |
| 57 private static final String TAG = "MediaCodecVideoDecoder"; | 59 private static final String TAG = "MediaCodecVideoDecoder"; |
| 58 | 60 |
| 59 // Tracks webrtc::VideoCodecType. | 61 // Tracks webrtc::VideoCodecType. |
| 60 public enum VideoCodecType { | 62 public enum VideoCodecType { |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 // MediaCodec.CodecException upon codec error. | 618 // MediaCodec.CodecException upon codec error. |
| 617 private void returnDecodedOutputBuffer(int index) | 619 private void returnDecodedOutputBuffer(int index) |
| 618 throws IllegalStateException, MediaCodec.CodecException { | 620 throws IllegalStateException, MediaCodec.CodecException { |
| 619 checkOnMediaCodecThread(); | 621 checkOnMediaCodecThread(); |
| 620 if (useSurface) { | 622 if (useSurface) { |
| 621 throw new IllegalStateException("returnDecodedOutputBuffer() called for su
rface decoding."); | 623 throw new IllegalStateException("returnDecodedOutputBuffer() called for su
rface decoding."); |
| 622 } | 624 } |
| 623 mediaCodec.releaseOutputBuffer(index, false /* render */); | 625 mediaCodec.releaseOutputBuffer(index, false /* render */); |
| 624 } | 626 } |
| 625 } | 627 } |
| OLD | NEW |