Skip to content

Commit 94e52e7

Browse files
committed
added:audio codec handle manage for module session
1 parent 5619b45 commit 94e52e7

File tree

5 files changed

+167
-2
lines changed

5 files changed

+167
-2
lines changed

XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,4 +769,52 @@ extern "C" bool ModuleSession_PushStream_HLSTimeSet(LPCXSTR lpszClientAddr, __in
769769
意思:是否成功
770770
备注:
771771
*********************************************************************/
772-
extern "C" bool ModuleSession_PushStream_HLSTimeGet(LPCXSTR lpszClientAddr, __int64u* pInt_Time);
772+
extern "C" bool ModuleSession_PushStream_HLSTimeGet(LPCXSTR lpszClientAddr, __int64u* pInt_Time);
773+
/********************************************************************
774+
函数名称:ModuleSession_PushStream_AudioCodecSet
775+
函数功能:设置音频编解码器句柄
776+
参数.一:lpszClientAddr
777+
In/Out:In
778+
类型:常量字符指针
779+
可空:N
780+
意思:输入要操作的客户端
781+
参数.二:xhAudioDecodec
782+
In/Out:In
783+
类型:句柄
784+
可空:N
785+
意思:输入解码器句柄
786+
参数.三:xhAudioEncodec
787+
In/Out:In
788+
类型:句柄
789+
可空:N
790+
意思:输入编码器句柄
791+
返回值
792+
类型:逻辑型
793+
意思:是否成功
794+
备注:
795+
*********************************************************************/
796+
extern "C" bool ModuleSession_PushStream_AudioCodecSet(LPCXSTR lpszClientAddr, XNETHANDLE xhAudioDecodec, XNETHANDLE xhAudioEncodec);
797+
/********************************************************************
798+
函数名称:ModuleSession_PushStream_AudioCodecGet
799+
函数功能:获取解码器句柄
800+
参数.一:lpszClientAddr
801+
In/Out:In
802+
类型:常量字符指针
803+
可空:N
804+
意思:输入要操作的客户端
805+
参数.二:pxhAudioDecodec
806+
In/Out:Out
807+
类型:句柄
808+
可空:N
809+
意思:输出解码器句柄
810+
参数.三:pxhAudioEncodec
811+
In/Out:Out
812+
类型:句柄
813+
可空:N
814+
意思:输出编码器句柄
815+
返回值
816+
类型:逻辑型
817+
意思:是否成功
818+
备注:
819+
*********************************************************************/
820+
extern "C" bool ModuleSession_PushStream_AudioCodecGet(LPCXSTR lpszClientAddr, XNETHANDLE* pxhAudioDecodec, XNETHANDLE* pxhAudioEncodec);

XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.cpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,104 @@ bool CModuleSession_PushStream::ModuleSession_PushStream_HLSTimeGet(LPCXSTR lpsz
791791
}
792792

793793
*pInt_Time = stl_MapIterator->second->st_HLSFile.nTime;
794+
st_Locker.unlock_shared();
795+
return true;
796+
}
797+
/********************************************************************
798+
函数名称:ModuleSession_PushStream_AudioCodecSet
799+
函数功能:设置音频编解码器句柄
800+
参数.一:lpszClientAddr
801+
In/Out:In
802+
类型:常量字符指针
803+
可空:N
804+
意思:输入要操作的客户端
805+
参数.二:xhAudioDecodec
806+
In/Out:In
807+
类型:句柄
808+
可空:N
809+
意思:输入解码器句柄
810+
参数.三:xhAudioEncodec
811+
In/Out:In
812+
类型:句柄
813+
可空:N
814+
意思:输入编码器句柄
815+
返回值
816+
类型:逻辑型
817+
意思:是否成功
818+
备注:
819+
*********************************************************************/
820+
bool CModuleSession_PushStream::ModuleSession_PushStream_AudioCodecSet(LPCXSTR lpszClientAddr, XNETHANDLE xhAudioDecodec, XNETHANDLE xhAudioEncodec)
821+
{
822+
Session_IsErrorOccur = false;
823+
824+
if (NULL == lpszClientAddr)
825+
{
826+
Session_IsErrorOccur = true;
827+
Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_PARAMENT;
828+
return false;
829+
}
830+
//是否存在
831+
st_Locker.lock_shared();
832+
unordered_map<xstring, PUSHSTREAM_PACKET*>::iterator stl_MapIterator = stl_MapPushStream.find(lpszClientAddr);
833+
if (stl_MapIterator == stl_MapPushStream.end())
834+
{
835+
Session_IsErrorOccur = true;
836+
Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_NOTFOUND;
837+
st_Locker.unlock_shared();
838+
return false;
839+
}
840+
stl_MapIterator->second->st_AVCodec.xhAudioEncodec = xhAudioEncodec;
841+
stl_MapIterator->second->st_AVCodec.xhAudioDecodec = xhAudioDecodec;
842+
843+
st_Locker.unlock_shared();
844+
return true;
845+
}
846+
/********************************************************************
847+
函数名称:ModuleSession_PushStream_AudioCodecGet
848+
函数功能:获取解码器句柄
849+
参数.一:lpszClientAddr
850+
In/Out:In
851+
类型:常量字符指针
852+
可空:N
853+
意思:输入要操作的客户端
854+
参数.二:pxhAudioDecodec
855+
In/Out:Out
856+
类型:句柄
857+
可空:N
858+
意思:输出解码器句柄
859+
参数.三:pxhAudioEncodec
860+
In/Out:Out
861+
类型:句柄
862+
可空:N
863+
意思:输出编码器句柄
864+
返回值
865+
类型:逻辑型
866+
意思:是否成功
867+
备注:
868+
*********************************************************************/
869+
bool CModuleSession_PushStream::ModuleSession_PushStream_AudioCodecGet(LPCXSTR lpszClientAddr, XNETHANDLE* pxhAudioDecodec, XNETHANDLE* pxhAudioEncodec)
870+
{
871+
Session_IsErrorOccur = false;
872+
873+
if (NULL == lpszClientAddr)
874+
{
875+
Session_IsErrorOccur = true;
876+
Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_PARAMENT;
877+
return false;
878+
}
879+
//是否存在
880+
st_Locker.lock_shared();
881+
unordered_map<xstring, PUSHSTREAM_PACKET*>::iterator stl_MapIterator = stl_MapPushStream.find(lpszClientAddr);
882+
if (stl_MapIterator == stl_MapPushStream.end())
883+
{
884+
Session_IsErrorOccur = true;
885+
Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_NOTFOUND;
886+
st_Locker.unlock_shared();
887+
return false;
888+
}
889+
*pxhAudioEncodec = stl_MapIterator->second->st_AVCodec.xhAudioEncodec;
890+
*pxhAudioDecodec = stl_MapIterator->second->st_AVCodec.xhAudioDecodec;
891+
794892
st_Locker.unlock_shared();
795893
return true;
796894
}

XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ typedef struct
1919
__int64u nTime;
2020
FILE* pSt_File;
2121
}st_HLSFile;
22+
struct
23+
{
24+
XNETHANDLE xhAudioDecodec;
25+
XNETHANDLE xhAudioEncodec;
26+
}st_AVCodec;
2227
XENGINE_PROTOCOL_AVINFO st_AVInfo;
2328
XCHAR tszSMSAddr[MAX_PATH];
2429
ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE enStreamType;
@@ -51,6 +56,9 @@ class CModuleSession_PushStream
5156
bool ModuleSession_PushStream_HLSClose(LPCXSTR lpszClientAddr, XNETHANDLE* pxhToken);
5257
bool ModuleSession_PushStream_HLSTimeSet(LPCXSTR lpszClientAddr, __int64u nTime);
5358
bool ModuleSession_PushStream_HLSTimeGet(LPCXSTR lpszClientAddr, __int64u *pInt_Time);
59+
public:
60+
bool ModuleSession_PushStream_AudioCodecSet(LPCXSTR lpszClientAddr, XNETHANDLE xhAudioDecodec, XNETHANDLE xhAudioEncodec);
61+
bool ModuleSession_PushStream_AudioCodecGet(LPCXSTR lpszClientAddr, XNETHANDLE* pxhAudioDecodec, XNETHANDLE* pxhAudioEncodec);
5462
private:
5563
shared_mutex st_Locker;
5664
private:

XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ EXPORTS
3939
ModuleSession_PushStream_HLSWrite
4040
ModuleSession_PushStream_HLSClose
4141
ModuleSession_PushStream_HLSTimeSet
42-
ModuleSession_PushStream_HLSTimeGet
42+
ModuleSession_PushStream_HLSTimeGet
43+
44+
ModuleSession_PushStream_AudioCodecSet
45+
ModuleSession_PushStream_AudioCodecGet

XEngine_Source/XEngine_ModuleSession/pch.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,12 @@ extern "C" bool ModuleSession_PushStream_HLSTimeSet(LPCXSTR lpszClientAddr, __in
171171
extern "C" bool ModuleSession_PushStream_HLSTimeGet(LPCXSTR lpszClientAddr, __int64u * pInt_Time)
172172
{
173173
return m_PushStream.ModuleSession_PushStream_HLSTimeGet(lpszClientAddr, pInt_Time);
174+
}
175+
extern "C" bool ModuleSession_PushStream_AudioCodecSet(LPCXSTR lpszClientAddr, XNETHANDLE xhAudioDecodec, XNETHANDLE xhAudioEncodec)
176+
{
177+
return m_PushStream.ModuleSession_PushStream_AudioCodecSet(lpszClientAddr, xhAudioDecodec, xhAudioEncodec);
178+
}
179+
extern "C" bool ModuleSession_PushStream_AudioCodecGet(LPCXSTR lpszClientAddr, XNETHANDLE* pxhAudioDecodec, XNETHANDLE* pxhAudioEncodec)
180+
{
181+
return m_PushStream.ModuleSession_PushStream_AudioCodecGet(lpszClientAddr, pxhAudioDecodec, pxhAudioEncodec);
174182
}

0 commit comments

Comments
 (0)