Commit 8a79e91e authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed android preview ratio

parent f96369ec
......@@ -5104,13 +5104,25 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) {
void linphone_core_resize_video_preview(LinphoneCore *lc, int width, int height) {
bool_t auto_camera_preview_resize = !!lp_config_get_int(lc->config, "video", "auto_resize_preview_to_keep_ratio", 0);
if (!auto_camera_preview_resize) return;
bctbx_message("Resizing video preview to: %ix%i", width, height);
#ifdef VIDEO_ENABLED
bctbx_message("Resizing camera video preview to: %ix%i", width, height);
getPlatformHelpers(lc)->resizeVideoPreview(width, height);
#endif
}
#ifdef VIDEO_ENABLED
static void video_stream_callback (void *userdata, const MSFilter *f, const unsigned int id, const void *arg) {
switch (id) {
case MS_CAMERA_PREVIEW_SIZE_CHANGED: {
LinphoneCore *lc = (LinphoneCore *)userdata;
MSVideoSize size = *(MSVideoSize *)arg;
bctbx_message("Camera video preview size changed: %ix%i", size.width, size.height);
linphone_core_resize_video_preview(lc, size.width, size.height);
break;
}
}
}
static void video_filter_callback(void *userdata, struct _MSFilter *f, unsigned int id, void *arg) {
switch(id) {
case MS_JPEG_WRITER_SNAPSHOT_TAKEN: {
......@@ -5127,13 +5139,6 @@ static void video_filter_callback(void *userdata, struct _MSFilter *f, unsigned
}
break;
}
case MS_CAMERA_PREVIEW_SIZE_CHANGED: {
MSVideoSize size = *(MSVideoSize *)arg;
bctbx_message("Camera preview size changed: %ix%i", size.width, size.height);
LinphoneCore *lc = (LinphoneCore *)userdata;
linphone_core_resize_video_preview(lc, size.width, size.height);
break;
}
}
}
#endif
......@@ -5204,9 +5209,7 @@ static void toggle_video_preview(LinphoneCore *lc, bool_t val){
if (video_preview_qrcode_enabled(lc->previewstream)) {
ms_filter_add_notify_callback(lc->previewstream->qrcode, video_filter_callback, lc, TRUE);
}
MSVideoSize size = video_preview_get_current_size(lc->previewstream);
linphone_core_resize_video_preview(lc, size.width, size.height);
ms_filter_add_notify_callback(lc->previewstream->source, video_filter_callback, lc, TRUE);
video_stream_set_event_callback(lc->previewstream, video_stream_callback, lc);
}
} else {
if (lc->previewstream != NULL) {
......
......@@ -3374,20 +3374,6 @@ void MediaSessionPrivate::startTextStream () {
lInfo() << "No valid text stream defined";
}
#ifdef VIDEO_ENABLED
static void video_filter_callback(void *userdata, struct _MSFilter *f, unsigned int id, void *arg) {
switch(id) {
case MS_CAMERA_PREVIEW_SIZE_CHANGED: {
MSVideoSize size = *(MSVideoSize *)arg;
bctbx_message("Camera preview size changed: %ix%i", size.width, size.height);
LinphoneCore *lc = (LinphoneCore *)userdata;
linphone_core_resize_video_preview(lc, size.width, size.height);
break;
}
}
}
#endif
void MediaSessionPrivate::startVideoStream (CallSession::State targetState) {
#ifdef VIDEO_ENABLED
L_Q();
......@@ -3505,12 +3491,6 @@ void MediaSessionPrivate::startVideoStream (CallSession::State targetState) {
}
}
if (videoStream->source) {
MSVideoSize size = video_preview_get_current_size(videoStream);
linphone_core_resize_video_preview(q->getCore()->getCCore(), size.width, size.height);
ms_filter_add_notify_callback(videoStream->source, video_filter_callback, q->getCore()->getCCore(), FALSE);
}
ms_media_stream_sessions_set_encryption_mandatory(&videoStream->ms.sessions, isEncryptionMandatory());
if (listener)
listener->onResetFirstVideoFrameDecoded(q->getSharedFromThis());
......@@ -4494,6 +4474,12 @@ void MediaSessionPrivate::videoStreamEventCb (const MSFilter *f, const unsigned
case MS_VIDEO_DECODER_SEND_RPSI:
/* Handled internally by mediastreamer2 */
break;
case MS_CAMERA_PREVIEW_SIZE_CHANGED: {
MSVideoSize size = *(MSVideoSize *)args;
lInfo() << "Camera video preview size changed: " << size.width << "x" << size.height;
linphone_core_resize_video_preview(q->getCore()->getCCore(), size.width, size.height);
break;
}
default:
lWarning() << "Unhandled event " << eventId;
break;
......@@ -5016,7 +5002,6 @@ LinphoneStatus MediaSession::update (const MediaSessionParams *msp, const string
video_stream_change_camera(d->videoStream, getCore()->getCCore()->video_conf.device);
else
video_stream_update_video_params(d->videoStream);
linphone_core_resize_video_preview(getCore()->getCCore(), vsize.width, vsize.height);
}
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment