Streaming live H264 video from DM368

Appro already got a reference design on how to stream livevideo, but it's based on Appro's own framework. For people like mewho want to use DVSDK4, it's not very helpful. The Appro designalso used WIS-Streamer, which is not really necessary.

 

To build a simple live h264 streaming RTSP server, this is allyou need:

1. Download latest live555 source code. Modify config.armlinux,so that its CC options point to the compiler you use, run"./genMakefiles armlinux"

2. Modify testH264VideoStreamer.cpp

#include <liveMedia.hh>
#include<BasicUsageEnvironment.hh>
#include <GroupsockHelper.hh>
#include<H264VideoFileServerMediaSubsession.hh>

H264VideoStreamFramer* videoSource;

int main(int argc, char** argv) {
	RTPSink* videoSink;
	char *inputFileName = argc>1?argv[1]: (char*)"live.264";

	// Begin by setting up our usageenvironment:
	TaskScheduler* scheduler =BasicTaskScheduler::createNew();
	UsageEnvironment*env =BasicUsageEnvironment::createNew(*scheduler);

	// Create 'groupsocks' for RTP andRTCP:
	struct in_addr destinationAddress;
	destinationAddress.s_addr =chooseRandomIPv4SSMAddress(*env);

	const unsigned short rtpPortNum =18888;
	const unsigned short rtcpPortNum =rtpPortNum+1;
	const unsigned char ttl = 255;

	const Port rtpPort(rtpPortNum);
	const Port rtcpPort(rtcpPortNum);

	Groupsock rtpGroupsock(*env,destinationAddress, rtpPort, ttl);
	rtpGroupsock.multicastSendOnly();
	Groupsock rtcpGroupsock(*env,destinationAddress, rtcpPort, ttl);
	rtcpGroupsock.multicastSendOnly();

	// Create a 'H264 Video RTP' sink from theRTP 'groupsock':
	OutPacketBuffer::maxSize =1<<17;
	videoSink = H264VideoRTPSink::createNew(*env,&rtpGroupsock, 96);

	RTSPServer* rtspServer =RTSPServer::createNew(*env, 8554);
	if (rtspServer == NULL) {
		*env<< "Failed to create RTSP server: "<< env->getResultMsg()<< "\n";
		exit(1);
	}
	ServerMediaSession* sms =ServerMediaSession::createNew(*env, "live", "live stream",
			"Session streamed by "live264Streamer"", True );
	sms->addSubsession(H264VideoFileServerMediaSubsession::createNew(*env,inputFileName,True));
	rtspServer->addServerMediaSession(sms);

	char* url =rtspServer->rtspURL(sms);
	*env << "Play thisstream using the URL "" << url<< ""\n";
	delete[] url;

	env->taskScheduler().doEventLoop(); // does notreturn

	return 0; // only to prevent compilerwarning
}

void afterPlaying(void* ) {
	Medium::close(videoSource);
}
3. create a named pipe: mkfifo live.264

4. Redirect your output stream to live.264, if your code isbased on the encode demo, change writer.c


转自:http://blog.sina.com.cn/s/blog_5e330a280100r88v.html


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值