mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
use BackgroundTask object instead of call directly sal API
This commit is contained in:
parent
9dd3f54f91
commit
017f4790b0
4 changed files with 23 additions and 33 deletions
|
|
@ -24,6 +24,7 @@
|
|||
#include "conference/conference.h"
|
||||
#include "conference/session/call-session-listener.h"
|
||||
#include "object/object-p.h"
|
||||
#include "utils/background-task.h"
|
||||
|
||||
// TODO: Remove me later.
|
||||
#include "private.h"
|
||||
|
|
@ -113,11 +114,11 @@ private:
|
|||
|
||||
CallCallbackObj nextVideoFrameDecoded;
|
||||
|
||||
unsigned long backgroundTaskId = 0;
|
||||
|
||||
bool ringingBeep = false;
|
||||
bool playingRingbackTone = false;
|
||||
|
||||
BackgroundTask bgTask;
|
||||
|
||||
L_DECLARE_PUBLIC(Call);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -186,14 +186,11 @@ void CallPrivate::onAckReceived (const shared_ptr<const CallSession> &session, L
|
|||
}
|
||||
|
||||
void CallPrivate::onBackgroundTaskToBeStarted (const shared_ptr<const CallSession> &session) {
|
||||
backgroundTaskId = sal_begin_background_task("liblinphone call notification", nullptr, nullptr);
|
||||
bgTask.start();
|
||||
}
|
||||
|
||||
void CallPrivate::onBackgroundTaskToBeStopped (const shared_ptr<const CallSession> &session) {
|
||||
if (backgroundTaskId != 0) {
|
||||
sal_end_background_task(backgroundTaskId);
|
||||
backgroundTaskId = 0;
|
||||
}
|
||||
bgTask.stop();
|
||||
}
|
||||
|
||||
bool CallPrivate::onCallSessionAccepted (const shared_ptr<const CallSession> &session) {
|
||||
|
|
@ -468,6 +465,8 @@ Call::Call (CallPrivate &p, shared_ptr<Core> core) : Object(p), CoreAccessor(cor
|
|||
L_D();
|
||||
d->nextVideoFrameDecoded._func = nullptr;
|
||||
d->nextVideoFrameDecoded._user_data = nullptr;
|
||||
|
||||
d->bgTask.setName("Liblinphone call notification");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ using namespace std;
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
FileTransferChatMessageModifier::FileTransferChatMessageModifier () {
|
||||
bgTask.setName("File transfer upload");
|
||||
}
|
||||
|
||||
belle_http_request_t *FileTransferChatMessageModifier::getHttpRequest () const {
|
||||
return httpRequest;
|
||||
}
|
||||
|
|
@ -480,29 +484,12 @@ error:
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void _chat_message_file_upload_background_task_ended (void *data) {
|
||||
FileTransferChatMessageModifier *d = (FileTransferChatMessageModifier *)data;
|
||||
d->fileUploadBackgroundTaskEnded();
|
||||
}
|
||||
|
||||
void FileTransferChatMessageModifier::fileUploadBackgroundTaskEnded () {
|
||||
lWarning() << "channel [" << this << "]: file upload background task has to be ended now, but work isn't finished.";
|
||||
fileUploadEndBackgroundTask();
|
||||
}
|
||||
|
||||
void FileTransferChatMessageModifier::fileUploadBeginBackgroundTask () {
|
||||
if (backgroundTaskId == 0) {
|
||||
backgroundTaskId = sal_begin_background_task("file transfer upload", _chat_message_file_upload_background_task_ended, this);
|
||||
if (backgroundTaskId) lInfo() << "channel [" << this << "]: starting file upload background task with id=[" << backgroundTaskId << "].";
|
||||
}
|
||||
bgTask.start();
|
||||
}
|
||||
|
||||
void FileTransferChatMessageModifier::fileUploadEndBackgroundTask () {
|
||||
if (backgroundTaskId) {
|
||||
lInfo() << "channel [" << this << "]: ending file upload background task with id=[" << backgroundTaskId << "].";
|
||||
sal_end_background_task(backgroundTaskId);
|
||||
backgroundTaskId = 0;
|
||||
}
|
||||
bgTask.stop();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include <belle-sip/belle-sip.h>
|
||||
|
||||
#include "chat-message-modifier.h"
|
||||
#include "utils/background-task.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ class FileTransferContent;
|
|||
|
||||
class FileTransferChatMessageModifier : public ChatMessageModifier {
|
||||
public:
|
||||
FileTransferChatMessageModifier () = default;
|
||||
FileTransferChatMessageModifier ();
|
||||
~FileTransferChatMessageModifier ();
|
||||
|
||||
Result encode (const std::shared_ptr<ChatMessage> &message, int &errorCode) override;
|
||||
|
|
@ -64,18 +65,20 @@ public:
|
|||
bool isFileTransferInProgressAndValid();
|
||||
|
||||
private:
|
||||
std::weak_ptr<ChatMessage> chatMessage;
|
||||
FileContent* currentFileContentToTransfer;
|
||||
unsigned long backgroundTaskId = 0;
|
||||
belle_http_request_t *httpRequest = nullptr;
|
||||
belle_http_request_listener_t *httpListener = nullptr;
|
||||
|
||||
int uploadFile();
|
||||
int startHttpTransfer(const std::string &url, const std::string &action, belle_http_request_listener_callbacks_t *cbs);
|
||||
void fileUploadBeginBackgroundTask();
|
||||
void fileUploadEndBackgroundTask();
|
||||
|
||||
void releaseHttpRequest();
|
||||
|
||||
std::weak_ptr<ChatMessage> chatMessage;
|
||||
FileContent* currentFileContentToTransfer;
|
||||
|
||||
belle_http_request_t *httpRequest = nullptr;
|
||||
belle_http_request_listener_t *httpListener = nullptr;
|
||||
|
||||
BackgroundTask bgTask;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue