Commit 9fc6bbb8 authored by liyuanhong's avatar liyuanhong

更新了UI操作

parent 452f5bbf
globalCon:
getPlayUrl: http://10.100.11.110:9999/video/streamInfo
......@@ -23,6 +23,7 @@ class StreamH264Flv():
self.mobile = "013146201117" # 手机号
self.channel = 1 # 频道号
self.isSendAudio = 1 # 是否发送音频0:不发送 1:发送
self.isSend = 0 # 是否发送消息 0:不发送 1:发送
# self.host = "10.100.11.125" # 开发环境
self.host = "10.100.12.3" # 测试环境
......@@ -33,6 +34,7 @@ class StreamH264Flv():
self.isGetPlayUrl = 0 # 是否已经获取了playUrl 0:没有 1:获取了
self.playUrl = "" # 视频播放地址
def setMobile(self,data):
self.mobile = data
def setChannel(self,data):
......@@ -63,10 +65,17 @@ class StreamH264Flv():
# self.client.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) # 在客户端开启心跳
# self.client.connect((self.host, self.port))
####################################################
# socket 断开
####################################################
def disConnectServer(self):
self.client.close()
####################################################
# 读取flv文件,并发送 (h264编码,并且音频为aac编码格式)
####################################################
def readFlvAndSend(self):
self.isSend = 1
with open(self.videoPath, 'rb') as fi:
con = fi.read(self.readSize)
data = con.hex()
......@@ -76,40 +85,50 @@ class StreamH264Flv():
else:
data = data
while con:
if len(data) < 30:
con = fi.read(self.readSize)
data = data + con.hex()
else:
tagSize = self.getAVTagSize(data)
if len(data) < (tagSize * 2 + 30):
if self.isSend == 1:
if len(data) < 30:
con = fi.read(self.readSize)
data = data + con.hex()
else:
tag = data[:tagSize * 2 + 30] # flv tag
tagType = self.getTagType(tag) # flv tag 类型,是音频 还是视频
AVtag = tag[30:] # 音视频 tag
avTimeStamp = self.getAVTimeStamp(tag) #获取时间戳
if avTimeStamp > 100:
if self.isGetPlayUrl == 0:
self.getPlayUrl(self.mobile,self.channel)
self.isGetPlayUrl = 1
if tagType == "08": # 音频
AVdata = AVtag[4:] # 音频数据
frameInfo = self.getAudioFrame(AVtag)
for frame in frameInfo["frames"]:
self.sendAudioFrame(frame,avTimeStamp)
elif tagType == "09": # 视频
AVdata = AVtag[10:] # 视频数据
frameInfo = self.getVideoFrame(AVtag)
for frame in frameInfo["frames"]:
self.sendVideoFrame(frame,avTimeStamp)
elif tagType == "12": # 脚本
AVdata = AVtag # 脚本数据
tagSize = self.getAVTagSize(data)
if len(data) < (tagSize * 2 + 30):
con = fi.read(self.readSize)
data = data + con.hex()
else:
AVdata = AVtag
data = data[(tagSize * 2 + 30):]
tag = data[:tagSize * 2 + 30] # flv tag
tagType = self.getTagType(tag) # flv tag 类型,是音频 还是视频
AVtag = tag[30:] # 音视频 tag
avTimeStamp = self.getAVTimeStamp(tag) #获取时间戳
if avTimeStamp > 100:
if self.isGetPlayUrl == 0:
self.getPlayUrl(self.mobile,self.channel)
self.isGetPlayUrl = 1
if tagType == "08": # 音频
AVdata = AVtag[4:] # 音频数据
if self.isSendAudio == 1:
frameInfo = self.getAudioFrame(AVtag)
for frame in frameInfo["frames"]:
self.sendAudioFrame(frame,avTimeStamp)
elif tagType == "09": # 视频
AVdata = AVtag[10:] # 视频数据
frameInfo = self.getVideoFrame(AVtag)
for frame in frameInfo["frames"]:
self.sendVideoFrame(frame,avTimeStamp)
elif tagType == "12": # 脚本
AVdata = AVtag # 脚本数据
else:
AVdata = AVtag
data = data[(tagSize * 2 + 30):]
else:
time.sleep(1)
self.client.close()
####################################################
# 停止发送消息
####################################################
def stopSend(self):
self.isSend = 0
####################################################
# 获取视频播放地址
####################################################
......
#coding: utf-8
from ui.MainWindow import MainWindow
if __name__ == "__main__":
MainWindow().show()
\ No newline at end of file
This diff is collapsed.
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