protected override void DeserializeFromStream(CitpBinaryReader reader) { base.DeserializeFromStream(reader); byte versionHi = reader.ReadByte(); byte versionLo = reader.ReadByte(); if (versionHi == 1 && versionLo == 0) { Version = MsexVersion.Version1_0; } else if (versionHi == 1 && versionLo == 1) { Version = MsexVersion.Version1_1; } else if (versionHi == 1 && versionLo == 2) { Version = MsexVersion.Version1_2; } else { Version = MsexVersion.UnsupportedVersion; } if (Version == MsexVersion.UnsupportedVersion) { throw new InvalidOperationException("Incorrect or invalid MSEX version"); } if (MessageType != CitpEnumHelper.GetEnumFromIdString <MsexMessageType>(reader.ReadIdString())) { throw new InvalidOperationException("Incorrect or invalid message type"); } }
protected override void DeserializeFromStream(CitpBinaryReader reader) { base.DeserializeFromStream(reader); switch (Version) { case MsexVersion.Version1_0: case MsexVersion.Version1_1: { SourceIdentifier = reader.ReadUInt16(); FrameFormat = CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString()); FrameWidth = reader.ReadUInt16(); FrameHeight = reader.ReadUInt16(); int frameBufferLength = reader.ReadUInt16(); FrameBuffer = reader.ReadBytes(frameBufferLength); } break; case MsexVersion.Version1_2: { MediaServerUuid = reader.ReadGuid(); SourceIdentifier = reader.ReadUInt16(); FrameFormat = CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString()); FrameWidth = reader.ReadUInt16(); FrameHeight = reader.ReadUInt16(); int frameBufferLength = reader.ReadUInt16(); FrameBuffer = reader.ReadBytes(frameBufferLength); } break; } }
protected override void DeserializeFromStream(CitpBinaryReader reader) { base.DeserializeFromStream(reader); if (MessageType != CitpEnumHelper.GetEnumFromIdString <SdmxMessageType>(reader.ReadIdString())) { throw new InvalidOperationException("Incorrect message type"); } }
protected override void DeserializeFromStream(CitpBinaryReader reader) { base.DeserializeFromStream(reader); SourceIdentifier = reader.ReadUInt16(); FrameFormat = CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString()); FrameWidth = reader.ReadUInt16(); FrameHeight = reader.ReadUInt16(); Fps = reader.ReadByte(); Timeout = reader.ReadByte(); }
protected override void DeserializeFromStream(CitpBinaryReader reader) { base.DeserializeFromStream(reader); switch (Version) { case MsexVersion.Version1_0: { LibraryType = (MsexLibraryType)reader.ReadByte(); LibraryNumber = reader.ReadByte(); ElementNumber = reader.ReadByte(); ThumbnailFormat = CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString()); ThumbnailWidth = reader.ReadUInt16(); ThumbnailHeight = reader.ReadUInt16(); int thumbnailBufferLength = reader.ReadUInt16(); ThumbnailBuffer = reader.ReadBytes(thumbnailBufferLength); } break; case MsexVersion.Version1_1: case MsexVersion.Version1_2: { LibraryType = (MsexLibraryType)reader.ReadByte(); LibraryId = MsexLibraryId.FromByteArray(reader.ReadBytes(4)); ElementNumber = reader.ReadByte(); ThumbnailFormat = CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString()); ThumbnailWidth = reader.ReadUInt16(); ThumbnailHeight = reader.ReadUInt16(); int thumbnailBufferLength = reader.ReadUInt16(); ThumbnailBuffer = reader.ReadBytes(thumbnailBufferLength); } break; } }
public static SdmxMessageType?GetMessageType(byte[] data) { string typeString = Encoding.UTF8.GetString(data, CitpMessageTypePosition, 4); return(CitpEnumHelper.GetEnumFromIdString <SdmxMessageType>(typeString)); }
protected override void DeserializeFromStream(CitpBinaryReader reader) { base.DeserializeFromStream(reader); switch (Version) { case MsexVersion.Version1_0: { ThumbnailFormat = CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString()); ThumbnailWidth = reader.ReadUInt16(); ThumbnailHeight = reader.ReadUInt16(); ThumbnailFlags = (MsexThumbnailFlags)reader.ReadByte(); LibraryType = (MsexLibraryType)reader.ReadByte(); LibraryNumber = reader.ReadByte(); int elementNumberCount = reader.ReadByte(); ElementNumbers = new List <byte>(elementNumberCount); for (int i = 0; i < elementNumberCount; ++i) { ElementNumbers.Add(reader.ReadByte()); } if (elementNumberCount == 0) { ShouldRequestAllThumbnails = true; } } break; case MsexVersion.Version1_1: { ThumbnailFormat = CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString()); ThumbnailWidth = reader.ReadUInt16(); ThumbnailHeight = reader.ReadUInt16(); ThumbnailFlags = (MsexThumbnailFlags)reader.ReadByte(); LibraryType = (MsexLibraryType)reader.ReadByte(); LibraryId = MsexLibraryId.FromByteArray(reader.ReadBytes(4)); int elementNumberCount = reader.ReadByte(); ElementNumbers = new List <byte>(elementNumberCount); for (int i = 0; i < elementNumberCount; ++i) { ElementNumbers.Add(reader.ReadByte()); } if (elementNumberCount == 0) { ShouldRequestAllThumbnails = true; } } break; case MsexVersion.Version1_2: { ThumbnailFormat = CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString()); ThumbnailWidth = reader.ReadUInt16(); ThumbnailHeight = reader.ReadUInt16(); ThumbnailFlags = (MsexThumbnailFlags)reader.ReadByte(); LibraryType = (MsexLibraryType)reader.ReadByte(); LibraryId = MsexLibraryId.FromByteArray(reader.ReadBytes(4)); int elementNumberCount = reader.ReadUInt16(); ElementNumbers = new List <byte>(elementNumberCount); for (int i = 0; i < elementNumberCount; ++i) { ElementNumbers.Add(reader.ReadByte()); } if (elementNumberCount == 0) { ShouldRequestAllThumbnails = true; } } break; } }
protected override void DeserializeFromStream(CitpBinaryReader reader) { base.DeserializeFromStream(reader); ReceivedContentType = CitpEnumHelper.GetEnumFromIdString <MsexMessageType>(reader.ReadIdString()); }
protected override void DeserializeFromStream(CitpBinaryReader reader) { base.DeserializeFromStream(reader); switch (Version) { case MsexVersion.Version1_0: case MsexVersion.Version1_1: { ProductName = reader.ReadString(); ProductVersionMajor = reader.ReadByte(); ProductVersionMinor = reader.ReadByte(); int dmxSourcesCount = reader.ReadByte(); LayerDmxSources = new List <CitpDmxConnectionString>(dmxSourcesCount); for (int i = 0; i < dmxSourcesCount; ++i) { LayerDmxSources.Add(CitpDmxConnectionString.Parse(reader.ReadString(true))); } } break; case MsexVersion.Version1_2: { Uuid = new Guid(reader.ReadString(true)); ProductName = reader.ReadString(); ProductVersionMajor = reader.ReadByte(); ProductVersionMinor = reader.ReadByte(); ProductVersionBugfix = reader.ReadByte(); byte supportedVersionsCount = reader.ReadByte(); SupportedMsexVersions = new List <MsexVersion>(supportedVersionsCount); for (int i = 0; i < supportedVersionsCount; ++i) { byte versionMajor = reader.ReadByte(); byte versionMinor = reader.ReadByte(); if (versionMajor == 1 && versionMinor == 0) { SupportedMsexVersions.Add(MsexVersion.Version1_0); } else if (versionMajor == 1 && versionMinor == 1) { SupportedMsexVersions.Add(MsexVersion.Version1_1); } else if (versionMajor == 1 && versionMinor == 2) { SupportedMsexVersions.Add(MsexVersion.Version1_2); } else { SupportedMsexVersions.Add(MsexVersion.UnsupportedVersion); } } SupportedLibraryTypes = new List <MsexLibraryType>(); var supportedLibraryTypesBits = new BitArray(reader.ReadBytes(2)); for (byte i = 0; i < supportedLibraryTypesBits.Length; ++i) { if (supportedLibraryTypesBits[i]) { SupportedLibraryTypes.Add((MsexLibraryType)i); } } int thumbnailFormatsCount = reader.ReadByte(); ThumbnailFormats = new List <MsexImageFormat>(thumbnailFormatsCount); for (int i = 0; i < thumbnailFormatsCount; ++i) { ThumbnailFormats.Add(CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString())); } int streamFormatsCount = reader.ReadByte(); StreamFormats = new List <MsexImageFormat>(streamFormatsCount); for (int i = 0; i < streamFormatsCount; ++i) { StreamFormats.Add(CitpEnumHelper.GetEnumFromIdString <MsexImageFormat>(reader.ReadIdString())); } int dmxSourcesCount = reader.ReadByte(); LayerDmxSources = new List <CitpDmxConnectionString>(dmxSourcesCount); for (int i = 0; i < dmxSourcesCount; ++i) { LayerDmxSources.Add(CitpDmxConnectionString.Parse(reader.ReadString(true))); } } break; } }
private static CitpLayerType?getLayerType(byte[] data) { string typeString = Encoding.UTF8.GetString(data, CitpContentTypePosition, 4); return(CitpEnumHelper.GetEnumFromIdString <CitpLayerType>(typeString)); }