Skip to content
GitLab
Explore
Sign in
Register
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
eb571498
Commit
eb571498
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
videomanager: catch exceptions
Change-Id: Ic4a90183ae7589d4ddf7dd196e54cd6e8cba02f3
parent
d10e7a1e
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
bin/jni/videomanager.i
+119
-109
119 additions, 109 deletions
bin/jni/videomanager.i
with
119 additions
and
109 deletions
bin/jni/videomanager.i
+
119
−
109
View file @
eb571498
...
...
@@ -64,6 +64,8 @@ std::vector<uint8_t> workspace;
int
rotAngle
=
0
;
AVBufferRef
*
rotMatrix
=
nullptr
;
constexpr
const
char
TAG
[]
=
"
videomanager.i
"
;
extern
JavaVM
*
gJavaVM
;
void
setRotation
(
int
angle
)
...
...
@@ -88,7 +90,7 @@ void rotateNV21(uint8_t* yinput, uint8_t* uvinput, unsigned ystride, unsigned uv
return;
}
if (rotation % 90 != 0 || rotation < 0 || rotation > 270) {
__android_log_print(ANDROID_LOG_ERROR,
"videomanager.i"
, "%u %u %d", width, height, rotation);
__android_log_print(ANDROID_LOG_ERROR,
TAG
, "%u %u %d", width, height, rotation);
return;
}
bool swap = rotation % 180 != 0;
...
...
@@ -149,6 +151,7 @@ int AndroidFormatToAVFormat(int androidformat) {
JNIEXPORT
void
JNICALL
Java_cx_ring_daemon_RingserviceJNI_captureVideoPacket
(
JNIEnv
*
jenv
,
jclass
jcls
,
jobject
buffer
,
jint
size
,
jint
offset
,
jboolean
keyframe
,
jlong
timestamp
,
jint
rotation
)
{
try {
auto frame = DRing::getNewFrame();
if (not frame)
return;
...
...
@@ -172,6 +175,9 @@ JNIEXPORT void JNICALL Java_cx_ring_daemon_RingserviceJNI_captureVideoPacket(JNI
packet->pts = timestamp;
frame->setPacket(std::move(packet));
DRing::publishFrame();
} catch (const std::exception& e) {
__android_log_print(ANDROID_LOG_ERROR, TAG, "Exception capturing video packet: %s", e.what());
}
}
JNIEXPORT
void
JNICALL
Java_cx_ring_daemon_RingserviceJNI_captureVideoFrame
(
JNIEnv
*
jenv
,
jclass
jcls
,
jobject
image
,
jint
rotation
)
...
...
@@ -184,6 +190,7 @@ JNIEXPORT void JNICALL Java_cx_ring_daemon_RingserviceJNI_captureVideoFrame(JNIE
static jmethodID imageGetPlanes = jenv->GetMethodID(imageClass, "getPlanes", "()[Landroid/media/Image$Plane;");
static jmethodID imageClose = jenv->GetMethodID(imageClass, "close", "()V");
try {
auto frame = DRing::getNewFrame();
if (not frame) {
jenv->CallVoidMethod(image, imageClose);
...
...
@@ -271,6 +278,9 @@ JNIEXPORT void JNICALL Java_cx_ring_daemon_RingserviceJNI_captureVideoFrame(JNIE
gJavaVM->DetachCurrentThread();
});
DRing::publishFrame();
} catch (const std::exception& e) {
__android_log_print(ANDROID_LOG_ERROR, TAG, "Exception capturing video frame: %s", e.what());
}
}
JNIEXPORT
jlong
JNICALL
Java_cx_ring_daemon_RingserviceJNI_acquireNativeWindow
(
JNIEnv
*
jenv
,
jclass
jcls
,
jobject
javaSurface
)
...
...
@@ -309,14 +319,14 @@ void AndroidDisplayCb(ANativeWindow *window, std::unique_ptr<DRing::FrameBuffer>
}
}
else
__android_log_print(ANDROID_LOG_WARN,
"videomanager.i"
, "Can't copy surface");
__android_log_print(ANDROID_LOG_WARN,
TAG
, "Can't copy surface");
ANativeWindow_unlockAndPost(window);
} else {
__android_log_print(ANDROID_LOG_WARN,
"videomanager.i"
, "Can't lock surface");
__android_log_print(ANDROID_LOG_WARN,
TAG
, "Can't lock surface");
}
i = std::move(frame);
} catch (...) {
__android_log_print(ANDROID_LOG_WARN,
"videomanager.i"
, "Can't copy frame: no window");
__android_log_print(ANDROID_LOG_WARN,
TAG
, "Can't copy frame: no window");
}
}
...
...
@@ -329,7 +339,7 @@ std::unique_ptr<DRing::FrameBuffer> sinkTargetPullCallback(ANativeWindow *window
ret = std::move(windows.at(window));
}
if (not ret) {
__android_log_print(ANDROID_LOG_WARN,
"videomanager.i"
, "Creating new video buffer of %zu kib", bytes/1024);
__android_log_print(ANDROID_LOG_WARN,
TAG
, "Creating new video buffer of %zu kib", bytes/1024);
ret.reset(new DRing::FrameBuffer());
}
ret->storage.resize(bytes);
...
...
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