0
我正試圖在Android中實現一個輕量級RTSP服務器,以將我的相機饋送實時流式傳輸到VLC媒體播放器。爲此,我使用libstreaming庫。我成功地在Android Studio中導入了該庫,並設法編譯並運行服務器端的skeleton code。不幸的是,該程序沒有按預期工作。相機預覽無法加載,我無法閱讀VLC媒體播放器中的MRL。有沒有人遇到過這個問題?任何幫助,將不勝感激!提前致謝。以下是我試過到目前爲止:無法在Android中實現RTSP服務器
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/
嘗試rtsp://192.168.2.3:1234/h264 <---注意編解碼器說明符! 你可能已經知道了這一點。 我使用avplay -debug 0 rtsp://xxx.xxx.xxx.xxx:xxxx/xxxx 來分析來自libstream的rtsp屬性 –