Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
jami-daemon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
140
Issues
140
List
Boards
Labels
Service Desk
Milestones
Iterations
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
savoirfairelinux
jami-daemon
Commits
476c21a9
Commit
476c21a9
authored
Aug 20, 2020
by
Pierre Lespagnol
Committed by
Sébastien Blin
Oct 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accel: Do not retry acceleration initialization with devices which failed
Change-Id: I728c20ffcb3d73dac2e97fa6121c0b627e54f35c
parent
5464ff6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
31 deletions
+50
-31
src/media/video/accel.cpp
src/media/video/accel.cpp
+42
-30
src/media/video/accel.h
src/media/video/accel.h
+8
-1
No files found.
src/media/video/accel.cpp
View file @
476c21a9
...
...
@@ -38,76 +38,80 @@ struct HardwareAPI
AVPixelFormat
format
;
AVPixelFormat
swFormat
;
std
::
vector
<
AVCodecID
>
supportedCodecs
;
std
::
set
<
std
::
string
>
possible_devices
;
std
::
list
<
std
::
pair
<
std
::
string
,
DeviceState
>
>
possible_devices
;
bool
dynBitrate
;
};
static
const
std
::
list
<
HardwareAPI
>
apiListDec
=
{
static
std
::
list
<
HardwareAPI
>
apiListDec
=
{
{
"nvdec"
,
AV_HWDEVICE_TYPE_CUDA
,
AV_PIX_FMT_CUDA
,
AV_PIX_FMT_NV12
,
{
AV_CODEC_ID_H264
,
AV_CODEC_ID_HEVC
,
AV_CODEC_ID_VP8
,
AV_CODEC_ID_MJPEG
},
{
"0"
,
"1"
,
"2"
},
{
{
"default"
,
DeviceState
::
NOT_TESTED
},
{
"1"
,
DeviceState
::
NOT_TESTED
},
{
"2"
,
DeviceState
::
NOT_TESTED
}
},
false
},
{
"vaapi"
,
AV_HWDEVICE_TYPE_VAAPI
,
AV_PIX_FMT_VAAPI
,
AV_PIX_FMT_NV12
,
{
AV_CODEC_ID_H264
,
AV_CODEC_ID_MPEG4
,
AV_CODEC_ID_VP8
,
AV_CODEC_ID_MJPEG
},
{
"/dev/dri/renderD128"
,
"/dev/dri/renderD129"
,
":0"
},
{{
"default"
,
DeviceState
::
NOT_TESTED
},
{
"/dev/dri/renderD128"
,
DeviceState
::
NOT_TESTED
},
{
"/dev/dri/renderD129"
,
DeviceState
::
NOT_TESTED
},
{
":0"
,
DeviceState
::
NOT_TESTED
}},
false
},
{
"vdpau"
,
AV_HWDEVICE_TYPE_VDPAU
,
AV_PIX_FMT_VDPAU
,
AV_PIX_FMT_NV12
,
{
AV_CODEC_ID_H264
,
AV_CODEC_ID_MPEG4
},
{},
{
{
"default"
,
DeviceState
::
NOT_TESTED
}
},
false
},
{
"videotoolbox"
,
AV_HWDEVICE_TYPE_VIDEOTOOLBOX
,
AV_PIX_FMT_VIDEOTOOLBOX
,
AV_PIX_FMT_NV12
,
{
AV_CODEC_ID_H264
,
AV_CODEC_ID_HEVC
,
AV_CODEC_ID_MPEG4
},
{},
{
{
"default"
,
DeviceState
::
NOT_TESTED
}
},
false
},
{
"qsv"
,
AV_HWDEVICE_TYPE_QSV
,
AV_PIX_FMT_QSV
,
AV_PIX_FMT_NV12
,
{
AV_CODEC_ID_H264
,
AV_CODEC_ID_HEVC
,
AV_CODEC_ID_MJPEG
,
AV_CODEC_ID_VP8
,
AV_CODEC_ID_VP9
},
{},
{
{
"default"
,
DeviceState
::
NOT_TESTED
}
},
false
},
};
static
const
std
::
list
<
HardwareAPI
>
apiListEnc
=
{
static
std
::
list
<
HardwareAPI
>
apiListEnc
=
{
{
"nvenc"
,
AV_HWDEVICE_TYPE_CUDA
,
AV_PIX_FMT_CUDA
,
AV_PIX_FMT_NV12
,
{
AV_CODEC_ID_H264
,
AV_CODEC_ID_HEVC
},
{
"0"
,
"1"
,
"2"
},
{
{
"default"
,
DeviceState
::
NOT_TESTED
},
{
"1"
,
DeviceState
::
NOT_TESTED
},
{
"2"
,
DeviceState
::
NOT_TESTED
}
},
true
},
{
"vaapi"
,
AV_HWDEVICE_TYPE_VAAPI
,
AV_PIX_FMT_VAAPI
,
AV_PIX_FMT_NV12
,
{
AV_CODEC_ID_H264
,
AV_CODEC_ID_HEVC
,
AV_CODEC_ID_MJPEG
,
AV_CODEC_ID_VP8
},
{
"/dev/dri/renderD128"
,
"/dev/dri/renderD129"
,
":0"
},
{{
"default"
,
DeviceState
::
NOT_TESTED
},
{
"/dev/dri/renderD128"
,
DeviceState
::
NOT_TESTED
},
{
"/dev/dri/renderD129"
,
DeviceState
::
NOT_TESTED
},
{
":0"
,
DeviceState
::
NOT_TESTED
}},
false
},
{
"videotoolbox"
,
AV_HWDEVICE_TYPE_VIDEOTOOLBOX
,
AV_PIX_FMT_VIDEOTOOLBOX
,
AV_PIX_FMT_NV12
,
{
AV_CODEC_ID_H264
,
AV_CODEC_ID_HEVC
},
{},
{
{
"default"
,
DeviceState
::
NOT_TESTED
}
},
false
},
{
"qsv"
,
AV_HWDEVICE_TYPE_QSV
,
AV_PIX_FMT_QSV
,
AV_PIX_FMT_NV12
,
{
AV_CODEC_ID_H264
,
AV_CODEC_ID_HEVC
,
AV_CODEC_ID_MJPEG
,
AV_CODEC_ID_VP8
},
{},
{
{
"default"
,
DeviceState
::
NOT_TESTED
}
},
false
},
};
...
...
@@ -199,30 +203,38 @@ HardwareAccel::init_device_type(std::string& dev)
JAMI_WARN
(
"-- Starting %s init for %s with default device."
,
(
type_
==
CODEC_ENCODER
)
?
"encoding"
:
"decoding"
,
name
);
if
(
name_
==
"qsv"
)
err
=
init_device
(
name
,
"auto"
,
0
);
else
err
=
init_device
(
name
,
nullptr
,
0
);
if
(
err
==
0
)
{
JAMI_DBG
(
"-- Init passed for %s with default device."
,
name
);
dev
=
"default"
;
return
0
;
}
else
{
JAMI_DBG
(
"-- Init failed for %s with default device."
,
name
);
if
(
possible_devices_
->
front
().
second
!=
DeviceState
::
NOT_USABLE
)
{
if
(
name_
==
"qsv"
)
err
=
init_device
(
name
,
"auto"
,
0
);
else
err
=
init_device
(
name
,
nullptr
,
0
);
if
(
err
==
0
)
{
JAMI_DBG
(
"-- Init passed for %s with default device."
,
name
);
possible_devices_
->
front
().
second
=
DeviceState
::
USABLE
;
dev
=
"default"
;
return
0
;
}
else
{
possible_devices_
->
front
().
second
=
DeviceState
::
NOT_USABLE
;
JAMI_DBG
(
"-- Init failed for %s with default device."
,
name
);
}
}
for
(
const
auto
&
device
:
possible_devices_
)
{
for
(
auto
&
device
:
*
possible_devices_
)
{
if
(
device
.
second
==
DeviceState
::
NOT_USABLE
)
continue
;
JAMI_WARN
(
"-- Init %s for %s with device %s."
,
(
type_
==
CODEC_ENCODER
)
?
"encoding"
:
"decoding"
,
name
,
device
.
c_str
());
err
=
init_device
(
name
,
device
.
c_str
(),
0
);
device
.
first
.
c_str
());
err
=
init_device
(
name
,
device
.
first
.
c_str
(),
0
);
if
(
err
==
0
)
{
JAMI_DBG
(
"-- Init passed for %s with device %s."
,
name
,
device
.
c_str
());
dev
=
device
;
JAMI_DBG
(
"-- Init passed for %s with device %s."
,
name
,
device
.
first
.
c_str
());
device
.
second
=
DeviceState
::
USABLE
;
dev
=
device
.
first
;
return
0
;
}
else
{
JAMI_DBG
(
"-- Init failed for %s with device %s."
,
name
,
device
.
c_str
());
device
.
second
=
DeviceState
::
NOT_USABLE
;
JAMI_DBG
(
"-- Init failed for %s with device %s."
,
name
,
device
.
first
.
c_str
());
}
}
return
-
1
;
...
...
@@ -409,7 +421,7 @@ HardwareAccel::getCompatibleAccel(AVCodecID id, int width, int height, CodecType
{
std
::
list
<
HardwareAccel
>
l
;
const
auto
&
list
=
(
type
==
CODEC_ENCODER
)
?
&
apiListEnc
:
&
apiListDec
;
for
(
auto
api
:
*
list
)
{
for
(
auto
&
api
:
*
list
)
{
const
auto
&
it
=
std
::
find
(
api
.
supportedCodecs
.
begin
(),
api
.
supportedCodecs
.
end
(),
id
);
if
(
it
!=
api
.
supportedCodecs
.
end
())
{
auto
hwtype
=
AV_HWDEVICE_TYPE_NONE
;
...
...
@@ -424,7 +436,7 @@ HardwareAccel::getCompatibleAccel(AVCodecID id, int width, int height, CodecType
api
.
dynBitrate
);
accel
.
height_
=
height
;
accel
.
width_
=
width
;
accel
.
possible_devices_
=
api
.
possible_devices
;
accel
.
possible_devices_
=
&
api
.
possible_devices
;
l
.
emplace_back
(
std
::
move
(
accel
));
}
}
...
...
src/media/video/accel.h
View file @
476c21a9
...
...
@@ -36,6 +36,13 @@ extern "C" {
namespace
jami
{
namespace
video
{
enum
class
DeviceState
{
NOT_TESTED
,
USABLE
,
NOT_USABLE
};
/**
* @brief Provides an abstraction layer to the hardware acceleration APIs in FFmpeg.
*/
...
...
@@ -174,7 +181,7 @@ private:
int
init_device
(
const
char
*
name
,
const
char
*
device
,
int
flags
);
int
init_device_type
(
std
::
string
&
dev
);
std
::
set
<
std
::
string
>
possible_devices_
;
std
::
list
<
std
::
pair
<
std
::
string
,
DeviceState
>>*
possible_devices_
;
};
}
// namespace video
...
...
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