Skip to content

Commit

Permalink
Merge pull request #10 from libxengine/develop
Browse files Browse the repository at this point in the history
V2.3.0.1001 Merge
  • Loading branch information
xengine-qyt authored Oct 7, 2023
2 parents 1ec8a62 + c6a5226 commit 257134a
Show file tree
Hide file tree
Showing 74 changed files with 2,379 additions and 1,664 deletions.
49 changes: 48 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
XEngine_StreamMedia V2.3.0.1001

增加:队列模块
增加:HLS配置项目
增加:srt解析转换程序线程
优化:av头包函数
修改:h264的sei会被解析为头的问题
修改:始终更新avc视频参数配置信息在rtmp推流的时候
修改:xstream http支持
修改:xstream http 帧大小字段
修改:http任务区分post和get
修改:为拉流修改提交名称方法名字
修改:jt1078 推流支持
修正:当程序退出的时候崩溃的问题
修正:FLV TAG大小不正确导致某些网页播放器无法播放的问题
修正:srt任务程序释放内存错误
修正:没有hTTP跨域控制字段的问题
修正:播放客户端只支持一个的问题
修正:xstream h264nalu头的解析问题
修正:SRT客户端退出没有关闭资源的问题
修正:如果没有音频,设置时间戳不被设置的问题
修正:发布流退出的时候创建流的问题
删除:会话模块的获取和设置音视频缓冲区
删除:JT1078 2014解析代码

added:queue module
added:hls configure
added:srt parse process thread
improved:avhdr packet function
modify:The sei of h264 is also parsed as a header.
modify:always update avc configure at the rtmp push
modify:xstream http supported
modify:xstream http chunked has frame size
modify:http tasks are divided into post and get
modify:post name to method name for pull stream
modify:jt1078 push stream supported
fixed:crashed when app exit
fixed:flv.js does not play because tagsize is not right
fixed:the problem free memory error that srt task
fixed:http Access-Control-Allow-Origin not set
fixed:just play once client
fixed:the problem that not support parse nalu header of h264
fixed:does not close srt client
fixed:if not audio,then video time will not set
fixed:create stream when publish stream exit
delete:get and set av buffer for push of session module
delete:jt1078 2014 was deleted
=======================================================
XEngine_StreamMedia V2.2.0.1001

添加:SRT推拉流支持
Expand Down Expand Up @@ -115,7 +163,6 @@ XEngine_StreamMedia V1.2.0.1001
修正:关闭通知没有释放通道内存的问题
修正:停止锁不正确的问题
修正:Center没有正确释放内存的问题
删除:插件池支持

added:http request return to json payload
added:comm packet for protocol module
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ c c++ streammedia server  
1. RTMP(H264,H265,AAC)
2. XStream
3. SRT
4. JT1078(planning)
4. JT1078
5. GB28181(planning)
6. WEBRTC(planning)

Expand Down
4 changes: 2 additions & 2 deletions XEngine_APPClient/APPClient_FLVPull/APPClient_FLVPull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ int main()
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
#endif
XNETHANDLE xhToken = 0;
LPCXSTR lpszFLVUrl = _X("http://127.0.0.1:5600/api?stream=play&sms=live/qyt&type=flv");
LPCXSTR lpszFLVUrl = _X("http://127.0.0.1:5600/api?stream=play&sms=live/013699435573_1&type=flv");

pSt_File = _xtfopen("D:\\XEngine_StreamMedia\\XEngine_APPClient\\Debug\\1.flv", "wb");

APIClient_Http_Create(&xhToken, APPClient_FLVPull_Callback);
APIClient_Http_SetUrl(xhToken, lpszFLVUrl, _X("GET"));
APIClient_Http_Excute(xhToken);

std::this_thread::sleep_for(std::chrono::seconds(10));
std::this_thread::sleep_for(std::chrono::seconds(20));

APIClient_Http_Close(xhToken);
fclose(pSt_File);
Expand Down
181 changes: 181 additions & 0 deletions XEngine_APPClient/APPClient_JT1078/APPClient_JT1078.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
#ifdef _MSC_BUILD
#include <windows.h>
#include <tchar.h>
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib")
#pragma comment(lib,"XEngine_Core/XEngine_OPenSsl")
#pragma comment(lib,"XEngine_Client/XClient_Socket")
#pragma comment(lib,"XEngine_AVCodec/XEngine_AVHelp")
#pragma comment(lib,"Ws2_32")
#endif
#include <thread>
#include <XEngine_Include/XEngine_CommHdr.h>
#include <XEngine_Include/XEngine_Types.h>
#include <XEngine_Include/XEngine_ProtocolHdr.h>
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
#include <XEngine_Include/XEngine_Core/OPenSsl_Define.h>
#include <XEngine_Include/XEngine_Core/OPenSsl_Error.h>
#include <XEngine_Include/XEngine_Client/XClient_Define.h>
#include <XEngine_Include/XEngine_Client/XClient_Error.h>
#include <XEngine_Include/XEngine_AVCodec/AVCollect_Define.h>
#include <XEngine_Include/XEngine_AVCodec/VideoCodec_Define.h>
#include <XEngine_Include/XEngine_AVCodec/AVHelp_Define.h>
#include <XEngine_Include/XEngine_AVCodec/AVHelp_Error.h>
#include "../../XEngine_Source/XEngine_UserProtocol.h"
using namespace std;

//需要优先配置XEngine
//WINDOWS使用VS2022 x86 或者 x64 debug 编译
//linux::g++ -std=c++17 -Wall -g APPClient_JT1078.cpp -o APPClient_JT1078.exe -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L /usr/local/lib/XEngine_Release/XEngine_SystemSdk -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIClient -lXEngine_SystemApi -ljsoncpp
//macos::g++ -std=c++17 -Wall -g APPClient_JT1078.cpp -o APPClient_JT1078.exe -lXEngine_BaseLib -lNetHelp_APIClient -lXEngine_SystemApi -ljsoncpp

void XEngine_Device_StrtoBCD(LPCXSTR lpszPhoneCode, XBYTE* ptszBCD)
{
for (int i = 0, nPos = 0; i < 6; i++)
{
OPenSsl_Codec_2BytesToBCD(&lpszPhoneCode[nPos], ptszBCD[i]);
nPos += 2;
}
}

int main()
{
WSADATA st_WSAData;
WSAStartup(MAKEWORD(2, 2), &st_WSAData);

LPCXSTR lpszFile = _X("D:\\h264 file\\1080P.264");
LPCXSTR lpszPhone = _X("013699435573");
LPCXSTR lpszAddr = _X("127.0.0.1");
int nPort = 5602;
XSOCKET hSocket;

if (!XClient_TCPSelect_Create(&hSocket, lpszAddr, nPort))
{
_xtprintf(_X("连接失败"));
return -1;
}

FILE *pSt_File = _xtfopen(lpszFile, _X("rb"));
if (NULL == pSt_File)
{
_xtprintf(_X("文件打开失败!"));
return -1;
}

int nSeq = 0;
XNETHANDLE xhToken = 0;
AVHelp_Parse_FrameInit(&xhToken, ENUM_XENGINE_AVCODEC_VIDEO_TYPE_H264);

while (true)
{
XCHAR tszRVBuffer[8192];
memset(tszRVBuffer, '\0', sizeof(tszRVBuffer));

int nRet = fread(tszRVBuffer, 1, sizeof(tszRVBuffer), pSt_File);
if (nRet <= 0)
{
fclose(pSt_File);
pSt_File = _xtfopen(lpszFile, _X("rb"));
if (NULL == pSt_File)
{
break;
}
}
int nListCount = 0;
AVHELP_FRAMEDATA** ppSt_Frame;
AVHelp_Parse_FrameGet(xhToken, tszRVBuffer, nRet, &ppSt_Frame, &nListCount);
for (int i = 0; i < nListCount; i++)
{
bool bFirst = true;
int nCpyCount = 0;
int nUseCount = 0;
int nMsgCount = ppSt_Frame[i]->nMsgLen;
XENGINE_AVCODEC_VIDEOFRAMETYPE enFrameType;

printf("%d\n", nMsgCount);
AVHelp_Parse_NaluType((LPCXSTR)ppSt_Frame[i]->ptszMsgBuffer, ENUM_XENGINE_AVCODEC_VIDEO_TYPE_H264, &enFrameType);
while (nMsgCount > 0)
{
XENGINE_RTPPACKETHDR st_RTPPacket;
XENGINE_RTPPACKETTAIL st_PacketTail;

memset(&st_RTPPacket, '\0', sizeof(XENGINE_RTPPACKETHDR));
memset(&st_PacketTail, '\0', sizeof(XENGINE_RTPPACKETTAIL));

st_RTPPacket.byFlags[0] = 0x30;
st_RTPPacket.byFlags[1] = 0x31;
st_RTPPacket.byFlags[2] = 0x63;
st_RTPPacket.byFlags[3] = 0x64;

st_RTPPacket.byV = 2;
st_RTPPacket.byX = 0;
st_RTPPacket.byCC = 1;
st_RTPPacket.byM = 0;
st_RTPPacket.byPT = 98;

st_RTPPacket.byChannel = 1;
st_RTPPacket.byType = 0;
st_RTPPacket.byPacket = 0;

if (nMsgCount > 950)
{
if (bFirst)
{
st_RTPPacket.byPacket = 1;
bFirst = false;
}
else
{
st_RTPPacket.byPacket = 3;
}
nCpyCount = 950;
}
else
{
st_RTPPacket.byM = 1;
st_RTPPacket.byPacket = 2;
nCpyCount = nMsgCount;
}

if (ENUM_XENGINE_AVCODEC_VIDEO_FRAMETYPE_P == enFrameType)
{
st_RTPPacket.byType = 1;
}
else
{
st_RTPPacket.byType = 0;
}

st_RTPPacket.wSerial = htons(nSeq++);
XEngine_Device_StrtoBCD(lpszPhone, st_RTPPacket.bySIMNumber);
BaseLib_OperatorTime_SetXTPTime(&st_RTPPacket.ullTimestamp);

int nPos = 0;
XCHAR tszMsgBuffer[2048];
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));

memcpy(tszMsgBuffer, &st_RTPPacket, sizeof(XENGINE_RTPPACKETHDR));
nPos += sizeof(XENGINE_RTPPACKETHDR);

memcpy(tszMsgBuffer + nPos, &st_PacketTail, sizeof(XENGINE_RTPPACKETTAIL));
nPos += sizeof(XENGINE_RTPPACKETTAIL);

XSHOT wLen = htons(nCpyCount);
memcpy(tszMsgBuffer + nPos, &wLen, sizeof(XSHOT));
nPos += sizeof(XSHOT);

XClient_TCPSelect_SendMsg(hSocket, tszMsgBuffer, nPos);
XClient_TCPSelect_SendMsg(hSocket, (LPCXSTR)ppSt_Frame[i]->ptszMsgBuffer + nUseCount, nCpyCount);
nUseCount += nCpyCount;
nMsgCount -= nCpyCount;
}
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ppSt_Frame[i]->ptszMsgBuffer);
}
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_Frame, nListCount);
std::this_thread::sleep_for(std::chrono::milliseconds(40));
}
AVHelp_Parse_FrameClose(xhToken);

WSACleanup();
return 0;
}
Loading

0 comments on commit 257134a

Please sign in to comment.