OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 package org.webrtc; | 11 package org.webrtc; |
12 | 12 |
13 import java.nio.ByteBuffer; | 13 import java.nio.ByteBuffer; |
14 import java.util.concurrent.TimeUnit; | 14 import java.util.concurrent.TimeUnit; |
15 | 15 |
16 /** | 16 /** |
17 * An encoded frame from a video stream. Used as an input for decoders and as an
output for | 17 * An encoded frame from a video stream. Used as an input for decoders and as an
output for |
18 * encoders. | 18 * encoders. |
19 */ | 19 */ |
20 public class EncodedImage { | 20 public class EncodedImage { |
| 21 // Must be kept in sync with common_types.h FrameType. |
21 public enum FrameType { | 22 public enum FrameType { |
22 EmptyFrame, | 23 EmptyFrame(0), |
23 VideoFrameKey, | 24 VideoFrameKey(3), |
24 VideoFrameDelta, | 25 VideoFrameDelta(4); |
| 26 |
| 27 private final int nativeIndex; |
| 28 |
| 29 private FrameType(int nativeIndex) { |
| 30 this.nativeIndex = nativeIndex; |
| 31 } |
| 32 |
| 33 public int getNative() { |
| 34 return nativeIndex; |
| 35 } |
| 36 |
| 37 public static FrameType fromNative(int nativeIndex) { |
| 38 for (FrameType type : FrameType.values()) { |
| 39 if (type.nativeIndex == nativeIndex) { |
| 40 return type; |
| 41 } |
| 42 } |
| 43 throw new IllegalArgumentException("Unknown native frame type: " + nativeI
ndex); |
| 44 } |
25 } | 45 } |
26 | 46 |
27 public final ByteBuffer buffer; | 47 public final ByteBuffer buffer; |
28 public final int encodedWidth; | 48 public final int encodedWidth; |
29 public final int encodedHeight; | 49 public final int encodedHeight; |
30 public final long captureTimeMs; // Deprecated | 50 public final long captureTimeMs; // Deprecated |
31 public final long captureTimeNs; | 51 public final long captureTimeNs; |
32 public final FrameType frameType; | 52 public final FrameType frameType; |
33 public final int rotation; | 53 public final int rotation; |
34 public final boolean completeFrame; | 54 public final boolean completeFrame; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 this.qp = qp; | 128 this.qp = qp; |
109 return this; | 129 return this; |
110 } | 130 } |
111 | 131 |
112 public EncodedImage createEncodedImage() { | 132 public EncodedImage createEncodedImage() { |
113 return new EncodedImage(buffer, encodedWidth, encodedHeight, captureTimeNs
, frameType, | 133 return new EncodedImage(buffer, encodedWidth, encodedHeight, captureTimeNs
, frameType, |
114 rotation, completeFrame, qp); | 134 rotation, completeFrame, qp); |
115 } | 135 } |
116 } | 136 } |
117 } | 137 } |
OLD | NEW |