OSDN Git Service

WebGUIのレスポンスが悪かったのを修正
[peercast-im/PeerCastIM.git] / PeerCast.root / PeerCast / core / common / nsv.cpp
1 // ------------------------------------------------
2 // File : nsv.cpp
3 // Date: 28-may-2003
4 // Author: giles
5 //
6 // (c) 2002-3 peercast.org
7 // ------------------------------------------------
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 // ------------------------------------------------
18
19 #include "nsv.h"
20 #ifdef _DEBUG
21 #include "chkMemoryLeak.h"
22 #define DEBUG_NEW new(__FILE__, __LINE__)
23 #define new DEBUG_NEW
24 #endif
25
26 // ------------------------------------------
27 void NSVStream::readEnd(Stream &,Channel *)
28 {
29 }
30
31 // ------------------------------------------
32 void NSVStream::readHeader(Stream &,Channel *)
33 {
34 }
35 // ------------------------------------------
36 int NSVStream::readPacket(Stream &in,Channel *ch)
37 {
38         ChanPacket pack;
39
40         if (ch->icyMetaInterval)
41         {
42
43                 int rlen = ch->icyMetaInterval;
44
45                 while (rlen)
46                 {
47                         int rl = rlen;
48                         if (rl > ChanMgr::MAX_METAINT)
49                                 rl = ChanMgr::MAX_METAINT;
50
51                         pack.init(ChanPacket::T_DATA,pack.data,rl,ch->streamPos);
52                         in.read(pack.data,pack.len);
53                         ch->newPacket(pack);
54                         ch->checkReadDelay(pack.len);
55                         ch->streamPos+=pack.len;
56
57                         rlen-=rl;
58                 }
59
60                 unsigned char len;
61                 in.read(&len,1);
62                 if (len)
63                 {
64                         if (len*16 > 1024) len = 1024/16;
65                         char buf[1024];
66                         in.read(buf,len*16);
67                         ch->processMp3Metadata(buf);
68                 }
69
70         }else{
71
72                 pack.init(ChanPacket::T_DATA,pack.data,ChanMgr::MAX_METAINT,ch->streamPos);
73                 in.read(pack.data,pack.len);
74                 ch->newPacket(pack);
75                 ch->checkReadDelay(pack.len);
76
77                 ch->streamPos += pack.len;
78         }
79         return 0;
80 }