2

I have a DVR as a server which is connected to a camera.I'm trying to stream the camera's view into my android phone.I managed to do it through LAN,but failed through 3g/cellular

I've done

Port forwarding

use DynDNS

3rd party app called MEye(only app that works in my case)

Here is the code

public class liveActivity extends Activity{

final static String USERNAME = "admin";
final static String PASSWORD = "";
public static String domainName = "xxx.dvrdns.org";
public static int PORT = 2218;
public static final String URL = "rtsp://192.168.0.xxx:554/user=" + USERNAME + "&password=" + PASSWORD + "&channel=1&stream=0.sdp?";
public static final String URL2 = "rtsp://" + domainName + ":" + PORT + "/user=" + USERNAME + "&password=" + PASSWORD + "&channel=1&stream=1.sdp?real_stream--rtp-caching=100";

private MediaPlayer mPlayer1;
private MediaPlayer mPlayer2;
SurfaceHolder.Callback mCallback1;
SurfaceHolder.Callback mCallback2;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_live);

    mPlayer1 = new MediaPlayer();

    mCallback1 = new SurfaceHolder.Callback() {
        @Override
        public void surfaceCreated(SurfaceHolder surfaceHolder) {

            try {

                mPlayer1.setDataSource(liveActivity.this, Uri.parse(URL2));
                mPlayer1.setDisplay(surfaceHolder);
                mPlayer1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                    @Override
                    public void onPrepared(MediaPlayer mediaPlayer) {
                        mPlayer1.start();
                    }
                });
                mPlayer1.prepareAsync();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {

        }

        @Override
        public void surfaceDestroyed(SurfaceHolder surfaceHolder) {

            mPlayer1.release();
        }
    };

    final SurfaceView surfaceView1 =
            (SurfaceView) findViewById(R.id.surfaceView1);
    // Configure the Surface View.
    surfaceView1.setKeepScreenOn(true);
    // Configure the Surface Holder and register the callback.
    SurfaceHolder holder1 = surfaceView1.getHolder();
    holder1.addCallback(mCallback1);
    holder1.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

}

P.S I heard from a software engineer that RTSP is for local only.Is that why I can't stream via 3g?

Machavity
  • 30,841
  • 27
  • 92
  • 100
Fay Zan
  • 165
  • 2
  • 17

1 Answers1

0

This is an old question, but just in case...

Given your solution is working in a LAN, presumably over WiFi, the approach itself sounds fine.

The issue you are most likely having is that your cellular network provider does not support RTSP streams, either uploading, downloading or both.

These type of restrictions are not uncommon in mobile networks - some operators used to block all uplink streaming protocols to avoid VoIP services for example.

Mick
  • 24,231
  • 1
  • 54
  • 120