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
0d0eb856
Commit
0d0eb856
authored
May 23, 2018
by
François Grisez
Browse files
Fixing crashes
parent
bf97dc85
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
33 deletions
+55
-33
src/android/media-codec-encoder.cpp
src/android/media-codec-encoder.cpp
+2
-2
src/android/media-codec-encoder.h
src/android/media-codec-encoder.h
+7
-6
src/android/media-codec-h264-encoder.cpp
src/android/media-codec-h264-encoder.cpp
+18
-16
src/android/media-codec-h265-encoder.cpp
src/android/media-codec-h265-encoder.cpp
+23
-4
src/utils/h265-utils.cpp
src/utils/h265-utils.cpp
+2
-3
src/voip/h265-nal-packer.h
src/voip/h265-nal-packer.h
+1
-1
src/voip/nal-packer.cpp
src/voip/nal-packer.cpp
+2
-1
No files found.
src/android/media-codec-encoder.cpp
View file @
0d0eb856
...
...
@@ -33,8 +33,8 @@ using namespace std;
namespace
mediastreamer
{
// Public methods
MediaCodecEncoderFilterImpl
::
MediaCodecEncoderFilterImpl
(
MSFilter
*
f
,
const
string
&
mime
,
NalPacker
*
packer
)
:
_f
(
f
),
_mime
(
mime
),
_p
acker
(
packer
)
{
MediaCodecEncoderFilterImpl
::
MediaCodecEncoderFilterImpl
(
MSFilter
*
f
,
const
std
::
string
&
mime
,
int
profile
,
int
level
,
NalPacker
*
packer
,
const
MSVideoConfiguration
*
vconfs
)
:
_f
(
f
),
_mime
(
mime
),
_p
rofile
(
profile
),
_level
(
level
),
_packer
(
packer
),
_vconfList
(
vconfs
)
{
_vconf
=
ms_video_find_best_configuration_for_size
(
_vconfList
,
MS_VIDEO_SIZE_CIF
,
ms_factory_get_cpu_count
(
f
->
factory
));
ms_video_starter_init
(
&
_starter
);
...
...
src/android/media-codec-encoder.h
View file @
0d0eb856
...
...
@@ -34,7 +34,6 @@ namespace mediastreamer {
class
MediaCodecEncoderFilterImpl
{
public:
MediaCodecEncoderFilterImpl
(
MSFilter
*
f
,
const
std
::
string
&
mime
,
NalPacker
*
packer
);
virtual
~
MediaCodecEncoderFilterImpl
();
virtual
void
preprocess
();
...
...
@@ -59,21 +58,23 @@ public:
void
notifyFir
();
protected:
MediaCodecEncoderFilterImpl
(
MSFilter
*
f
,
const
std
::
string
&
mime
,
int
profile
,
int
level
,
NalPacker
*
packer
,
const
MSVideoConfiguration
*
vconfs
);
virtual
void
onFrameEncodedHook
(
MSQueue
*
frame
)
{};
media_status_t
allocEncoder
();
media_status_t
tryColorFormat
(
AMediaFormat
*
format
,
unsigned
value
);
int
encConfigure
();
MSFilter
*
_f
=
nullptr
;
std
::
string
_mime
;
int
_profile
=
0
;
int
_level
=
0
;
std
::
unique_ptr
<
NalPacker
>
_packer
;
const
MSVideoConfiguration
*
_vconfList
;
MSVideoConfiguration
_vconf
;
bool
_avpfEnabled
=
false
;
int
_profile
=
0
;
int
_level
=
0
;
MSFilter
*
_f
=
nullptr
;
std
::
string
_mime
;
std
::
unique_ptr
<
NalPacker
>
_packer
;
AMediaCodec
*
_codec
=
nullptr
;
uint64_t
_framenum
=
0
;
MSVideoStarter
_starter
;
...
...
src/android/media-codec-h264-encoder.cpp
View file @
0d0eb856
...
...
@@ -21,20 +21,20 @@
#include "h264utils.h"
#include "media-codec-encoder.h"
#define MS_MEDIACODECH26
4
_CONF(required_bitrate, bitrate_limit, resolution, fps, ncpus) \
#define MS_MEDIACODECH26
5
_CONF(required_bitrate, bitrate_limit, resolution, fps, ncpus) \
{ required_bitrate, bitrate_limit, { MS_VIDEO_SIZE_ ## resolution ## _W, MS_VIDEO_SIZE_ ## resolution ## _H }, fps, ncpus, nullptr }
static
const
MSVideoConfiguration
_media_codec_h264_conf_list
[]
=
{
MS_MEDIACODECH26
4
_CONF
(
2048000
,
1000000
,
UXGA
,
25
,
2
),
MS_MEDIACODECH26
4
_CONF
(
1024000
,
5000000
,
SXGA_MINUS
,
25
,
2
),
MS_MEDIACODECH26
4
_CONF
(
1024000
,
5000000
,
720
P
,
30
,
2
),
MS_MEDIACODECH26
4
_CONF
(
750000
,
2048000
,
XGA
,
25
,
2
),
MS_MEDIACODECH26
4
_CONF
(
500000
,
1024000
,
SVGA
,
15
,
2
),
MS_MEDIACODECH26
4
_CONF
(
600000
,
3000000
,
VGA
,
30
,
2
),
MS_MEDIACODECH26
4
_CONF
(
400000
,
800000
,
VGA
,
15
,
2
),
MS_MEDIACODECH26
4
_CONF
(
128000
,
512000
,
CIF
,
15
,
1
),
MS_MEDIACODECH26
4
_CONF
(
100000
,
380000
,
QVGA
,
15
,
1
),
MS_MEDIACODECH26
4
_CONF
(
0
,
170000
,
QCIF
,
10
,
1
),
MS_MEDIACODECH26
5
_CONF
(
2048000
,
1000000
,
UXGA
,
25
,
2
),
MS_MEDIACODECH26
5
_CONF
(
1024000
,
5000000
,
SXGA_MINUS
,
25
,
2
),
MS_MEDIACODECH26
5
_CONF
(
1024000
,
5000000
,
720
P
,
30
,
2
),
MS_MEDIACODECH26
5
_CONF
(
750000
,
2048000
,
XGA
,
25
,
2
),
MS_MEDIACODECH26
5
_CONF
(
500000
,
1024000
,
SVGA
,
15
,
2
),
MS_MEDIACODECH26
5
_CONF
(
600000
,
3000000
,
VGA
,
30
,
2
),
MS_MEDIACODECH26
5
_CONF
(
400000
,
800000
,
VGA
,
15
,
2
),
MS_MEDIACODECH26
5
_CONF
(
128000
,
512000
,
CIF
,
15
,
1
),
MS_MEDIACODECH26
5
_CONF
(
100000
,
380000
,
QVGA
,
15
,
1
),
MS_MEDIACODECH26
5
_CONF
(
0
,
170000
,
QCIF
,
10
,
1
),
};
namespace
mediastreamer
{
...
...
@@ -42,11 +42,13 @@ namespace mediastreamer {
class
MediaCodecH264EncoderFilterImpl
:
public
MediaCodecEncoderFilterImpl
{
public:
MediaCodecH264EncoderFilterImpl
(
MSFilter
*
f
)
:
MediaCodecEncoderFilterImpl
(
f
,
"video/avc"
,
new
H264NalPacker
())
{
_vconfList
=
_media_codec_h264_conf_list
;
_profile
=
1
;
// AVCProfileBaseline
_level
=
1024
;
// AVCLevel32
}
MediaCodecH264EncoderFilterImpl
(
MSFilter
*
f
)
:
MediaCodecEncoderFilterImpl
(
f
,
"video/avc"
,
1
,
// AVCProfileBaseline
1024
,
// AVCLevel32
new
H264NalPacker
(),
_media_codec_h264_conf_list
)
{}
~
MediaCodecH264EncoderFilterImpl
()
{
if
(
_sps
)
freemsg
(
_sps
);
...
...
src/android/media-codec-h265-encoder.cpp
View file @
0d0eb856
...
...
@@ -20,14 +20,33 @@
#include "h265-nal-packer.h"
#include "media-codec-encoder.h"
#define MS_MEDIACODECH265_CONF(required_bitrate, bitrate_limit, resolution, fps, ncpus) \
{ required_bitrate, bitrate_limit, { MS_VIDEO_SIZE_ ## resolution ## _W, MS_VIDEO_SIZE_ ## resolution ## _H }, fps, ncpus, nullptr }
static
const
MSVideoConfiguration
_media_codec_h265_conf_list
[]
=
{
MS_MEDIACODECH265_CONF
(
2048000
,
1000000
,
UXGA
,
25
,
2
),
MS_MEDIACODECH265_CONF
(
1024000
,
5000000
,
SXGA_MINUS
,
25
,
2
),
MS_MEDIACODECH265_CONF
(
1024000
,
5000000
,
720
P
,
30
,
2
),
MS_MEDIACODECH265_CONF
(
750000
,
2048000
,
XGA
,
25
,
2
),
MS_MEDIACODECH265_CONF
(
500000
,
1024000
,
SVGA
,
15
,
2
),
MS_MEDIACODECH265_CONF
(
600000
,
3000000
,
VGA
,
30
,
2
),
MS_MEDIACODECH265_CONF
(
400000
,
800000
,
VGA
,
15
,
2
),
MS_MEDIACODECH265_CONF
(
128000
,
512000
,
CIF
,
15
,
1
),
MS_MEDIACODECH265_CONF
(
100000
,
380000
,
QVGA
,
15
,
1
),
MS_MEDIACODECH265_CONF
(
0
,
170000
,
QCIF
,
10
,
1
),
};
namespace
mediastreamer
{
class
MediaCodecH265EncoderFilterImpl
:
public
MediaCodecEncoderFilterImpl
{
public:
MediaCodecH265EncoderFilterImpl
(
MSFilter
*
f
)
:
MediaCodecEncoderFilterImpl
(
f
,
"video/hevc"
,
new
H265NalPacker
(
f
->
factory
))
{
_profile
=
1
;
// HEVCProfileMain
_level
=
256
;
// HEVCMainTierLevel31
}
MediaCodecH265EncoderFilterImpl
(
MSFilter
*
f
)
:
MediaCodecEncoderFilterImpl
(
f
,
"video/hevc"
,
1
,
// HEVCProfileMain
256
,
// HEVCMainTierLevel31
new
H265NalPacker
(
f
->
factory
),
_media_codec_h265_conf_list
)
{}
static
void
onFilterInit
(
MSFilter
*
f
)
{
f
->
data
=
new
MediaCodecH265EncoderFilterImpl
(
f
);
...
...
src/utils/h265-utils.cpp
View file @
0d0eb856
...
...
@@ -78,7 +78,7 @@ void H265FuHeader::parse(const uint8_t *header) {
header2
>>=
1
;
bool
start
=
((
header2
&
0x01
)
!=
0
);
if
(
start
&&
end
)
throw
runtime_error
(
"parsing an FU header with both start and end flags enabled"
);
if
(
start
&&
end
)
throw
invalid_argument
(
"parsing an FU header with both start and end flags enabled"
);
if
(
start
)
{
_pos
=
Position
::
Start
;
...
...
@@ -97,8 +97,7 @@ mblk_t *H265FuHeader::forge() const {
header
|=
_type
;
mblk_t
*
newHeader
=
allocb
(
1
,
0
);
*
newHeader
->
b_wptr
=
header
;
newHeader
++
;
*
newHeader
->
b_wptr
++
=
header
;
return
newHeader
;
}
...
...
src/voip/h265-nal-packer.h
View file @
0d0eb856
...
...
@@ -26,7 +26,7 @@ namespace mediastreamer {
class
H265NalPacker
:
public
NalPacker
{
public:
H265NalPacker
(
const
MSFactory
*
factory
)
:
NalPacker
(
new
NaluAggregator
,
new
NaluSpliter
(),
factory
)
{}
H265NalPacker
(
const
MSFactory
*
factory
)
:
NalPacker
(
new
NaluAggregator
()
,
new
NaluSpliter
(),
factory
)
{}
private:
class
NaluAggregator
:
public
NaluAggregatorInterface
{
...
...
src/voip/nal-packer.cpp
View file @
0d0eb856
...
...
@@ -31,7 +31,8 @@ void NalPacker::NaluAggregatorInterface::setMaxSize(size_t maxSize) {
_maxSize
=
maxSize
;
}
NalPacker
::
NalPacker
(
NaluAggregatorInterface
*
naluAggregator
,
NaluSpliterInterface
*
naluSpliter
,
const
MSFactory
*
factory
)
{
NalPacker
::
NalPacker
(
NaluAggregatorInterface
*
naluAggregator
,
NaluSpliterInterface
*
naluSpliter
,
const
MSFactory
*
factory
)
:
_naluSpliter
(
naluSpliter
),
_naluAggregator
(
naluAggregator
)
{
setMaxPayloadSize
(
ms_factory_get_payload_max_size
(
factory
));
}
...
...
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