youtube_explode/lib/src/videos/streams/stream_manifest.dart

38 lines
1.3 KiB
Dart
Raw Normal View History

2020-06-03 13:18:37 +02:00
import 'dart:collection';
import 'audio_stream_info.dart';
import 'stream_info.dart';
2020-06-05 16:17:08 +02:00
import 'streams.dart';
2020-06-03 13:18:37 +02:00
/// Manifest that contains information about available media streams
/// in a specific video.
class StreamManifest {
/// Available streams.
final UnmodifiableListView<StreamInfo> streams;
/// Initializes an instance of [StreamManifest]
StreamManifest(Iterable<StreamInfo> streams)
: streams = UnmodifiableListView(streams);
/// Gets streams that contain audio
/// (which includes muxed and audio-only streams).
2020-06-05 20:14:22 +02:00
Iterable<AudioStreamInfo> get audio => streams.whereType<AudioStreamInfo>();
2020-06-03 13:18:37 +02:00
/// Gets streams that contain video
/// (which includes muxed and video-only streams).
2020-06-05 20:14:22 +02:00
Iterable<VideoStreamInfo> get video => streams.whereType<VideoStreamInfo>();
2020-06-03 13:18:37 +02:00
/// Gets muxed streams (contain both audio and video).
/// Note that muxed streams are limited in quality and don't go beyond 720p30.
2020-06-05 20:14:22 +02:00
Iterable<MuxedStreamInfo> get muxed => streams.whereType<MuxedStreamInfo>();
2020-06-03 13:18:37 +02:00
/// Gets audio-only streams (no video).
2020-06-05 20:14:22 +02:00
Iterable<AudioOnlyStreamInfo> get audioOnly =>
2020-06-03 13:18:37 +02:00
streams.whereType<AudioOnlyStreamInfo>();
/// Gets video-only streams (no audio).
/// These streams have the widest range of qualities available.
2020-06-05 20:14:22 +02:00
Iterable<VideoOnlyStreamInfo> get videoOnly =>
2020-06-03 13:18:37 +02:00
streams.whereType<VideoOnlyStreamInfo>();
}