public MediaServer.Storage.ProtoGenerated.Session CreateNewSession ( MediaFileId mediaFileId, TimeSpan mediaDuration, TimeSpan?startPosition = null ) { var timeWatched = new Duration { EndPostionInSec = 0, StartPostionInSec = 0 }; if (startPosition.HasValue) { timeWatched.StartPostionInSec = startPosition.Value.TotalSeconds; timeWatched.EndPostionInSec = startPosition.Value.TotalSeconds; } var session = new MediaServer.Storage.ProtoGenerated.Session { Id = Guid.NewGuid().ToString("N"), MediaId = mediaFileId.ToString(), Duration = timeWatched, StartUTC = _timeService.GetCurrentTimeAsUnixSeconds(), EndUTC = _timeService.GetCurrentTimeAsUnixSeconds(), MediaLenghtInSec = mediaDuration.TotalSeconds, }; return(session); }
public async Task UpsertSession(MediaServer.Storage.ProtoGenerated.Session session) { await _sessionClient.UpsertAsync(new UpsertRequest { Session = session }); }
public Task UpsertSession(MediaServer.Storage.ProtoGenerated.Session session) { using (var db = _databaseFactory.GetRepository()) { db.Upsert(session); } return(Task.CompletedTask); }