Skip to content

Commit 3e3721a

Browse files
committed
fixed:av record index
1 parent e5c11ed commit 3e3721a

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

XEngine_Source/XEngine_ServiceApp/XEngine_HttpApp/XEngine_TaskPost/TaskPost_AVRecord.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ static XHANDLE xhScreen = NULL;
88
static XHANDLE xhPacket = NULL;
99
static XHANDLE xhFilter = NULL;
1010
static XHANDLE xhScale = NULL;
11+
static int nVideoIndex = -1;
12+
static int nAudioIndex = -1;
1113

1214
void XCALLBACK HTTPTask_TaskPost_CBVideo(XHANDLE*** pppSt_AVBuffer, XPVOID lParam)
1315
{
@@ -19,7 +21,7 @@ void XCALLBACK HTTPTask_TaskPost_CBVideo(XHANDLE*** pppSt_AVBuffer, XPVOID lPara
1921
VideoCodec_Stream_EnCodec(xhVideo, ppSt_AVFrame[0], &ppSt_AVPacket, &nListCount);
2022
for (int j = 0; j < nListCount; j++)
2123
{
22-
AVFormat_Packet_StreamWrite(xhPacket, 0, ppSt_AVPacket[j]);
24+
AVFormat_Packet_StreamWrite(xhPacket, nVideoIndex, ppSt_AVPacket[j]);
2325
}
2426
AVHelp_Memory_FreeAVList(&ppSt_AVPacket, nListCount);
2527
}
@@ -37,7 +39,7 @@ void XCALLBACK HTTPTask_TaskPost_CBAudio(XHANDLE*** pppSt_AVBuffer, XPVOID lPara
3739
AudioCodec_Stream_EnCodec(xhAudio, ppSt_MSGBuffer[i], &ppSt_AVPacket, &nAudioCount);
3840
for (int j = 0; j < nAudioCount; j++)
3941
{
40-
AVFormat_Packet_StreamWrite(xhPacket, 1, ppSt_AVPacket[j]);
42+
AVFormat_Packet_StreamWrite(xhPacket, nAudioIndex, ppSt_AVPacket[j]);
4143
}
4244
AVHelp_Memory_FreeAVList(&ppSt_AVPacket, nAudioCount);
4345
}
@@ -127,6 +129,7 @@ bool HTTPTask_TaskPost_AVRecordStart(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuff
127129
VideoCodec_Stream_GetAVCodec(xhVideo, &xhVideoCodec);
128130
AVFormat_Packet_StreamCreate(xhPacket, xhVideoCodec);
129131
BaseLib_Memory_FreeCStyle((XPPMEM)&xhVideoCodec);
132+
nVideoIndex = 0;
130133
}
131134
//启用音频
132135
if (_tcsxlen(st_AVRecord.tszAudioDevice) > 0)
@@ -181,6 +184,15 @@ bool HTTPTask_TaskPost_AVRecordStart(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuff
181184
st_TimeBase.nNum = 1;
182185
AVFormat_Packet_TimeBase(xhPacket, 1, &st_TimeBase);
183186
BaseLib_Memory_FreeCStyle((XPPMEM)&xhAudioCodec);
187+
188+
if (-1 == nVideoIndex)
189+
{
190+
nAudioIndex = 0;
191+
}
192+
else
193+
{
194+
nAudioIndex = 1;
195+
}
184196
}
185197
bRecord = true;
186198
AVFormat_Packet_Start(xhPacket);

0 commit comments

Comments
 (0)