Commit 03144434 authored by DanmeiChen's avatar DanmeiChen
Browse files

rework notify callback later

parent b401a0b0
......@@ -5705,10 +5705,8 @@ static void video_filter_callback(void *userdata, struct _MSFilter *f, unsigned
LinphoneCore *lc = (LinphoneCore *)userdata;
if (linphone_core_cbs_get_qrcode_found(linphone_core_get_current_callbacks(lc)) != NULL) {
char* result = ms_strdup((const char*)arg);
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->doLater([lc, result]() {
linphone_core_notify_qrcode_found(lc, result);
ms_free(result);
});
linphone_core_notify_qrcode_found(lc, result);
ms_free(result);
}
break;
}
......@@ -5734,7 +5732,7 @@ LinphoneStatus linphone_core_take_preview_snapshot(LinphoneCore *lc, const char
lc->previewstream->ms.factory = lc->factory;
linphone_core_enable_video_preview(lc, TRUE);
ms_filter_add_notify_callback(lc->previewstream->local_jpegwriter, video_filter_callback, lc, TRUE);
ms_filter_add_notify_callback(lc->previewstream->local_jpegwriter, video_filter_callback, lc, FALSE);
ms_filter_call_method(lc->previewstream->local_jpegwriter, MS_JPEG_WRITER_TAKE_SNAPSHOT, (void*)file);
} else {
ms_filter_call_method(lc->previewstream->local_jpegwriter, MS_JPEG_WRITER_TAKE_SNAPSHOT, (void*)file);
......@@ -5780,7 +5778,7 @@ static void toggle_video_preview(LinphoneCore *lc, bool_t val){
}
video_preview_start(lc->previewstream, lc->video_conf.device);
if (video_preview_qrcode_enabled(lc->previewstream)) {
ms_filter_add_notify_callback(lc->previewstream->qrcode, video_filter_callback, lc, TRUE);
ms_filter_add_notify_callback(lc->previewstream->qrcode, video_filter_callback, lc, FALSE);
}
video_stream_set_event_callback(lc->previewstream, video_stream_callback, lc);
}
......
......@@ -657,13 +657,8 @@ void Call::onTmmbrReceived (const shared_ptr<CallSession> &session, int streamIn
linphone_call_notify_tmmbr_received(this->toC(), streamIndex, tmmbr);
}
void Call::onSnapshotTaken(const shared_ptr<CallSession> &session, const char *file_path) {
char* file = ms_strdup((const char*)file_path);
getCore()->doLater([this, file](){
linphone_call_notify_snapshot_taken(this->toC(), file);
ms_free(file);
});
linphone_call_notify_snapshot_taken(this->toC(), file_path);
}
// =============================================================================
......
......@@ -465,8 +465,8 @@ void MS2VideoControl::requestNotifyNextVideoFrameDecoded () {
void MS2VideoControl::sSnapshotTakenCb(void *userdata, struct _MSFilter *f, unsigned int id, void *arg) {
MS2VideoControl *d = (MS2VideoControl *)userdata;
if (id == MS_JPEG_WRITER_SNAPSHOT_TAKEN) {
const char *filepath = (const char *) arg;
d->onSnapshotTaken(filepath);
MSJpegWriteEventData *data = static_cast<MSJpegWriteEventData *>(arg);
d->onSnapshotTaken(data->filePath);
}
}
......@@ -475,7 +475,7 @@ int MS2VideoControl::takePreviewSnapshot (const string& file) {
if (vs && vs->local_jpegwriter) {
ms_filter_clear_notify_callback(vs->jpegwriter);
const char *filepath = file.empty() ? nullptr : file.c_str();
ms_filter_add_notify_callback(vs->local_jpegwriter, sSnapshotTakenCb, this, TRUE);
ms_filter_add_notify_callback(vs->local_jpegwriter, sSnapshotTakenCb, this, FALSE);
return ms_filter_call_method(vs->local_jpegwriter, MS_JPEG_WRITER_TAKE_SNAPSHOT, (void *)filepath);
}
lWarning() << "Cannot take local snapshot: no currently running video stream on this call";
......@@ -487,7 +487,7 @@ int MS2VideoControl::takeVideoSnapshot (const string& file) {
if (vs && vs->jpegwriter) {
ms_filter_clear_notify_callback(vs->jpegwriter);
const char *filepath = file.empty() ? nullptr : file.c_str();
ms_filter_add_notify_callback(vs->jpegwriter, sSnapshotTakenCb, this, TRUE);
ms_filter_add_notify_callback(vs->jpegwriter, sSnapshotTakenCb, this, FALSE);
return ms_filter_call_method(vs->jpegwriter, MS_JPEG_WRITER_TAKE_SNAPSHOT, (void *)filepath);
}
lWarning() << "Cannot take snapshot: no currently running video stream on this call";
......
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