リビジョン | 0a55e16b1466333c8372b7d60f4f1072cc2ded44 (tree) |
---|---|
日時 | 2016-01-11 21:37:12 |
作者 | eru <eru01@user...> |
コミッター | eru |
FLVの視聴・リレーに対応。
@@ -2101,7 +2101,7 @@ void Channel::getStreamPath(char *str) | ||
2101 | 2101 | |
2102 | 2102 | getIDStr(idStr); |
2103 | 2103 | |
2104 | - sprintf(str,"/stream/%s%s",idStr,info.getTypeExt(info.contentType)); | |
2104 | + sprintf(str,"/stream/%s%s",idStr,info.getTypeExt()); | |
2105 | 2105 | } |
2106 | 2106 | |
2107 | 2107 |
@@ -2506,9 +2506,9 @@ bool Channel::writeVariable(Stream &out, const String &var, int index) | ||
2506 | 2506 | strcpy(buf,uptime.cstr()); |
2507 | 2507 | } |
2508 | 2508 | else if (var == "type") |
2509 | - sprintf(buf,"%s",ChanInfo::getTypeStr(info.contentType)); | |
2509 | + sprintf(buf,"%s",info.getTypeStr()); | |
2510 | 2510 | else if (var == "ext") |
2511 | - sprintf(buf,"%s",ChanInfo::getTypeExt(info.contentType)); | |
2511 | + sprintf(buf,"%s",info.getTypeExt()); | |
2512 | 2512 | else if (var == "proto") { |
2513 | 2513 | switch(info.contentType) { |
2514 | 2514 | case ChanInfo::T_WMA: |
@@ -3952,6 +3952,36 @@ unsigned int ChanHitList::getSeq() | ||
3952 | 3952 | } |
3953 | 3953 | |
3954 | 3954 | // ----------------------------------- |
3955 | +const char *ChanInfo::getTypeStr() | |
3956 | +{ | |
3957 | + if (contentTypeStr.isEmpty()) { | |
3958 | + return getTypeStr(contentType); | |
3959 | + } | |
3960 | + else { | |
3961 | + return contentTypeStr.cstr(); | |
3962 | + } | |
3963 | +} | |
3964 | +// ----------------------------------- | |
3965 | +const char *ChanInfo::getTypeExt() | |
3966 | +{ | |
3967 | + if (streamExt.isEmpty()) { | |
3968 | + return getTypeExt(contentType); | |
3969 | + } | |
3970 | + else { | |
3971 | + return streamExt.cstr(); | |
3972 | + } | |
3973 | +} | |
3974 | +// ----------------------------------- | |
3975 | +const char *ChanInfo::getMIMEType() | |
3976 | +{ | |
3977 | + if (streamType.isEmpty()) { | |
3978 | + return getMIMEType(contentType); | |
3979 | + } | |
3980 | + else { | |
3981 | + return streamType.cstr(); | |
3982 | + } | |
3983 | +} | |
3984 | +// ----------------------------------- | |
3955 | 3985 | const char *ChanInfo::getTypeStr(TYPE t) |
3956 | 3986 | { |
3957 | 3987 | switch (t) |
@@ -4027,6 +4057,33 @@ const char *ChanInfo::getTypeExt(TYPE t) | ||
4027 | 4057 | } |
4028 | 4058 | } |
4029 | 4059 | // ----------------------------------- |
4060 | +const char *ChanInfo::getMIMEType(TYPE t) | |
4061 | +{ | |
4062 | + switch(t) | |
4063 | + { | |
4064 | + case ChanInfo::T_OGG: | |
4065 | + return MIME_XOGG; | |
4066 | + case ChanInfo::T_OGM: | |
4067 | + return MIME_XOGG; | |
4068 | + case ChanInfo::T_MP3: | |
4069 | + return MIME_MP3; | |
4070 | + case ChanInfo::T_MOV: | |
4071 | + return MIME_MOV; | |
4072 | + case ChanInfo::T_MPG: | |
4073 | + return MIME_MPG; | |
4074 | + case ChanInfo::T_NSV: | |
4075 | + return MIME_NSV; | |
4076 | + case ChanInfo::T_ASX: | |
4077 | + return MIME_ASX; | |
4078 | + case ChanInfo::T_WMA: | |
4079 | + return MIME_WMA; | |
4080 | + case ChanInfo::T_WMV: | |
4081 | + return MIME_WMV; | |
4082 | + default: | |
4083 | + return "application/octet-stream"; | |
4084 | + } | |
4085 | +} | |
4086 | +// ----------------------------------- | |
4030 | 4087 | ChanInfo::TYPE ChanInfo::getTypeFromStr(const char *str) |
4031 | 4088 | { |
4032 | 4089 | if (stricmp(str,"MP3")==0) |
@@ -4195,6 +4252,24 @@ bool ChanInfo::update(ChanInfo &info) | ||
4195 | 4252 | changed = true; |
4196 | 4253 | } |
4197 | 4254 | |
4255 | + if (!contentTypeStr.isSame(info.contentTypeStr)) | |
4256 | + { | |
4257 | + contentTypeStr = info.contentTypeStr; | |
4258 | + changed = true; | |
4259 | + } | |
4260 | + | |
4261 | + if (!streamType.isSame(info.streamType)) | |
4262 | + { | |
4263 | + streamType = info.streamType; | |
4264 | + changed = true; | |
4265 | + } | |
4266 | + | |
4267 | + if (!streamExt.isSame(info.streamExt)) | |
4268 | + { | |
4269 | + streamExt = info.streamExt; | |
4270 | + changed = true; | |
4271 | + } | |
4272 | + | |
4198 | 4273 | if(ppFlags != info.ppFlags) //JP-MOD |
4199 | 4274 | { |
4200 | 4275 | ppFlags = info.ppFlags; |
@@ -4253,6 +4328,9 @@ void ChanInfo::init() | ||
4253 | 4328 | name.clear(); |
4254 | 4329 | bitrate = 0; |
4255 | 4330 | contentType = T_UNKNOWN; |
4331 | + contentTypeStr.clear(); | |
4332 | + streamType.clear(); | |
4333 | + streamExt.clear(); | |
4256 | 4334 | srcProtocol = SP_UNKNOWN; |
4257 | 4335 | id.clear(); |
4258 | 4336 | url.clear(); |
@@ -4346,6 +4424,13 @@ void ChanInfo::readInfoAtoms(AtomStream &atom,int numc) | ||
4346 | 4424 | char type[16]; |
4347 | 4425 | atom.readString(type,sizeof(type),d); |
4348 | 4426 | contentType = ChanInfo::getTypeFromStr(type); |
4427 | + contentTypeStr = type; | |
4428 | + }else if (id == PCP_CHAN_INFO_STREAMTYPE) | |
4429 | + { | |
4430 | + atom.readString(streamType.data,sizeof(streamType.data),d); | |
4431 | + }else if (id == PCP_CHAN_INFO_STREAMEXT) | |
4432 | + { | |
4433 | + atom.readString(streamExt.data,sizeof(streamExt.data),d); | |
4349 | 4434 | }else if (id == PCP_CHAN_INFO_PPFLAGS) //JP-MOD |
4350 | 4435 | { |
4351 | 4436 | ppFlags = (unsigned int)atom.readInt(); |
@@ -4364,7 +4449,11 @@ void ChanInfo::writeInfoAtoms(AtomStream &atom) | ||
4364 | 4449 | atom.writeString(PCP_CHAN_INFO_URL,url.cstr()); |
4365 | 4450 | atom.writeString(PCP_CHAN_INFO_DESC,desc.cstr()); |
4366 | 4451 | atom.writeString(PCP_CHAN_INFO_COMMENT,comment.cstr()); |
4367 | - atom.writeString(PCP_CHAN_INFO_TYPE,getTypeStr(contentType)); | |
4452 | + atom.writeString(PCP_CHAN_INFO_TYPE,getTypeStr()); | |
4453 | + if (!streamType.isEmpty()) | |
4454 | + atom.writeString(PCP_CHAN_INFO_STREAMTYPE,streamType.cstr()); | |
4455 | + if (!streamExt.isEmpty()) | |
4456 | + atom.writeString(PCP_CHAN_INFO_STREAMEXT,streamExt.cstr()); | |
4368 | 4457 | if(ppFlags) |
4369 | 4458 | atom.writeInt(PCP_CHAN_INFO_PPFLAGS,ppFlags); //JP-MOD |
4370 | 4459 |
@@ -4409,7 +4498,7 @@ XML::Node *ChanInfo::createChannelXML() | ||
4409 | 4498 | nameUNI.cstr(), |
4410 | 4499 | idStr, |
4411 | 4500 | bitrate, |
4412 | - getTypeStr(contentType), | |
4501 | + getTypeStr(), | |
4413 | 4502 | genreUNI.cstr(), |
4414 | 4503 | descUNI.cstr(), |
4415 | 4504 | urlUNI.cstr(), |
@@ -4533,9 +4622,10 @@ void ChanInfo::updateFromXML(XML::Node *n) | ||
4533 | 4622 | } |
4534 | 4623 | |
4535 | 4624 | readXMLString(typeStr,n,"type"); |
4536 | - if (!typeStr.isEmpty()) | |
4537 | - contentType = getTypeFromStr(typeStr.cstr()); | |
4538 | - | |
4625 | + if (!typeStr.isEmpty()) { | |
4626 | + contentType = getTypeFromStr(typeStr.cstr()); | |
4627 | + contentTypeStr = typeStr; | |
4628 | + } | |
4539 | 4629 | |
4540 | 4630 | readXMLString(idStr,n,"id"); |
4541 | 4631 | if (!idStr.isEmpty()) |
@@ -4729,7 +4819,7 @@ void PlayList::addChannel(const char *path, ChanInfo &info) | ||
4729 | 4819 | info.id.toStr(idStr); |
4730 | 4820 | char *nid = info.id.isSet()?idStr:info.name.cstr(); |
4731 | 4821 | |
4732 | - sprintf(url.cstr(),"%s/stream/%s%s",path,nid,ChanInfo::getTypeExt(info.contentType)); | |
4822 | + sprintf(url.cstr(),"%s/stream/%s%s",path,nid,info.getTypeExt()); | |
4733 | 4823 | addURL(url.cstr(),info.name,info.url); |
4734 | 4824 | } |
4735 | 4825 |
@@ -148,9 +148,13 @@ public: | ||
148 | 148 | unsigned int getAge(); |
149 | 149 | bool isActive() {return id.isSet();} |
150 | 150 | bool isPrivate() {return bcID.getFlags() & 1;} |
151 | + const char *getTypeStr(); | |
152 | + const char *getTypeExt(); | |
153 | + const char *getMIMEType(); | |
151 | 154 | static const char *getTypeStr(TYPE); |
152 | 155 | static const char *getProtocolStr(PROTOCOL); |
153 | 156 | static const char *getTypeExt(TYPE); |
157 | + static const char *getMIMEType(TYPE); | |
154 | 158 | static TYPE getTypeFromStr(const char *str); |
155 | 159 | static PROTOCOL getProtocolFromStr(const char *str); |
156 | 160 |
@@ -158,6 +162,7 @@ public: | ||
158 | 162 | GnuID id,bcID; |
159 | 163 | int bitrate; |
160 | 164 | TYPE contentType; |
165 | + ::String contentTypeStr,streamType,streamExt; | |
161 | 166 | PROTOCOL srcProtocol; |
162 | 167 | unsigned int lastPlayStart,lastPlayEnd; |
163 | 168 | unsigned int numSkips; |
@@ -109,6 +109,8 @@ static const ID4 PCP_CHAN_PKT_META = "meta"; | ||
109 | 109 | |
110 | 110 | static const ID4 PCP_CHAN_INFO = "info"; |
111 | 111 | static const ID4 PCP_CHAN_INFO_TYPE = "type"; |
112 | +static const ID4 PCP_CHAN_INFO_STREAMTYPE = "styp"; | |
113 | +static const ID4 PCP_CHAN_INFO_STREAMEXT = "sext"; | |
112 | 114 | static const ID4 PCP_CHAN_INFO_BITRATE = "bitr"; |
113 | 115 | static const ID4 PCP_CHAN_INFO_GENRE = "gnre"; |
114 | 116 | static const ID4 PCP_CHAN_INFO_NAME = "name"; |
@@ -1294,33 +1294,12 @@ bool Servent::handshakeStream(ChanInfo &chanInfo) | ||
1294 | 1294 | { |
1295 | 1295 | switch (chanInfo.contentType) |
1296 | 1296 | { |
1297 | - case ChanInfo::T_OGG: | |
1298 | - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_XOGG); | |
1299 | - break; | |
1300 | - case ChanInfo::T_MP3: | |
1301 | - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MP3); | |
1302 | - break; | |
1303 | 1297 | case ChanInfo::T_MOV: |
1304 | 1298 | sock->writeLine("Connection: close"); |
1305 | 1299 | sock->writeLine("Content-Length: 10000000"); |
1306 | - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MOV); | |
1307 | - break; | |
1308 | - case ChanInfo::T_MPG: | |
1309 | - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MPG); | |
1310 | - break; | |
1311 | - case ChanInfo::T_NSV: | |
1312 | - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_NSV); | |
1313 | - break; | |
1314 | - case ChanInfo::T_ASX: | |
1315 | - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_ASX); | |
1316 | - break; | |
1317 | - case ChanInfo::T_WMA: | |
1318 | - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_WMA); | |
1319 | - break; | |
1320 | - case ChanInfo::T_WMV: | |
1321 | - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_WMV); | |
1322 | 1300 | break; |
1323 | 1301 | } |
1302 | + sock->writeLineF("%s %s",HTTP_HS_CONTENT,chanInfo.getMIMEType()); | |
1324 | 1303 | } else if (outputProtocol == ChanInfo::SP_MMS) |
1325 | 1304 | { |
1326 | 1305 | sock->writeLine("Server: Rex/9.0.0.2980"); |
@@ -1893,7 +1893,7 @@ void Servent::handshakeICY(Channel::SRC_TYPE type, bool isHTTP) | ||
1893 | 1893 | info.id = chanMgr->broadcastID; |
1894 | 1894 | info.id.encode(NULL,info.name.cstr(),loginMount.cstr(),info.bitrate); |
1895 | 1895 | |
1896 | - LOG_DEBUG("Incoming source: %s : %s",info.name.cstr(),ChanInfo::getTypeStr(info.contentType)); | |
1896 | + LOG_DEBUG("Incoming source: %s : %s",info.name.cstr(),info.getTypeStr()); | |
1897 | 1897 | |
1898 | 1898 | |
1899 | 1899 | if (isHTTP) |
@@ -1217,7 +1217,7 @@ void ServMgr::saveSettings(const char *fn) | ||
1217 | 1217 | if (!c->sourceURL.isEmpty()) |
1218 | 1218 | iniFile.writeStrValue("sourceURL",c->sourceURL.cstr()); |
1219 | 1219 | iniFile.writeStrValue("sourceProtocol",ChanInfo::getProtocolStr(c->info.srcProtocol)); |
1220 | - iniFile.writeStrValue("contentType",ChanInfo::getTypeStr(c->info.contentType)); | |
1220 | + iniFile.writeStrValue("contentType",c->info.getTypeStr()); | |
1221 | 1221 | iniFile.writeIntValue("bitrate",c->info.bitrate); |
1222 | 1222 | iniFile.writeStrValue("contactURL",c->info.url.cstr()); |
1223 | 1223 | iniFile.writeStrValue("id",idstr); |
@@ -44,9 +44,9 @@ extern int version_ex; // VERSION_EX | ||
44 | 44 | #if 1 /* for VP extend version */ |
45 | 45 | //#define VERSION_EX 1 |
46 | 46 | static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only |
47 | -static const int PCP_CLIENT_VERSION_EX_NUMBER = 45; | |
48 | -static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0045)"; | |
49 | -static const char *PCX_VERSTRING_EX = "v0.1218(IM0045)"; | |
47 | +static const int PCP_CLIENT_VERSION_EX_NUMBER = 50; | |
48 | +static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0050)"; | |
49 | +static const char *PCX_VERSTRING_EX = "v0.1218(IM0050)"; | |
50 | 50 | |
51 | 51 | static const char *PCP_CLIENT_DIST_URL = "http://pecaim.net/"; |
52 | 52 | static const char *PCP_CLIENT_VERSION_URL = "version.pecaim.net"; |