Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: webrtc/sdk/android/api/org/webrtc/EncodedImage.java

Issue 3010623002: Change capture time format to nanoseconds in EncodedImage. (Closed)
Patch Set: Update decoder wrapper. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/sdk/android/instrumentationtests/src/org/webrtc/HardwareVideoEncoderTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15
15 /** 16 /**
16 * 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
17 * encoders. 18 * encoders.
18 */ 19 */
19 public class EncodedImage { 20 public class EncodedImage {
20 public enum FrameType { 21 public enum FrameType {
21 EmptyFrame, 22 EmptyFrame,
22 VideoFrameKey, 23 VideoFrameKey,
23 VideoFrameDelta, 24 VideoFrameDelta,
24 } 25 }
25 26
26 public final ByteBuffer buffer; 27 public final ByteBuffer buffer;
27 public final int encodedWidth; 28 public final int encodedWidth;
28 public final int encodedHeight; 29 public final int encodedHeight;
29 public final long captureTimeMs; 30 public final long captureTimeMs; // Deprecated
31 public final long captureTimeNs;
30 public final FrameType frameType; 32 public final FrameType frameType;
31 public final int rotation; 33 public final int rotation;
32 public final boolean completeFrame; 34 public final boolean completeFrame;
33 public final Integer qp; 35 public final Integer qp;
34 36
35 private EncodedImage(ByteBuffer buffer, int encodedWidth, int encodedHeight, l ong captureTimeMs, 37 private EncodedImage(ByteBuffer buffer, int encodedWidth, int encodedHeight, l ong captureTimeNs,
36 FrameType frameType, int rotation, boolean completeFrame, Integer qp) { 38 FrameType frameType, int rotation, boolean completeFrame, Integer qp) {
37 this.buffer = buffer; 39 this.buffer = buffer;
38 this.encodedWidth = encodedWidth; 40 this.encodedWidth = encodedWidth;
39 this.encodedHeight = encodedHeight; 41 this.encodedHeight = encodedHeight;
40 this.captureTimeMs = captureTimeMs; 42 this.captureTimeMs = TimeUnit.NANOSECONDS.toMillis(captureTimeNs);
43 this.captureTimeNs = captureTimeNs;
41 this.frameType = frameType; 44 this.frameType = frameType;
42 this.rotation = rotation; 45 this.rotation = rotation;
43 this.completeFrame = completeFrame; 46 this.completeFrame = completeFrame;
44 this.qp = qp; 47 this.qp = qp;
45 } 48 }
46 49
47 public static Builder builder() { 50 public static Builder builder() {
48 return new Builder(); 51 return new Builder();
49 } 52 }
50 53
51 public static class Builder { 54 public static class Builder {
52 private ByteBuffer buffer; 55 private ByteBuffer buffer;
53 private int encodedWidth; 56 private int encodedWidth;
54 private int encodedHeight; 57 private int encodedHeight;
55 private long captureTimeMs; 58 private long captureTimeNs;
56 private EncodedImage.FrameType frameType; 59 private EncodedImage.FrameType frameType;
57 private int rotation; 60 private int rotation;
58 private boolean completeFrame; 61 private boolean completeFrame;
59 private Integer qp; 62 private Integer qp;
60 63
61 private Builder() {} 64 private Builder() {}
62 65
63 public Builder setBuffer(ByteBuffer buffer) { 66 public Builder setBuffer(ByteBuffer buffer) {
64 this.buffer = buffer; 67 this.buffer = buffer;
65 return this; 68 return this;
66 } 69 }
67 70
68 public Builder setEncodedWidth(int encodedWidth) { 71 public Builder setEncodedWidth(int encodedWidth) {
69 this.encodedWidth = encodedWidth; 72 this.encodedWidth = encodedWidth;
70 return this; 73 return this;
71 } 74 }
72 75
73 public Builder setEncodedHeight(int encodedHeight) { 76 public Builder setEncodedHeight(int encodedHeight) {
74 this.encodedHeight = encodedHeight; 77 this.encodedHeight = encodedHeight;
75 return this; 78 return this;
76 } 79 }
77 80
81 @Deprecated
78 public Builder setCaptureTimeMs(long captureTimeMs) { 82 public Builder setCaptureTimeMs(long captureTimeMs) {
79 this.captureTimeMs = captureTimeMs; 83 this.captureTimeNs = TimeUnit.MILLISECONDS.toNanos(captureTimeMs);
80 return this; 84 return this;
81 } 85 }
82 86
87 public Builder setCaptureTimeNs(long captureTimeNs) {
88 this.captureTimeNs = captureTimeNs;
89 return this;
90 }
91
83 public Builder setFrameType(EncodedImage.FrameType frameType) { 92 public Builder setFrameType(EncodedImage.FrameType frameType) {
84 this.frameType = frameType; 93 this.frameType = frameType;
85 return this; 94 return this;
86 } 95 }
87 96
88 public Builder setRotation(int rotation) { 97 public Builder setRotation(int rotation) {
89 this.rotation = rotation; 98 this.rotation = rotation;
90 return this; 99 return this;
91 } 100 }
92 101
93 public Builder setCompleteFrame(boolean completeFrame) { 102 public Builder setCompleteFrame(boolean completeFrame) {
94 this.completeFrame = completeFrame; 103 this.completeFrame = completeFrame;
95 return this; 104 return this;
96 } 105 }
97 106
98 public Builder setQp(Integer qp) { 107 public Builder setQp(Integer qp) {
99 this.qp = qp; 108 this.qp = qp;
100 return this; 109 return this;
101 } 110 }
102 111
103 public EncodedImage createEncodedImage() { 112 public EncodedImage createEncodedImage() {
104 return new EncodedImage(buffer, encodedWidth, encodedHeight, captureTimeMs , frameType, 113 return new EncodedImage(buffer, encodedWidth, encodedHeight, captureTimeNs , frameType,
105 rotation, completeFrame, qp); 114 rotation, completeFrame, qp);
106 } 115 }
107 } 116 }
108 } 117 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/sdk/android/instrumentationtests/src/org/webrtc/HardwareVideoEncoderTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698