Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Commit

Permalink
update disableLogs() implementation, fixes #115
Browse files Browse the repository at this point in the history
  • Loading branch information
tanersener committed Mar 22, 2020
1 parent 6658a89 commit 66fb0be
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@ public void apply(final LogMessage logMessage) {

} else if (call.method.equals("disableLogs")) {

Config.enableLogCallback(null);
Config.enableLogCallback(new LogCallback() {

@Override
public void apply(LogMessage message) {
// EMPTY LOG CALLBACK
}
});

} else if (call.method.equals("enableStatistics")) {

Expand Down
26 changes: 26 additions & 0 deletions ios/Classes/EmptyLogDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2020 Taner Sener
*
* This file is part of FlutterFFmpeg.
*
* FlutterFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FlutterFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FlutterFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/

#include <mobileffmpeg/LogDelegate.h>

/**
* Empty log delegate
*/
@interface EmptyLogDelegate : NSObject<LogDelegate>
@end
30 changes: 30 additions & 0 deletions ios/Classes/EmptyLogDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2020 Taner Sener
*
* This file is part of FlutterFFmpeg.
*
* FlutterFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FlutterFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FlutterFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/

#include "EmptyLogDelegate.h"

/**
* Empty log delegate
*/
@implementation EmptyLogDelegate

- (void)logCallback: (int)level :(NSString*)message {
}

@end
13 changes: 12 additions & 1 deletion ios/Classes/FlutterFfmpegPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#import "FlutterFFmpegPlugin.h"
#import "EmptyLogDelegate.h"

#import <mobileffmpeg/ArchDetect.h>
#import <mobileffmpeg/MobileFFmpegConfig.h>
Expand Down Expand Up @@ -53,6 +54,16 @@
*/
@implementation FlutterFFmpegPlugin {
FlutterEventSink _eventSink;
EmptyLogDelegate *_emptyLogDelegate;
}

- (instancetype)init {
self = [super init];
if (self) {
_emptyLogDelegate = [[EmptyLogDelegate alloc] init];
}

return self;
}

- (FlutterError *)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink)eventSink {
Expand Down Expand Up @@ -145,7 +156,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {

} else if ([@"disableLogs" isEqualToString:call.method]) {

[MobileFFmpegConfig setLogDelegate:nil];
[MobileFFmpegConfig setLogDelegate:_emptyLogDelegate];

} else if ([@"enableStatistics" isEqualToString:call.method]) {

Expand Down

0 comments on commit 66fb0be

Please sign in to comment.