1 /*****************************************************************************
2 * AbstractJVLCTest.java: VLC Java Bindings
3 *****************************************************************************
4 * Copyright (C) 1998-2008 the VideoLAN team
6 * Authors: Filippo Carone <filippo@carone.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 package org.videolan.jvlc;
28 import java.io.BufferedOutputStream;
29 import java.io.FileOutputStream;
30 import java.io.InputStream;
31 import java.io.OutputStream;
33 import java.net.URLConnection;
35 import org.apache.commons.io.IOUtils;
36 import org.junit.After;
37 import org.junit.Before;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40 import org.videolan.jvlc.internal.AbstractVLCInternalTest;
43 public abstract class AbstractJVLCTest
50 private String address = "http://streams.videolan.org/streams-videolan/reference/mp4/bl.mp4";
55 private Logger log = LoggerFactory.getLogger(AbstractVLCInternalTest.class);
58 public void testSetup()
60 jvlc = new JVLC("-vvv --ignore-config --no-media-library -I dummy --aout=dummy --vout=dummy --rtsp-host 127.0.0.1:5554");
65 public void tearDown()
70 private void downloadSample()
72 OutputStream out = null;
73 URLConnection conn = null;
74 InputStream in = null;
75 URL sampleResource = this.getClass().getResource("/sample.avi");
76 if (sampleResource != null)
78 log.debug("Sample file already downloaded");
79 mrl = sampleResource.getPath();
84 log.info("Downloading sample: {}", address);
85 String testResoucesPath = this.getClass().getResource("/sample").getPath();
86 URL url = new URL(address);
87 out = new BufferedOutputStream(new FileOutputStream(testResoucesPath + ".avi"));
88 conn = url.openConnection();
89 in = conn.getInputStream();
90 byte[] buffer = new byte[1024];
93 while ((numRead = in.read(buffer)) != -1)
95 out.write(buffer, 0, numRead);
96 numWritten += numRead;
98 log.info("Sample downloaded.");
99 mrl = testResoucesPath + ".avi";
107 IOUtils.closeQuietly(in);
108 IOUtils.closeQuietly(out);