[Open] Trying to connect on a video streaming

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

[Open] Trying to connect on a video streaming

Postby gmime » Sat Nov 22, 2008 5:53 pm

Hi,

I am French so I'll do my best with my English. :oops:

I am working on an Android application that shall catch a 3GP video streaming.
I already have my interface working correctly on my emulator. I am using the SDK 1.0

So here is the error report:

11-22 16:39:40.016: ERROR/OSNetworkSystem(309): unknown socket error -1
11-22 16:39:40.136: ERROR/VideoPlayer(309): unknown error
11-22 16:39:40.136: ERROR/VideoPlayer(309): java.net.SocketException: unknown error
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocketImpl(Native Method)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocket(OSNetworkSystem.java:79)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.net.PlainSocketImpl2.create(PlainSocketImpl2.java:59)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at java.net.Socket.checkClosedAndCreate(Socket.java:763)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at java.net.Socket.connect(Socket.java:910)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:61)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:800)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:786)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at demo.java.prototype.setDataSource(prototype.java:156)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at demo.java.prototype.access$2(prototype.java:150)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at demo.java.prototype$5.run(prototype.java:128)
11-22 16:39:40.136: ERROR/VideoPlayer(309): at java.lang.Thread.run(Thread.java:935)
11-22 16:39:40.276: ERROR/MediaPlayer(309): Attempt to call getDuration without a valid mediaplayer



I saw on this forum that I do have to give INTERNET permission. I've done it as well.

Here is a part of my code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. private void playVideo() {
  3.  
  4.    
  5.  
  6.           final String path = mPath.getText().toString();
  7.  
  8.           Log.v(TAG, "path: " + path);
  9.  
  10.  
  11.  
  12.           // If the path has not changed, just start the media player
  13.  
  14.           if (path.equals(current) && mp != null) {
  15.  
  16.               mp.start();
  17.  
  18.               return;
  19.  
  20.           }
  21.  
  22.           current = path;
  23.  
  24.  
  25.  
  26.           // Create a new media player and set the listeners
  27.  
  28.           mp = new MediaPlayer();
  29.  
  30.           mp.setOnErrorListener(this);
  31.  
  32.           mp.setOnBufferingUpdateListener(this);
  33.  
  34.           mp.setOnCompletionListener(this);
  35.  
  36.           mp.setOnPreparedListener(this);
  37.  
  38.           mp.setAudioStreamType(2);
  39.  
  40.  
  41.  
  42.  
  43.  
  44.           // Set the surface for the video output
  45.  
  46.        //   mp.setDisplay((SurfaceHolder) holder.getSurface());
  47.  
  48.          
  49.  
  50.           // Set the data source in another thread
  51.  
  52.           // which actually downloads the mp3 or videos
  53.  
  54.           // to a temporary location
  55.  
  56.           Runnable r = new Runnable() {
  57.  
  58.               public void run() {
  59.  
  60.              
  61.  
  62.                   try {
  63.  
  64.                       setDataSource(path);
  65.  
  66.                       mp.prepareAsync();
  67.  
  68.                   } catch (IOException e) {
  69.  
  70.                       Log.e(TAG, e.getMessage(), e);
  71.  
  72.                   }
  73.  
  74.                  
  75.  
  76.                   Log.v(TAG, "Duration:  ===>" + mp.getDuration());
  77.  
  78.                   mp.start();
  79.  
  80.               }
  81.  
  82.           };
  83.  
  84.           new Thread(r).start();
  85.  
  86.      
  87.  
  88.   }
  89.  
  90.  
  91.  
  92.   /**
  93.  
  94.    * If the user has specified a local url, then we download the
  95.  
  96.    * url stream to a temporary location and then call the setDataSource
  97.  
  98.    * for that local file
  99.  
  100.    *
  101.  
  102.    * @param path
  103.  
  104.    * @throws IOException
  105.  
  106.    */
  107.  
  108.   private void setDataSource(String path) throws IOException {
  109.  
  110.       if (!URLUtil.isNetworkUrl(path)) {
  111.  
  112.           mp.setDataSource(path);
  113.  
  114.       } else {
  115.  
  116.           URL url = new URL(path);
  117.  
  118.           URLConnection cn = url.openConnection();
  119.  
  120.          cn.connect();
  121.  
  122.           InputStream stream = cn.getInputStream();
  123.  
  124.           if (stream == null)
  125.  
  126.               throw new RuntimeException("stream is null");
  127.  
  128.           File temp = File.createTempFile("mediaplayertmp", "dat");
  129.  
  130.           String tempPath = temp.getAbsolutePath();
  131.  
  132.           FileOutputStream out = new FileOutputStream(temp);
  133.  
  134.           byte buf[] = new byte[128];
  135.  
  136.           do {
  137.  
  138.               int numread = stream.read(buf);
  139.  
  140.               if (numread <= 0)
  141.  
  142.                   break;
  143.  
  144.               out.write(buf, 0, numread);
  145.  
  146.           } while (true);
  147.  
  148.           mp.setDataSource(tempPath);
  149.  
  150.           try {
  151.  
  152.               stream.close();
  153.  
  154.           }
  155.  
  156.           catch (IOException ex) {
  157.  
  158.               Log.e(TAG, "error: " + ex.getMessage(), ex);
  159.  
  160.           }
  161.  
  162.       }
  163.  
  164.   }
  165.  
  166.  
  167.  
  168.  
Parsed in 0.041 seconds, using GeSHi 1.0.8.4


The exception occurs when a do cn.connect();.

I have also give all access to Android emulator with my FireWall....

Does somebody see anything?

Thanks in advance for your help :wink:

Gmime
Last edited by gmime on Mon Nov 24, 2008 7:15 pm, edited 1 time in total.
gmime
Freshman
Freshman
 
Posts: 8
Joined: Sat Nov 22, 2008 3:35 pm

Top

Postby MrSnowflake » Sun Nov 23, 2008 1:39 pm

Does "URLConnection cn = url.openConnection();" give you a valid URLConnection?
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby gmime » Mon Nov 24, 2008 10:52 am

Hi,

Thanks for your interest to my problem.

In fact I have two kind of problem. Since I try to catch a video streaming I am using two different sources:
1- VLC in local loop (http://127.0.0.1:8080)
2- A rtcp streaming from my local network (rtsp://192.XXX.1.3X/live.sdp)

Then for those two streaming I have a different behaviour:

First case with VLC


It is the cn.connect problem. I try to connect on my local loop.

Here is my cn object:

Image

After that this is the error from my Android console:


11-24 09:33:55.251: VERBOSE/VideoPlayer(351): path: http://127.0.0.1:8080
11-24 09:43:14.661: ERROR/OSNetworkSystem(351): unknown socket error -1
11-24 09:43:26.650: ERROR/VideoPlayer(351): unknown error
11-24 09:43:26.650: ERROR/VideoPlayer(351): java.net.SocketException: unknown error
11-24 09:43:26.650: ERROR/VideoPlayer(351): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocketImpl(Native Method)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocket(OSNetworkSystem.java:79)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at org.apache.harmony.luni.net.PlainSocketImpl2.create(PlainSocketImpl2.java:59)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at java.net.Socket.checkClosedAndCreate(Socket.java:763)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at java.net.Socket.connect(Socket.java:910)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:61)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:800)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:786)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at demo.java.prototype.setDataSource(prototype.java:157)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at demo.java.prototype.access$2(prototype.java:150)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at demo.java.prototype$5.run(prototype.java:128)
11-24 09:43:26.650: ERROR/VideoPlayer(351): at java.lang.Thread.run(Thread.java:935)
11-24 09:43:28.520: ERROR/MediaPlayer(351): Attempt to call getDuration without a valid mediaplayer
11-24 09:43:28.520: VERBOSE/VideoPlayer(351): Duration: ===>6



Using a RTCP streaming

The error is a Media player error since I do not go through the same code.

Here is the error:

11-24 09:31:21.901: INFO/ActivityManager(53): Displayed activity demo.java/.prototype: 5012 ms
11-24 09:31:26.220: VERBOSE/VideoPlayer(311): path: rtsp://192.1xx.1.3x/live.sdp
11-24 09:31:27.000: DEBUG/dalvikvm(93): GC freed 1006 objects / 51376 bytes in 83ms
11-24 09:31:41.770: ERROR/VideoPlayer(311): Prepare failed.: status=0xFFFFFFFF
11-24 09:31:41.770: ERROR/VideoPlayer(311): java.io.IOException: Prepare failed.: status=0xFFFFFFFF
11-24 09:31:41.770: ERROR/VideoPlayer(311): at android.media.MediaPlayer.prepare(Native Method)
11-24 09:31:41.770: ERROR/VideoPlayer(311): at demo.java.prototype$5.run(prototype.java:129)
11-24 09:31:41.770: ERROR/VideoPlayer(311): at java.lang.Thread.run(Thread.java:935)
11-24 09:31:50.801: ERROR/MediaPlayer(311): Attempt to call getDuration without a valid mediaplayer
11-24 09:31:50.811: VERBOSE/VideoPlayer(311): Duration: ===>1090813832
11-24 09:31:50.821: ERROR/MediaPlayer(311): Error (-38,0)
11-24 09:31:50.841: ERROR/VideoPlayer(311): onError---> what:-38 extra:0
11-24 09:31:50.841: ERROR/MediaPlayer(311): stop called in state 0
11-24 09:31:50.931: WARN/MediaPlayer(311): mediaplayer went away with unhandled events




I am a beginner so all suggestion will be welcome !! :D
gmime
Freshman
Freshman
 
Posts: 8
Joined: Sat Nov 22, 2008 3:35 pm

Postby gmime » Mon Nov 24, 2008 11:40 am

I've removed this part of code to see what happen:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. if (!URLUtil.isNetworkUrl(path)) {
  3.  
  4.           mp.setDataSource(path);
  5.  
  6.       } else {
  7.  
  8.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4



And the error is Unknown protocol: rtsp !

11-24 10:36:47.196: VERBOSE/VideoPlayer(196): path: rtsp://192.168.1.39/live.sdp
11-24 10:37:16.446: ERROR/VideoPlayer(196): Unknown protocol: rtsp
11-24 10:37:16.446: ERROR/VideoPlayer(196): java.net.MalformedURLException: Unknown protocol: rtsp
11-24 10:37:16.446: ERROR/VideoPlayer(196): at java.net.URL.<init>(URL.java:313)
11-24 10:37:16.446: ERROR/VideoPlayer(196): at java.net.URL.<init>(URL.java:155)
11-24 10:37:16.446: ERROR/VideoPlayer(196): at demo.java.prototype.setDataSource(prototype.java:157)
11-24 10:37:16.446: ERROR/VideoPlayer(196): at demo.java.prototype.access$2(prototype.java:150)
11-24 10:37:16.446: ERROR/VideoPlayer(196): at demo.java.prototype$5.run(prototype.java:128)
11-24 10:37:16.446: ERROR/VideoPlayer(196): at java.lang.Thread.run(Thread.java:935)


Maybe the protocol has not been implemented yet....
Do not see how I can do to read this streaming... :? :shock:
gmime
Freshman
Freshman
 
Posts: 8
Joined: Sat Nov 22, 2008 3:35 pm

Postby MrSnowflake » Mon Nov 24, 2008 11:52 am

Try using RTP.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby gmime » Mon Nov 24, 2008 11:59 am

Same thing with RTP:

11-24 10:53:36.316: VERBOSE/VideoPlayer(233): path: rtp://192.168.1.39/live.sdp
11-24 10:53:56.436: ERROR/VideoPlayer(233): Unknown protocol: rtp
11-24 10:53:56.436: ERROR/VideoPlayer(233): java.net.MalformedURLException: Unknown protocol: rtp
11-24 10:53:56.436: ERROR/VideoPlayer(233): at java.net.URL.<init>(URL.java:313)
11-24 10:53:56.436: ERROR/VideoPlayer(233): at java.net.URL.<init>(URL.java:155)
11-24 10:53:56.436: ERROR/VideoPlayer(233): at demo.java.prototype.setDataSource(prototype.java:157)
11-24 10:53:56.436: ERROR/VideoPlayer(233): at demo.java.prototype.access$2(prototype.java:150)
11-24 10:53:56.436: ERROR/VideoPlayer(233): at demo.java.prototype$5.run(prototype.java:128)
11-24 10:53:56.436: ERROR/VideoPlayer(233): at java.lang.Thread.run(Thread.java:935)


Even with VLC I could not open the streaming on RTP...
Maybe a port redirection problem ?

I do not know....
I try to find some exemple to get some inspiration.
gmime
Freshman
Freshman
 
Posts: 8
Joined: Sat Nov 22, 2008 3:35 pm

Top

Postby gmime » Tue Nov 25, 2008 11:27 am

Note: I have tried a sample for MP3 streaming and it works well... No connection problem on an distant URL. Then I think my network configuration is correct.

It is really uncomfortable to not have any information about the cn.connect error... :(

I think that even if the video format is not correct it shall not lead to a connection error am I right?
Any idea to help me debugging ? :oops:
gmime
Freshman
Freshman
 
Posts: 8
Joined: Sat Nov 22, 2008 3:35 pm

Postby gmime » Wed Nov 26, 2008 2:39 pm

I've found this comment on android google group:

The media framework does support RTSP with RTP payloads. The OpenCore
code includes an RTSP/RTP client built on sockets that will handle
buffering and transport controls.

It does not work in the emulator environment due to some firewall
issues in the emulator network layer.


It is my problem I think...
gmime
Freshman
Freshman
 
Posts: 8
Joined: Sat Nov 22, 2008 3:35 pm

Postby medicalfix » Thu Dec 11, 2008 3:45 am

Hey guys! man I'm glad to see I'm not the only one with RTSP issues! :P

I wonder if this firewall is also affecting the actual phone?
If you do figure out how to get RTSP streaming working, please let us know! I'm currently doing all that is possible to get it working but I'm running out of ideas!

First, I can confirm that the MediaPlayer does have an RTSP client. I do receive the OPTIONS, and DESCRIBE messages but for some reason messages from the server don't reach the Client to get to the next step SETUP...

Well...

Thanks,
Jona
medicalfix
Junior Developer
Junior Developer
 
Posts: 17
Joined: Sat Nov 01, 2008 9:55 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 7 guests