Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public async Task UpsertSession(MediaServer.Storage.ProtoGenerated.Session session)
 {
     await _sessionClient.UpsertAsync(new UpsertRequest
     {
         Session = session
     });
 }
Ejemplo n.º 3
0
        public Task UpsertSession(MediaServer.Storage.ProtoGenerated.Session session)
        {
            using (var db = _databaseFactory.GetRepository())
            {
                db.Upsert(session);
            }

            return(Task.CompletedTask);
        }