Commit e4fd443b authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed corrupted QRCode result

parent f08aebe2
......@@ -22,7 +22,11 @@
#include <mediastreamer2/msfilter.h>
#define MS_QRCODE_READER_QRCODE_FOUND MS_FILTER_EVENT(MS_QRCODE_READER_ID, 0, const char*)
typedef struct _MSQrCodeReaderEventData {
char data[255];
} MSQrCodeReaderEventData;
#define MS_QRCODE_READER_QRCODE_FOUND MS_FILTER_EVENT(MS_QRCODE_READER_ID, 0, MSQrCodeReaderEventData)
#define MS_QRCODE_READER_RESET_SEARCH MS_FILTER_METHOD_NO_ARG(MS_QRCODE_READER_ID, 0)
#define MS_QRCODE_READET_SET_DECODER_RECT MS_FILTER_METHOD(MS_QRCODE_READER_ID, 1, MSRect)
......
......@@ -67,10 +67,6 @@ typedef struct {
MSFilter *f;
}QRCodeReaderStruct;
typedef struct {
char resultText[512];//Can be changed depending on the size of the URL
}QRCodeReaderNotifyStruct;
static void qrcode_init(MSFilter *f) {
QRCodeReaderStruct *qrc = ms_new0(QRCodeReaderStruct, 1);
qrc->searchQRCode = TRUE;
......@@ -105,7 +101,6 @@ static int set_decoder_rect(MSFilter *f, void *arg) {
static void read_qrcode(MSFilter *f) {
QRCodeReaderStruct *qrc = (QRCodeReaderStruct *)f->data;
if (qrc->image) {
QRCodeReaderNotifyStruct qrcNotify;
Ref<Result> result;
Ref<Binarizer> binarizer;
binarizer = new HybridBinarizer(qrc->image->getLuminanceSource());
......@@ -119,9 +114,10 @@ static void read_qrcode(MSFilter *f) {
return;
}
Ref<String> text = result->getText();
snprintf(qrcNotify.resultText, sizeof(qrcNotify.resultText), "%s", text->getText().c_str());
MSQrCodeReaderEventData data = {{0}};
snprintf(data.data, sizeof(data.data), "%s", text->getText().c_str());
qrc->searchQRCode = FALSE;
ms_filter_notify(f, MS_QRCODE_READER_QRCODE_FOUND, qrcNotify.resultText);
ms_filter_notify(f, MS_QRCODE_READER_QRCODE_FOUND, &data);
}
}
......
......@@ -46,7 +46,8 @@ static void qrcode_found_cb(void *data, MSFilter *f, unsigned int event_id, void
if (event_id == MS_QRCODE_READER_QRCODE_FOUND) {
qrcode_callback_data *found = (qrcode_callback_data *)data;
found->qrcode_found = TRUE;
if (arg) found->text = ms_strdup((char *)arg);
MSQrCodeReaderEventData *data = (MSQrCodeReaderEventData *)arg;
if (arg) found->text = ms_strdup((char *)data->data);
}
}
......
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