From 0a55e16b1466333c8372b7d60f4f1072cc2ded44 Mon Sep 17 00:00:00 2001 From: eru Date: Mon, 11 Jan 2016 21:37:12 +0900 Subject: [PATCH] =?utf8?q?FLV=E3=81=AE=E8=A6=96=E8=81=B4=E3=83=BB=E3=83=AA?= =?utf8?q?=E3=83=AC=E3=83=BC=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- core/common/channel.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++++---- core/common/channel.h | 5 +++ core/common/pcp.h | 2 + core/common/servent.cpp | 23 +---------- core/common/servhs.cpp | 2 +- core/common/servmgr.cpp | 2 +- core/common/version2.h | 6 +-- 7 files changed, 112 insertions(+), 36 deletions(-) diff --git a/core/common/channel.cpp b/core/common/channel.cpp index a49f282..970ac9a 100644 --- a/core/common/channel.cpp +++ b/core/common/channel.cpp @@ -2101,7 +2101,7 @@ void Channel::getStreamPath(char *str) getIDStr(idStr); - sprintf(str,"/stream/%s%s",idStr,info.getTypeExt(info.contentType)); + sprintf(str,"/stream/%s%s",idStr,info.getTypeExt()); } @@ -2506,9 +2506,9 @@ bool Channel::writeVariable(Stream &out, const String &var, int index) strcpy(buf,uptime.cstr()); } else if (var == "type") - sprintf(buf,"%s",ChanInfo::getTypeStr(info.contentType)); + sprintf(buf,"%s",info.getTypeStr()); else if (var == "ext") - sprintf(buf,"%s",ChanInfo::getTypeExt(info.contentType)); + sprintf(buf,"%s",info.getTypeExt()); else if (var == "proto") { switch(info.contentType) { case ChanInfo::T_WMA: @@ -3952,6 +3952,36 @@ unsigned int ChanHitList::getSeq() } // ----------------------------------- +const char *ChanInfo::getTypeStr() +{ + if (contentTypeStr.isEmpty()) { + return getTypeStr(contentType); + } + else { + return contentTypeStr.cstr(); + } +} +// ----------------------------------- +const char *ChanInfo::getTypeExt() +{ + if (streamExt.isEmpty()) { + return getTypeExt(contentType); + } + else { + return streamExt.cstr(); + } +} +// ----------------------------------- +const char *ChanInfo::getMIMEType() +{ + if (streamType.isEmpty()) { + return getMIMEType(contentType); + } + else { + return streamType.cstr(); + } +} +// ----------------------------------- const char *ChanInfo::getTypeStr(TYPE t) { switch (t) @@ -4027,6 +4057,33 @@ const char *ChanInfo::getTypeExt(TYPE t) } } // ----------------------------------- +const char *ChanInfo::getMIMEType(TYPE t) +{ + switch(t) + { + case ChanInfo::T_OGG: + return MIME_XOGG; + case ChanInfo::T_OGM: + return MIME_XOGG; + case ChanInfo::T_MP3: + return MIME_MP3; + case ChanInfo::T_MOV: + return MIME_MOV; + case ChanInfo::T_MPG: + return MIME_MPG; + case ChanInfo::T_NSV: + return MIME_NSV; + case ChanInfo::T_ASX: + return MIME_ASX; + case ChanInfo::T_WMA: + return MIME_WMA; + case ChanInfo::T_WMV: + return MIME_WMV; + default: + return "application/octet-stream"; + } +} +// ----------------------------------- ChanInfo::TYPE ChanInfo::getTypeFromStr(const char *str) { if (stricmp(str,"MP3")==0) @@ -4195,6 +4252,24 @@ bool ChanInfo::update(ChanInfo &info) changed = true; } + if (!contentTypeStr.isSame(info.contentTypeStr)) + { + contentTypeStr = info.contentTypeStr; + changed = true; + } + + if (!streamType.isSame(info.streamType)) + { + streamType = info.streamType; + changed = true; + } + + if (!streamExt.isSame(info.streamExt)) + { + streamExt = info.streamExt; + changed = true; + } + if(ppFlags != info.ppFlags) //JP-MOD { ppFlags = info.ppFlags; @@ -4253,6 +4328,9 @@ void ChanInfo::init() name.clear(); bitrate = 0; contentType = T_UNKNOWN; + contentTypeStr.clear(); + streamType.clear(); + streamExt.clear(); srcProtocol = SP_UNKNOWN; id.clear(); url.clear(); @@ -4346,6 +4424,13 @@ void ChanInfo::readInfoAtoms(AtomStream &atom,int numc) char type[16]; atom.readString(type,sizeof(type),d); contentType = ChanInfo::getTypeFromStr(type); + contentTypeStr = type; + }else if (id == PCP_CHAN_INFO_STREAMTYPE) + { + atom.readString(streamType.data,sizeof(streamType.data),d); + }else if (id == PCP_CHAN_INFO_STREAMEXT) + { + atom.readString(streamExt.data,sizeof(streamExt.data),d); }else if (id == PCP_CHAN_INFO_PPFLAGS) //JP-MOD { ppFlags = (unsigned int)atom.readInt(); @@ -4364,7 +4449,11 @@ void ChanInfo::writeInfoAtoms(AtomStream &atom) atom.writeString(PCP_CHAN_INFO_URL,url.cstr()); atom.writeString(PCP_CHAN_INFO_DESC,desc.cstr()); atom.writeString(PCP_CHAN_INFO_COMMENT,comment.cstr()); - atom.writeString(PCP_CHAN_INFO_TYPE,getTypeStr(contentType)); + atom.writeString(PCP_CHAN_INFO_TYPE,getTypeStr()); + if (!streamType.isEmpty()) + atom.writeString(PCP_CHAN_INFO_STREAMTYPE,streamType.cstr()); + if (!streamExt.isEmpty()) + atom.writeString(PCP_CHAN_INFO_STREAMEXT,streamExt.cstr()); if(ppFlags) atom.writeInt(PCP_CHAN_INFO_PPFLAGS,ppFlags); //JP-MOD @@ -4409,7 +4498,7 @@ XML::Node *ChanInfo::createChannelXML() nameUNI.cstr(), idStr, bitrate, - getTypeStr(contentType), + getTypeStr(), genreUNI.cstr(), descUNI.cstr(), urlUNI.cstr(), @@ -4533,9 +4622,10 @@ void ChanInfo::updateFromXML(XML::Node *n) } readXMLString(typeStr,n,"type"); - if (!typeStr.isEmpty()) - contentType = getTypeFromStr(typeStr.cstr()); - + if (!typeStr.isEmpty()) { + contentType = getTypeFromStr(typeStr.cstr()); + contentTypeStr = typeStr; + } readXMLString(idStr,n,"id"); if (!idStr.isEmpty()) @@ -4729,7 +4819,7 @@ void PlayList::addChannel(const char *path, ChanInfo &info) info.id.toStr(idStr); char *nid = info.id.isSet()?idStr:info.name.cstr(); - sprintf(url.cstr(),"%s/stream/%s%s",path,nid,ChanInfo::getTypeExt(info.contentType)); + sprintf(url.cstr(),"%s/stream/%s%s",path,nid,info.getTypeExt()); addURL(url.cstr(),info.name,info.url); } diff --git a/core/common/channel.h b/core/common/channel.h index bfbf66b..17c4a2c 100644 --- a/core/common/channel.h +++ b/core/common/channel.h @@ -148,9 +148,13 @@ public: unsigned int getAge(); bool isActive() {return id.isSet();} bool isPrivate() {return bcID.getFlags() & 1;} + const char *getTypeStr(); + const char *getTypeExt(); + const char *getMIMEType(); static const char *getTypeStr(TYPE); static const char *getProtocolStr(PROTOCOL); static const char *getTypeExt(TYPE); + static const char *getMIMEType(TYPE); static TYPE getTypeFromStr(const char *str); static PROTOCOL getProtocolFromStr(const char *str); @@ -158,6 +162,7 @@ public: GnuID id,bcID; int bitrate; TYPE contentType; + ::String contentTypeStr,streamType,streamExt; PROTOCOL srcProtocol; unsigned int lastPlayStart,lastPlayEnd; unsigned int numSkips; diff --git a/core/common/pcp.h b/core/common/pcp.h index b4f2bfb..21bc0a9 100644 --- a/core/common/pcp.h +++ b/core/common/pcp.h @@ -109,6 +109,8 @@ static const ID4 PCP_CHAN_PKT_META = "meta"; static const ID4 PCP_CHAN_INFO = "info"; static const ID4 PCP_CHAN_INFO_TYPE = "type"; +static const ID4 PCP_CHAN_INFO_STREAMTYPE = "styp"; +static const ID4 PCP_CHAN_INFO_STREAMEXT = "sext"; static const ID4 PCP_CHAN_INFO_BITRATE = "bitr"; static const ID4 PCP_CHAN_INFO_GENRE = "gnre"; static const ID4 PCP_CHAN_INFO_NAME = "name"; diff --git a/core/common/servent.cpp b/core/common/servent.cpp index b6e8ed2..fc1e1ba 100644 --- a/core/common/servent.cpp +++ b/core/common/servent.cpp @@ -1294,33 +1294,12 @@ bool Servent::handshakeStream(ChanInfo &chanInfo) { switch (chanInfo.contentType) { - case ChanInfo::T_OGG: - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_XOGG); - break; - case ChanInfo::T_MP3: - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MP3); - break; case ChanInfo::T_MOV: sock->writeLine("Connection: close"); sock->writeLine("Content-Length: 10000000"); - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MOV); - break; - case ChanInfo::T_MPG: - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MPG); - break; - case ChanInfo::T_NSV: - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_NSV); - break; - case ChanInfo::T_ASX: - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_ASX); - break; - case ChanInfo::T_WMA: - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_WMA); - break; - case ChanInfo::T_WMV: - sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_WMV); break; } + sock->writeLineF("%s %s",HTTP_HS_CONTENT,chanInfo.getMIMEType()); } else if (outputProtocol == ChanInfo::SP_MMS) { sock->writeLine("Server: Rex/9.0.0.2980"); diff --git a/core/common/servhs.cpp b/core/common/servhs.cpp index 66f8e38..b153706 100644 --- a/core/common/servhs.cpp +++ b/core/common/servhs.cpp @@ -1893,7 +1893,7 @@ void Servent::handshakeICY(Channel::SRC_TYPE type, bool isHTTP) info.id = chanMgr->broadcastID; info.id.encode(NULL,info.name.cstr(),loginMount.cstr(),info.bitrate); - LOG_DEBUG("Incoming source: %s : %s",info.name.cstr(),ChanInfo::getTypeStr(info.contentType)); + LOG_DEBUG("Incoming source: %s : %s",info.name.cstr(),info.getTypeStr()); if (isHTTP) diff --git a/core/common/servmgr.cpp b/core/common/servmgr.cpp index e2b911c..2d064c6 100644 --- a/core/common/servmgr.cpp +++ b/core/common/servmgr.cpp @@ -1217,7 +1217,7 @@ void ServMgr::saveSettings(const char *fn) if (!c->sourceURL.isEmpty()) iniFile.writeStrValue("sourceURL",c->sourceURL.cstr()); iniFile.writeStrValue("sourceProtocol",ChanInfo::getProtocolStr(c->info.srcProtocol)); - iniFile.writeStrValue("contentType",ChanInfo::getTypeStr(c->info.contentType)); + iniFile.writeStrValue("contentType",c->info.getTypeStr()); iniFile.writeIntValue("bitrate",c->info.bitrate); iniFile.writeStrValue("contactURL",c->info.url.cstr()); iniFile.writeStrValue("id",idstr); diff --git a/core/common/version2.h b/core/common/version2.h index ce680f9..f47498e 100644 --- a/core/common/version2.h +++ b/core/common/version2.h @@ -44,9 +44,9 @@ extern int version_ex; // VERSION_EX #if 1 /* for VP extend version */ //#define VERSION_EX 1 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only -static const int PCP_CLIENT_VERSION_EX_NUMBER = 45; -static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0045)"; -static const char *PCX_VERSTRING_EX = "v0.1218(IM0045)"; +static const int PCP_CLIENT_VERSION_EX_NUMBER = 50; +static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0050)"; +static const char *PCX_VERSTRING_EX = "v0.1218(IM0050)"; static const char *PCP_CLIENT_DIST_URL = "http://pecaim.net/"; static const char *PCP_CLIENT_VERSION_URL = "version.pecaim.net"; -- 2.11.0