using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// An entity representing a stream in a media file.
///
public class MediaFileStream : IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The number of this stream.
/// The media file.
public MediaFileStream(int streamNumber, MediaFile mediaFile)
{
StreamNumber = streamNumber;
if (mediaFile == null)
{
throw new ArgumentNullException(nameof(mediaFile));
}
mediaFile.MediaFileStreams.Add(this);
}
///
/// Initializes a new instance of the class.
///
///
/// Default constructor. Protected due to required properties, but present because EF needs it.
///
protected MediaFileStream()
{
}
///
/// Gets or sets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
///
/// Gets or sets the stream number.
///
///
/// Required.
///
public int StreamNumber { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}