rwscode / dart_castscreen

A dart package can cast video streams to UPnP & DLNA devices.
https://pub.dev/packages/castscreen
Apache License 2.0
3 stars 0 forks source link

dart_castscreen

A dart package can cast video streams to UPnP & DLNA devices.

Features

Examples

void main(List args) async { final clients = await CastScreen.discoverClient(); for (var client in clients) { print(client); } }


- [Discover client with options](https://github.com/rwscode/dart_castscreen/blob/main/test/discover_client_options/main.dart)
```dart
import 'package:castscreen/castscreen.dart';

void main(List<String> args) async {
  final clients = await CastScreen.discoverClient(
    ipv4: true,
    ipv6: false,
    port: 1900,
    ST: 'upnp:rootdevice',
    timeout: const Duration(seconds: 3),
    onError: (Exception e) => print('error: $e'),
  );
  for (var client in clients) {
    print(client);
  }
}

void main(List args) async { final devices = await CastScreen.discoverDevice(); for (var device in devices) { print(device); } }


- [Discover device with options](https://github.com/rwscode/dart_castscreen/blob/main/test/discover_device_options/main.dart)
```dart
import 'package:castscreen/castscreen.dart';

void main(List<String> args) async {
  final devices = await CastScreen.discoverDevice(
    ipv4: true,
    ipv6: false,
    port: 1900,
    ST: 'upnp:rootdevice',
    timeout: const Duration(seconds: 3),
    onError: (Exception e) => print('error: $e'),
  );
  for (var device in devices) {
    print(device);
  }
}

void main(List args) async { final devices = await CastScreen.discoverDevice(); final dev = devices.first; final alive = await dev.alive(); if (!alive) { print('Device is not alive.'); return; } final output = await dev.avTransportService! .invoke<CustomActionInput, CustomActionOutput>( 'Custom', CustomActionInput(), CustomActionInput.toMap, CustomActionOutput.fromMap, ); print(output); }

final class CustomActionInput { const CustomActionInput(); static Map<String, String> toMap(CustomActionInput input) { return {}; } }

final class CustomActionOutput { const CustomActionOutput(); factory CustomActionOutput.fromMap(Map<String, String> m) { return const CustomActionOutput(); } }


- [Invoke action for map](https://github.com/rwscode/dart_castscreen/blob/main/test/invoke_action_map/main.dart)
```dart
import 'package:castscreen/castscreen.dart';

void main(List<String> args) async {
  final devices = await CastScreen.discoverDevice();
  final dev = devices.first;
  final alive = await dev.alive();
  if (!alive) {
    print('Device is not alive.');
    return;
  }
  final output = await dev.avTransportService!.invokeMap('Custom', {});
  print(output);
}

void main(List args) async { final devices = await CastScreen.discoverDevice(); final dev = devices.first; final alive = await dev.alive(); if (!alive) { print('Device is not alive.'); return; } final output = await dev .setAVTransportURI(SetAVTransportURIInput('http://example.com/v.mp4')); print(output); }


- [Invoke stop](https://github.com/rwscode/dart_castscreen/blob/main/test/invoke_stop/main.dart)
```dart
import 'package:castscreen/castscreen.dart';

void main(List<String> args) async {
  final devices = await CastScreen.discoverDevice();
  final dev = devices.first;
  final alive = await dev.alive();
  if (!alive) {
    print('Device is not alive.');
    return;
  }
  final output = await dev.stop(StopInput());
  print(output);
}

Extensions

SCPD files

Protocol