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
22430a59
Commit
22430a59
authored
Jan 05, 2021
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兼容了mac下崩溃问题
parent
c6665048
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
14 deletions
+47
-14
lib/protocal/Protocal_1078.py
lib/protocal/Protocal_1078.py
+1
-1
lib/service/StreamH264Flv.py
lib/service/StreamH264Flv.py
+14
-5
ui/CameraArea.py
ui/CameraArea.py
+32
-8
No files found.
lib/protocal/Protocal_1078.py
View file @
22430a59
lib/service/StreamH264Flv.py
View file @
22430a59
...
@@ -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
:
print
(
"发送视频消息:"
+
msg
)
try
:
self
.
client
.
send
(
binascii
.
a2b_hex
(
msg
))
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
)
...
...
ui/CameraArea.py
View file @
22430a59
...
@@ -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
if
self
.
getOsName
()
==
"Windows"
:
threadObj
=
threading
.
Thread
(
target
=
self
.
doGetPlayUrl
,
args
=
(
textCtr
,))
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
:
if
self
.
getOsName
()
==
"Windows"
:
threadObj
=
threading
.
Thread
(
target
=
self
.
doConnect
,
args
=
())
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
:
if
self
.
getOsName
()
==
"Windows"
:
threadObj
=
threading
.
Thread
(
target
=
self
.
pushStream
)
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
if
self
.
getOsName
()
==
"Windows"
:
threadObj
=
threading
.
Thread
(
target
=
self
.
doPausePush
)
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
if
self
.
getOsName
()
==
"Windows"
:
threadObj
=
threading
.
Thread
(
target
=
self
.
doContinuePush
)
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
if
self
.
getOsName
()
==
"Windows"
:
threadObj
=
threading
.
Thread
(
target
=
self
.
doStopPush
)
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
if
self
.
getOsName
()
==
"Windows"
:
threadObj
=
threading
.
Thread
(
target
=
self
.
stopDoShowFrame
)
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
if
self
.
getOsName
()
==
"Windows"
:
threadObj
=
threading
.
Thread
(
target
=
self
.
doPlayFrame
)
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
"
)
...
...
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