Git Product home page Git Product logo

rtsp-ws-proxy's Introduction

RTSP-WS-Proxy

一个RTSP转Websocket的服务端和对应的web端播放器

服务端:

WSServer目录下 环境基于centos7,如需在其它环境下使用,请先替换使用到的第三方库 服务端编译:

	cd WSServer
	make

服务端依赖的第三方库: boost 版本不宜过高,否则会与websocketpp不兼容,我使用的是yum安装的,版本号1.53 websocketpp include中已有头文件,不需要单独编译,依赖boost jsoncpp 我使用的版本是1.8.4 ffmpeg 使用的是4.2.2,早一些的版本也可使用 如更换使用环境,请检查编译后的第三方库,更新Makefile服务端运行方法: 服务端运行方法:

	WSProxy 9001

9001是服务端绑定的websocket端口

web端:

ClientPlayer目录下 wsplayer.js是播放器,testplayer.html是示例,需要浏览器支持html5的mse 播放器使用方法示例:

var video1 = document.getElementById('video1');
    player = new wsplayer("ws://192.168.5.133:9001","rtsp://192.168.5.1/stream1",video1);    
    player.openws();

在new wsplayer("ws://192.168.5.133:9001","rtsp://192.168.5.1/stream1",video1);中使用的三个参数,第一个是服务端的ws地址,第二个是要打开的rtsp地址,第三个是播放器绑定的htmldocument对象

原理:

web端将要打开的rtsp地址发送给服务端,服务端打开rtsp流成功后将流的mime发送给web并开始推送fmp4数据,web利用mime初始化mse,成功后将websocket收到的二进制数据交给mse播放,程序目前只支持h264视频和aac音频,如要接入其它格式,请修改服务端,在服务端进行转码工作

rtsp-ws-proxy's People

Contributors

garefield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rtsp-ws-proxy's Issues

linux运行wsserver出现段错误

感谢作者的辛苦贡献,本人在centos7服务器运行一段时间后,wsserver会出现段错误导致服务崩溃,调试coredump文件见下面日志,疑似buf的内容和buflen长度不一致,还请作者解惑,不胜感激。
Core was generated by `./WSServer 9001'.
Program terminated with signal 11, Segmentation fault.
#0 0x0000000000000021 in ?? ()
(gdb) bt
#0 0x0000000000000021 in ?? ()
#1 0x000000000069a3b5 in RtspSource::SendWSData (this=0x55fb000) at RtspSource.cpp:422
#2 0x00000000006a0141 in boost::_mfi::mf0<void, RtspSource>::operator() (this=0x7fe109c96848, p=0x55fb000) at /usr/include/boost/bind/mem_fn_template.hpp:49
#3 0x00000000006a00a4 in boost::_bi::list1<boost::_bi::value<RtspSource*> >::operator()<boost::_mfi::mf0<void, RtspSource>, boost::_bi::list0> (this=0x7fe109c96858, f=..., a=...)
at /usr/include/boost/bind/bind.hpp:253
#4 0x000000000069fe47 in boost::_bi::bind_t<void, boost::_mfi::mf0<void, RtspSource>, boost::_bi::list1<boost::_bi::value<RtspSource*> > >::operator() (this=0x7fe109c96848)
at /usr/include/boost/bind/bind_template.hpp:20
#5 0x000000000069fb76 in boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf0<void, RtspSource>, boost::_bi::list1<boost::_bi::value<RtspSource*> > > >::run (this=0x7fe109c96690)
at /usr/include/boost/thread/detail/thread.hpp:117
#6 0x00007fe3c0ae425a in boost::(anonymous namespace)::thread_proxy (param=) at libs/thread/src/pthread/thread.cpp:165
#7 0x00007fe3bfc88ea5 in start_thread (arg=0x7fe3bdea7700) at pthread_create.c:307
#8 0x00007fe3bf9b19fd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb) f 1
#1 0x000000000069a3b5 in RtspSource::SendWSData (this=0x55fb000) at RtspSource.cpp:422
warning: Source file is more recent than executable.
422 delete fdata;
(gdb) p fdata->buf
$1 = (uint8_t *) 0x7fe23c000088 "\360^\325\032\341\177"
(gdb) p fdata->buflen
$2 = 32
(gdb)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.