Commit e8bc5943 authored by liyuanhong's avatar liyuanhong

修复了多次推流,崩溃问题

parent b0be6402
......@@ -104,6 +104,18 @@ class Protocal_1078:
msg = msg + self.int2hexStringByBytes(self.lastTime,2)
msg = msg + self.int2hexStringByBytes(int(len(data) / 2),2)
msg = msg + data
if len(msg) % 2 != 0:
print("1-" + str(len(self.frameHeader1078)))
print("2--" + str(len(self.int2hexStringByBytes(self.V + self.P + self.X + self.CC))))
print("3---" + str(len(self.int2hexStringByBytes(self.M + self.PT))))
print("4----" + str(len(self.int2hexStringByBytes(self.sn,2))))
print("5-----" + str(len(self.sim)))
print("6------" + str(len(self.int2hexStringByBytes(self.logicC))))
print("7-------" + str(len(self.int2hexStringByBytes(self.dataType + self.pkgTag))))
print("8--------" + str(len(self.int2hexStringByBytes(self.time,8))))
print("9---------" + str(len(self.int2hexStringByBytes(self.lastKeyTime,2))))
print(self.lastKeyTime)
return msg
#####################################################
......@@ -121,7 +133,6 @@ class Protocal_1078:
msg = msg + self.int2hexStringByBytes(self.dataType + self.pkgTag)
msg = msg + self.int2hexStringByBytes(self.time,8)
msg = msg + self.int2hexStringByBytes(int(len(data) / 2),2)
msg = msg + data
return msg
......@@ -138,6 +149,7 @@ class Protocal_1078:
self.dataType = 2 << 4 # 0010
else:
self.dataType = 2 << 4 # 0010
datas = self.splitStrByLen(self.dataBody,1900)
pkgs = []
for i in range(0,len(datas)):
......
......@@ -39,6 +39,7 @@ class StreamH264Flv():
self.timeStampSeek = 0 # 时间搓偏移,推理完成后设置为最后一帧的时间搓值;循环推流的时候需要加上该值
self.isOpenVideoLog = 0 # 是否开启视频日志 0:不开启 1:开启
self.isOpenAudioLog = 0 # 是否开启音频日志 0:不开启 1:开启
self.protocal_1078 = Protocal_1078()
def setMobile(self,data):
......@@ -155,7 +156,7 @@ class StreamH264Flv():
self.pushStatusText.SetValue("已连网")
timeCur = self.getCurTime()
self.multiPushStatus = self.multiPushStatus + 1
self.timeStampSeek = self.timeStampSeek + timeStamp + 5000
self.timeStampSeek = timeStamp + 5000
self.logTextCtr.WriteText(timeCur + "视频推流完,自动结束推流!\n")
# self.client.close()
......@@ -189,25 +190,24 @@ class StreamH264Flv():
# 发送视频帧
####################################################
def sendVideoFrame(self,fra,timeStamp):
protocal_1078 = Protocal_1078()
protocal_1078.setSim(self.mobile)
protocal_1078.setLogcC(self.channel)
protocal_1078.setTime(timeStamp)
self.protocal_1078.setSim(self.mobile)
self.protocal_1078.setLogcC(self.channel)
self.protocal_1078.setTime(timeStamp)
frameType = fra[8:10]
if frameType == "65":
self.videoLastKeyTime = timeStamp
protocal_1078.setLastKeyTime(timeStamp - self.videoLastKeyTime)
protocal_1078.setLastTime(timeStamp - self.videoLastTime)
self.protocal_1078.setLastKeyTime(timeStamp - self.videoLastKeyTime)
self.protocal_1078.setLastTime(timeStamp - self.videoLastTime)
self.videoLastTime = timeStamp
else:
protocal_1078.setLastKeyTime(timeStamp - self.videoLastKeyTime)
protocal_1078.setLastTime(timeStamp - self.videoLastTime)
self.protocal_1078.setLastKeyTime(timeStamp - self.videoLastKeyTime)
self.protocal_1078.setLastTime(timeStamp - self.videoLastTime)
self.videoLastTime = timeStamp
if len(fra) % 2 != 0: # 处理有问题的帧数据
print("出现了视频问题帧,并自动修复...")
fra = fra[:len(fra) - 1]
protocal_1078.setDataBody(fra)
pkgs = protocal_1078.genPkgsByFrame()
self.protocal_1078.setDataBody(fra)
pkgs = self.protocal_1078.genPkgsByFrame()
for msg in pkgs:
if self.isOpenVideoLog != 0:
print("发送视频消息:" + msg)
......@@ -221,15 +221,14 @@ class StreamH264Flv():
# 发送音频帧
####################################################
def sendAudioFrame(self,fra,timeStamp):
protocal_1078 = Protocal_1078()
protocal_1078.setSim(self.mobile)
protocal_1078.setLogcC(self.channel)
protocal_1078.setTime(timeStamp)
self.protocal_1078.setSim(self.mobile)
self.protocal_1078.setLogcC(self.channel)
self.protocal_1078.setTime(timeStamp)
if len(fra) % 2 != 0: # 处理有问题的帧数据
print("出现了视频问题帧,并自动修复...")
fra = fra[:len(fra) - 1]
protocal_1078.setDataBody(fra)
pkgs = protocal_1078.genAudioPkgsByFrame()
self.protocal_1078.setDataBody(fra)
pkgs = self.protocal_1078.genAudioPkgsByFrame()
for msg in pkgs:
if self.isOpenAudioLog != 0:
print("发送音频消息:" + msg)
......@@ -259,6 +258,7 @@ class StreamH264Flv():
####################################################
def getAVTimeStamp(self,tag):
timeStamp = tag[16:22]
timeStamp = tag[22:24] + timeStamp
timeStamp = int(timeStamp,16)
return timeStamp
......@@ -312,9 +312,6 @@ class StreamH264Flv():
def getAudioFrame(self,AVTag):
frameData = {}
frames = []
if AVTag[2:4] == "00":
frameData["frames"] = []
else:
AVdata = AVTag[4:]
cp_id_bit = 0 << 27
cp_id_start = 0 << 26
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment