I’m developping an android app to monitor some IP cameras. I’m using the MjpegView Class to stream the video.
I’ve three cameras.
- - Camera 1: A public camera i found on internet, without user/password.
- - Camera 2: A public camera but this one require username/password.
- - Camera 3: The camera I’m going to use finally in my app. It will also ask for credentials.
The code in my main activity is the following:
public class MainActivity extends Activity {
private MjpegView mv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Camera 1
String URL = "http://216.62.222.101/mjpg/video.mjpg";
//Camera 2
// String URL = "http://user:user@iprobocam.marmitek.com/cgi/mjpg/mjpg.cgi";
//Camera 3
// String URL = "http://MyIp:MyPort/mjpg/video.mjpg";
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
mv = new MjpegView(this);
setContentView(mv);
mv.setSource(MjpegInputStream.read(URL));
mv.setDisplayMode(MjpegView.SIZE_BEST_FIT);
mv.showFps(true);
}
public void onPause() {
super.onPause();
mv.stopPlayback();
}
I can stream the camera 1 without problems. When I run the app with the cameras 2 or 3 there are no errors neither warnings but the most I get is a black screen. I thougth it was a problem with the authentification but if I remove it from my camera I get the same result, the black screen.
What is the difference between the cameras that makes some of them work but not others?
Thanks in advance for any help.
--- EDIT ---
I've found something weird while running the app with the camera 2.
I catch an exception in MjpegView
class when it calls the method MjpegInputStream.readMjpegFrame
.
Looking deeper I notice that the method getEndOfSeqeunce
always return 1 while Camera 1 (the one which works well) return higher values (between 66 and 68).
I hope this can give someone an idea of what is happening here...