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
e8bc5943
Commit
e8bc5943
authored
Jan 08, 2021
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复了多次推流,崩溃问题
parent
b0be6402
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
34 deletions
+43
-34
lib/protocal/Protocal_1078.py
lib/protocal/Protocal_1078.py
+13
-1
lib/service/StreamH264Flv.py
lib/service/StreamH264Flv.py
+30
-33
No files found.
lib/protocal/Protocal_1078.py
View file @
e8bc5943
...
...
@@ -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
)):
...
...
lib/service/StreamH264Flv.py
View file @
e8bc5943
...
...
@@ -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
...
...
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