资源简介
nginx服务器搭建,基于librtmp的rtmp推流封装。在访问量不是特别大的时候可以正常使用,大数据量的情况没有进行过压力测试不知道效果怎么样。
代码片段和文件信息
#include “stdafx.h“
#include “SGRtmpSend.h“
SGRtmpSend::SGRtmpSend()
{
m_rtmp = NULL;
m_nTick = 0;
memset(&m_SpsPps 0 sizeof(m_SpsPps));
m_bSendSpsPps = FALSE;
}
SGRtmpSend::~SGRtmpSend()
{
if (m_rtmp != NULL)
{
m_rtmp->Close();
m_rtmp = NULL;
}
}
BOOL SGRtmpSend::ConnectRtmpSrv(const char* szRtmpUrl)
{
if (m_rtmp == NULL)
{
m_rtmp = LibrtmpGetInstance();
}
return m_rtmp->Connect(szRtmpUrl);
}
int SGRtmpSend::GetStartCodeInfoWithSpsPps(BYTE *pBuffer int bufSize std::vectorameDataInfo> &startCodeInfo)
{
if (pBuffer == NULL || bufSize == 0)
{
return 0;
}
tagframeDataInfo lframeDataInfo;
int nCount = 0;
for (int i = 0; i + 3 < bufSize; i++)
{
if (*(pBuffer + i) == 0x00 && *(pBuffer + i + 1) == 0x00 && *(pBuffer + i + 2) == 0x01)
{
if ((i != 0) && (*(pBuffer + i - 1) == 0x00))
{
lframeDataInfo.nStartCodeLen = 4;
lframeDataInfo.nStartPos = i - 1;
}
else
{
lframeDataInfo.nStartCodeLen = 3;
lframeDataInfo.nStartPos = i;
}
startCodeInfo.push_back(lframeDataInfo);
if ((*(pBuffer + i + 3) & 0x1F) == NAL_IDR_SLICE || (*(pBuffer + i + 3) & 0x1F) == NAL_SLICE)
{
//++nCount;
//if (nCount == 0)
{
break;
}
}
i += 3;
}
}
if (startCodeInfo.size() == 0)
{
return 0;
}
return 1;
}
BOOL SGRtmpSend::SendVideoData(BYTE* pBuff DWORD dwBuffSize)
{
m_SpsPps.bHasAudio = false;
m_SpsPps.nframeRate = 25;
std::vectorameDataInfo> startCodeInfo;
if (!GetStartCodeInfoWithSpsPps((BYTE*)pBuff dwBuffSize startCodeInfo))
{
return FALSE;
}
int nPosSize = startCodeInfo.size();
for (int i = 0; i != nPosSize; i++)
{
if (i == nPosSize - 1)
{
startCodeInfo[i].nframeDataLen = dwBuffSize - startCodeInfo[i].nStartPos - startCodeInfo[i].nStartCodeLen;
}
else
{
startCodeInfo[i].nframeDataLen = startCodeInfo[i + 1].nStartPos - startCodeInfo[i].nStartPos - startCodeInfo[i].nStartCodeLen;
}
switch (*(((BYTE*)pBuff) + startCodeInfo[i].nStartPos + startCodeInfo[i].nStartCodeLen) & 0x1F)
{
case NAL_SPS:
{
m_SpsPps.nSpsLen = startCodeInfo[i].nframeDataLen;
memcpy(m_SpsPps.Sps ((BYTE*)pBuff) + startCodeInfo[i].nStartPos + startCodeInfo[i].nStartCodeLen m_SpsPps.nSpsLen);
if ((m_SpsPps.nSpsLen != 0) && (m_SpsPps.nPpsLen != 0) && !m_bSendSpsPps)
{
m_bSendSpsPps = TRUE;
h264_decode_sps(m_SpsPps.Sps m_SpsPps.nSpsLen m_SpsPps.nWidth m_SpsPps.nHeight);
m_rtmp->Sendmetadata(&m_SpsPps);
memset(&m_SpsPps 0 sizeof(RTMPmetadata));
m_SpsPps.bHasAudio = false;
m_SpsPps.nframeRate = 25;
}
break;
}
case NAL_PPS:
{
m_SpsPps.nPpsLen = startCodeInfo[i].nframeDataLen;
memcpy(m_SpsPps.Pps ((BYTE*)pBuff) + startCodeInfo[i].nStartPos + startCodeInfo[i].nStartCodeLen m_SpsPps.nPpsLen);
if ((m_SpsPps.nSpsLen != 0) && (m_SpsPps.nPpsLen != 0) && !m_bSendSpsPps)
{
m_bSend
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-08-21 10:52 nginx\
目录 0 2018-08-21 10:52 nginx\conf\
文件 3463 2013-06-12 13:12 nginx\conf\mime.types
文件 3418 2017-09-27 08:46 nginx\conf\nginx.conf
目录 0 2018-08-21 10:52 nginx\logs\
文件 271416 2018-07-11 14:54 nginx\logs\access.log
文件 2265463 2018-07-12 08:03 nginx\logs\error.log
文件 6 2018-07-11 13:41 nginx\logs\nginx.pid
文件 2676736 2013-06-12 13:12 nginx\nginx.exe
目录 0 2018-08-21 10:52 nginx\temp\
目录 0 2018-08-21 11:00 nginx\temp\client_body_temp\
目录 0 2018-08-21 11:00 nginx\temp\fastcgi_temp\
目录 0 2018-08-21 11:00 nginx\temp\proxy_temp\
目录 0 2018-08-21 11:00 nginx\temp\scgi_temp\
目录 0 2018-08-21 11:00 nginx\temp\uwsgi_temp\
文件 172 2017-09-07 14:57 nginx\使用说明.txt
目录 0 2018-08-21 10:59 rtmp\
文件 2546176 2015-01-04 23:14 rtmp\LibrtmpStream.dll
文件 3034 2014-09-10 16:46 rtmp\LibrtmpStream.lib
文件 726 2014-09-23 14:30 rtmp\LibrtmpStreamInterface.h
文件 1947 2014-08-25 08:56 rtmp\LibtrmpData.h
文件 6499 2017-09-08 14:20 rtmp\SGRtmpSend.cpp
文件 2054 2017-09-08 14:19 rtmp\SGRtmpSend.h
文件 517 2018-08-21 10:59 rtmp\使用说明.txt
- 上一篇:斑马打印机ZPL指令中文手册
- 下一篇:样本标注工具ob
jectmarker.exe
相关资源
- nginx-1.17.1.tar.gz
- 免部署的Windows 平台下的nginx-rtmp-win
- nginx离线安装包
- CentOS6/7下nginx离线安装包以及所需要的
- windows版nginx(1.19.3)包含nginx-http-fl
- Fastdfs+nginx Dockerfile及安装包
- 精通Nginx第2版高清非扫描版
- 精通Nginx(第二版) 高清 带目录 非扫
- 目录树美化nginx-autoindex美化文件浏览
- 流媒体服务器源码包nginx+rtmp
- nginx1.14.0压缩包
- nginx 1.7.11.3 Gryphon.zip
- rtmp流网页播放器
- nginx1.9.0和其所用到所有包
- Nginx安装-让文件服务器fastdfs提供有
- nginx扩展nginx-rtmp-module实现流媒体直播
- windows基于nginx搭建rtmp流服务器
- windows版基于nginx点播视频服务器rtmp
- RtmpClient.rar
- nginx-1.15.9
- ubuntu16.04搭建FASTDFS图片服务器,并配
- Rtmp Flash播放器 3.5
- nginx-1.6.3
- Nginx+RTMP 推拉流集群方案
- CentOS-7-x86_64-Everything-1611的版本安装
- 最简单的基于libRTMP的
- CentOS6/7下gcc离线安装包,解决内网/内
- srs-3.0release.zip
- AMS-3.0 (Free)------过期不再使用,请
- 深入理解nginx模块开发与架构解析第二
评论
共有 条评论