问题
I'm trying to stream video from the Android phone, which should be watched in an mediaplayer. I've been looking at http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system which seems to be a dead end since it send the raw file data, and not a streamable format.
Then I tried using some code from SipDroid, more specific; parts of VideoCamera.java, RtpPacket.java and RtpSocket.java, which gives a stream on UDP, however these is not playable in i.e. mplayer(can't detect the codec). Wireshark tells that it is a UDP packet and not a RTP packet so something might be missing?
I'm kind'a stuck, have you any suggestions how to get past this bump?
回答1:
Right click on the packet in Wireshark and select the decode as option. Then select rtp. Now you can see RTP packets in Wireshark.
回答2:
I think that you can find the solution from the following code snippet:
package com.Videoplaying;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class Video extends Activity {
private MediaController mc;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView vd = (VideoView) findViewById(R.id.VideoView);
String LINK = "http://daily3gp.com/vids/747.3gp";
mc = new MediaController(this);
mc.setMediaPlayer(vd);
Uri uri = Uri.parse(LINK);
vd.setMediaController(mc);
vd.setVideoURI(uri);
vd.requestFocus();
vd.start();
}
}
来源:https://stackoverflow.com/questions/4155166/streaming-video-from-android