Package se.despotify.client.protocol.channel

Examples of se.despotify.client.protocol.channel.Channel


  }

  /* Request image using a 20 byte id. The response is a JPG. */
  public void sendImageRequest(ChannelListener listener, String id) throws DespotifyException {
    /* Create channel and buffer. */
    Channel    channel = new Channel("Image-Channel", Channel.Type.TYPE_IMAGE, listener);
    ByteBuffer buffer  = ByteBuffer.allocate(2 + 20);

    /* Append channel id and image hash. */
    buffer.putShort((short)channel.getId());
    buffer.put(Hex.toBytes(id));
    buffer.flip();

    /* Register channel. */
    Channel.register(channel);
 
View Full Code Here


  }

  /* Request AES key for a track. */
  public void sendAesKeyRequest(ChannelListener listener, Track track) throws DespotifyException {
    /* Create channel and buffer. */
    Channel    channel = new Channel("AES-Key-Channel", Channel.Type.TYPE_AESKEY, listener);
    ByteBuffer buffer  = ByteBuffer.allocate(20 + 16 + 2 + 2);

    /* Request the AES key for this file by sending the file id and track id. */
    buffer.put(Hex.toBytes(track.getFiles().get(0))); /* 20 bytes */
    buffer.put(track.getByteUUID()); /* 16 bytes */
    buffer.putShort((short)0x0000);
    buffer.putShort((short)channel.getId());
    buffer.flip();

    /* Register channel. */
    Channel.register(channel);

 
View Full Code Here

      /* Create channel callback */
      ChannelCallback callback = new ChannelCallback();

    /* Create channel and buffer. */
    Channel channel = new Channel("Image-Channel", Channel.Type.TYPE_IMAGE, callback);
    ByteBuffer buffer  = ByteBuffer.allocate(2 + 20);

    /* Append channel id and image hash. */
    buffer.putShort((short)channel.getId());
    buffer.put(image.getByteUUID());
    buffer.flip();

    /* Register channel. */
    Channel.register(channel);
View Full Code Here

    ChannelCallback callback = new ChannelCallback();

    /* Send browse request. */

    /* Create channel and buffer. */
    Channel channel = new Channel("Browse-Channel", Channel.Type.TYPE_BROWSE, callback);
    ByteBuffer buffer = ByteBuffer.allocate(2 + 1 + 16 + 4);


    buffer.putShort((short) channel.getId());
    buffer.put((byte) BrowseType.artist.getValue());
    buffer.put(artist.getByteUUID());
    buffer.putInt(0); // unknown


View Full Code Here

    ChannelCallback callback = new ChannelCallback();

    /* Send browse request. */

    /* Create channel and buffer. */
    Channel channel = new Channel("Browse-Channel", Channel.Type.TYPE_BROWSE, callback);
    ByteBuffer buffer = ByteBuffer.allocate(2 + 1 + 16 + 4);


    buffer.putShort((short) channel.getId());
    buffer.put((byte) BrowseType.album.getValue());
    buffer.put(album.getByteUUID());
    buffer.putInt(0); // unknown


View Full Code Here

  @Override
  public Boolean send(DespotifyManager connectionManager) throws DespotifyException {

    ChannelCallback callback = new ChannelCallback();

    Channel channel = new Channel("Playlist-Channel", Channel.Type.TYPE_PLAYLIST, callback);
    ByteBuffer buffer  = ByteBuffer.allocate(2 + 16 + 1 + 4 + 4 + 4 + 1);

    buffer.putShort((short)channel.getId()); // channel id
    buffer.put(Hex.toBytes("00000000000000000000000000000000")); // uuid? not used
    buffer.put((byte)0x00); // unknown
    buffer.putInt(-1); // playlist history. -1: current. 0: changes since version 0, 1: since version 1, etc.
    buffer.putInt(0)// unknown
    buffer.putInt(-1); // unknown
View Full Code Here

    ChannelCallback callback = new ChannelCallback();

    byte[] utf8Bytes = query.getBytes(Charset.forName("UTF8"));

    /* Create channel and buffer. */
    Channel channel = new Channel("Search-Channel", Channel.Type.TYPE_SEARCH, callback);
    ByteBuffer buffer = ByteBuffer.allocate(2 + 4 + 4 + 2 + 1 + utf8Bytes.length);

    /* Check offset and limit. */
    if (offset < 0) {
      throw new IllegalArgumentException("Offset needs to be >= 0");
    }
//    else if ((maxResults < 0 && maxResults != -1) || maxResults == 0) {
//      throw new IllegalArgumentException("Limit needs to be either -1 for no limit or > 0");
//    }

    /* Append channel id, some values, query length and query. */
    buffer.putShort((short) channel.getId());
    buffer.putInt(offset); /* Result offset. */
    buffer.putInt(maxResults); /* Reply limit. */
    buffer.putShort((short) 0x0000);
    buffer.put((byte) utf8Bytes.length);
    buffer.put(utf8Bytes);
View Full Code Here

    ChannelCallback callback = new ChannelCallback();

    /* Send browse request. */

    /* Create channel and buffer. */
    Channel channel = new Channel("Browse-Channel", Channel.Type.TYPE_BROWSE, callback);
    ByteBuffer buffer = ByteBuffer.allocate(2 + 1 + tracks.length * 16); //+ ((type == BrowseType.artist || type == BrowseType.album)?4:0));

//    if(ids.size() > 1 && type != BrowseType.track){
//      throw new IllegalArgumentException("Only BrowserType.track accepts multiple ids.");
//    }

    /* Append channel id and type. */
    buffer.putShort((short) channel.getId());
    buffer.put((byte) BrowseType.track.getValue());

    /* Append (16 byte) ids. */
    for (Track track : tracks) {
      buffer.put(Arrays.copyOfRange(track.getByteUUID(), 0, 16));
View Full Code Here

    /* Create channel callback */
    ChannelCallback callback = new ChannelCallback();

    /* Create channel and buffer. */
    Channel channel = new Channel("Change-Playlist-Channel", Channel.Type.TYPE_PLAYLIST, callback);
    byte[] xmlBytes = xml.getBytes();
    ByteBuffer buffer = ByteBuffer.allocate(2 + 17 + 4 + 4 + 4 + 1 + 1 + xmlBytes.length);

    /* Append channel id, playlist id and some bytes... */
    buffer.putShort((short) channel.getId());
    buffer.put(playlist.getByteUUID()); /* 16 bytes */
    buffer.put((byte) 0x00); // 0x00 for adding tracks, 0x02 for the rest?
    buffer.putInt(playlist.getRevision().intValue());
    buffer.putInt(playlist.getTracks().size());
    buffer.putInt(playlist.getChecksum().intValue()); /* -1: Create playlist. */
 
View Full Code Here

    /* Create channel callback */
    ChannelCallback callback = new ChannelCallback();

    /* Create channel and buffer. */
    Channel channel  = new Channel("Change-Playlist-Channel", Channel.Type.TYPE_PLAYLIST, callback);
    byte[]     xmlBytes = xml.getBytes();
    ByteBuffer buffer   = ByteBuffer.allocate(2 + 17 + 4 + 4 + 4 + 1 + 1 + xmlBytes.length);

    /* Append channel id, playlist id and some bytes... */
    buffer.putShort((short)channel.getId());
    buffer.put(playlist.getByteUUID()); /* 16 bytes */
    buffer.put((byte)0x00); // 0x00 for adding tracks, 0x02 for the rest?
    buffer.putInt(playlist.getRevision().intValue());
    buffer.putInt(playlist.getTracks().size());
    buffer.putInt(playlist.getChecksum().intValue()); /* -1: Create playlist. */
 
View Full Code Here

TOP

Related Classes of se.despotify.client.protocol.channel.Channel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.