Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mirrorSimulator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李远洪
mirrorSimulator
Commits
9fc6bbb8
Commit
9fc6bbb8
authored
Dec 31, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新了UI操作
parent
452f5bbf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
201 additions
and
56 deletions
+201
-56
config/config.yaml
config/config.yaml
+2
-0
lib/service/StreamH264Flv.py
lib/service/StreamH264Flv.py
+47
-28
start.py
start.py
+5
-0
ui/CameraArea.py
ui/CameraArea.py
+147
-28
No files found.
config/config.yaml
0 → 100644
View file @
9fc6bbb8
globalCon
:
getPlayUrl
:
http://10.100.11.110:9999/video/streamInfo
lib/service/StreamH264Flv.py
View file @
9fc6bbb8
...
@@ -23,6 +23,7 @@ class StreamH264Flv():
...
@@ -23,6 +23,7 @@ class StreamH264Flv():
self
.
mobile
=
"013146201117"
# 手机号
self
.
mobile
=
"013146201117"
# 手机号
self
.
channel
=
1
# 频道号
self
.
channel
=
1
# 频道号
self
.
isSendAudio
=
1
# 是否发送音频0:不发送 1:发送
self
.
isSendAudio
=
1
# 是否发送音频0:不发送 1:发送
self
.
isSend
=
0
# 是否发送消息 0:不发送 1:发送
# self.host = "10.100.11.125" # 开发环境
# self.host = "10.100.11.125" # 开发环境
self
.
host
=
"10.100.12.3"
# 测试环境
self
.
host
=
"10.100.12.3"
# 测试环境
...
@@ -33,6 +34,7 @@ class StreamH264Flv():
...
@@ -33,6 +34,7 @@ class StreamH264Flv():
self
.
isGetPlayUrl
=
0
# 是否已经获取了playUrl 0:没有 1:获取了
self
.
isGetPlayUrl
=
0
# 是否已经获取了playUrl 0:没有 1:获取了
self
.
playUrl
=
""
# 视频播放地址
self
.
playUrl
=
""
# 视频播放地址
def
setMobile
(
self
,
data
):
def
setMobile
(
self
,
data
):
self
.
mobile
=
data
self
.
mobile
=
data
def
setChannel
(
self
,
data
):
def
setChannel
(
self
,
data
):
...
@@ -63,10 +65,17 @@ class StreamH264Flv():
...
@@ -63,10 +65,17 @@ class StreamH264Flv():
# self.client.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) # 在客户端开启心跳
# self.client.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) # 在客户端开启心跳
# self.client.connect((self.host, self.port))
# self.client.connect((self.host, self.port))
####################################################
# socket 断开
####################################################
def
disConnectServer
(
self
):
self
.
client
.
close
()
####################################################
####################################################
# 读取flv文件,并发送 (h264编码,并且音频为aac编码格式)
# 读取flv文件,并发送 (h264编码,并且音频为aac编码格式)
####################################################
####################################################
def
readFlvAndSend
(
self
):
def
readFlvAndSend
(
self
):
self
.
isSend
=
1
with
open
(
self
.
videoPath
,
'rb'
)
as
fi
:
with
open
(
self
.
videoPath
,
'rb'
)
as
fi
:
con
=
fi
.
read
(
self
.
readSize
)
con
=
fi
.
read
(
self
.
readSize
)
data
=
con
.
hex
()
data
=
con
.
hex
()
...
@@ -76,40 +85,50 @@ class StreamH264Flv():
...
@@ -76,40 +85,50 @@ class StreamH264Flv():
else
:
else
:
data
=
data
data
=
data
while
con
:
while
con
:
if
len
(
data
)
<
30
:
if
self
.
isSend
==
1
:
con
=
fi
.
read
(
self
.
readSize
)
if
len
(
data
)
<
30
:
data
=
data
+
con
.
hex
()
else
:
tagSize
=
self
.
getAVTagSize
(
data
)
if
len
(
data
)
<
(
tagSize
*
2
+
30
):
con
=
fi
.
read
(
self
.
readSize
)
con
=
fi
.
read
(
self
.
readSize
)
data
=
data
+
con
.
hex
()
data
=
data
+
con
.
hex
()
else
:
else
:
tag
=
data
[:
tagSize
*
2
+
30
]
# flv tag
tagSize
=
self
.
getAVTagSize
(
data
)
tagType
=
self
.
getTagType
(
tag
)
# flv tag 类型,是音频 还是视频
if
len
(
data
)
<
(
tagSize
*
2
+
30
):
AVtag
=
tag
[
30
:]
# 音视频 tag
con
=
fi
.
read
(
self
.
readSize
)
avTimeStamp
=
self
.
getAVTimeStamp
(
tag
)
#获取时间戳
data
=
data
+
con
.
hex
()
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
# 脚本数据
else
:
else
:
AVdata
=
AVtag
tag
=
data
[:
tagSize
*
2
+
30
]
# flv tag
data
=
data
[(
tagSize
*
2
+
30
):]
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
()
self
.
client
.
close
()
####################################################
# 停止发送消息
####################################################
def
stopSend
(
self
):
self
.
isSend
=
0
####################################################
####################################################
# 获取视频播放地址
# 获取视频播放地址
####################################################
####################################################
...
...
start.py
0 → 100644
View file @
9fc6bbb8
#coding: utf-8
from
ui.MainWindow
import
MainWindow
if
__name__
==
"__main__"
:
MainWindow
()
.
show
()
\ No newline at end of file
ui/CameraArea.py
View file @
9fc6bbb8
#coding: utf-8
#coding: utf-8
import
json
import
os
import
os
import
sys
import
threading
import
time
import
requests
import
wx
import
wx
import
yaml
from
lib.service.StreamH264Flv
import
StreamH264Flv
class
CameraArea
():
class
CameraArea
():
def
__init__
(
self
,
frame
):
def
__init__
(
self
,
frame
):
self
.
frame
=
frame
self
.
frame
=
frame
self
.
mainPanel
=
None
self
.
mainPanel
=
None
self
.
devId
=
"010000000000"
self
.
devId
=
"010000000000"
self
.
channel
=
1
self
.
channel
=
1
self
.
getGetPlayUrl
=
"http://10.100.11.110:9999/video/streamInfo"
# 获取推流播放地址的url
self
.
pushObj
=
None
# 推流对象
with
open
(
"config/config.yaml"
,
'r'
,
encoding
=
"utf-8"
)
as
fi
:
fi_data
=
fi
.
read
()
data
=
yaml
.
load
(
fi_data
,
Loader
=
yaml
.
FullLoader
)
self
.
getGetPlayUrl
=
data
[
"globalCon"
][
"getPlayUrl"
]
self
.
pushStatusText
=
None
self
.
logTextCtr
=
None
sys
.
stdout
=
self
.
logTextCtr
def
setDevId
(
self
,
data
):
def
setDevId
(
self
,
data
):
self
.
devId
=
data
self
.
devId
=
data
...
@@ -17,67 +35,110 @@ class CameraArea():
...
@@ -17,67 +35,110 @@ class CameraArea():
self
.
channel
=
data
self
.
channel
=
data
#################################################
#################################################
# 创建一个pannel
# 创建一个
顶级
pannel
#################################################
#################################################
def
create
(
self
):
def
create
(
self
):
self
.
mainPanel
=
wx
.
Panel
(
self
.
frame
)
self
.
mainPanel
=
wx
.
Panel
(
self
.
frame
)
boxSizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
boxSizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
topPanel
=
wx
.
Panel
(
self
.
mainPanel
)
topPanel
=
self
.
getTopPanel
(
boxSizer
)
bottomPanel
=
wx
.
Panel
(
self
.
mainPanel
)
bottomPanel
=
self
.
getBottomPanel
(
boxSizer
)
bottomPanel
.
SetBackgroundColour
(
wx
.
YELLOW
)
boxSizer
.
Add
(
topPanel
,
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer
.
Add
(
topPanel
,
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer
.
Add
(
bottomPanel
,
2
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer
.
Add
(
bottomPanel
,
2
,
flag
=
wx
.
EXPAND
|
wx
.
TOP
,
border
=
5
)
self
.
mainPanel
.
SetSizer
(
boxSizer
)
self
.
mainPanel
.
SetSizer
(
boxSizer
)
return
self
.
mainPanel
#################################################
# 获取顶部pannel的内容
#################################################
def
getTopPanel
(
self
,
boxSizer
):
topPanel
=
wx
.
Panel
(
self
.
mainPanel
)
preView
=
wx
.
Panel
(
topPanel
)
preView
=
wx
.
Panel
(
topPanel
)
boxSizer_preView
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
boxSizer_preView
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
preView_staticText
=
wx
.
StaticText
(
preView
,
label
=
'预览区域(未实现):'
,
pos
=
(
10
,
10
))
preView_staticText
=
wx
.
StaticText
(
preView
,
label
=
'预览区域(未实现):'
,
pos
=
(
10
,
10
))
preView_content
=
wx
.
Panel
(
topPanel
,
style
=
wx
.
BORDER_SIMPLE
)
preView_content
=
wx
.
Panel
(
topPanel
,
style
=
wx
.
BORDER_SIMPLE
)
boxSizer_preView
.
Add
(
preView_staticText
,
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer_preView
.
Add
(
preView_staticText
,
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer_preView
.
Add
(
preView_content
,
11
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer_preView
.
Add
(
preView_content
,
11
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
preView
.
SetSizer
(
boxSizer_preView
)
preView
.
SetSizer
(
boxSizer_preView
)
paramView
=
wx
.
Panel
(
topPanel
)
paramView
=
wx
.
Panel
(
topPanel
)
wx
.
StaticText
(
paramView
,
label
=
'本地视频:'
,
pos
=
(
10
,
10
))
wx
.
StaticText
(
paramView
,
label
=
'本地视频:'
,
pos
=
(
10
,
10
))
videoPathText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
5
),
size
=
wx
.
Size
(
300
,
-
1
))
# 要推流的视频地址
fiPath
=
os
.
getcwd
()
+
"
\\
flv
\\
aaa3.flv"
selectPathButton
=
wx
.
Button
(
paramView
,
label
=
"选择视频文件"
,
pos
=
(
375
,
5
))
videoPathText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
5
),
size
=
wx
.
Size
(
300
,
-
1
),
value
=
fiPath
)
# 要推流的视频地址
self
.
frame
.
Bind
(
wx
.
EVT_BUTTON
,
lambda
evt
,
textCtr
=
videoPathText
:
self
.
selectVideoFile
(
evt
,
textCtr
),
selectPathButton
)
selectPathButton
=
wx
.
Button
(
paramView
,
label
=
"选择视频文件"
,
pos
=
(
375
,
5
))
self
.
frame
.
Bind
(
wx
.
EVT_BUTTON
,
lambda
evt
,
textCtr
=
videoPathText
:
self
.
selectVideoFile
(
evt
,
textCtr
),
selectPathButton
)
wx
.
StaticText
(
paramView
,
label
=
'推流地址:'
,
pos
=
(
10
,
40
))
wx
.
StaticText
(
paramView
,
label
=
'推流地址:'
,
pos
=
(
10
,
40
))
pushHostText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
35
),
size
=
wx
.
Size
(
150
,
-
1
),
value
=
"10.100.11.125"
)
# 推流地址
pushHostText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
35
),
size
=
wx
.
Size
(
150
,
-
1
),
value
=
"10.100.11.125"
)
# 推流地址
wx
.
StaticText
(
paramView
,
label
=
'推流端口:'
,
pos
=
(
235
,
40
))
wx
.
StaticText
(
paramView
,
label
=
'推流端口:'
,
pos
=
(
235
,
40
))
pushPortText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
300
,
35
),
size
=
wx
.
Size
(
80
,
-
1
),
value
=
"1078"
)
# 推流端口
pushPortText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
300
,
35
),
size
=
wx
.
Size
(
80
,
-
1
),
value
=
"1078"
)
# 推流端口
wx
.
StaticText
(
paramView
,
label
=
'设 备号:'
,
pos
=
(
10
,
70
))
wx
.
StaticText
(
paramView
,
label
=
'设 备号:'
,
pos
=
(
10
,
70
))
pushHostText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
65
),
size
=
wx
.
Size
(
150
,
-
1
),
value
=
self
.
devId
)
# 设备号
devIdText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
65
),
size
=
wx
.
Size
(
150
,
-
1
),
value
=
self
.
devId
)
# 设备号
wx
.
StaticText
(
paramView
,
label
=
'频 道号:'
,
pos
=
(
235
,
70
))
wx
.
StaticText
(
paramView
,
label
=
'频 道号:'
,
pos
=
(
235
,
70
))
pushPortText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
300
,
65
),
size
=
wx
.
Size
(
80
,
-
1
),
value
=
str
(
self
.
channel
))
# 频道号
channelText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
300
,
65
),
size
=
wx
.
Size
(
80
,
-
1
),
value
=
str
(
self
.
channel
))
# 频道号
wx
.
StaticText
(
paramView
,
label
=
'当前状态:'
,
pos
=
(
10
,
100
))
wx
.
StaticText
(
paramView
,
label
=
'当前状态:'
,
pos
=
(
10
,
100
))
pushStatusText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
95
),
size
=
wx
.
Size
(
60
,
-
1
),
value
=
"未推流"
,
style
=
wx
.
TE_READONLY
)
# 推流状态显示
self
.
pushStatusText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
95
),
size
=
wx
.
Size
(
80
,
-
1
),
value
=
"未推流"
,
pushStatusText
.
SetForegroundColour
(
wx
.
RED
)
style
=
wx
.
TE_READONLY
)
# 推流状态显示
self
.
pushStatusText
.
SetForegroundColour
(
wx
.
RED
)
wx
.
StaticText
(
paramView
,
label
=
'消息发送间隔(毫秒):'
,
pos
=
(
10
,
130
))
wx
.
StaticText
(
paramView
,
label
=
'消息发送间隔(毫秒):'
,
pos
=
(
10
,
130
))
msgSendDurText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
150
,
125
),
size
=
wx
.
Size
(
40
,
-
1
),
value
=
"7"
)
# 消息发送间隔
msgSendDurText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
150
,
125
),
size
=
wx
.
Size
(
40
,
-
1
),
value
=
"7"
)
# 消息发送间隔
wx
.
StaticText
(
paramView
,
label
=
'播放地址:'
,
pos
=
(
10
,
190
))
wx
.
StaticText
(
paramView
,
label
=
'播放地址:'
,
pos
=
(
10
,
190
))
msgSendDurText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
185
),
size
=
wx
.
Size
(
400
,
-
1
))
# 视频播放地址
videoPlayText
=
wx
.
TextCtrl
(
paramView
,
pos
=
(
70
,
185
),
size
=
wx
.
Size
(
350
,
-
1
))
# 视频播放地址
getPlayUrlButton
=
wx
.
Button
(
paramView
,
label
=
"获取播放地址"
,
pos
=
(
425
,
185
))
self
.
frame
.
Bind
(
wx
.
EVT_BUTTON
,
lambda
evt
,
textCtr
=
videoPlayText
:
self
.
getPlayUrl
(
evt
,
textCtr
),
getPlayUrlButton
)
ctrView
=
wx
.
Panel
(
topPanel
,
style
=
wx
.
BORDER_SIMPLE
)
connectButton
=
wx
.
Button
(
ctrView
,
label
=
"1、连网"
,
pos
=
(
5
,
5
))
ctrView
=
wx
.
Panel
(
topPanel
)
self
.
frame
.
Bind
(
wx
.
EVT_BUTTON
,
lambda
evt
,
host
=
pushHostText
.
GetValue
(),
port
=
pushPortText
.
GetValue
()
\
startPushButton
=
wx
.
Button
(
ctrView
,
label
=
"开始推流"
,
pos
=
(
5
,
5
))
,
devId
=
devIdText
.
GetValue
(),
channel
=
channelText
.
GetValue
(),
sendDur
=
msgSendDurText
.
GetValue
()
\
stopPushButton
=
wx
.
Button
(
ctrView
,
label
=
"停止推流"
,
pos
=
(
90
,
5
))
,
isSendAudio
=
1
,
flvPath
=
videoPathText
.
GetValue
():
self
.
connect
(
evt
,
host
,
port
,
devId
,
channel
,
sendDur
,
isSendAudio
,
flvPath
),
ctrView
.
SetBackgroundColour
(
wx
.
RED
)
connectButton
)
startPushButton
=
wx
.
Button
(
ctrView
,
label
=
"2、开始推流"
,
pos
=
(
120
,
5
))
self
.
frame
.
Bind
(
wx
.
EVT_BUTTON
,
lambda
evt
:
self
.
startPush
(
evt
),
startPushButton
)
pausePushButton
=
wx
.
Button
(
ctrView
,
label
=
"3、停止推流"
,
pos
=
(
5
,
35
))
rePushButton
=
wx
.
Button
(
ctrView
,
label
=
"4、继续推流"
,
pos
=
(
120
,
35
))
stopPushButton
=
wx
.
Button
(
ctrView
,
label
=
"5、结束推流"
,
pos
=
(
5
,
65
))
disConnectButton
=
wx
.
Button
(
ctrView
,
label
=
"6、断网"
,
pos
=
(
120
,
65
))
# ctrView.SetBackgroundColour("PINK")
boxSizer_1
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
boxSizer_1
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
boxSizer_1
.
Add
(
preView
,
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer_1
.
Add
(
preView
,
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer_1
.
Add
(
paramView
,
2
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer_1
.
Add
(
paramView
,
2
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer_1
.
Add
(
ctrView
,
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer_1
.
Add
(
ctrView
,
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
topPanel
.
SetSizer
(
boxSizer_1
)
topPanel
.
SetSizer
(
boxSizer_1
)
return
topPanel
return
self
.
mainPanel
#################################################
# 获取底部pannel的内容
#################################################
def
getBottomPanel
(
self
,
boxSizer
):
bottomPanel
=
wx
.
Panel
(
self
.
mainPanel
)
boxSizer_bottom
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
logArea
=
wx
.
Panel
(
bottomPanel
)
logStaticText
=
wx
.
StaticText
(
logArea
,
label
=
'日志:'
)
self
.
logTextCtr
=
wx
.
TextCtrl
(
logArea
,
size
=
wx
.
Size
(
40
,
-
1
),
style
=
wx
.
TE_MULTILINE
)
boxSizer_logArea
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
boxSizer_logArea
.
Add
(
logStaticText
,
2
,
flag
=
wx
.
EXPAND
|
wx
.
TOP
,
border
=
10
)
boxSizer_logArea
.
Add
(
self
.
logTextCtr
,
100
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
logArea
.
SetSizer
(
boxSizer_logArea
)
ctrArea
=
wx
.
Panel
(
bottomPanel
)
ctrArea
.
SetBackgroundColour
(
"RED"
)
boxSizer_bottom
.
Add
(
logArea
,
60
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
)
boxSizer_bottom
.
Add
(
ctrArea
,
40
,
flag
=
wx
.
EXPAND
|
wx
.
LEFT
,
border
=
5
)
bottomPanel
.
SetSizer
(
boxSizer_bottom
)
return
bottomPanel
#################################################
# 打开文件选择对话框
#################################################
def
selectVideoFile
(
self
,
evt
,
textCtr
):
def
selectVideoFile
(
self
,
evt
,
textCtr
):
wildcard
=
"Video file (*.flv)|*.flv"
wildcard
=
"Video file (*.flv)|*.flv"
dlg
=
wx
.
FileDialog
(
dlg
=
wx
.
FileDialog
(
self
.
frame
,
message
=
"
Choose a file
"
,
self
.
frame
,
message
=
"
选择flv视频文件
"
,
defaultDir
=
os
.
getcwd
(),
defaultDir
=
os
.
getcwd
(),
defaultFile
=
""
,
defaultFile
=
""
,
wildcard
=
wildcard
,
wildcard
=
wildcard
,
...
@@ -88,4 +149,62 @@ class CameraArea():
...
@@ -88,4 +149,62 @@ class CameraArea():
if
dlg
.
ShowModal
()
==
wx
.
ID_OK
:
if
dlg
.
ShowModal
()
==
wx
.
ID_OK
:
path
=
dlg
.
GetPath
()
path
=
dlg
.
GetPath
()
textCtr
.
SetValue
(
path
)
textCtr
.
SetValue
(
path
)
dlg
.
Destroy
()
dlg
.
Destroy
()
\ No newline at end of file
####################################################
# 获取视频播放地址
####################################################
def
getPlayUrl
(
self
,
evt
,
textCtr
):
res
=
requests
.
post
(
self
.
getGetPlayUrl
,
data
=
json
.
dumps
({
'devId'
:
self
.
devId
,
'chan'
:
str
(
self
.
channel
)}))
.
text
res
=
json
.
loads
(
res
)
url
=
res
[
"data"
][
"url"
]
textCtr
.
SetValue
(
url
)
####################################################
# 连网
####################################################
def
connect
(
self
,
evt
,
host
,
port
,
devId
,
channel
,
sendDur
,
isSendAudio
,
flvPath
):
obj
=
StreamH264Flv
()
obj
.
setHost
(
host
)
obj
.
setPort
(
int
(
port
))
obj
.
setSendDur
(
int
(
sendDur
)
/
1000
)
obj
.
setIsSendAudio
(
isSendAudio
)
obj
.
setMobile
(
devId
)
obj
.
setChannel
(
int
(
channel
))
obj
.
setVideoPath
(
flvPath
)
self
.
pushObj
=
obj
self
.
pushObj
.
connectServer
()
timeCur
=
self
.
getCurTime
()
self
.
logTextCtr
.
WriteText
(
timeCur
+
"连网成功!
\n
"
)
self
.
pushStatusText
.
SetValue
(
"已连网"
)
####################################################
# 获取当前时间
####################################################
def
getCurTime
(
self
):
timeCur
=
int
(
time
.
time
()
*
1000
)
timeArray
=
time
.
localtime
(
timeCur
/
1000
)
timeCur
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
timeArray
)
timeCur
=
"["
+
timeCur
+
"] "
return
timeCur
####################################################
# 断网
####################################################
def
disConnect
(
self
,
evt
):
self
.
pushObj
.
disConnectServer
()
####################################################
# 开始推流
####################################################
def
startPush
(
self
,
evt
):
# threadObj = threading.Thread(target=self.pushStream(), args=())
# threadObj.start()
wx
.
CallAfter
(
self
.
pushStream
)
timeCur
=
self
.
getCurTime
()
self
.
logTextCtr
.
WriteText
(
timeCur
+
"推流成功!
\n
"
)
self
.
pushStatusText
.
SetValue
(
"推流中"
)
def
pushStream
(
self
):
self
.
pushObj
.
readFlvAndSend
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment