private void InitializeData(UInt32 playoutId, UInt64 timelinePosition) { _key = new AcspPackKey(Byte12Data.GoodRequest, Byte13NodeNames.UpdateTimelineRequest); // for now we are going with a FIXED-length schema where we do not have any of the variable-length AcspTimelineExtension involved _packLength = new AcspBerLength(36); // RequestId(4), PlayoutId(4), TimelinePosition(8), RateNumerator(8), RateDenominator(8), ExtensionCount(4) _requestId = new AcspRequestId(); ConvertPlayoutIdToByteArray(playoutId); ConvertTimelinePositionToByteArray(timelinePosition); // UInt64 numerator = 24; // assuming a default edit rate of 24:1 for the default constructor UInt64 numerator = 25; // TEMPORARILY overriding the edit unit for a specific test scenario ConvertRateNumeratorToByteArray(numerator); UInt64 denominator = 1; // assuming a default edit rate of 24:1 for the default constructor ConvertRateDenominatorToByteArray(denominator); UInt32 extensionCount = 0; // assuming zero extension counts in this vanilla implementation ConvertExtensionCountToByteArray(extensionCount); }
private void InitializeData(String inputUrl, UInt32 inputId) { _key = new AcspPackKey(Byte12Data.GoodRequest, Byte13NodeNames.SetRplLocationRequest); // Calculate required length of the value part of the packArray // which is 4 bytes for RequestId, 4 bytes for PlayoutId, and a // variable amount for the length of the ResourceUrl int length = 4 + 4 + inputUrl.Length; _packLength = new AcspBerLength(length); // Generate the new RequestId _requestId = new AcspRequestId(); // Set the Playout ID _playoutId = BitConverter.GetBytes(inputId); if (BitConverter.IsLittleEndian) { Array.Reverse(_playoutId); } // Set the Resource URL // Note that per SMPTE 430-10:2010, this field is supposed to be of type "URL", which may be different than expected UTF8 _resourceUrl = Encoding.UTF8.GetBytes(inputUrl); }
private void InitializeAnnounceRequestData() { _key = new AcspPackKey(Byte12Data.GoodRequest, Byte13NodeNames.AnnounceRequest); _requestId = new AcspRequestId(); _currentTime = DateTimeOffset.UtcNow; _currentEpochTime = _currentTime.ToUnixTimeSeconds(); _deviceDescription = "Proludio AcsListener Test Device Description"; _valueLength = _deviceDescription.Length + 4 + 8; _packLength = new AcspBerLength(_valueLength); }
private void InitializeData(UInt32 leaseDurationSeconds) { _key = new AcspPackKey(Byte12Data.GoodRequest, Byte13NodeNames.GetNewLeaseRequest); _packLength = new AcspBerLength(8); // 4 bytes for RequestId, 4 bytes for LeaseDuration _requestId = new AcspRequestId(); _leaseDuration = BitConverter.GetBytes(leaseDurationSeconds); if (BitConverter.IsLittleEndian) { Array.Reverse(_leaseDuration); } }
private void InitializeData(bool outputMode) { _key = new AcspPackKey(Byte12Data.GoodRequest, Byte13NodeNames.SetOutputModeRequest); _packLength = new AcspBerLength(5); // 4 bytes for RequestId, 1 byte for OutputMode _requestId = new AcspRequestId(); int temp = 0; if (outputMode == true) { temp = 1; } _outputMode = (Byte)temp; }
/// <summary> /// The AnnounceResponse constructor expects a byte array of at least 21 elements, /// 4 bytes for RequestID, 8 bytes for EpochTime, 4 bytes for DeviceDescriptionLength, and a /// minimum of 5 bytes for the KL (key and length) parts of the StatusResponse KLV. The /// DeviceDescription and StatusMessage (the V in the KLV) are of variable length and will add to the /// 21 byte minimum. /// </summary> /// <param name="inputArray">Byte pack that is decoded in to the Announce Response</param> public AcspAnnounceResponse(Byte[] inputArray) { if (inputArray.Length < 21) { throw new ArgumentOutOfRangeException("Error: was expecting at least a 21-byte array for AnnounceResponse constructor"); } // Take 4-byte slice and convert to UInt32 for RequestId int i = 0; Byte[] data = new Byte[4]; Array.Copy(inputArray, 0, data, 0, data.Length); i = i + data.Length; _requestId = new AcspRequestId(data); // Take 8 byte slice and convert to Int64 for CurrentTime data = new Byte[8]; Array.Copy(inputArray, i, data, 0, data.Length); i = i + data.Length; if (BitConverter.IsLittleEndian) { Array.Reverse(data); } _currentTime = BitConverter.ToInt64(data, 0); // Take 4 byte slice and convert to AcspBerLength data = new Byte[4]; Array.Copy(inputArray, i, data, 0, data.Length); i = i + data.Length; _deviceDescriptionLength = new AcspBerLength(data); // Take variable-length byte slice and convert UTF-8 string int length = _deviceDescriptionLength.Length; if (length > 0) { data = new Byte[length]; Array.Copy(inputArray, i, data, 0, data.Length); i = i + data.Length; _deviceDescription = Encoding.UTF8.GetString(data); } // Take variable-length (but at least 5 bytes) slice and convert to AcspStatusResponse int statusLength = inputArray.Length - i; data = new Byte[statusLength]; Array.Copy(inputArray, i, data, 0, data.Length); _statusResponse = new AcspStatusResponse(data); }
/// <summary> /// Constructor for a standard Acsp Response Header object. Takes the standard 20 bytes /// comprised of 16 bytes for the Pack Key, and 4 bytes for the BER length item. /// </summary> /// <param name="inputArray"> 20 byte array comprising 16 bytes for Pack Key, and 4 bytes for BER length</param> /// public AcspResponseHeader(Byte[] inputArray) { if (inputArray.Length != 20) { throw new IndexOutOfRangeException("Error: expecting 20-byte input"); } Byte[] keyArray = new Byte[16]; Byte[] lengthArray = new Byte[4]; Array.Copy(inputArray, 0, keyArray, 0, keyArray.Length); // Copy first 16 bytes of inputArray in to keyArray Array.Copy(inputArray, keyArray.Length, lengthArray, 0, lengthArray.Length); // Copy last 4 bytes of inputArray in to lengthArray _key = new AcspPackKey(keyArray); _packLength = new AcspBerLength(lengthArray); }
public AcspStatusResponse(Byte[] bytePack) { if (bytePack.Length < 5) { throw new ArgumentOutOfRangeException($"Error: expected at least a 5-byte array to be passed to the Status Response constructor"); } Byte[] lengthArray = new Byte[4]; int i = 0; // index for Array.Copy _key = (GeneralStatusResponseKey)bytePack[0]; i = i + 1; // Adding 1 byte for _key Array.Copy(bytePack, i, lengthArray, 0, lengthArray.Length); i = i + lengthArray.Length; // Adding more bytes for the BER length array _length = new AcspBerLength(lengthArray); Byte[] messageArray = new byte[_length.Length]; Array.Copy(bytePack, i, messageArray, 0, messageArray.Length); i = i + messageArray.Length; // Adding more bytes for the message string _message = Encoding.UTF8.GetString(messageArray); }
private void InitializeData() { _key = new AcspPackKey(Byte12Data.GoodRequest, Byte13NodeNames.TerminateLeaseRequest); _packLength = new AcspBerLength(4); _requestId = new AcspRequestId(); }
private void InitializeData() { _key = new AcspPackKey(Byte12Data.GoodRequest, Byte13NodeNames.GetStatusRequest); _packLength = new AcspBerLength(4); // 4 bytes for the RequestId _requestId = new AcspRequestId(); }