/// <summary> /// Replaces the comment packet in a collection of packets /// with the rendered version of a Xiph comment or inserts a /// comment packet if the stream lacks one. /// </summary> /// <param name="packets"> /// A <see cref="ByteVectorCollection" /> object containing /// a collection of packets. /// </param> /// <param name="comment"> /// A <see cref="XiphComment" /> object to store the rendered /// version of in <paramref name="packets" />. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="packets" /> or <paramref name="comment" /// /> is <see langword="null" />. /// </exception> public override void SetCommentPacket(ByteVectorCollection packets, XiphComment comment) { if (packets == null) { throw new ArgumentNullException("packets"); } if (comment == null) { throw new ArgumentNullException("comment"); } ByteVector data = new ByteVector((byte)0x03); data.Add(id); data.Add(comment.Render(true)); if (packets.Count > 1 && PacketType(packets [1]) == 0x03) { if (data.Count < packets [1].Count) { data.Add(new ByteVector(packets [1].Count - data.Count, 0)); } packets [1] = data; } else { packets.Insert(1, data); } }
public void Insert() { ByteVectorCollection list = BuildList(); list.Insert(1, "QUACK"); Assert.AreEqual("ABC,QUACK,DEF,GHI", list.ToByteVector(",").ToString()); }
/// <summary> /// Replaces the comment packet in a collection of packets /// with the rendered version of a Xiph comment or inserts a /// comment packet if the stream lacks one. /// </summary> /// <param name="packets"> /// A <see cref="ByteVectorCollection" /> object containing /// a collection of packets. /// </param> /// <param name="comment"> /// A <see cref="XiphComment" /> object to store the rendered /// version of in <paramref name="packets" />. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="packets" /> or <paramref name="comment" /// /> is <see langword="null" />. /// </exception> public override void SetCommentPacket(ByteVectorCollection packets, XiphComment comment) { if (packets == null) { throw new ArgumentNullException("packets"); } if (comment == null) { throw new ArgumentNullException("comment"); } ByteVector data = new ByteVector(); data.Add(magic_signature_comment); data.Add(comment.Render(true)); if (packets.Count > 1 && MagicSignature(packets [1]) == magic_signature_comment) { packets [1] = data; } else { packets.Insert(1, data); } }
/// <summary> /// Replaces the comment packet in a collection of packets /// with the rendered version of a Xiph comment or inserts a /// comment packet if the stream lacks one. /// </summary> /// <param name="packets"> /// A <see cref="ByteVectorCollection" /> object containing /// a collection of packets. /// </param> /// <param name="comment"> /// A <see cref="XiphComment" /> object to store the rendered /// version of in <paramref name="packets" />. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="packets" /> or <paramref name="comment" /// /> is <see langword="null" />. /// </exception> public override void SetCommentPacket (ByteVectorCollection packets, XiphComment comment) { if (packets == null) throw new ArgumentNullException ("packets"); if (comment == null) throw new ArgumentNullException ("comment"); ByteVector data = new ByteVector ((byte) 0x03); data.Add (id); data.Add (comment.Render (true)); if (packets.Count > 1 && PacketType (packets [1]) == 0x03) { if (data.Count < packets [1].Count) data.Add (new ByteVector (packets [1].Count - data.Count, 0)); packets [1] = data; } else packets.Insert (1, data); }
public override void SetCommentPacket(ByteVectorCollection packets, XiphComment comment) { if (packets == null) { throw new ArgumentNullException("packets"); } if (comment == null) { throw new ArgumentNullException("comment"); } byte[] data = new byte[] { 0x81 }; ByteVector item = new ByteVector(data) { id, comment.Render(1) }; if ((packets.Count > 1) && (PacketType(packets[1]) == 0x81)) { packets[1] = item; } else { packets.Insert(1, item); } }
/// <summary> /// Replaces the comment packet in a collection of packets /// with the rendered version of a Xiph comment or inserts a /// comment packet if the stream lacks one. /// </summary> /// <param name="packets"> /// A <see cref="ByteVectorCollection" /> object containing /// a collection of packets. /// </param> /// <param name="comment"> /// A <see cref="XiphComment" /> object to store the rendered /// version of in <paramref name="packets" />. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="packets" /> or <paramref name="comment" /// /> is <see langword="null" />. /// </exception> public override void SetCommentPacket (ByteVectorCollection packets, XiphComment comment) { if (packets == null) throw new ArgumentNullException ("packets"); if (comment == null) throw new ArgumentNullException ("comment"); ByteVector data = new ByteVector (); data.Add (magic_signature_comment); data.Add (comment.Render (true)); if (packets.Count > 1 && MagicSignature (packets [1]) == magic_signature_comment) packets [1] = data; else packets.Insert (1, data); }