Coder Social home page Coder Social logo

Comments (2)

xia-chu avatar xia-chu commented on June 19, 2024

ZLMediaKit目前支持rtsp/rtmp推流,这两种推流器分别通过RtspPusher和RtmpPusher对象实现。
为了方便使用,目前已经通过MediaPusher对象对这两者进行了封装。

RtspPusher和RtmpPusher主要实现了推流协议,具体的rtsp和rtmp数据源其实是来自MediaSource类,
对应的类分别是RtspMediaSource和RtmpMediaSource。

RtmpPusher对象在构造时会绑定一个RtmpMediaSource类:
image

所以你要实现rtmp推流,那么你必须先生成一个RtmpMediaSource类(rtsp推流,则需要生成RtspMediaSource),并且在构造RtmpPusher对象时传入RtmpMediaSource类。

开发者应该使用MediaPusher对象(而不是直接使用RtmpPusher或RtspPusher对象),
MediaPuser支持推rtsp、rtmp流,使用更灵活。

MediaPuser的构造函数跟上述的RtmpPusher对象基本一致:
image

通过上面的叙述,我们已经解释清楚了推流器的构造方法,那么MediaSource类该怎么构造呢?

目前RtmpMediaSource类可以通过RtmpMediaSourceMuxer对象构造生成(生成的RtmpMediaSource会自动注册到全局的map中),而MultiMediaSourceMuxer对象封装了RtmpMediaSourceMuxer和RtspMediaSourceMuxer的构造方式。
但是MultiMediaSourceMuxer对象接口对于初学者而言比较复杂,
所以初学者可以使用DevChannel类来生成RtmpMediaSource和RtspMediaSource.

你可以先构造DevChannel类,然后往里面输入H264数据和AAC数据,这样它就会自动生成RtmpMediaSource和RtspMediaSource然后自动注册到全局map。

然后通过这个构造函数:
image
构造MediaPusher对象并开始推流即可。

需要注意的是,DevChannel类构造后并不会马上生成RtmpMediaSource并注册,这个注册机制需要你输入完整的sps pps idr之后才能触发。所以你需要确保输入了这些数据之后,才能构建MediaPusher对象,否则MediaSource::find会返回查找失败。

最后你通过MediaPusher::publish接口开始推流即可(你可以推rtsp和rtmp):
image

from zlmediakit.

astatong avatar astatong commented on June 19, 2024

感谢:)

from zlmediakit.

Related Issues (20)

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.