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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
444feddf
Commit
444feddf
authored
9 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
android: fix segfault when probing formats
Change-Id: I15f9c2d8b1414c58cf77c58b8a0c4b6d3068a76e Tuleap:
#537
parent
0abf627b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/media/video/androidvideo/video_device_impl.cpp
+17
-20
17 additions, 20 deletions
src/media/video/androidvideo/video_device_impl.cpp
with
17 additions
and
20 deletions
src/media/video/androidvideo/video_device_impl.cpp
+
17
−
20
View file @
444feddf
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include
<stdexcept>
#include
<stdexcept>
#include
<string>
#include
<string>
#include
<vector>
#include
<vector>
#include
<array>
namespace
ring
{
namespace
video
{
namespace
ring
{
namespace
video
{
...
@@ -43,9 +44,9 @@ struct android_fmt {
...
@@ -43,9 +44,9 @@ struct android_fmt {
enum
VideoPixelFormat
ring_format
;
enum
VideoPixelFormat
ring_format
;
};
};
static
const
st
ruct
android_fmt
and_formats
[]
{
static
const
st
d
::
array
<
android_fmt
,
2
>
and_formats
{
{
17
,
"NV21"
,
VIDEO_PIXFMT_NV21
},
android_fmt
{
17
,
"NV21"
,
VIDEO_PIXFMT_NV21
},
{
842094169
,
"YUV420"
,
VIDEO_PIXFMT_YUV420P
},
android_fmt
{
842094169
,
"YUV420"
,
VIDEO_PIXFMT_YUV420P
},
};
};
class
VideoDeviceImpl
{
class
VideoDeviceImpl
{
...
@@ -71,7 +72,7 @@ class VideoDeviceImpl {
...
@@ -71,7 +72,7 @@ class VideoDeviceImpl {
std
::
vector
<
VideoSize
>
sizes_
{};
std
::
vector
<
VideoSize
>
sizes_
{};
std
::
vector
<
FrameRate
>
rates_
{};
std
::
vector
<
FrameRate
>
rates_
{};
const
struct
android_fmt
*
fmt_
{
nullptr
};
const
android_fmt
*
fmt_
{
nullptr
};
VideoSize
size_
{};
VideoSize
size_
{};
FrameRate
rate_
{};
FrameRate
rate_
{};
};
};
...
@@ -83,26 +84,19 @@ VideoDeviceImpl::selectFormat()
...
@@ -83,26 +84,19 @@ VideoDeviceImpl::selectFormat()
* formats_ contains camera parameters as returned by the GetCameraInfo
* formats_ contains camera parameters as returned by the GetCameraInfo
* signal, find the matching V4L2 formats
* signal, find the matching V4L2 formats
*/
*/
unsigned
int
current
,
best
=
UINT_MAX
;
unsigned
best
=
UINT_MAX
;
for
(
const
auto
&
fmt
:
formats_
)
{
for
(
auto
fmt
:
formats_
)
{
const
struct
android_fmt
*
and_fmt
;
auto
f
=
and_formats
.
begin
()
;
for
(
and_fmt
=
std
::
begin
(
and_formats
);
for
(;
f
!=
and_formats
.
end
();
++
f
)
{
and_formats
<
std
::
end
(
and_formats
);
if
(
f
->
code
==
fmt
)
{
and_fmt
++
)
{
auto
pos
=
std
::
distance
(
and_formats
.
begin
(),
f
);
if
(
fmt
==
and_fmt
->
code
)
{
if
(
pos
<
best
)
current
=
and_fmt
-
std
::
begin
(
and_formats
)
;
best
=
pos
;
break
;
break
;
}
}
}
}
if
(
f
==
and_formats
.
end
())
/* No match found, we should add it */
if
(
and_fmt
==
std
::
end
(
and_formats
))
{
RING_WARN
(
"AndroidVideo: No format matching %d"
,
fmt
);
RING_WARN
(
"AndroidVideo: No format matching %d"
,
fmt
);
continue
;
}
if
(
current
<
best
)
best
=
current
;
}
}
if
(
best
!=
UINT_MAX
)
{
if
(
best
!=
UINT_MAX
)
{
...
@@ -119,6 +113,9 @@ VideoDeviceImpl::VideoDeviceImpl(const std::string& path) : name(path)
...
@@ -119,6 +113,9 @@ VideoDeviceImpl::VideoDeviceImpl(const std::string& path) : name(path)
{
{
std
::
vector
<
unsigned
>
sizes
;
std
::
vector
<
unsigned
>
sizes
;
std
::
vector
<
unsigned
>
rates
;
std
::
vector
<
unsigned
>
rates
;
formats_
.
reserve
(
16
);
sizes
.
reserve
(
16
);
rates
.
reserve
(
16
);
emitSignal
<
DRing
::
VideoSignal
::
GetCameraInfo
>
(
name
,
&
formats_
,
&
sizes
,
&
rates
);
emitSignal
<
DRing
::
VideoSignal
::
GetCameraInfo
>
(
name
,
&
formats_
,
&
sizes
,
&
rates
);
for
(
size_t
i
=
0
,
n
=
sizes
.
size
();
i
<
n
;
i
+=
2
)
for
(
size_t
i
=
0
,
n
=
sizes
.
size
();
i
<
n
;
i
+=
2
)
sizes_
.
emplace_back
(
sizes
[
i
],
sizes
[
i
+
1
]);
sizes_
.
emplace_back
(
sizes
[
i
],
sizes
[
i
+
1
]);
...
...
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