live555 android 直播,通过live555实现H264 RTSP直播

前面的文章中介绍了《H264视频通过RTMP流直播》,下面将介绍一下如何将H264实时视频通过RTSP直播。

实现思路是将视频流发送给live555, 由live555来实现H264数据流直播。

视频采集模块通过FIFO队列将H264数据帧发送给live555. live555 在收到客户端的RTSP播放请求后,开始从FIFO中读取H264视频数据并通过RTSP直播出去。整个流程如下图所示:

4315b89fe11f7300ef3a267f7e5156bb.png

调整和修改Live555 MediaServer

下载live555源码,在media目录下增加四个文件并修改文件live555MediaServer.cpp。增加的四个文件如下:

WW_H264VideoServerMediaSubsession.h

WW_H264VideoServerMediaSubsession.cpp

WW_H264VideoSource.h

WW_H264VideoSource.cpp

下面附上四个文件的源码:

WW_H264VideoServerMediaSubsession.h

#pragma once

#include "liveMedia.hh"

#include "BasicUsageEnvironment.hh"

#include "GroupsockHelper.hh"

#include "OnDemandServerMediaSubsession.hh"

#include "WW_H264VideoSource.h"

classWW_H264VideoServerMediaSubsession :publicOnDemandServerMediaSubsession

{

public:

WW_H264VideoServerMediaSubsession(UsageEnvironment & env, FramedSource * source);

~WW_H264VideoServerMediaSubsession(void);

public:

virtualcharconst* getAuxSDPLine(RTPSink * rtpSink, FramedSource * inputSource);

virtualFramedSource * createNewStreamSource(unsigned clientSessionId, unsigned & estBitrate);// "estBitrate" is the stream's estimated bitrate, in kbps

virtualRTPSink * createNewRTPSink(Groupsock * rtpGroupsock, unsignedcharrtpPayloadTypeIfDynamic, FramedSource * inputSource);

staticWW_H264VideoServerMediaSubsession * createNew(UsageEnvironment & env, FramedSource * source);

staticvoidafterPlayingDummy(void* ptr);

staticvoidchkForAuxSDPLine(void* ptr);

voidchkForAuxSDPLine1();

private:

FramedSource * m_pSource;

char* m_pSDPLine;

RTPSink * m_pDummyRTPSink;

charm_done;

};

WW_H264VideoServerMediaSubsession.cpp

#include "WW_H264VideoServerMediaSubsession.h"

WW_H264VideoServerMediaSubsession::WW_H264VideoServerMediaSubsession(UsageEnvironment & env, FramedSource * source) : OnDemandServerMediaSubsession(env, True)

{

m_pSource = source;

m_pSDPLine = 0;

}

WW_H264VideoServerMediaSubsession::~WW_H264VideoServerMediaSubsession(void)

{

if(m_pSDPLine)

{

free(m_pSDPLine);

}

}

WW_H264VideoServerMediaSubsession * WW_H264VideoServerMediaSubsession::createNew(UsageEnvironment & env, FramedSource * source)

{

returnnewWW_H264VideoServerMediaSubsession(env, source);

}

FramedSource * WW_H264VideoServerMediaSubsession::createNewStreamSource(unsigned clientSessionId, unsigned & estBitrate)

{

returnH264VideoStreamFramer::createNew(envir(),newWW_H264VideoSource(envir()));

}

RTPSink * WW_H264VideoServerMediaSubsession::createNewRTPSink(Groupsock * rtpGroupsock, unsigned charrtpPayloadTypeIfDynamic, FramedSource * inputSource)

{

returnH264VideoRTPSin

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值