首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谷歌眼镜流视频到服务器

谷歌眼镜流视频到服务器
EN

Stack Overflow用户
提问于 2014-01-19 22:01:50
回答 1查看 3.8K关注 0票数 3

我正试图为Google构建一个应用程序,它可以流到服务器上,并让客户通过web浏览器查看该流。到目前为止,我似乎需要通过RTSP对像Wowza这样的媒体服务器这样做,然后有一个web服务器托管一些观看RTMP流的视频播放器,但我没有多少运气。

使用libstreaming (https://github.com/fyhertz/libstreaming),我永远无法查看流。

我也会对使用WebRTC做一些事情感兴趣,这样我就可以做出类似于Hangout的解决方案,但我不确定是否有任何库支持这一点。

任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-15 14:46:08

自1月份以来,libsreaming就开始在玻璃上工作。它的RTSP视频可以很容易地在VLC播放器或插件中观看。下面的代码不包括自动生成的存根.

代码语言:javascript
复制
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();
}
}
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21223277

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档