1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
import android.media.MediaCodecInfo;
import android.media.MediaCrypto;
import android.media.MediaFormat;
import android.os.Bundle;
import android.view.Surface;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* Implementation of MediaCodecWrapperFactory that returns MediaCodecInterfaces wrapping
* {@link android.media.MediaCodec} objects.
*/
class MediaCodecWrapperFactoryImpl implements MediaCodecWrapperFactory {
private static class MediaCodecWrapperImpl implements MediaCodecWrapper {
private final MediaCodec mediaCodec;
public MediaCodecWrapperImpl(MediaCodec mediaCodec) {
this.mediaCodec = mediaCodec;
}
@Override
public void configure(MediaFormat format, Surface surface, MediaCrypto crypto, int flags) {
mediaCodec.configure(format, surface, crypto, flags);
}
@Override
public void start() {
mediaCodec.start();
}
@Override
public void flush() {
mediaCodec.flush();
}
@Override
public void stop() {
mediaCodec.stop();
}
@Override
public void release() {
mediaCodec.release();
}
@Override
public int dequeueInputBuffer(long timeoutUs) {
return mediaCodec.dequeueInputBuffer(timeoutUs);
}
@Override
public void queueInputBuffer(
int index, int offset, int size, long presentationTimeUs, int flags) {
mediaCodec.queueInputBuffer(index, offset, size, presentationTimeUs, flags);
}
@Override
public int dequeueOutputBuffer(BufferInfo info, long timeoutUs) {
return mediaCodec.dequeueOutputBuffer(info, timeoutUs);
}
@Override
public void releaseOutputBuffer(int index, boolean render) {
mediaCodec.releaseOutputBuffer(index, render);
}
@Override
public MediaFormat getInputFormat() {
return mediaCodec.getInputFormat();
}
@Override
public MediaFormat getOutputFormat() {
return mediaCodec.getOutputFormat();
}
@Override
public MediaFormat getOutputFormat(int index) {
return mediaCodec.getOutputFormat(index);
}
@Override
public ByteBuffer getInputBuffer(int index) {
return mediaCodec.getInputBuffer(index);
}
@Override
public ByteBuffer getOutputBuffer(int index) {
return mediaCodec.getOutputBuffer(index);
}
@Override
public Surface createInputSurface() {
return mediaCodec.createInputSurface();
}
@Override
public void setParameters(Bundle params) {
mediaCodec.setParameters(params);
}
@Override
public MediaCodecInfo getCodecInfo() {
return mediaCodec.getCodecInfo();
}
}
@Override
public MediaCodecWrapper createByCodecName(String name) throws IOException {
return new MediaCodecWrapperImpl(MediaCodec.createByCodecName(name));
}
}
|