|
|
@ -144,7 +144,6 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
btnPause = (Button) findViewById(R.id.pause);
|
|
|
|
btnPause = (Button) findViewById(R.id.pause);
|
|
|
|
btnPause.setEnabled(false);
|
|
|
|
btnPause.setEnabled(false);
|
|
|
|
|
|
|
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
|
|
|
String url = intent.getStringExtra("url");
|
|
|
|
String url = intent.getStringExtra("url");
|
|
|
|
if (!TextUtils.isEmpty(url)) {
|
|
|
|
if (!TextUtils.isEmpty(url)) {
|
|
|
|
rtmpUrl = url;
|
|
|
|
rtmpUrl = url;
|
|
|
@ -431,6 +430,48 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
mPublisher.startCamera();
|
|
|
|
mPublisher.startCamera();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void startRTMPServer() {
|
|
|
|
|
|
|
|
File streamingDir = new File(getDataDir(), "streaming");
|
|
|
|
|
|
|
|
if (!streamingDir.exists()) {
|
|
|
|
|
|
|
|
streamingDir.mkdirs();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
File confFile = new File(streamingDir, "zlmediakit.ini");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InputStream inputStream = null;
|
|
|
|
|
|
|
|
FileOutputStream fos = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
inputStream = getAssets().open("config.ini");
|
|
|
|
|
|
|
|
fos = new FileOutputStream(confFile);
|
|
|
|
|
|
|
|
int len=-1;
|
|
|
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
|
|
|
while ((len=inputStream.read(buffer)) != -1) {
|
|
|
|
|
|
|
|
fos.write(buffer,0, len);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fos.flush();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
closeFriendly(inputStream);
|
|
|
|
|
|
|
|
closeFriendly(fos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZLMediaKit.startServer(streamingDir.getAbsolutePath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void stopRTMPServer() {
|
|
|
|
|
|
|
|
ZLMediaKit.stopServer();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void closeFriendly(AutoCloseable closeable) {
|
|
|
|
|
|
|
|
if (closeable != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
closeable.close();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static String getRandomAlphaString(int length) {
|
|
|
|
private static String getRandomAlphaString(int length) {
|
|
|
|
String base = "abcdefghijklmnopqrstuvwxyz";
|
|
|
|
String base = "abcdefghijklmnopqrstuvwxyz";
|
|
|
|
Random random = new Random();
|
|
|
|
Random random = new Random();
|
|
|
|