Changeset 107
- Timestamp:
- 03/02/07 16:43:53 (2 years ago)
- Files:
-
- dmp/trunk/Bridge/Bridge.cs (modified) (2 diffs)
- dmp/trunk/XmLRpcBridgeServer/BridgeXmlRpcServer.cs (modified) (3 diffs)
- dmp/trunk/gwt-windows-1.3.3/src/DMP/DMPXmlRpcClient.java (modified) (2 diffs)
- dmp/trunk/gwt-windows-1.3.3/src/DMP/server/MusicServImpl.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dmp/trunk/Bridge/Bridge.cs
r104 r107 135 135 /// <param name="id">The id of the requested song</param> 136 136 /// <returns>A stream of the requested song</returns> 137 public Stream getSongStream(int id )137 public Stream getSongStream(int id, out long length) 138 138 { 139 139 int libraryId = this.db.getRemoteLibraryId(id); … … 143 143 //Track song = clientList[libraryId].Database.LookupTrackById(remoteSongId); 144 144 Track song = db.getRemoteTrack(id); 145 return clientList[libraryId].Database.StreamTrack(song, out songSize); 145 Stream musicStream = clientList[libraryId].Database.StreamTrack(song, out length); 146 return musicStream; 146 147 //return null; 147 148 } dmp/trunk/XmLRpcBridgeServer/BridgeXmlRpcServer.cs
r99 r107 16 16 const int port = 6666; 17 17 private Bridge bridge; 18 private int bufferChunkSize = 8192; 18 19 19 20 public BridgeXmlRpcServer() … … 58 59 59 60 /// <summary> 61 /// Gets a song's URL using the song's ID number. 62 /// </summary> 63 /// <param name="songID">the song's integer id number</param> 64 /// <returns>a string to the song's location</returns> 65 [XmlRpcExposed] 66 public String getSongURL(int songID) 67 { 68 return bridge.getSongURL(songID); 69 } 70 71 /// <summary> 72 /// Gets a song using the song's ID number. 73 /// </summary> 74 /// <param name="songID">the song's id number</param> 75 /// <returns>a byte array containing the song's data</returns> 76 [XmlRpcExposed] 77 public byte[] getSong(int songID) 78 { 79 Console.WriteLine("getSong " + songID + " in BridgeXmlRpcServer"); 80 long length; 81 Stream musicStream = bridge.getSongStream(songID, out length); 82 int lengthInt = (int)length; 83 84 MemoryStream musicStreamBuffer = new MemoryStream(lengthInt); 85 86 int count = 0; 87 byte[] buf = new byte[bufferChunkSize]; 88 89 do { 90 count = musicStream.Read(buf, 0, bufferChunkSize); 91 musicStreamBuffer.Write(buf, 0, count); 92 } while (count != 0); 93 94 byte[] finalMusic = musicStreamBuffer.GetBuffer(); 95 return finalMusic; 96 } 97 98 /* Old method, kept for reference. 99 /// <summary> 60 100 /// Gets a song using the song's ID number. 61 101 /// </summary> … … 63 103 /// <returns>a byte array containing the song's data</returns> 64 104 [XmlRpcExposed] 65 public byte[] getSong (int songID)105 public byte[] getSong2(int songID) 66 106 { 67 Console.WriteLine("getSong " + songID + " in BridgeXmlRpcServer"); 68 Stream musicStream = bridge.getSongStream(songID); 107 long length; 108 Console.WriteLine("getSong2 " + songID + " in BridgeXmlRpcServer"); 109 Stream musicStream = bridge.getSongStream(songID, out length); 110 //musicStream.ReadTimeout = (int) 4268032; 69 111 Track song = bridge.getTrackInfo(songID); 70 112 byte[] musicBytes = new byte[song.Size]; 71 musicStream.Read(musicBytes, 0, song.Size); 113 IAsyncResult result = 114 musicStream.BeginRead(musicBytes,0,musicBytes.Length,null,10); 115 //System.Threading.Thread.Sleep(6000); 116 result.AsyncWaitHandle.WaitOne(); 117 musicStream.Flush(); 118 int bytesRead = musicStream.EndRead(result); 119 if (bytesRead < song.Size) 120 { 121 //throw new IOException("Not enough bytes read."); 122 } 72 123 return musicBytes; 124 //musicStream.Read(musicBytes, 0, musicBytes.Length); 125 //return musicBytes; 73 126 } 127 * */ 74 128 75 129 /// <summary> dmp/trunk/gwt-windows-1.3.3/src/DMP/DMPXmlRpcClient.java
r78 r107 52 52 public byte[] getSong(int songID) 53 53 { 54 System.out.println("getSong on DMPXmlRpcClient");54 System.out.println("getSong " + songID + " on DMPXmlRpcClient"); 55 55 byte[] response = null; 56 56 ArrayList<Object> params = new ArrayList<Object>(); … … 59 59 { 60 60 response = (byte[]) client.execute("server.getSong", params); 61 } 62 catch (XmlRpcException e) { 63 e.printStackTrace(); 64 } 65 return response; 66 } 67 68 /** 69 * Gets the URL to the song with the specified ID. 70 * @param songID the song's ID 71 * @return the song's URL 72 */ 73 public String getSongURL(int songID) 74 { 75 String response = null; 76 ArrayList<Object> params = new ArrayList<Object>(); 77 params.add(songID); 78 try 79 { 80 response = (String) client.execute("server.getSongURL",params); 61 81 } 62 82 catch (XmlRpcException e) { dmp/trunk/gwt-windows-1.3.3/src/DMP/server/MusicServImpl.java
r78 r107 5 5 6 6 import java.io.*; 7 import java.net.*; 7 8 8 9 import com.google.gwt.user.server.rpc.RemoteServiceServlet; … … 65 66 flashFileHandles.remove(song); 66 67 } 68 } 69 70 /** Old method, kept for reference. 71 * Makes a flash file from the input song. 72 * @param song the song to make the flash file from 73 */ 74 public void makeFlash2(Vector song) 75 { 76 Integer songID = Integer.parseInt(song.get(0).toString()); 77 String songURLString = client.getSongURL(songID.intValue()); 78 URL songURL; 79 InputStream music; 80 try { 81 songURL = new URL(songURLString); 82 } catch (MalformedURLException e) { 83 e.printStackTrace(); 84 return; 85 } 86 try { 87 music = songURL.openStream(); 88 } catch (IOException e) { 89 e.printStackTrace(); 90 return; 91 } 92 byte[] musicBytes = new byte[5000000]; 93 try { 94 music.read(musicBytes); 95 } catch (IOException e) { 96 e.printStackTrace(); 97 return; 98 } 99 //makeFlash2(musicBytes,song); 67 100 } 68 101 … … 76 109 public void makeFlash(Vector song) 77 110 { 78 Integer songID = Integer.parseInt( song.get(0).toString());111 Integer songID = Integer.parseInt((song.get(0).toString())); 79 112 byte[] musicBytes = client.getSong(songID.intValue()); 80 113 if(musicBytes == null) … … 82 115 return; 83 116 } 117 // create music and flash temp files 84 118 File tempMusicFile; 85 119 File tempFlashFile; … … 108 142 return; 109 143 } 144 // use temp files to create flash movie 110 145 createFlashMovie(tempMusicFile.getPath(),tempFlashFile.getPath()); 111 146 tempMusicFile.delete();
