我尝试在没有RTSP的情况下通过RTP将H264流式传输到VLC,即从IP摄像头接收H.264流,并将其发送到另一台主机上的VLC。 VLC打开了网址“ rtp:// @:12345 ”。 请注意,openRTSP执行相同的操作但使用H264VideoFileSink类将数据输出到文件中,我替换了那部分代码:
<form action="#" method="POST" id="forgotForm">
<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="Email OR Mobile" id="email" name="email" value="" aria-required="true" required="" data-msg-required="Please enter your email">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
</form>
home.php
<?php
$email=$_POST['email'];//here value it will come like 9986128658 or admin@gmail.com
?>
然后,
if (strcmp(subsession->mediumName(), "video") == 0) {
if (strcmp(subsession->codecName(), "H264") == 0) {
// For H.264 video stream, we use a special sink that adds 'start codes',
// and (at the start) the SPS and PPS NAL units:
//fileSink = H264VideoFileSink::createNew(*env, outFileName,
// subsession->fmtp_spropparametersets(),
// fileSinkBufferSize, oneFilePerFrame);
char const* outputAddressStr = "192.168.1.123"; // this could also be unicast
struct in_addr outputAddress;
outputAddress.s_addr = our_inet_addr(outputAddressStr);
const Port outputPort(12345);
unsigned char const outputTTL = 255;
Groupsock outputGroupsock(*env, outputAddress, outputPort, outputTTL);
rtpSink = H264VideoRTPSink::createNew(*env, &outputGroupsock, 96);
}
…
结果是openRTSP正在运行,但VLC没有收到任何信息。我使用Wireshark进行检查,没有数据包发送到目标IP和端口。
我也尝试使用testMP3Streamer,用上面的单播地址替换多播地址。 VLC可以播放它。 有人可以给我一些建议吗?
答案 0 :(得分:0)
您的代码中存在多个错误,首先public
范围太窄,接下来需要H264 Framer来提供Groupsock
,如您在H264VideoRTPSink.cpp中所见:
H264VideoRTPSink
然后将所有内容放在一起会产生类似的结果:
Boolean H264VideoRTPSink::sourceIsCompatibleWithUs(MediaSource& source) {
// Our source must be an appropriate framer:
return source.isH264VideoStreamFramer();
}