我正在尝试为Google Glass构建一个可以流式传输到服务器并让客户端通过Web浏览器查看流的应用程序.到目前为止,我似乎需要通过RTSP到Wowza等媒体服务器这样做,然后有一个托管一些视频播放器的Web服务器来查看RTMP流,但我没有太多运气.
使用libstreaming(https://github.com/fyhertz/libstreaming)我永远无法查看流.
我也有兴趣使用WebRTC做一些事情,这样我就可以制作类似于Hangouts的解决方案,但我不确定是否有任何支持这个的库.
任何帮助表示赞赏.
解决方法:
从1月份开始,libsreaming已被修复为Glass上的工作.它的RTSP视频可以在VLC播放器或插件中轻松查看.下面的代码不包括自动生成的存根.
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(); } };@OverrIDeprotected 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);}@OverrIDepublic 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);}@OverrIDepublic voID onDestroy() { super.onDestroy(); unbindService(mRtspServerConnection);}@OverrIDepublic voID onSessionStarted() { ((TextVIEw) findVIEwByID(R.ID.connectInfo)).setText("");}@OverrIDepublic voID onSessionStopped() { displayConnectString();}}
总结 以上是内存溢出为你收集整理的android – Google Glass流视频到服务器全部内容,希望文章能够帮你解决android – Google Glass流视频到服务器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)