-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented SegmentMetadataStore and fixed bug where assertion would …
…prevent initialization of metadata.
- Loading branch information
Showing
7 changed files
with
108 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Org.Vitrivr.CineastApi.Model; | ||
using UnityEngine; | ||
|
||
namespace Vitrivr.UnityInterface.CineastApi.Model.Data | ||
{ | ||
/// <summary> | ||
/// Access and local representation of metadata for segments. | ||
/// </summary> | ||
[Serializable] | ||
public class SegmentMetadataStore : MetadataStore | ||
{ | ||
public SegmentMetadataStore(string id) | ||
{ | ||
SegmentId = id; | ||
Initialized = false; | ||
} | ||
|
||
public string SegmentId { get; private set; } | ||
|
||
public void Initialize(MediaSegmentMetadataQueryResult data) | ||
{ | ||
if (Initialized) | ||
{ | ||
Debug.LogWarning($"Attempted to initialize already initialized metadata for media object {SegmentId}!"); | ||
return; | ||
} | ||
|
||
foreach (var meta in data.Content.Where(meta => meta.SegmentId == SegmentId)) | ||
{ | ||
if (!Storage.ContainsKey(meta.Domain)) | ||
{ | ||
Storage.Add(meta.Domain, new Dictionary<string, string>()); | ||
} | ||
|
||
var domain = Storage[meta.Domain]; | ||
domain.Add(meta.Key, meta.Value); | ||
} | ||
|
||
Initialized = true; | ||
} | ||
|
||
public override async Task InitializeAsync() | ||
{ | ||
if (Initialized) | ||
{ | ||
Debug.LogWarning($"Attempted to initialize already initialized metadata for media object {SegmentId}!"); | ||
return; | ||
} | ||
|
||
var metadataResult = await CineastWrapper.MetadataApi.FindSegMetaByIdAsync(SegmentId); | ||
if (!Initialized) | ||
{ | ||
Initialize(metadataResult); | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Runtime/Vitrivr/UnityInterface/CineastApi/Model/Data/SegmentMetadataStore.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters