Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
cbe39fc8
Commit
cbe39fc8
authored
6 years ago
by
Kateryna Kostiuk
Browse files
Options
Downloads
Patches
Plain Diff
video: iOS encoding/decoding
Enable Video Toolbox Change-Id: I3f20d35c7e66be37954861d2be411a4c16c51257
parent
1aaf0d79
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
contrib/src/ffmpeg/rules.mak
+5
-0
5 additions, 0 deletions
contrib/src/ffmpeg/rules.mak
src/media/media_encoder.cpp
+10
-0
10 additions, 0 deletions
src/media/media_encoder.cpp
src/media/video/accel.cpp
+18
-10
18 additions, 10 deletions
src/media/video/accel.cpp
with
33 additions
and
10 deletions
contrib/src/ffmpeg/rules.mak
+
5
−
0
View file @
cbe39fc8
...
...
@@ -201,6 +201,11 @@ endif
ifdef
HAVE_IOS
FFMPEGCONF
+=
\
--enable-videotoolbox
\
--enable-hwaccel
=
h263_videotoolbox
\
--enable-hwaccel
=
h264_videotoolbox
\
--enable-hwaccel
=
mpeg4_videotoolbox
\
--enable-encoder
=
h264_videotoolbox
\
--target-os
=
darwin
\
--enable-cross-compile
\
--arch
=
$(
ARCH
)
\
...
...
This diff is collapsed.
Click to expand it.
src/media/media_encoder.cpp
+
10
−
0
View file @
cbe39fc8
...
...
@@ -391,6 +391,15 @@ MediaEncoder::encode(VideoFrame& input, bool is_keyframe, int64_t frame_number)
#ifdef RING_ACCEL
auto
desc
=
av_pix_fmt_desc_get
(
static_cast
<
AVPixelFormat
>
(
input
.
format
()));
bool
isHardware
=
desc
&&
(
desc
->
flags
&
AV_PIX_FMT_FLAG_HWACCEL
);
#ifdef ENABLE_VIDEOTOOLBOX
//Videotoolbox handles frames allocations itself and do not need creating frame context manually.
//Now videotoolbox supports only fully accelerated pipeline
bool
isVideotoolbox
=
static_cast
<
AVPixelFormat
>
(
input
.
format
())
==
AV_PIX_FMT_VIDEOTOOLBOX
;
if
(
accel_
&&
isVideotoolbox
)
{
// Fully accelerated pipeline, skip main memory
frame
=
input
.
pointer
();
}
else
{
#else
std
::
unique_ptr
<
VideoFrame
>
framePtr
;
if
(
accel_
&&
accel_
->
isLinked
())
{
// Fully accelerated pipeline, skip main memory
...
...
@@ -414,6 +423,7 @@ MediaEncoder::encode(VideoFrame& input, bool is_keyframe, int64_t frame_number)
}
frame
=
framePtr
->
pointer
();
}
else
{
#endif //ENABLE_VIDEOTOOLBOX
#endif
libav_utils
::
fillWithBlack
(
scaledFrame_
.
pointer
());
scaler_
.
scale_with_aspect
(
input
,
scaledFrame_
);
...
...
This diff is collapsed.
Click to expand it.
src/media/video/accel.cpp
+
18
−
10
View file @
cbe39fc8
...
...
@@ -148,6 +148,7 @@ HardwareAccel::setDetails(AVCodecContext* codecCtx)
codecCtx
->
get_format
=
getFormatCb
;
codecCtx
->
thread_safe_callbacks
=
1
;
}
else
if
(
type_
==
CODEC_ENCODER
)
{
if
(
framesCtx_
)
// encoder doesn't need a device context, only a frame context
codecCtx
->
hw_frames_ctx
=
av_buffer_ref
(
framesCtx_
);
}
...
...
@@ -265,12 +266,16 @@ HardwareAccel::setupDecoder(AVCodecID id, int width, int height)
for
(
const
auto
&
api
:
apiList
)
{
if
(
std
::
find
(
api
.
supportedCodecs
.
begin
(),
api
.
supportedCodecs
.
end
(),
id
)
!=
api
.
supportedCodecs
.
end
())
{
auto
accel
=
std
::
make_unique
<
HardwareAccel
>
(
id
,
api
.
name
,
api
.
format
,
api
.
swFormat
,
CODEC_DECODER
);
if
(
accel
->
initDevice
()
&&
accel
->
initFrame
(
width
,
height
))
{
JAMI_DBG
()
<<
"Attempting to use hardware decoder "
<<
accel
->
getCodecName
()
<<
" with "
<<
api
.
name
;
if
(
accel
->
initDevice
())
{
// we don't need frame context for videotoolbox
if
(
api
.
format
==
AV_PIX_FMT_VIDEOTOOLBOX
||
accel
->
initFrame
(
width
,
height
))
{
JAMI_DBG
()
<<
"Attempting to use hardware dencoder "
<<
accel
->
getCodecName
()
<<
" with "
<<
api
.
name
;
return
accel
;
}
}
}
}
return
nullptr
;
}
...
...
@@ -289,15 +294,18 @@ HardwareAccel::setupEncoder(AVCodecID id, int width, int height, AVBufferRef* fr
auto
accel
=
std
::
make_unique
<
HardwareAccel
>
(
id
,
api
.
name
,
api
.
format
,
api
.
swFormat
,
CODEC_ENCODER
);
const
auto
&
codecName
=
accel
->
getCodecName
();
if
(
avcodec_find_encoder_by_name
(
codecName
.
c_str
()))
{
// Set up a fully accelerated pipeline, else fallback to using the main memory
if
(
accel
->
linkHardware
(
framesCtx
)
||
(
accel
->
initDevice
()
&&
accel
->
initFrame
(
width
,
height
)))
{
if
(
accel
->
initDevice
())
{
// we don't need frame context for videotoolbox
if
(
api
.
format
==
AV_PIX_FMT_VIDEOTOOLBOX
||
accel
->
linkHardware
(
framesCtx
)
||
accel
->
initFrame
(
width
,
height
))
{
JAMI_DBG
()
<<
"Attempting to use hardware encoder "
<<
codecName
;
return
accel
;
}
}
}
}
}
JAMI_WARN
()
<<
"Not using hardware encoding"
;
return
nullptr
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment