Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gst-plugins-bad
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Justin Kim
gst-plugins-bad
Commits
9a89dac1
Commit
9a89dac1
authored
Oct 09, 2017
by
Justin Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ahc2src: accept framerate settings
parent
a04acb2b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
31 deletions
+53
-31
sys/androidmedia/gstahc2src.c
sys/androidmedia/gstahc2src.c
+53
-31
No files found.
sys/androidmedia/gstahc2src.c
View file @
9a89dac1
...
...
@@ -1078,7 +1078,8 @@ gst_ahc2_src_set_caps (GstBaseSrc * src, GstCaps * caps)
GstVideoFormat
format
;
gint
fmt
=
-
1
;
const
gchar
*
format_str
=
NULL
;
gint
width
,
height
,
fps_n
,
fps_d
;
const
GValue
*
framerate_value
;
gint
width
,
height
,
fps_min
=
0
,
fps_max
=
0
;
ANativeWindow
*
image_reader_window
=
NULL
;
...
...
@@ -1093,9 +1094,30 @@ gst_ahc2_src_set_caps (GstBaseSrc * src, GstCaps * caps)
gst_structure_get_int
(
s
,
"width"
,
&
width
);
gst_structure_get_int
(
s
,
"height"
,
&
height
);
gst_structure_get_fraction
(
s
,
"framerate"
,
&
fps_n
,
&
fps_d
);
framerate_value
=
gst_structure_get_value
(
s
,
"framerate"
);
fps_n
*=
1000
/
fps_d
;
if
(
GST_VALUE_HOLDS_FRACTION_RANGE
(
framerate_value
))
{
const
GValue
*
min
,
*
max
;
min
=
gst_value_get_fraction_range_min
(
framerate_value
);
max
=
gst_value_get_fraction_range_max
(
framerate_value
);
fps_min
=
gst_value_get_fraction_numerator
(
min
)
/
gst_value_get_fraction_denominator
(
min
);
fps_max
=
gst_value_get_fraction_numerator
(
max
)
/
gst_value_get_fraction_denominator
(
max
);
}
else
if
(
GST_VALUE_HOLDS_FRACTION
(
framerate_value
))
{
fps_min
=
fps_max
=
gst_value_get_fraction_numerator
(
framerate_value
)
/
gst_value_get_fraction_denominator
(
framerate_value
);
}
else
{
GST_WARNING_OBJECT
(
self
,
"framerate holds unrecognizable value"
);
}
if
(
fps_min
!=
0
&&
fps_max
!=
0
)
{
gint
fps_range
[
2
]
=
{
fps_min
,
fps_max
};
ACaptureRequest_setEntry_i32
(
priv
->
capture_request
,
ACAMERA_CONTROL_AE_TARGET_FPS_RANGE
,
2
,
fps_range
);
GST_DEBUG_OBJECT
(
self
,
"setting fps range [%d, %d]"
,
fps_min
,
fps_max
);
}
switch
(
format
)
{
case
GST_VIDEO_FORMAT_NV12
:
...
...
@@ -1182,7 +1204,7 @@ gst_ahc2_src_get_caps (GstBaseSrc * src, GstCaps * filter)
GstStructure
*
format
=
NULL
;
ACameraMetadata
*
metadata
=
NULL
;
ACameraMetadata_const_entry
entry
;
ACameraMetadata_const_entry
entry
,
fps_entry
;
if
(
ACameraManager_getCameraCharacteristics
(
priv
->
camera_manager
,
priv
->
camera_id_list
->
cameraIds
[
priv
->
camera_index
],
...
...
@@ -1261,16 +1283,16 @@ gst_ahc2_src_get_caps (GstBaseSrc * src, GstCaps * filter)
g_free
(
cap_str
);
}
}
#endif
GST_DEBUG_OBJECT
(
self
,
"Checking available FPS ranges:"
);
if
(
ACameraMetadata_getConstEntry
(
metadata
,
ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
,
&
entry
)
==
ACAMERA_OK
)
{
ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
,
&
fps_
entry
)
==
ACAMERA_OK
)
{
int
i
=
0
;
for
(;
i
<
entry
.
count
;
i
++
)
{
GST_DEBUG_OBJECT
(
self
,
" (min: %d, max: %d)"
,
entry
.
data
.
i32
[
i
*
2
],
entry
.
data
.
i32
[
i
*
2
+
1
]);
for
(;
i
<
fps_entry
.
count
;
i
+=
2
)
{
GST_DEBUG_OBJECT
(
self
,
" (min: %d, max: %d)"
,
fps_entry
.
data
.
i32
[
i
],
fps_entry
.
data
.
i32
[
i
+
1
]);
}
}
#endif
/* Only NV12 is acceptable. */
format
=
gst_structure_new
(
"video/x-raw"
,
...
...
@@ -1281,26 +1303,40 @@ gst_ahc2_src_get_caps (GstBaseSrc * src, GstCaps * filter)
ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS
,
&
entry
)
==
ACAMERA_OK
)
{
gint
i
=
0
;
for
(;
i
<
entry
.
count
;
i
++
)
{
gint
input
=
entry
.
data
.
i32
[
i
*
4
+
3
];
gint
fmt
=
entry
.
data
.
i32
[
i
*
4
+
0
];
for
(;
i
<
entry
.
count
;
i
+=
4
)
{
gint
input
=
entry
.
data
.
i32
[
i
+
3
];
gint
fmt
=
entry
.
data
.
i32
[
i
+
0
];
if
(
input
)
continue
;
if
(
fmt
==
AIMAGE_FORMAT_YUV_420_888
)
{
gint
width
=
entry
.
data
.
i32
[
i
*
4
+
1
];
gint
height
=
entry
.
data
.
i32
[
i
*
4
+
2
];
gint
fps_idx
=
0
;
gint
width
=
entry
.
data
.
i32
[
i
+
1
];
gint
height
=
entry
.
data
.
i32
[
i
+
2
];
GstStructure
*
size
=
gst_structure_copy
(
format
);
GST_DEBUG_OBJECT
(
self
,
" (w: %d, h: %d)"
,
width
,
height
);
gst_structure_set
(
size
,
"width"
,
G_TYPE_INT
,
width
,
"height"
,
G_TYPE_INT
,
height
,
"interlaced"
,
G_TYPE_BOOLEAN
,
FALSE
,
"pixel-aspect-ratio"
,
GST_TYPE_FRACTION
,
1
,
1
,
NULL
);
gst_caps_append_structure
(
caps
,
size
);
GST_DEBUG_OBJECT
(
self
,
" (w: %d, h: %d)"
,
width
,
height
);
for
(
fps_idx
=
0
;
fps_idx
<
fps_entry
.
count
;
fps_idx
+=
2
)
{
GstStructure
*
s
=
gst_structure_copy
(
size
);
if
(
fps_entry
.
data
.
i32
[
fps_idx
]
==
fps_entry
.
data
.
i32
[
fps_idx
+
1
])
{
gst_structure_set
(
s
,
"framerate"
,
GST_TYPE_FRACTION
,
fps_entry
.
data
.
i32
[
fps_idx
],
1
,
NULL
);
}
else
{
gst_structure_set
(
s
,
"framerate"
,
GST_TYPE_FRACTION_RANGE
,
fps_entry
.
data
.
i32
[
fps_idx
],
1
,
fps_entry
.
data
.
i32
[
fps_idx
+
1
],
1
,
NULL
);
}
gst_caps_append_structure
(
caps
,
s
);
}
gst_structure_free
(
size
);
}
}
}
else
{
...
...
@@ -1723,7 +1759,7 @@ image_reader_on_image_available (void *context, AImageReader * reader)
gst_wrapped_aimage_ref
(
wrapped_aimage
),
(
GDestroyNotify
)
gst_wrapped_aimage_unref
);
GST_
DEBUG
_OBJECT
(
self
,
"Created a wrapped memory (ptr: %p, length: %d)"
,
GST_
TRACE
_OBJECT
(
self
,
"Created a wrapped memory (ptr: %p, length: %d)"
,
mem
,
length
);
gst_buffer_append_memory
(
buffer
,
mem
);
}
...
...
@@ -1742,7 +1778,7 @@ image_reader_on_image_available (void *context, AImageReader * reader)
gst_wrapped_aimage_unref
(
wrapped_aimage
);
g_mutex_unlock
(
&
priv
->
mutex
);
GST_
DEBUG
_OBJECT
(
self
,
GST_
TRACE
_OBJECT
(
self
,
"created buffer from image callback %"
G_GSIZE_FORMAT
", ts %"
GST_TIME_FORMAT
", dur %"
GST_TIME_FORMAT
", offset %"
G_GINT64_FORMAT
", offset_end %"
G_GINT64_FORMAT
,
...
...
@@ -2099,17 +2135,3 @@ gst_ahc2_src_photography_init (gpointer g_iface, gpointer iface_data)
iface
->
get_zoom
=
gst_ahc2_src_get_zoom
;
iface
->
set_zoom
=
gst_ahc2_src_set_zoom
;
}
#if 0
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "ahc2src", GST_RANK_NONE,
GST_TYPE_AHC2_SRC)) {
GST_ERROR ("Failed to register android camera2 source");
return FALSE;
}
return TRUE;
}
#endif
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