Skip to content

Commit

Permalink
Set constant frame buffer size (#138)
Browse files Browse the repository at this point in the history
* Set constant frame buffer size & fix Dart formatting

* Switch to pub.dev version of dart_vlc_ffi & update changelog
  • Loading branch information
alexmercerind authored Aug 25, 2021
1 parent bb55014 commit 022871d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.7

- Fixed `Player.open` (`OnOpen` event) randomly causing crash on Windows.
- Using constant frame buffer size until #137 is resolved.

## 0.1.6

- A hotfix update to fix a critical bug.
Expand Down
5 changes: 3 additions & 2 deletions dartvlc/internal/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ class PlayerEvents : public PlayerGetters {
video_width_ = video_width;
video_height_ = video_height;
int32_t pitch = video_width * 4;
int32_t size = video_height * pitch;
video_frame_buffer_.reset(new uint8_t[size]);
// https://github.com/alexmercerind/dart_vlc/pull/137
// int32_t size = video_height * pitch;
// video_frame_buffer_.reset(new uint8_t[size]);
vlc_media_player_.setVideoCallbacks(
std::bind(&PlayerEvents::OnVideoLockCallback, this,
std::placeholders::_1),
Expand Down
6 changes: 5 additions & 1 deletion dartvlc/internal/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* GNU Lesser General Public License v2.1
*/

// https://github.com/alexmercerind/dart_vlc/pull/137
#define BUFFER_SIZE 67108864

#include <optional>
#include <vlcpp/vlc.hpp>

Expand All @@ -21,7 +24,8 @@ class PlayerInternal {
VLC::MediaListPlayer vlc_media_list_player_;
VLC::MediaList vlc_media_list_;
std::unique_ptr<PlayerState> state_ = nullptr;
std::unique_ptr<uint8_t> video_frame_buffer_ = nullptr;
std::unique_ptr<uint8_t[]> video_frame_buffer_ =
std::make_unique<uint8_t[]>(BUFFER_SIZE);
int32_t video_width_ = 0;
int32_t video_height_ = 0;
std::optional<int32_t> preferred_video_width_ = std::nullopt;
Expand Down
13 changes: 7 additions & 6 deletions lib/dart_vlc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ abstract class DartVLC {
final libraryPath = path.join(
path.dirname(Platform.resolvedExecutable), 'dart_vlc_plugin.dll');
FFI.DartVLC.initialize(libraryPath);
}
else if (Platform.isLinux) {
} else if (Platform.isLinux) {
final libraryPath = path.join(path.dirname(Platform.resolvedExecutable),
'lib', 'libdart_vlc_plugin.so');
FFI.DartVLC.initialize(libraryPath);
}
else if(Platform.isMacOS) {
final libraryPath = path.join(path.dirname(path.dirname(Platform.resolvedExecutable)),
'Frameworks', 'dart_vlc.framework', 'dart_vlc');
} else if (Platform.isMacOS) {
final libraryPath = path.join(
path.dirname(path.dirname(Platform.resolvedExecutable)),
'Frameworks',
'dart_vlc.framework',
'dart_vlc');
FFI.DartVLC.initialize(libraryPath);
}
}
Expand Down
26 changes: 13 additions & 13 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ packages:
dart_vlc_ffi:
dependency: "direct main"
description:
path: ffi
relative: true
source: path
name: dart_vlc_ffi
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.2"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -75,14 +75,14 @@ packages:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.2"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.2"
path_provider_platform_interface:
dependency: transitive
description:
Expand All @@ -96,28 +96,28 @@ packages:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.3"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.2"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.1"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
version: "4.2.3"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -143,7 +143,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.2.6"
xdg_directories:
dependency: transitive
description:
Expand All @@ -152,5 +152,5 @@ packages:
source: hosted
version: "0.2.0"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=2.13.0 <3.0.0"
flutter: ">=2.0.0"
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ environment:
dependencies:
flutter:
sdk: flutter
dart_vlc_ffi:
path: ./ffi
dart_vlc_ffi: ^0.1.4
path: ">=1.8.0 <2.0.0"
path_provider: ">=2.0.2 <3.0.0"
audio_video_progress_bar: ">=0.9.0 <1.0.0"
Expand Down

0 comments on commit 022871d

Please sign in to comment.