我正在尝试在 Android 中实现一个轻量级的 RTSP 服务器,以将我的相机源实时流式传输到 VLC 媒体播放器。为此,我正在使用libstreaming库。我在 Android Studio 中成功导入了该库,并设法编译并运行了服务器端的骨架代码。不幸的是,该程序没有按预期工作。相机预览无法加载,我无法在 VLC 媒体播放器中读取 MRL。有没有人遇到过这个问题?任何帮助,将不胜感激!提前致谢。这是我迄今为止尝试过的:
public class MainActivity extends Activity {
private final static String TAG = "MainActivity";
private SurfaceView mSurfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mSurfaceView = (SurfaceView) findViewById(R.id.surface);
// Sets the port of the RTSP server to 1234
Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putString(RtspServer.KEY_PORT, String.valueOf(1234));
editor.commit();
// Configures the SessionBuilder
SessionBuilder.getInstance()
.setSurfaceView(mSurfaceView)
.setPreviewOrientation(90)
.setContext(getApplicationContext())
.setAudioEncoder(SessionBuilder.AUDIO_NONE)
.setVideoEncoder(SessionBuilder.VIDEO_H264);
// Starts the RTSP server
this.startService(new Intent(this,RtspServer.class));
}
}
我正在尝试访问 MRL:rtsp://192.168.2.3:1234/