public BassPicture(TagPicture picture) { AttributeIndex = picture.AttributeIndex; MimeType = picture.MIMEType; Type = (PictureType)picture.PictureType; Description = picture.Description; Data = picture.Data; Storage = (PictureStorage) picture.PictureStorage; }
public TagPicture a(byte[] A_0, short A_1, int A_2, bool A_3) { if (A_0 == null) { return(null); } TagPicture picture = null; byte[] destinationArray = null; try { string str; TagPicture.PICTURE_TYPE unknown; int index = 0; if ((A_1 & 1) != 0) { this.a(A_0[0], A_0[1], A_0[2], A_0[3]); index = 4; } Encoding encoding = this.a(A_0[index]); index++; if (A_3) { str = "Unknown"; if (((A_0[index] == 0x4a) && (A_0[index + 1] == 80)) && (A_0[index + 2] == 0x47)) { str = "image/jpeg"; } else if (((A_0[index] == 0x47) && (A_0[index + 1] == 0x49)) && (A_0[index + 2] == 70)) { str = "image/gif"; } else if (((A_0[index] == 0x42) && (A_0[index + 1] == 80)) && (A_0[index + 2] == 0x4d)) { str = "image/bmp"; } else if (((A_0[index] == 80) && (A_0[index + 1] == 0x4e)) && (A_0[index + 2] == 0x47)) { str = "image/png"; } index += 3; } else { str = this.a(A_0, ref index); index++; } byte num2 = A_0[index]; try { unknown = (TagPicture.PICTURE_TYPE)num2; } catch { unknown = TagPicture.PICTURE_TYPE.Unknown; } index++; string description = this.a(A_0, ref index, encoding); index++; int length = A_0.Length - index; if (length <= 0) { return(picture); } destinationArray = new byte[length]; Array.Copy(A_0, index, destinationArray, 0, length); if ((A_1 & 2) != 0) { List <byte> list = new List <byte>(length); for (int i = 0; i < length; i++) { list.Add(destinationArray[i]); if (((i < (length - 1)) && (destinationArray[i] == 0xff)) && (destinationArray[i + 1] == 0)) { i++; } } destinationArray = list.ToArray(); } picture = new TagPicture(A_2, str, unknown, description, destinationArray); } catch { } return(picture); }
public override bool UpdateTitle(TAG_INFO tag, string url) { if (tag == null) { this.v2SongTitleNext = string.Empty; return(false); } if (!string.IsNullOrEmpty(url)) { url = url.Trim(new char[1]).Replace('\0', ' '); } if (!base.UseBASS || !this.IsConnected) { string text = base.SongTitle; if (string.IsNullOrEmpty(text)) { text = tag.ToString(); } return(this.SHOUTcastUpdateTitle(text, url)); } if (this.UseSHOUTcastv2) { try { StringWriterWithEncoding stringWriterWithEncoding = new StringWriterWithEncoding(Encoding.UTF8); using (XmlWriter xmlWriter = XmlWriter.Create(stringWriterWithEncoding, new XmlWriterSettings { Encoding = stringWriterWithEncoding.Encoding, IndentChars = string.Empty, Indent = false, NewLineHandling = NewLineHandling.None, NewLineChars = string.Empty, CheckCharacters = false })) { xmlWriter.WriteStartElement("metadata"); if (this.v2SendSongTitleOnly) { if (string.IsNullOrEmpty(base.SongTitle)) { xmlWriter.WriteElementString("TIT2", tag.ToString()); } else { xmlWriter.WriteElementString("TIT2", base.SongTitle); } } else { if (!string.IsNullOrEmpty(tag.artist)) { xmlWriter.WriteElementString("TIT2", tag.title); xmlWriter.WriteElementString("TPE1", tag.artist); } else { xmlWriter.WriteElementString("TIT2", tag.ToString()); } if (!string.IsNullOrEmpty(tag.album)) { xmlWriter.WriteElementString("TALB", tag.album); } if (!string.IsNullOrEmpty(tag.albumartist)) { xmlWriter.WriteElementString("TPE2", tag.albumartist); } if (!string.IsNullOrEmpty(tag.genre)) { xmlWriter.WriteElementString("TCON", tag.genre); } if (!string.IsNullOrEmpty(tag.year)) { xmlWriter.WriteElementString("TYER", tag.year); } if (!string.IsNullOrEmpty(tag.copyright)) { xmlWriter.WriteElementString("TCOP", tag.copyright); } if (!string.IsNullOrEmpty(tag.publisher)) { xmlWriter.WriteElementString("TPUB", tag.publisher); } if (!string.IsNullOrEmpty(tag.composer)) { xmlWriter.WriteElementString("TCOM", tag.composer); } if (!string.IsNullOrEmpty(tag.conductor)) { xmlWriter.WriteElementString("TPE3", tag.conductor); } if (!string.IsNullOrEmpty(tag.remixer)) { xmlWriter.WriteElementString("TPE4", tag.remixer); } if (!string.IsNullOrEmpty(tag.lyricist)) { xmlWriter.WriteElementString("TEXT", tag.lyricist); } if (!string.IsNullOrEmpty(tag.isrc)) { xmlWriter.WriteElementString("TSRC", tag.isrc); } if (!string.IsNullOrEmpty(tag.producer)) { xmlWriter.WriteStartElement("IPLS"); xmlWriter.WriteAttributeString("role", "producer"); xmlWriter.WriteString(tag.producer); xmlWriter.WriteEndElement(); } if (!string.IsNullOrEmpty(tag.grouping)) { xmlWriter.WriteElementString("TIT1", tag.grouping); } if (!string.IsNullOrEmpty(this.StationName)) { xmlWriter.WriteElementString("TRSN", this.StationName); } xmlWriter.WriteElementString("TENC", BassNet.InternalName + " (Broadcast Framework)"); if (!string.IsNullOrEmpty(url)) { xmlWriter.WriteElementString("WOAF", url); } if (!string.IsNullOrEmpty(this.Url)) { xmlWriter.WriteElementString("WORS", this.Url); } } if (this.v2SongTitleNext != null) { xmlWriter.WriteStartElement("extension"); xmlWriter.WriteStartElement("title"); xmlWriter.WriteAttributeString("seq", "1"); if (string.IsNullOrEmpty(base.SongTitle)) { xmlWriter.WriteString(tag.ToString()); } else { xmlWriter.WriteString(base.SongTitle); } xmlWriter.WriteEndElement(); xmlWriter.WriteStartElement("title"); xmlWriter.WriteAttributeString("seq", "2"); xmlWriter.WriteString(this.v2SongTitleNext); xmlWriter.WriteEndElement(); xmlWriter.WriteElementString("soon", this.v2SongTitleNext); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); xmlWriter.Flush(); } bool result = BassEnc.BASS_Encode_CastSendMeta(base.Encoder.EncoderHandle, BASSEncodeMetaDataType.BASS_METADATA_XML_SHOUTCAST, stringWriterWithEncoding.ToString()); if (this.v2SendArtwork) { Task.Factory.StartNew(delegate() { try { BASSEncodeMetaDataType bassencodeMetaDataType = (BASSEncodeMetaDataType)0; TagPicture tagPicture = null; byte[] array = null; if (tag.PictureCount > 0) { tagPicture = tag.PictureGet(0); } if (tagPicture == null && !string.IsNullOrEmpty(this.v2StreamArtwork)) { tagPicture = new TagPicture(this.v2StreamArtwork, TagPicture.PICTURE_TYPE.Location, this.StationName); } if (tagPicture != null) { tagPicture = new TagPicture(tagPicture, 300); if (tagPicture.PictureStorage == TagPicture.PICTURE_STORAGE.Internal) { if (tagPicture.Data.Length <= 523680) { array = tagPicture.Data; } } else { try { using (Stream stream = new FileStream(Encoding.UTF8.GetString(tagPicture.Data), FileMode.Open, FileAccess.Read)) { if (stream.Length <= 523680L) { byte[] array2 = new byte[stream.Length]; stream.Read(array2, 0, (int)stream.Length); array = array2; } stream.Close(); } } catch { } } string mimetype = tagPicture.MIMEType; if (!(mimetype == "image/jpeg")) { if (!(mimetype == "image/bmp")) { if (!(mimetype == "image/png")) { if (mimetype == "image/gif") { bassencodeMetaDataType = BASSEncodeMetaDataType.BASS_METADATA_BIN_ALBUMART_GIF; } } else { bassencodeMetaDataType = BASSEncodeMetaDataType.BASS_METADATA_BIN_ALBUMART_PNG; } } else { bassencodeMetaDataType = BASSEncodeMetaDataType.BASS_METADATA_BIN_ALBUMART_BMP; } } else { bassencodeMetaDataType = BASSEncodeMetaDataType.BASS_METADATA_BIN_ALBUMART_JPG; } } if (bassencodeMetaDataType > (BASSEncodeMetaDataType)0 && array != null) { BassEnc.BASS_Encode_CastSendMeta(this.Encoder.EncoderHandle, bassencodeMetaDataType, array); } } catch { } }); } this.v2SongTitleNext = string.Empty; return(result); } catch { return(false); } } if (base.ForceUTF8TitleUpdates) { string text2 = base.SongTitle; if (string.IsNullOrEmpty(text2)) { text2 = tag.ToString(); } this.v2SongTitleNext = string.Empty; bool flag = BassEnc.BASS_Encode_CastSetTitle(base.Encoder.EncoderHandle, Encoding.UTF8.GetBytes(text2 + "\0"), string.IsNullOrEmpty(url) ? null : Encoding.UTF8.GetBytes(url + "\0")); if (!flag) { flag = this.SHOUTcastUpdateTitle(text2, url); } return(flag); } string text3 = base.SongTitle; if (string.IsNullOrEmpty(text3)) { text3 = tag.ToString(); } this.v2SongTitleNext = string.Empty; bool flag2 = BassEnc.BASS_Encode_CastSetTitle(base.Encoder.EncoderHandle, this._encoding.GetBytes(text3 + "\0"), string.IsNullOrEmpty(url) ? null : this._encoding.GetBytes(url + "\0")); if (!flag2) { flag2 = this.SHOUTcastUpdateTitle(text3, url); } return(flag2); }
private void SHOUTcastv2UpdateStationArtwork() { if (this.IsConnected && this.UseSHOUTcastv2 && this.v2SendArtwork && !string.IsNullOrEmpty(this.v2StationArtwork)) { Task.Factory.StartNew(delegate() { try { BASSEncodeMetaDataType bassencodeMetaDataType = (BASSEncodeMetaDataType)0; byte[] array = null; TagPicture tagPicture = new TagPicture(this.v2StationArtwork, TagPicture.PICTURE_TYPE.Location, this.StationName); if (tagPicture != null) { tagPicture = new TagPicture(tagPicture, 300); if (tagPicture.PictureStorage == TagPicture.PICTURE_STORAGE.Internal) { if (tagPicture.Data.Length <= 523680) { array = tagPicture.Data; } } else { try { using (Stream stream = new FileStream(Encoding.UTF8.GetString(tagPicture.Data), FileMode.Open, FileAccess.Read)) { if (stream.Length <= 523680L) { byte[] array2 = new byte[stream.Length]; stream.Read(array2, 0, (int)stream.Length); array = array2; } stream.Close(); } } catch { } } string mimetype = tagPicture.MIMEType; if (!(mimetype == "image/jpeg")) { if (!(mimetype == "image/bmp")) { if (!(mimetype == "image/png")) { if (mimetype == "image/gif") { bassencodeMetaDataType = BASSEncodeMetaDataType.BASS_METADATA_BIN_STATIONLOGO_GIF; } } else { bassencodeMetaDataType = BASSEncodeMetaDataType.BASS_METADATA_BIN_STATIONLOGO_PNG; } } else { bassencodeMetaDataType = BASSEncodeMetaDataType.BASS_METADATA_BIN_STATIONLOGO_BMP; } } else { bassencodeMetaDataType = BASSEncodeMetaDataType.BASS_METADATA_BIN_STATIONLOGO_JPG; } } if (bassencodeMetaDataType > (BASSEncodeMetaDataType)0 && array != null) { BassEnc.BASS_Encode_CastSendMeta(base.Encoder.EncoderHandle, bassencodeMetaDataType, array); } } catch { } }); } }