Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
080cb108
Commit
080cb108
authored
Apr 26, 2018
by
François Grisez
Browse files
Fix regretion around unpacker status
parent
619849fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
19 deletions
+34
-19
src/videofilters/h264dec.cpp
src/videofilters/h264dec.cpp
+2
-2
src/voip/rfc3984.cpp
src/voip/rfc3984.cpp
+24
-9
src/voip/rfc3984.hpp
src/voip/rfc3984.hpp
+8
-8
No files found.
src/videofilters/h264dec.cpp
View file @
080cb108
...
...
@@ -302,7 +302,7 @@ static void dec_process(MSFilter *f){
}
H264NalUnpacker
::
Status
ret
=
d
->
unpacker
->
unpack
(
im
,
&
nalus
);
if
(
ret
.
test
(
NalUnpacker
::
StatusFlag
::
F
rameAvailable
)
)
{
if
(
ret
.
f
rameAvailable
){
int
size
;
uint8_t
*
p
,
*
end
;
bool_t
need_reinit
=
FALSE
;
...
...
@@ -338,7 +338,7 @@ static void dec_process(MSFilter *f){
}
p
+=
len
;
}
if
(
ret
.
test
(
NalUnpacker
::
StatusFlag
::
F
rameCorrupted
)
)
requestPLI
=
TRUE
;
if
(
ret
.
f
rameCorrupted
)
requestPLI
=
TRUE
;
}
d
->
packet_num
++
;
}
...
...
src/voip/rfc3984.cpp
View file @
080cb108
...
...
@@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <bitset>
#include <exception>
#include "mediastreamer2/msfilter.h"
...
...
@@ -218,6 +219,21 @@ void H264NaluSpliter::feed(mblk_t *nalu) {
// Unpacker class
// ==============
NalUnpacker
::
Status
&
NalUnpacker
::
Status
::
operator
|=
(
const
Status
&
s2
)
{
this
->
frameAvailable
=
(
this
->
frameAvailable
||
s2
.
frameAvailable
);
this
->
frameCorrupted
=
(
this
->
frameCorrupted
||
s2
.
frameCorrupted
);
this
->
isKeyFrame
=
(
this
->
isKeyFrame
||
s2
.
isKeyFrame
);
return
*
this
;
}
unsigned
int
NalUnpacker
::
Status
::
toUInt
()
const
{
bitset
<
3
>
flags
;
if
(
frameAvailable
)
flags
.
set
(
0
);
if
(
frameCorrupted
)
flags
.
set
(
1
);
if
(
isKeyFrame
)
flags
.
set
(
2
);
return
flags
.
to_ulong
();
}
NalUnpacker
::
NalUnpacker
(
FuAggregatorInterface
*
aggregator
,
ApSpliterInterface
*
spliter
)
:
_fuAggregator
(
aggregator
),
_apSpliter
(
spliter
)
{
ms_queue_init
(
&
_q
);
}
...
...
@@ -235,7 +251,8 @@ NalUnpacker::Status NalUnpacker::unpack(mblk_t *im, MSQueue *out) {
_lastTs
=
ts
;
if
(
!
_fuAggregator
->
isAggregating
()
&&
!
ms_queue_empty
(
&
_q
))
{
Status
status
;
status
.
set
(
StatusFlag
::
FrameAvailable
).
set
(
StatusFlag
::
FrameCorrupted
);
status
.
frameAvailable
=
true
;
status
.
frameCorrupted
=
true
;
ret
=
outputFrame
(
out
,
status
);
ms_warning
(
"Incomplete H264 frame (missing marker bit after seq number %u)"
,
mblk_get_cseq
(
ms_queue_peek_last
(
out
)));
...
...
@@ -252,7 +269,7 @@ NalUnpacker::Status NalUnpacker::unpack(mblk_t *im, MSQueue *out) {
if
(
_refCSeq
!=
cseq
)
{
ms_message
(
"sequence inconsistency detected (diff=%i)"
,
(
int
)(
cseq
-
_refCSeq
));
_refCSeq
=
cseq
;
_status
.
set
(
StatusFlag
::
F
rameCorrupted
)
;
_status
.
f
rameCorrupted
=
true
;
}
}
...
...
@@ -282,7 +299,7 @@ NalUnpacker::Status NalUnpacker::unpack(mblk_t *im, MSQueue *out) {
_lastTs
=
ts
;
ms_debug
(
"Marker bit set"
);
Status
status
;
status
.
set
(
StatusFlag
::
F
rameAvailable
)
;
status
.
f
rameAvailable
=
true
;
ret
=
outputFrame
(
out
,
status
);
}
...
...
@@ -298,7 +315,7 @@ NalUnpacker::Status NalUnpacker::outputFrame(MSQueue *out, const Status &flags)
while
(
!
ms_queue_empty
(
&
_q
))
{
ms_queue_put
(
out
,
ms_queue_get
(
&
_q
));
}
_status
=
0
;
_status
=
Status
()
;
return
res
;
}
...
...
@@ -436,16 +453,14 @@ NalUnpacker::PacketType H264NalUnpacker::getNaluType(const mblk_t *nalu) const {
}
H264NalUnpacker
::
Status
H264NalUnpacker
::
outputFrame
(
MSQueue
*
out
,
const
Status
&
flags
)
{
Status
res
=
_status
;
if
(
res
.
test
(
NalUnpacker
::
StatusFlag
::
IsKeyFrame
)
&&
_sps
&&
_pps
)
{
if
(
_status
.
isKeyFrame
&&
_sps
&&
_pps
)
{
/*prepend out of band provided sps and pps*/
ms_queue_put
(
out
,
_sps
);
ms_queue_put
(
out
,
_pps
);
_sps
=
NULL
;
_pps
=
NULL
;
}
NalUnpacker
::
outputFrame
(
out
,
flags
);
return
res
;
return
NalUnpacker
::
outputFrame
(
out
,
flags
);
}
};
// end of mediastreamer2 namespace
...
...
@@ -502,7 +517,7 @@ extern "C" {
unsigned
int
rfc3984_unpack2
(
Rfc3984Context
*
ctx
,
mblk_t
*
im
,
MSQueue
*
naluq
)
{
MSQueue
q
;
ms_queue_init
(
&
q
);
unsigned
int
status
=
ctx
->
unpacker
.
unpack
(
im
,
&
q
).
to
_ulong
();
unsigned
int
status
=
ctx
->
unpacker
.
unpack
(
im
,
&
q
).
to
UInt
();
if
(
status
&
Rfc3984FrameAvailable
)
{
status
|=
ctx
->
analyser
.
analyse
(
&
q
).
toUInt
();
while
(
mblk_t
*
m
=
ms_queue_get
(
&
q
))
{
...
...
src/voip/rfc3984.hpp
View file @
080cb108
...
...
@@ -19,7 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once
#include <bitset>
#include <memory>
#include "mediastreamer2/mscommon.h"
...
...
@@ -146,13 +145,14 @@ public:
class
NalUnpacker
{
public:
class
StatusFlag
{
public:
static
const
size_t
FrameAvailable
=
0
;
static
const
size_t
FrameCorrupted
=
1
;
static
const
size_t
IsKeyFrame
=
2
;
struct
Status
{
bool
frameAvailable
=
false
;
bool
frameCorrupted
=
false
;
bool
isKeyFrame
=
false
;
Status
&
operator
|=
(
const
Status
&
s2
);
unsigned
int
toUInt
()
const
;
};
typedef
std
::
bitset
<
3
>
Status
;
class
FuAggregatorInterface
{
public:
...
...
@@ -196,7 +196,7 @@ protected:
virtual
PacketType
getNaluType
(
const
mblk_t
*
nalu
)
const
=
0
;
MSQueue
_q
;
Status
_status
=
0
;
Status
_status
;
uint32_t
_lastTs
=
0x943FEA43
;
bool
_initializedRefCSeq
=
false
;
uint16_t
_refCSeq
=
0
;
...
...
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