Commit 22430a59 authored by liyuanhong's avatar liyuanhong

兼容了mac下崩溃问题

parent c6665048
...@@ -15,7 +15,7 @@ class Protocal_1078: ...@@ -15,7 +15,7 @@ class Protocal_1078:
self.dataType = 0 << 4 # 数据类型 , 0000:数据I祯,0001:视频P帧,0010:视频B帧,0011:音频帧,0100:透传数据 self.dataType = 0 << 4 # 数据类型 , 0000:数据I祯,0001:视频P帧,0010:视频B帧,0011:音频帧,0100:透传数据
self.pkgTag = 1 # 分包处理 ,0000:原子包,不可拆分等,0001:分包处理时的第一个包,0010:分包处理时的最后一个包,0011:分包处理时的中间包 self.pkgTag = 1 # 分包处理 ,0000:原子包,不可拆分等,0001:分包处理时的第一个包,0010:分包处理时的最后一个包,0011:分包处理时的中间包
self.time = 33 # 时间戳 self.time = 33 # 时间戳
self.lastKeyTime = 33 # Last I Frame Interval 该祯与上一个关键祯之间的时间间隔,单位毫秒(ms),当数据类型为非视频祯时,则没有该字段 self.lastKeyTime = 33 # Last I Frame Interval 该祯与上一个关键祯之间的时间间隔,单位毫秒(ms),当数据类型为非视频祯时,则没有该字段
self.lastTime = 33 # Last Frame Interval 该祯与上一个祯之间的时间时间,单位毫秒(ms),当数据类型为非视频祯时,则没有该字段 self.lastTime = 33 # Last Frame Interval 该祯与上一个祯之间的时间时间,单位毫秒(ms),当数据类型为非视频祯时,则没有该字段
self.lenS = 950 # 数据长度 self.lenS = 950 # 数据长度
self.dataBody = "" # 数据体,要发送的帧数据 self.dataBody = "" # 数据体,要发送的帧数据
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
import binascii import binascii
import json import json
import re import re
import socket
import time import time
import requests import requests
from lib.protocal.Protocal_1078 import Protocal_1078 from lib.protocal.Protocal_1078 import Protocal_1078
...@@ -39,6 +37,8 @@ class StreamH264Flv(): ...@@ -39,6 +37,8 @@ class StreamH264Flv():
self.pushStatusText = None # 状态显示窗 self.pushStatusText = None # 状态显示窗
self.multiPushStatus = 0 # 多次推流标记, 0:该连接第一次推流 1:该连接第一次对流 2: 该连接第二次对流 self.multiPushStatus = 0 # 多次推流标记, 0:该连接第一次推流 1:该连接第一次对流 2: 该连接第二次对流
self.timeStampSeek = 0 # 时间搓偏移,推理完成后设置为最后一帧的时间搓值;循环推流的时候需要加上该值 self.timeStampSeek = 0 # 时间搓偏移,推理完成后设置为最后一帧的时间搓值;循环推流的时候需要加上该值
self.isOpenVideoLog = 0 # 是否开启视频日志 0:不开启 1:开启
self.isOpenAudioLog = 0 # 是否开启音频日志 0:不开启 1:开启
def setMobile(self,data): def setMobile(self,data):
...@@ -67,6 +67,10 @@ class StreamH264Flv(): ...@@ -67,6 +67,10 @@ class StreamH264Flv():
self.logTextCtr = data self.logTextCtr = data
def setPushStatusText(self,data): def setPushStatusText(self,data):
self.pushStatusText = data self.pushStatusText = data
def setIsOpenVideoLog(self,data):
self.isOpenVideoLog = data
def setIsOpenAudioLog(self,data):
self.isOpenAudioLog = data
#################################################### ####################################################
...@@ -205,8 +209,12 @@ class StreamH264Flv(): ...@@ -205,8 +209,12 @@ class StreamH264Flv():
protocal_1078.setDataBody(fra) protocal_1078.setDataBody(fra)
pkgs = protocal_1078.genPkgsByFrame() pkgs = protocal_1078.genPkgsByFrame()
for msg in pkgs: for msg in pkgs:
# print("发送视频消息:" + msg) if self.isOpenVideoLog != 0:
self.client.send(binascii.a2b_hex(msg)) print("发送视频消息:" + msg)
try:
self.client.send(binascii.a2b_hex(msg))
except:
print(msg)
time.sleep(self.sendDur) time.sleep(self.sendDur)
#################################################### ####################################################
...@@ -223,7 +231,8 @@ class StreamH264Flv(): ...@@ -223,7 +231,8 @@ class StreamH264Flv():
protocal_1078.setDataBody(fra) protocal_1078.setDataBody(fra)
pkgs = protocal_1078.genAudioPkgsByFrame() pkgs = protocal_1078.genAudioPkgsByFrame()
for msg in pkgs: for msg in pkgs:
# print("发送音频消息:" + msg) if self.isOpenAudioLog != 0:
print("发送音频消息:" + msg)
self.client.send(binascii.a2b_hex(msg)) self.client.send(binascii.a2b_hex(msg))
time.sleep(self.sendDur) time.sleep(self.sendDur)
......
...@@ -197,7 +197,10 @@ class CameraArea(): ...@@ -197,7 +197,10 @@ class CameraArea():
def getPlayUrl(self,evt,textCtr): def getPlayUrl(self,evt,textCtr):
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr sys.stderr = self.logTextCtr
threadObj = threading.Thread(target=self.doGetPlayUrl,args=(textCtr,)) if self.getOsName() == "Windows":
threadObj = threading.Thread(target=self.doGetPlayUrl,args=(textCtr,))
else:
threadObj = threading.Thread(target=self.doGetPlayUrl(textCtr), args=(textCtr,))
threadObj.start() threadObj.start()
#################################################### ####################################################
...@@ -219,7 +222,10 @@ class CameraArea(): ...@@ -219,7 +222,10 @@ class CameraArea():
sys.stderr = self.logTextCtr sys.stderr = self.logTextCtr
isSendAudio = self.getAudioStatus() isSendAudio = self.getAudioStatus()
if self.pushObj == None: if self.pushObj == None:
threadObj = threading.Thread(target=self.doConnect,args=()) if self.getOsName() == "Windows":
threadObj = threading.Thread(target=self.doConnect,args=())
else:
threadObj = threading.Thread(target=self.doConnect(), args=())
threadObj.start() threadObj.start()
else: else:
timeCur = self.getCurTime() timeCur = self.getCurTime()
...@@ -283,7 +289,10 @@ class CameraArea(): ...@@ -283,7 +289,10 @@ class CameraArea():
try: try:
timeCur = self.getCurTime() timeCur = self.getCurTime()
if self.pushObj != None: if self.pushObj != None:
threadObj = threading.Thread(target=self.pushStream) if self.getOsName() == "Windows":
threadObj = threading.Thread(target=self.pushStream)
else:
threadObj = threading.Thread(target=self.pushStream())
threadObj.start() threadObj.start()
self.logTextCtr.WriteText(timeCur + "推流成功!\n") self.logTextCtr.WriteText(timeCur + "推流成功!\n")
self.pushStatusText.SetValue("推流中") self.pushStatusText.SetValue("推流中")
...@@ -305,7 +314,10 @@ class CameraArea(): ...@@ -305,7 +314,10 @@ class CameraArea():
def pausePush(self,evt): def pausePush(self,evt):
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr sys.stderr = self.logTextCtr
threadObj = threading.Thread(target=self.doPausePush) if self.getOsName() == "Windows":
threadObj = threading.Thread(target=self.doPausePush)
else:
threadObj = threading.Thread(target=self.doPausePush())
threadObj.start() threadObj.start()
def doPausePush(self): def doPausePush(self):
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
...@@ -321,7 +333,10 @@ class CameraArea(): ...@@ -321,7 +333,10 @@ class CameraArea():
def continuePush(self,evt): def continuePush(self,evt):
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr sys.stderr = self.logTextCtr
threadObj = threading.Thread(target=self.doContinuePush) if self.getOsName() == "Windows":
threadObj = threading.Thread(target=self.doContinuePush)
else:
threadObj = threading.Thread(target=self.doContinuePush())
threadObj.start() threadObj.start()
def doContinuePush(self): def doContinuePush(self):
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
...@@ -337,7 +352,10 @@ class CameraArea(): ...@@ -337,7 +352,10 @@ class CameraArea():
def stopPush(self,evt): def stopPush(self,evt):
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr sys.stderr = self.logTextCtr
threadObj = threading.Thread(target=self.doStopPush) if self.getOsName() == "Windows":
threadObj = threading.Thread(target=self.doStopPush)
else:
threadObj = threading.Thread(target=self.doStopPush())
threadObj.start() threadObj.start()
def doStopPush(self): def doStopPush(self):
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
...@@ -406,7 +424,10 @@ class CameraArea(): ...@@ -406,7 +424,10 @@ class CameraArea():
def stopShowFrame(self,evt): def stopShowFrame(self,evt):
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr sys.stderr = self.logTextCtr
threadObj = threading.Thread(target=self.stopDoShowFrame) if self.getOsName() == "Windows":
threadObj = threading.Thread(target=self.stopDoShowFrame)
else:
threadObj = threading.Thread(target=self.stopDoShowFrame())
threadObj.start() threadObj.start()
def stopDoShowFrame(self): def stopDoShowFrame(self):
self.isShowFrame = 0 self.isShowFrame = 0
...@@ -417,7 +438,10 @@ class CameraArea(): ...@@ -417,7 +438,10 @@ class CameraArea():
def playFrame(self,evt): def playFrame(self,evt):
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr sys.stderr = self.logTextCtr
threadObj = threading.Thread(target=self.doPlayFrame) if self.getOsName() == "Windows":
threadObj = threading.Thread(target=self.doPlayFrame)
else:
threadObj = threading.Thread(target=self.doPlayFrame())
threadObj.start() threadObj.start()
timeCur = self.getCurTime() timeCur = self.getCurTime()
self.logTextCtr.WriteText(timeCur + "开始播放视频!\n") self.logTextCtr.WriteText(timeCur + "开始播放视频!\n")
......
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