Skip to content

Commit 56dfd82

Browse files
Merge pull request #73 from alexmercerind/ffi-migration
[dart_vlc_ffi] Migration to FFI
2 parents 586646a + 52f9f60 commit 56dfd82

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2469
-3470
lines changed

README.md

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22
<h4 align="center">Flutter 🎞 media playback, broadcast, recording & chromecast library for Windows & Linux.</h4>
33
<h5 align="center">Written in C++ using libVLC & libVLC++.</h5>
44

5+
![](https://github.com/alexmercerind/dart_vlc/blob/assets/dart_vlc_6.png?raw=true)
6+
7+
![](https://github.com/alexmercerind/dart_vlc/blob/assets/dart_vlc_7.png?raw=true)
8+
59
## Installation
610

11+
**Flutter**
12+
713
```yaml
814
dependencies:
915
...
1016
dart_vlc: ^0.0.8
1117
```
1218
13-
![](https://github.com/alexmercerind/dart_vlc/blob/assets/dart_vlc_6.png?raw=true)
19+
**Dart CLI**
1420
15-
![](https://github.com/alexmercerind/dart_vlc/blob/assets/dart_vlc_7.png?raw=true)
21+
```yaml
22+
dependencies:
23+
...
24+
dart_vlc_ffi: ^0.0.1
25+
```
26+
27+
More on Dart CLI implementation [here](./ffi/README.md).
1628
1729
1830
## Support
@@ -21,26 +33,44 @@ Consider supporting the project by starring the repository or buying me a coffee
2133
2234
<a href="https://www.buymeacoffee.com/alexmercerind"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=alexmercerind&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff"></a>
2335
36+
**Donate in Crypto**
37+
38+
- ETH (Ethereum)
39+
- `0x92f92BC204cDFDAB655e6A69e5Aa4bA5476D7661`
40+
- BTC (Bitcoin)
41+
- `1M3DNwnX1GDauPoPr7VywojMRWygje8ctq`
42+
43+
Thanks a lot for your support.
44+
2445
Looking for contributors for macOS port.
2546

2647
## Documentation
2748

49+
#### Initialize the library
50+
51+
```dart
52+
void main() {
53+
DartVLC.initialize();
54+
runApp(MyApp());
55+
}
56+
```
57+
2858
#### Create a new player instance.
2959
```dart
3060
Player player = new Player(id: 69420);
3161
```
3262

3363
#### Create a media for playback.
3464
```dart
35-
Media media0 = await Media.file(
65+
Media media0 = Media.file(
3666
new File('C:/music.mp3')
3767
);
3868
39-
Media media1 = await Media.network(
69+
Media media1 = Media.network(
4070
'https://www.example.com/music.aac'
4171
);
4272
43-
Media media2 = await Media.asset(
73+
Media media2 = Media.asset(
4474
'assets/music.ogg'
4575
);
4676
```
@@ -49,24 +79,32 @@ Media media2 = await Media.asset(
4979
```dart
5080
Playlist playlist = new Playlist(
5181
medias: [
52-
await Media.file(new File('C:/music.mp3')),
53-
await Media.asset('assets/music.ogg'),
54-
await Media.network('https://www.example.com/music.aac'),
82+
Media.file(new File('C:/music.mp3')),
83+
Media.asset('assets/music.ogg'),
84+
Media.network('https://www.example.com/music.aac'),
5585
],
5686
);
5787
```
5888

5989
#### Open a media or playlist into a player.
90+
91+
```dart
92+
player.open(
93+
Media.file(new File('C:/music0.mp3')),
94+
autoStart: true, // default
95+
);
96+
```
97+
6098
```dart
6199
player.open(
62100
new Playlist(
63101
medias: [
64-
await Media.file(new File('C:/music0.mp3')),
65-
await Media.file(new File('C:/music1.mp3')),
66-
await Media.file(new File('C:/music2.mp3')),
102+
Media.file(new File('C:/music0.mp3')),
103+
Media.file(new File('C:/music1.mp3')),
104+
Media.file(new File('C:/music2.mp3')),
67105
],
68106
),
69-
autoStart: true, // default
107+
autoStart: false,
70108
);
71109
```
72110

@@ -95,14 +133,14 @@ player.jump(10);
95133
#### Manipulate an already playing playlist.
96134
```dart
97135
player.add(
98-
await Media.file(new File('C:/music0.mp3')),
136+
Media.file(new File('C:/music0.mp3')),
99137
);
100138
101139
player.remove(4);
102140
103141
player.insert(
104142
2,
105-
await Media.file(new File('C:/music0.mp3')),
143+
Media.file(new File('C:/music0.mp3')),
106144
);
107145
108146
player.move(0, 4);
@@ -117,7 +155,7 @@ player.setRate(1.25);
117155

118156
#### Get & change playback device.
119157
```dart
120-
List<Device> devices = await Devices.all;
158+
List<Device> devices = Devices.all;
121159
122160
player.setDevice(
123161
devices[0],
@@ -156,7 +194,7 @@ Thanks to [@tomassasovsky](https://github.com/tomassasovsky) for adding visual c
156194

157195
#### Retrieve metadata of media.
158196
```dart
159-
Media media = await Media.network(
197+
Media media = Media.network(
160198
'https://www.example.com/media.mp3',
161199
parse: true,
162200
timeout: new Duration(seconds: 10),
@@ -205,14 +243,14 @@ player.generalStream.listen((GeneralState state) {
205243
Create using preset.
206244

207245
```dart
208-
Equalizer equalizer = await Equalizer.createMode(EqualizerMode.party);
246+
Equalizer equalizer = Equalizer.createMode(EqualizerMode.party);
209247
player.setEqualizer(equalizer);
210248
```
211249

212250
Create custom equalizer.
213251

214252
```dart
215-
Equalizer equalizer = await Equalizer.createEmpty();
253+
Equalizer equalizer = Equalizer.createEmpty();
216254
equalizer.setPreAmp(10.0);
217255
equalizer.setBandAmp(31.25, -10.0);
218256
equalizer.setBandAmp(100.0, -10.0);
@@ -231,9 +269,9 @@ equalizer.bandAmps;
231269
Broadcasting to localhost.
232270

233271
```dart
234-
Broadcast broadcast = await Broadcast.create(
272+
Broadcast broadcast = Broadcast.create(
235273
id: 0,
236-
media: await Media.file(new File('C:/video.mp4')),
274+
media: Media.file(new File('C:/video.mp4')),
237275
configuration: new BroadcastConfiguration(
238276
access: 'http',
239277
mux: 'mpeg1',
@@ -257,9 +295,9 @@ broadcast.dispose();
257295
Thanks to [@DomingoMG](https://github.com/DomingoMG) for adding `Record` and `Chromecast` classes.
258296

259297
```dart
260-
Record record = await Record.create(
298+
Record record = Record.create(
261299
id: 205,
262-
media: await Media.network('https://www.example.com/streaming-media.MP3'),
300+
media: Media.network('https://www.example.com/streaming-media.MP3'),
263301
pathFile: '/home/alexmercerind/recording.MP3',
264302
);
265303
record.start();
@@ -298,12 +336,10 @@ Windows
298336

299337

300338
## Workings
339+
The repository contains a [C++ wrapper](https://github.com/alexmercerind/dart_vlc/tree/master/dartvlc) based on libVLC++. This makes handling of events and controls a lot easier & has additional features in it.
340+
I preferred to do majority of handling in C++ itself, thus Dart code is minimal & very slight mapping to it.
301341

302-
The internal wrapper used in the plugin is [here](https://github.com/alexmercerind/dart_vlc/tree/master/dartvlc) in the repository (Based on libVLC++). It makes handling of events and controls a lot easier & has additional features to it.
303-
304-
Same wrapper will be used for upcoming FFI version.
305-
306-
I preferred to do majority of plugin handling in C++ itself, thus Dart code is minimal & very slight mapping to it.
342+
This project might seem like a Flutter plugin, but it is based on FFI instead. [Here](https://github.com/alexmercerind/dart_vlc/tree/master/ffi) are the FFI bindings to [C++ wrapper](https://github.com/alexmercerind/dart_vlc/tree/master/dartvlc), which are shared by all platforms & same can be used in Dart CLI apps aswell.
307343

308344
## Progress
309345

@@ -348,10 +384,10 @@ Done
348384
- `Chromecast` class.
349385
- `Equalizer` support.
350386
- Adding headers for `Media.network` (Not possible, added user agent).
387+
- Switching to FFI for more cross platform freedom.
351388

352389
Under progress or planned features (irrespective of order)...
353390

354-
- FFI version of the library for plain Dart applications.
355391
- Removing [libVLC++](https://github.com/videolan/libvlcpp) dependency. (Maybe).
356392
- Writing metadata tags.
357393
- Making things more efficient.
@@ -363,7 +399,7 @@ Under progress or planned features (irrespective of order)...
363399

364400
First of all, thanks to the [VideoLAN](https://www.videolan.org) team for creating [libVLC](https://github.com/videolan/vlc) & [libVLC++](https://github.com/videolan/libvlcpp). Really great guys really great at their work.
365401

366-
Massive thanks to [@stuartmorgan](https://github.com/stuartmorgan) from [Flutter](http://flutter.dev) team to review code & help me fix the loopholes.
402+
Massive thanks to [@stuartmorgan](https://github.com/stuartmorgan) from [Flutter](http://flutter.dev) team to my review code & help me fix the loopholes.
367403

368404
Thanks to following members of libVLC community to give me bit of look & advice about how things work:
369405

@@ -382,15 +418,15 @@ Contributions to the project are open, it will be appreciated if you discuss the
382418

383419
## License
384420

385-
Copyright (C) 2021, Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
421+
Copyright (C) 2021, Hitesh Kumar Saini <saini123hitesh@gmail.com>.
386422

387423
This library & work under this repository is licensed under GNU Lesser General Public License v2.1.
388424

389425
## Vision
390426

391-
There aren't any media (audio or video) playback libraries for Flutter on Windows/Linux yet. So, this project is all about that.
427+
There aren't any media (audio or video) playback libraries for Flutter or Dart on Windows/Linux yet. So, this project is all about that.
392428
As one might be already aware, VLC is one of the best media playback tools out there.
393429

394-
So, now you can use it to play audio or video files from Flutter Desktop apps.
430+
So, now you can use it to play audio or video files from Flutter or Dart apps.
395431

396-
Although, the mentioned repositories above are for audio playback, video playback is also a part of consideration for this project.
432+
Support for other platforms is also under progress.

dartvlc/broadcast.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* dart_vlc: A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
33
*
4-
* Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
4+
* Hitesh Kumar Saini
55
* https://github.com/alexmercerind
6-
* alexmercerind@gmail.com
6+
* saini123hitesh@gmail.com; alexmercerind@gmail.com
77
*
88
* GNU Lesser General Public License v2.1
99
*/

dartvlc/chromecast.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* dart_vlc: A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
33
*
4-
* Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
4+
* Hitesh Kumar Saini
55
* https://github.com/alexmercerind
6-
* alexmercerind@gmail.com
6+
* saini123hitesh@gmail.com; alexmercerind@gmail.com
77
*
88
* GNU Lesser General Public License v2.1
99
*/
@@ -29,7 +29,7 @@ class Chromecast {
2929
this->instance = VLC::Instance(0, nullptr);
3030
}
3131

32-
void send() {
32+
void start() {
3333
std::stringstream sout;
3434
sout << "#chromecast{ip="<< this->ipAddress <<", demux-filter=demux_chromecast, conversion-quality=0}";
3535
libvlc_vlm_add_broadcast(
@@ -59,9 +59,9 @@ class Chromecast {
5959

6060
class Chromecasts {
6161
public:
62-
Chromecast* get(int id, Media* media, std::string pathFile) {
62+
Chromecast* get(int id, Media* media, std::string ipAddress) {
6363
if (this->chromecasts.find(id) == this->chromecasts.end()) {
64-
this->chromecasts[id] = new Chromecast(id, media, pathFile);
64+
this->chromecasts[id] = new Chromecast(id, media, ipAddress);
6565
}
6666
return this->chromecasts[id];
6767
}

dartvlc/device.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* dart_vlc: A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
33
*
4-
* Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
4+
* Hitesh Kumar Saini
55
* https://github.com/alexmercerind
6-
* alexmercerind@gmail.com
6+
* saini123hitesh@gmail.com; alexmercerind@gmail.com
77
*
88
* GNU Lesser General Public License v2.1
99
*/

dartvlc/equalizer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* dart_vlc: A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
33
*
4-
* Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
4+
* Hitesh Kumar Saini
55
* https://github.com/alexmercerind
6-
* alexmercerind@gmail.com
6+
* saini123hitesh@gmail.com; alexmercerind@gmail.com
77
*
88
* GNU Lesser General Public License v2.1
99
*/

dartvlc/internal/events.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* dart_vlc: A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
33
*
4-
* Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
4+
* Hitesh Kumar Saini
55
* https://github.com/alexmercerind
6-
* alexmercerind@gmail.com
6+
* saini123hitesh@gmail.com; alexmercerind@gmail.com
77
*
88
* GNU Lesser General Public License v2.1
99
*/

dartvlc/internal/getters.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* dart_vlc: A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
33
*
4-
* Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
4+
* Hitesh Kumar Saini
55
* https://github.com/alexmercerind
6-
* alexmercerind@gmail.com
6+
* saini123hitesh@gmail.com; alexmercerind@gmail.com
77
*
88
* GNU Lesser General Public License v2.1
99
*/

dartvlc/internal/internal.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* dart_vlc: A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
33
*
4-
* Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
4+
* Hitesh Kumar Saini
55
* https://github.com/alexmercerind
6-
* alexmercerind@gmail.com
6+
* saini123hitesh@gmail.com; alexmercerind@gmail.com
77
*
88
* GNU Lesser General Public License v2.1
99
*/

dartvlc/internal/setters.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* dart_vlc: A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
33
*
4-
* Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
4+
* Hitesh Kumar Saini
55
* https://github.com/alexmercerind
6-
* alexmercerind@gmail.com
6+
* saini123hitesh@gmail.com; alexmercerind@gmail.com
77
*
88
* GNU Lesser General Public License v2.1
99
*/

dartvlc/internal/state.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* dart_vlc: A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
33
*
4-
* Hitesh Kumar Saini, Domingo Montesdeoca Gonzalez & contributors.
4+
* Hitesh Kumar Saini
55
* https://github.com/alexmercerind
6-
* alexmercerind@gmail.com
6+
* saini123hitesh@gmail.com; alexmercerind@gmail.com
77
*
88
* GNU Lesser General Public License v2.1
99
*/

0 commit comments

Comments
 (0)