removed bad free and added better to clean output chan

This commit is contained in:
Saxon1 2018-05-06 00:26:02 +09:30
parent c56f414229
commit 39e6a785ef
2 changed files with 7 additions and 6 deletions

View File

@ -64,7 +64,6 @@ const (
ringBufferElementSize = 150000 ringBufferElementSize = 150000
httpTimeOut = 5 // s httpTimeOut = 5 // s
packetsPerFrame = 7 packetsPerFrame = 7
h264BufferSize = 1000000
bitrateTime = 60 // s bitrateTime = 60 // s
mjpegParserInChanLen = 100000 mjpegParserInChanLen = 100000
ffmpegPath = "/usr/local/bin/ffmpeg" ffmpegPath = "/usr/local/bin/ffmpeg"
@ -298,9 +297,14 @@ func (r *revid) getFramePacketization() []byte {
// flushDataPacketization removes data from the revid inst's coutput chan // flushDataPacketization removes data from the revid inst's coutput chan
func (r *revid) flushData() { func (r *revid) flushData() {
for len(r.outputChan) > 0 { for {
<-(r.outputChan) select {
case <-r.outputChan:
default:
goto done
} }
}
done:
} }
// packClips takes data segments; whether that be tsPackets or mjpeg frames and // packClips takes data segments; whether that be tsPackets or mjpeg frames and

View File

@ -70,17 +70,14 @@ unsigned int RTMP_write_frame(char* data, uint data_length){
if (!RTMP_IsConnected(rtmp)) { if (!RTMP_IsConnected(rtmp)) {
printf("RTMP is not connected!\n"); printf("RTMP is not connected!\n");
free(dataForC); free(dataForC);
free(data);
return 0; return 0;
} }
if (!RTMP_Write(rtmp, (const char*)data, data_length)) { if (!RTMP_Write(rtmp, (const char*)data, data_length)) {
printf("RTMP write error!\n"); printf("RTMP write error!\n");
free(dataForC); free(dataForC);
free(data);
return 0; return 0;
} }
free(dataForC); free(dataForC);
free(data);
return 1; return 1;
} }