Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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-client-android
Commits
70ecca1a
Commit
70ecca1a
authored
6 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
camera: run video on separate thread
Change-Id: If6e1df69da88ed396dd3a753cd2ff324e0812762
parent
0c504b61
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ring-android/app/src/main/java/cx/ring/services/CameraServiceCamera2.java
+10
-7
10 additions, 7 deletions
.../src/main/java/cx/ring/services/CameraServiceCamera2.java
with
10 additions
and
7 deletions
ring-android/app/src/main/java/cx/ring/services/CameraServiceCamera2.java
+
10
−
7
View file @
70ecca1a
...
...
@@ -20,7 +20,6 @@
package
cx.ring.services
;
import
android.content.Context
;
import
android.content.res.Configuration
;
import
android.graphics.ImageFormat
;
import
android.graphics.Point
;
import
android.graphics.SurfaceTexture
;
...
...
@@ -162,7 +161,7 @@ class CameraServiceCamera2 extends CameraService {
}
}
private
Pair
<
MediaCodec
,
Surface
>
openCameraWithEncoder
(
VideoParams
videoParams
,
String
mimeType
)
{
private
Pair
<
MediaCodec
,
Surface
>
openCameraWithEncoder
(
VideoParams
videoParams
,
String
mimeType
,
Handler
handler
)
{
final
int
BITRATE
=
1600
*
1024
;
MediaFormat
format
=
MediaFormat
.
createVideoFormat
(
mimeType
,
videoParams
.
width
,
videoParams
.
height
);
format
.
setInteger
(
MediaFormat
.
KEY_MAX_INPUT_SIZE
,
0
);
...
...
@@ -195,7 +194,7 @@ class CameraServiceCamera2 extends CameraService {
codec
.
setParameters
(
params
);
codec
.
configure
(
format
,
null
,
null
,
MediaCodec
.
CONFIGURE_FLAG_ENCODE
);
encoderInput
=
codec
.
createInputSurface
();
c
odec
.
set
Callback
(
new
MediaCodec
.
Callback
()
{
MediaC
odec
.
Callback
callback
=
new
MediaCodec
.
Callback
()
{
@Override
public
void
onInputBufferAvailable
(
@NonNull
MediaCodec
codec
,
int
index
)
{
}
...
...
@@ -216,7 +215,13 @@ class CameraServiceCamera2 extends CameraService {
public
void
onOutputFormatChanged
(
@NonNull
MediaCodec
codec
,
@NonNull
MediaFormat
format
)
{
Log
.
e
(
TAG
,
"MediaCodec onOutputFormatChanged "
+
format
);
}
});
};
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
codec
.
setCallback
(
callback
,
handler
);
}
else
{
codec
.
setCallback
(
callback
);
}
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"Can't open codec"
,
e
);
codec
=
null
;
...
...
@@ -230,14 +235,12 @@ class CameraServiceCamera2 extends CameraService {
* Compares two {@code Size}s based on their areas.
*/
static
class
CompareSizesByArea
implements
Comparator
<
Size
>
{
@Override
public
int
compare
(
Size
lhs
,
Size
rhs
)
{
// We cast here to ensure the multiplications won't overflow
return
Long
.
signum
((
long
)
lhs
.
getWidth
()
*
lhs
.
getHeight
()
-
(
long
)
rhs
.
getWidth
()
*
rhs
.
getHeight
());
}
}
public
void
requestKeyFrame
()
{
...
...
@@ -337,7 +340,7 @@ class CameraServiceCamera2 extends CameraService {
SurfaceTexture
texture
=
view
.
getSurfaceTexture
();
Surface
s
=
new
Surface
(
texture
);
final
Pair
<
MediaCodec
,
Surface
>
codec
=
hw_accel
?
openCameraWithEncoder
(
videoParams
,
MediaFormat
.
MIMETYPE_VIDEO_AVC
)
:
null
;
final
Pair
<
MediaCodec
,
Surface
>
codec
=
hw_accel
?
openCameraWithEncoder
(
videoParams
,
MediaFormat
.
MIMETYPE_VIDEO_AVC
,
handler
)
:
null
;
final
List
<
Surface
>
targets
=
new
ArrayList
<>(
2
);
targets
.
add
(
s
);
...
...
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