2

I'm trying to implement a lightweight RTSP server in Android to live-stream my camera feed to VLC media player. For this, I'm using libstreaming library. I successfully imported the library in Android Studio and managed to compile and run the skeleton code for server side. Unfortunately, the program is not working as expected. The camera preview fails to load and I'm unable to read the MRL in VLC media player. Has anyone faced this issue before? Any help would be appreciated! Thanks in advance. Here is what I've tried so far:

    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));

    }

}

I'm trying to access the MRL: rtsp://192.168.2.3:1234/

Vinit Shandilya
  • 1,643
  • 5
  • 24
  • 44
  • Try rtsp://192.168.2.3:1234/h264 <--- Notice the codec specifier! You probably already figured this out. I use avplay -debug 0 rtsp://xxx.xxx.xxx.xxx:xxxx/xxxx to analyse the rtsp properties coming from libstream – Dominic Cerisano Dec 13 '15 at 21:22

1 Answers1

3

The code you are trying is good. The URL needs to have specific format,

URL in VLC player should be rtsp://phone_local_ip:1234?h264=200-20-320-240

200 = buf | 20 = fps | 320 = width | 240 = height

Umair
  • 1,206
  • 1
  • 13
  • 28