|
|
|
@ -53,7 +53,7 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
|
|
|
|
|
|
private SharedPreferences sp;
|
|
|
|
|
// private String rtmpUrl = "rtmp://192.168.50.250/live/0";
|
|
|
|
|
private String rtmpUrl = "rtmp://61.169.135.146/live/abcd";
|
|
|
|
|
private String rtmpUrl = "rtmp://61.169.135.146/live/0";
|
|
|
|
|
private String recPath = Environment.getExternalStorageDirectory().getPath() + "/test.mp4";
|
|
|
|
|
|
|
|
|
|
private SrsPublisher mPublisher;
|
|
|
|
@ -123,11 +123,11 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
|
private void init() {
|
|
|
|
|
// restore data.
|
|
|
|
|
sp = getSharedPreferences("MpLive", MODE_PRIVATE);
|
|
|
|
|
rtmpUrl = sp.getString("rtmpUrl", rtmpUrl);
|
|
|
|
|
// rtmpUrl = sp.getString("rtmpUrl", rtmpUrl);
|
|
|
|
|
|
|
|
|
|
// initialize url.
|
|
|
|
|
final EditText efu = (EditText) findViewById(R.id.url);
|
|
|
|
|
efu.setText(rtmpUrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnPublish = (Button) findViewById(R.id.publish);
|
|
|
|
|
btnSwitchCamera = (Button) findViewById(R.id.swCam);
|
|
|
|
@ -141,9 +141,9 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
|
if (!TextUtils.isEmpty(url)) {
|
|
|
|
|
rtmpUrl = url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
efu.setText(rtmpUrl);
|
|
|
|
|
mCameraView = (SrsCameraView) findViewById(R.id.glsurfaceview_camera);
|
|
|
|
|
int rotation = intent.getIntExtra("rotation", -1);
|
|
|
|
|
final int rotation = intent.getIntExtra("rotation", -1);
|
|
|
|
|
if (rotation != -1) {
|
|
|
|
|
//设置图像显示方向
|
|
|
|
|
mCameraView.setPreviewOrientation(rotation);
|
|
|
|
@ -164,7 +164,7 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
|
mPublisher.setVideoHDMode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cameraId = intent.getIntExtra("cameraId", 0);
|
|
|
|
|
cameraId = intent.getIntExtra("cameraId", 1);
|
|
|
|
|
// mPublisher.startCamera();
|
|
|
|
|
|
|
|
|
|
mCameraView.setCameraCallbacksHandler(new SrsCameraView.CameraCallbacksHandler() {
|
|
|
|
@ -174,15 +174,17 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
int autoStart = intent.getIntExtra("autoStart", 0);
|
|
|
|
|
final int autoStart = intent.getIntExtra("autoStart", 1);
|
|
|
|
|
if (autoStart != 0) {
|
|
|
|
|
mPublisher.switchCameraFace(cameraId);
|
|
|
|
|
mPublisher.switchCameraFace(cameraId,rotation);
|
|
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
rtmpUrl = "rtmp://61.169.135.146/live/0";
|
|
|
|
|
SharedPreferences.Editor editor = sp.edit();
|
|
|
|
|
editor.putString("rtmpUrl", rtmpUrl);
|
|
|
|
|
editor.apply();
|
|
|
|
|
efu.setText(rtmpUrl + " cameraid=" + cameraId + " auto=" + autoStart);
|
|
|
|
|
mPublisher.startPublish(rtmpUrl);
|
|
|
|
|
if (btnSwitchEncoder.getText().toString().contentEquals("soft encoder")) {
|
|
|
|
|
Toast.makeText(getApplicationContext(), "Use hard encoder", Toast.LENGTH_SHORT).show();
|
|
|
|
@ -195,7 +197,7 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
|
}
|
|
|
|
|
}, 500);
|
|
|
|
|
} else {
|
|
|
|
|
mPublisher.switchCameraFace(cameraId);
|
|
|
|
|
mPublisher.switchCameraFace(cameraId,rotation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int autoClose = intent.getIntExtra("autoClose", 0);
|
|
|
|
@ -224,7 +226,7 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
|
efu.setText(rtmpUrl);
|
|
|
|
|
mPublisher.startPublish(rtmpUrl);
|
|
|
|
|
// mPublisher.startCamera();
|
|
|
|
|
mPublisher.switchCameraFace(cameraId);
|
|
|
|
|
mPublisher.switchCameraFace(cameraId,rotation);
|
|
|
|
|
|
|
|
|
|
if (btnSwitchEncoder.getText().toString().contentEquals("soft encoder")) {
|
|
|
|
|
Toast.makeText(getApplicationContext(), "Use hard encoder", Toast.LENGTH_SHORT).show();
|
|
|
|
@ -263,7 +265,7 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
|
|
|
|
|
int size = cameraData.size();
|
|
|
|
|
if (size > 0) {
|
|
|
|
|
int i = (++cameraId) % size;
|
|
|
|
|
mPublisher.switchCameraFace(i);
|
|
|
|
|
mPublisher.switchCameraFace(cameraId,rotation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|