Skip to content

Commit dfdc749

Browse files
committed
TestMedia : remove MediaEncoder/Decoder tests
1 parent b4e74a5 commit dfdc749

File tree

1 file changed

+1
-90
lines changed

1 file changed

+1
-90
lines changed

src/javaforce/tests/TestMedia.java

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
public class TestMedia implements MediaIO {
1919
public static void usage() {
20-
System.out.println("TestMedia encoder | decoder | output | input");
20+
System.out.println("TestMedia output | input");
2121
System.exit(1);
2222
}
2323

@@ -39,8 +39,6 @@ public static void main(String[] args) {
3939
}
4040
try {
4141
switch (args[a]) {
42-
case "decoder": decoder(); break;
43-
case "encoder": encoder(true); break;
4442
case "input": input(); break;
4543
case "output": output(true); break;
4644
default: usage();
@@ -51,42 +49,6 @@ public static void main(String[] args) {
5149
}
5250
}
5351

54-
public static void decoder() {
55-
if (!new File("test-0.mp4").exists()) {
56-
encoder(false);
57-
}
58-
while (true) {
59-
TestMedia media = new TestMedia();
60-
MediaDecoder decoder = new MediaDecoder();
61-
media.open("test-0.mp4");
62-
decoder.start(media, 640, 480, 2, 44100, true);
63-
boolean eof = false;
64-
int pkts = 0;
65-
do {
66-
int type = decoder.read();
67-
pkts++;
68-
switch (type) {
69-
case MediaCoder.VIDEO_FRAME:
70-
int[] px = decoder.getVideo();
71-
if (px == null) break;
72-
System.out.println("video=" + px.length);
73-
break;
74-
case MediaCoder.AUDIO_FRAME:
75-
short[] sams = decoder.getAudio();
76-
if (sams == null) break;
77-
System.out.println("audio=" + sams.length);
78-
break;
79-
case MediaCoder.END_FRAME:
80-
eof = true;
81-
break;
82-
}
83-
} while (!eof);
84-
System.out.println("packets=" + pkts);
85-
decoder.stop();
86-
media.close();
87-
}
88-
}
89-
9052
public static void input() {
9153
if (!new File("test-0.mp4").exists()) {
9254
output(false);
@@ -153,57 +115,6 @@ public static void sine(short[] sams) {
153115
public static String encoder_audio_src = "random";
154116
public static boolean use_media_io = false;
155117

156-
public static void encoder(boolean loop) {
157-
TestMedia media = new TestMedia();
158-
int[] px = new int[640*480];
159-
short[] sams = new short[7350];
160-
int i = 0;
161-
int video = MediaCoder.AV_CODEC_ID_H265;
162-
int audio = MediaCoder.AV_CODEC_ID_AAC;
163-
do {
164-
MediaEncoder encoder = new MediaEncoder();
165-
AudioInput input = new AudioInput();
166-
if (use_media_io) {
167-
media.size = 0;
168-
media.create(i++);
169-
encoder.start(media, 640, 480, 24, 2, 44100, "mp4", video, audio);
170-
} else {
171-
String file = "test-" + (i++) + ".mp4";
172-
encoder.startFile(file, 640, 480, 24, 2, 44100, "mp4", video, audio);
173-
System.out.println("file=" + file);
174-
}
175-
if (i == 10) i = 0;
176-
int frame_size = encoder.getAudioFramesize() * 2; //*2=stereo
177-
JFLog.log("frame_size=" + frame_size);
178-
if (encoder_audio_src.equals("mic")) {
179-
input.start(2, 44100, 16, frame_size, "<default>");
180-
}
181-
System.out.println("Audio Frame Size=" + encoder.getAudioFramesize());
182-
for(int a=0;a<24 * encoder_seconds;a++) {
183-
JFLog.log("loop=" + a);
184-
random(px);
185-
if (encoder_audio_src.equals("mic")) {
186-
while (!input.read(sams)) {
187-
JF.sleep(50);
188-
}
189-
} else {
190-
sine(sams);
191-
}
192-
encoder.addVideo(px);
193-
encoder.addAudio(sams);
194-
}
195-
encoder.stop();
196-
if (use_media_io) {
197-
media.close();
198-
System.out.println("size=" + media.size);
199-
}
200-
if (encoder_audio_src.equals("mic")) {
201-
input.stop();
202-
}
203-
System.gc();
204-
} while (loop);
205-
}
206-
207118
public static void output(boolean loop) {
208119
TestMedia media = new TestMedia();
209120
int[] px = new int[640*480];

0 commit comments

Comments
 (0)