2020-06-05 16:17:08 +02:00
|
|
|
import 'streams.dart';
|
2020-06-03 13:18:37 +02:00
|
|
|
|
|
|
|
/// YouTube media stream that contains video.
|
|
|
|
abstract class VideoStreamInfo extends StreamInfo {
|
|
|
|
/// Video codec.
|
|
|
|
final String videoCodec;
|
|
|
|
|
|
|
|
/// Video quality label, as seen on YouTube.
|
|
|
|
final String videoQualityLabel;
|
|
|
|
|
|
|
|
/// Video quality.
|
|
|
|
final VideoQuality videoQuality;
|
|
|
|
|
|
|
|
/// Video resolution.
|
|
|
|
final VideoResolution videoResolution;
|
|
|
|
|
|
|
|
/// Video framerate.
|
|
|
|
final Framerate framerate;
|
|
|
|
|
|
|
|
///
|
|
|
|
VideoStreamInfo(
|
|
|
|
int tag,
|
|
|
|
Uri url,
|
|
|
|
Container container,
|
|
|
|
FileSize size,
|
|
|
|
Bitrate bitrate,
|
|
|
|
this.videoCodec,
|
|
|
|
this.videoQualityLabel,
|
|
|
|
this.videoQuality,
|
|
|
|
this.videoResolution,
|
|
|
|
this.framerate)
|
|
|
|
: super(tag, url, container, size, bitrate);
|
|
|
|
}
|
|
|
|
|
2020-06-06 16:07:51 +02:00
|
|
|
/// Extensions for Iterables of [VideoStreamInfo]
|
|
|
|
extension VideoStreamInfoExtension on Iterable<VideoStreamInfo> {
|
|
|
|
/// Gets all video qualities available in a collection of video streams.
|
|
|
|
Set<VideoQuality> getAllVideoQualities() =>
|
|
|
|
map((e) => e.videoQuality).toSet();
|
|
|
|
|
|
|
|
/// Gets video quality labels of all streams available in
|
|
|
|
/// a collection of video streams.
|
|
|
|
/// This could be longer than [getAllVideoQualities] since this gives also all
|
|
|
|
/// the different fps.
|
|
|
|
Set<String> getAllVideoQualitiesLabel() =>
|
|
|
|
map((e) => e.videoQualityLabel).toSet();
|
|
|
|
|
|
|
|
/// Gets the video stream with highest video quality.
|
|
|
|
List<VideoStreamInfo> sortByVideoQuality() => toList()
|
|
|
|
..sort((a, b) => b.framerate.compareTo(a.framerate))
|
|
|
|
..sort((a, b) => b.videoQuality.index.compareTo(a.videoQuality.index));
|
|
|
|
}
|