Skip to content

Commit 764d170

Browse files
committed
modify:hls supported delete file when stream closed
1 parent 612d489 commit 764d170

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ typedef struct tag_XEngine_ServiceConfig
6969
XCHAR tszHLSPath[MAX_PATH];
7070
int nTime;
7171
bool bEnable;
72+
bool bClear;
7273
}st_PullHls;
7374
struct
7475
{

XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE
146146
pSt_ServerConfig->st_XPull.st_PullRtsp.nARTPPort = st_PullRtsp["nARTPPort"].asInt();
147147
pSt_ServerConfig->st_XPull.st_PullRtsp.nARTCPPort = st_PullRtsp["nARTCPPort"].asInt();
148148

149+
pSt_ServerConfig->st_XPull.st_PullHls.bClear = st_PullHls["bClear"].asBool();
149150
pSt_ServerConfig->st_XPull.st_PullHls.nTime = st_PullHls["nTime"].asInt();
150151
_tcsxcpy(pSt_ServerConfig->st_XPull.st_PullHls.tszHLSPath, st_PullHls["tszHLSPath"].asCString());
151152

XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_AVPacket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool XEngine_AVPacket_AVCreate(LPCXSTR lpszClientAddr)
3434
_xstprintf(tszHLSFile, _X("%s/%s.m3u8"), st_ServiceConfig.st_XPull.st_PullHls.tszHLSPath, tszSMSAddr);
3535
_xstprintf(tszTSFile, _X("%s/%s/%lld.ts"), st_ServiceConfig.st_XPull.st_PullHls.tszHLSPath, tszSMSAddr, time(NULL));
3636

37-
HLSProtocol_M3u8File_AddStream(xhHLSFile, &xhSub, tszHLSFile, false);
37+
HLSProtocol_M3u8Packet_AddStream(xhHLSFile, &xhSub, tszHLSFile, false);
3838
ModuleSession_PushStream_HLSInsert(lpszClientAddr, tszTSFile, xhSub);
3939
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HLS端:%s,媒体文件创建成功,M3U8文件地址:%s,TS文件地址:%s"), lpszClientAddr, tszHLSFile, tszTSFile);
4040
}
@@ -432,7 +432,7 @@ bool XEngine_AVPacket_AVFrame(XCHAR* ptszSDBuffer, int* pInt_SDLen, XCHAR* ptszR
432432
ModuleSession_PushStream_HLSClose(lpszClientAddr, &xhSubFile);
433433

434434
BaseLib_OperatorString_GetSeparatorStr(tszHLSFile, _X("/"), tszFile, 2, false);
435-
HLSProtocol_M3u8File_AddFile(xhHLSFile, xhSubFile, tszFile, double(nCalValue), false);
435+
HLSProtocol_M3u8Packet_AddFile(xhHLSFile, xhSubFile, tszFile, double(nCalValue), false);
436436
//打开新的
437437
_xstprintf(tszTSFile, _X("%s/%s/%lld.ts"), st_ServiceConfig.st_XPull.st_PullHls.tszHLSPath, tszSMSAddr, time(NULL));
438438
ModuleSession_PushStream_HLSInsert(lpszClientAddr, tszTSFile, xhSubFile);

XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Network.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void XEngine_Network_Close(LPCXSTR lpszClientAddr, XSOCKET hSocket, bool bHeart,
254254
ModuleSession_PushStream_HLSClose(lpszClientAddr, &xhHLSToken);
255255
if (xhHLSToken > 0)
256256
{
257-
HLSProtocol_M3u8File_Delete(xhHLSFile, xhHLSToken);
257+
HLSProtocol_M3u8Packet_Delete(xhHLSFile, xhHLSToken, st_ServiceConfig.st_XPull.st_PullHls.bClear);
258258
}
259259
ModuleSession_PullStream_PublishDelete(tszSMSAddr);
260260
ModuleSession_PushStream_Destroy(lpszClientAddr);

XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void ServiceApp_Stop(int signo)
8888
ManagePool_Thread_NQDestroy(xhJT1078Pool);
8989
//销毁其他资源
9090
ModuleHelp_SrtCore_Destory();
91-
HLSProtocol_M3u8File_Delete(xhHLSFile);
91+
HLSProtocol_M3u8Packet_Delete(xhHLSFile);
9292
srt_cleanup();
9393

9494
HelpComponents_XLog_Destroy(xhLog);
@@ -500,7 +500,7 @@ int main(int argc, char** argv)
500500

501501
if (st_ServiceConfig.st_XPull.st_PullHls.bEnable)
502502
{
503-
if (!HLSProtocol_M3u8File_Create(&xhHLSFile, NULL))
503+
if (!HLSProtocol_M3u8Packet_Create(&xhHLSFile, NULL))
504504
{
505505
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动HLS(M3U8)文件流失败,错误:%d"), HLSProtocol_GetLastError());
506506
goto XENGINE_SERVICEAPP_EXIT;
@@ -555,7 +555,7 @@ int main(int argc, char** argv)
555555
ManagePool_Thread_NQDestroy(xhJT1078Pool);
556556
//销毁其他资源
557557
ModuleHelp_SrtCore_Destory();
558-
HLSProtocol_M3u8File_Delete(xhHLSFile);
558+
HLSProtocol_M3u8Packet_Delete(xhHLSFile);
559559
srt_cleanup();
560560

561561
HelpComponents_XLog_Destroy(xhLog);

0 commit comments

Comments
 (0)