Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the StreamData class and sets all properties based on the KStudioEventStream provided
        /// </summary>
        /// <param name="stream">KStudioEventStream to get data from</param>
        public StreamData(KStudioEventStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            this.EventStream      = stream;
            this.PublicMetadata   = stream.GetMetadata(KStudioMetadataType.Public);
            this.PersonalMetadata = stream.GetMetadata(KStudioMetadataType.PersonallyIdentifiableInformation);
            this.EventHeaders     = new ObservableCollection <KStudioEventHeader>();

            KStudioSeekableEventStream seekStream = stream as KStudioSeekableEventStream;

            if (seekStream != null)
            {
                this.StartTime = seekStream.StartRelativeTime;
                this.EndTime   = seekStream.EndRelativeTime;

                List <KStudioEventHeader> headers = seekStream.EventHeaders.ToList();
                foreach (KStudioEventHeader header in headers)
                {
                    this.EventHeaders.Add(header);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates (add/edits) stream-level metadata in an event file
        /// </summary>
        /// <param name="client">KStudioClient to use for accessing the event file</param>
        /// <param name="fileName">Path to event file</param>
        /// <param name="streamName">Name of stream which should contain the metadata</param>
        /// <param name="type">Type of metadata to update (Public or Personal)</param>
        /// <param name="key">Key of metadata object to add/edit</param>
        /// <param name="value">Value of metadata object to add/edit</param>
        /// <returns>String which contains the updated contents of the target metadata object</returns>
        public static string UpdateStreamMetadata(KStudioClient client, string fileName, string streamName, KStudioMetadataType type, string key, object value)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            if (string.IsNullOrEmpty(streamName))
            {
                throw new ArgumentNullException("streamName");
            }

            string metadataText = string.Empty;

            using (KStudioEventFile file = client.OpenEventFileForEdit(fileName))
            {
                // find the stream in the file and alter its metadata
                Guid dataTypeId = StreamSupport.ConvertStreamStringToGuid(streamName);
                if (dataTypeId == KStudioEventStreamDataTypeIds.Null)
                {
                    throw new InvalidOperationException(Strings.ErrorNullStream);
                }

                KStudioEventStream stream = file.EventStreams.FirstOrDefault(s => s.DataTypeId == dataTypeId);
                if (stream != null)
                {
                    KStudioMetadata metadata = stream.GetMetadata(type);
                    Metadata.AlterMetadata(metadata, key, value);
                    metadataText = Metadata.GetMetadataAsText(metadata, type, stream.DataTypeName);
                }
            }

            return(metadataText);
        }