Question

I'm trying to build an app for Google Glass that can stream to a server and have a client view the stream via a web browser. So far it seems I need to do this via RTSP to a media server such as Wowza and then have a web server hosting some video player that views the RTMP stream but I'm not having much luck.

Using libstreaming (https://github.com/fyhertz/libstreaming) I'm never able to view the stream.

I also would be interested in doing something with WebRTC so that I could make a solution similar to Hangouts but am not sure there is any libraries that support this yet.

Any help is appreciated.

Était-ce utile?

La solution

Since January, libsreaming has been fixed to work on Glass. Its RTSP video can easily be viewed in VLC player or plugin. Code below does not include the auto-generated stubs.

public class MainActivity extends Activity implements SurfaceHolder.Callback, Session.Callback {

private int mRtspPort = -1;

private ServiceConnection mRtspServerConnection = new ServiceConnection() {

    private static final int RTSP_PORT = 1234;

    @Override
    public void onServiceConnected(ComponentName className, IBinder binder) {
        RtspServer s = ((RtspServer.LocalBinder) binder).getService();
        s.setPort(RTSP_PORT);
        mRtspPort = s.getPort();
    }
  };

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_main);

    // Configures the SessionBuilder
    SessionBuilder.getInstance()
            .setSurfaceView((SurfaceView) findViewById(R.id.surface))
            .setCallback(this)
            .setPreviewOrientation(90)
            .setContext(getApplicationContext())
            .setAudioEncoder(SessionBuilder.AUDIO_NONE)
            .setVideoEncoder(SessionBuilder.VIDEO_H264)
            .setVideoQuality(new VideoQuality(320, 240, 20, 500000));

    // Starts the RTSP server
    bindService(new Intent(this, RtspServer.class), mRtspServerConnection, Context.BIND_AUTO_CREATE);
}

@Override
public void onResume() {
    super.onResume();
    mResumed = true;
    displayConnectString();
    SessionBuilder.getInstance().getSurfaceView().setAspectRatioMode(SurfaceView.ASPECT_RATIO_PREVIEW);
    SessionBuilder.getInstance().getSurfaceView().getHolder().addCallback(this);
}

private void displayConnectString() {
    WifiManager wifiMgr = (WifiManager) getSystemService(WIFI_SERVICE);
    WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
    int ip = wifiInfo.getIpAddress();
    String ipAddress = Formatter.formatIpAddress(ip);
    ((TextView) findViewById(R.id.connectInfo)).setText("rtsp://" + ipAddress + ":" + mRtspPort);
}

@Override
public void onDestroy() {
    super.onDestroy();
    unbindService(mRtspServerConnection);
}

@Override
public void onSessionStarted() {
    ((TextView) findViewById(R.id.connectInfo)).setText("");
}

@Override
public void onSessionStopped() {
    displayConnectString();
}
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top