• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionf9238f2bf489d476ded8f4c5ef72eed91136615b (tree)
Time2010-10-23 03:24:46
Authoreru <eru01@user...>
Commitereru

Log Message

Android OS内蔵プレイヤーからの再生に一応対応

Change Summary

Incremental Difference

--- a/PeerCast.root/PeerCast/core/common/servent.cpp
+++ b/PeerCast.root/PeerCast/core/common/servent.cpp
@@ -1335,10 +1335,17 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
13351335 sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MMS);
13361336 }else
13371337 {
1338- sock->writeLine("Content-Type: application/vnd.ms.wms-hdr.asfv1");
1339- if (ch)
1340- sock->writeLineF("Content-Length: %d",ch->headPack.len);
1341- sock->writeLine("Connection: Keep-Alive");
1338+ if (agent.contains("Android"))
1339+ {
1340+ LOG_DEBUG("INFO: Android client detected.");
1341+ sock->writeLineF("%s %s", HTTP_HS_CONTENT, MIME_WMV);
1342+ } else
1343+ {
1344+ sock->writeLine("Content-Type: application/vnd.ms.wms-hdr.asfv1");
1345+ if (ch)
1346+ sock->writeLineF("Content-Length: %d",ch->headPack.len);
1347+ sock->writeLine("Connection: Keep-Alive");
1348+ }
13421349 }
13431350
13441351 } else if (outputProtocol == ChanInfo::SP_PCP)
--- a/PeerCast.root/PeerCast/core/common/servhs.cpp
+++ b/PeerCast.root/PeerCast/core/common/servhs.cpp
@@ -382,7 +382,59 @@ void Servent::handshakeHTTP(HTTP &http, bool isHTTP)
382382 handshakeICY(Channel::SRC_ICECAST,isHTTP);
383383 sock = NULL; // socket is taken over by channel, so don`t close it
384384
385- }else if (http.isRequest(servMgr->password))
385+ } else if (http.isRequest("HEAD")) // for android client
386+ {
387+ char *str = in + 4;
388+
389+ if (str = stristr(str, "/stream/"))
390+ {
391+ int cnt = 0;
392+
393+ str += 8;
394+ while (*str && (('0' <= *str && *str <= '9') || ('A' <= *str && *str <= 'F') || ('a' <= *str && *str <= 'f')))
395+ ++cnt, ++str;
396+
397+ if (cnt == 32 && !strncmp(str, ".wmv", 4))
398+ {
399+ // interpret "HEAD /stream/[0-9a-fA-F]{32}.wmv" as GET
400+ LOG_DEBUG("INFO: interpret as GET");
401+
402+ char *fn = in+5;
403+
404+ char *pt = strstr(fn,HTTP_PROTO1);
405+ if (pt)
406+ pt[-1] = 0;
407+
408+ if (!sock->host.isLocalhost())
409+ if (!isAllowed(ALLOW_DIRECT) || !isFiltered(ServFilter::F_DIRECT))
410+ throw HTTPException(HTTP_SC_UNAVAILABLE,503);
411+
412+ triggerChannel(fn+8,ChanInfo::SP_HTTP,isPrivate());
413+
414+ return;
415+ }
416+ }
417+
418+ if (http.isRequest(servMgr->password))
419+ {
420+ if (!isAllowed(ALLOW_BROADCAST))
421+ throw HTTPException(HTTP_SC_UNAVAILABLE,503);
422+
423+ loginPassword.set(servMgr->password); // pwd already checked
424+
425+ sock->writeLine("OK2");
426+ sock->writeLine("icy-caps:11");
427+ sock->writeLine("");
428+ LOG_DEBUG("ShoutCast client");
429+
430+ handshakeICY(Channel::SRC_SHOUTCAST,isHTTP);
431+ sock = NULL; // socket is taken over by channel, so don`t close it
432+
433+ }else
434+ {
435+ throw HTTPException(HTTP_SC_BADREQUEST,400);
436+ }
437+ } else if (http.isRequest(servMgr->password))
386438 {
387439 if (!isAllowed(ALLOW_BROADCAST))
388440 throw HTTPException(HTTP_SC_UNAVAILABLE,503);
--- a/PeerCast.root/PeerCast/core/common/version2.h
+++ b/PeerCast.root/PeerCast/core/common/version2.h
@@ -44,9 +44,9 @@ extern int version_ex; // VERSION_EX
4444 #if 1 /* for VP extend version */
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
47-static const int PCP_CLIENT_VERSION_EX_NUMBER = 40;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0040)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0040)";
47+static const int PCP_CLIENT_VERSION_EX_NUMBER = 41;
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0041)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0041)";
5050
5151 static const char *PCP_CLIENT_DIST_URL = "http://pecaim.net/";
5252 static const char *PCP_CLIENT_VERSION_URL = "version.pecaim.net";
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp
@@ -1335,10 +1335,17 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
13351335 sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MMS);
13361336 }else
13371337 {
1338- sock->writeLine("Content-Type: application/vnd.ms.wms-hdr.asfv1");
1339- if (ch)
1340- sock->writeLineF("Content-Length: %d",ch->headPack.len);
1341- sock->writeLine("Connection: Keep-Alive");
1338+ if (agent.contains("Android"))
1339+ {
1340+ LOG_DEBUG("INFO: Android client detected.");
1341+ sock->writeLineF("%s %s", HTTP_HS_CONTENT, MIME_WMV);
1342+ } else
1343+ {
1344+ sock->writeLine("Content-Type: application/vnd.ms.wms-hdr.asfv1");
1345+ if (ch)
1346+ sock->writeLineF("Content-Length: %d",ch->headPack.len);
1347+ sock->writeLine("Connection: Keep-Alive");
1348+ }
13421349 }
13431350
13441351 } else if (outputProtocol == ChanInfo::SP_PCP)
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp
@@ -382,7 +382,59 @@ void Servent::handshakeHTTP(HTTP &http, bool isHTTP)
382382 handshakeICY(Channel::SRC_ICECAST,isHTTP);
383383 sock = NULL; // socket is taken over by channel, so don`t close it
384384
385- }else if (http.isRequest(servMgr->password))
385+ } else if (http.isRequest("HEAD")) // for android client
386+ {
387+ char *str = in + 4;
388+
389+ if (str = stristr(str, "/stream/"))
390+ {
391+ int cnt = 0;
392+
393+ str += 8;
394+ while (*str && (('0' <= *str && *str <= '9') || ('A' <= *str && *str <= 'F') || ('a' <= *str && *str <= 'f')))
395+ ++cnt, ++str;
396+
397+ if (cnt == 32 && !strncmp(str, ".wmv", 4))
398+ {
399+ // interpret "HEAD /stream/[0-9a-fA-F]{32}.wmv" as GET
400+ LOG_DEBUG("INFO: interpret as GET");
401+
402+ char *fn = in+5;
403+
404+ char *pt = strstr(fn,HTTP_PROTO1);
405+ if (pt)
406+ pt[-1] = 0;
407+
408+ if (!sock->host.isLocalhost())
409+ if (!isAllowed(ALLOW_DIRECT) || !isFiltered(ServFilter::F_DIRECT))
410+ throw HTTPException(HTTP_SC_UNAVAILABLE,503);
411+
412+ triggerChannel(fn+8,ChanInfo::SP_HTTP,isPrivate());
413+
414+ return;
415+ }
416+ }
417+
418+ if (http.isRequest(servMgr->password))
419+ {
420+ if (!isAllowed(ALLOW_BROADCAST))
421+ throw HTTPException(HTTP_SC_UNAVAILABLE,503);
422+
423+ loginPassword.set(servMgr->password); // pwd already checked
424+
425+ sock->writeLine("OK2");
426+ sock->writeLine("icy-caps:11");
427+ sock->writeLine("");
428+ LOG_DEBUG("ShoutCast client");
429+
430+ handshakeICY(Channel::SRC_SHOUTCAST,isHTTP);
431+ sock = NULL; // socket is taken over by channel, so don`t close it
432+
433+ }else
434+ {
435+ throw HTTPException(HTTP_SC_BADREQUEST,400);
436+ }
437+ } else if (http.isRequest(servMgr->password))
386438 {
387439 if (!isAllowed(ALLOW_BROADCAST))
388440 throw HTTPException(HTTP_SC_UNAVAILABLE,503);
--- a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
@@ -44,9 +44,9 @@ extern int version_ex; // VERSION_EX
4444 #if 1 /* for VP extend version */
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
47-static const int PCP_CLIENT_VERSION_EX_NUMBER = 40;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0040)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0040)";
47+static const int PCP_CLIENT_VERSION_EX_NUMBER = 41;
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0041)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0041)";
5050
5151 static const char *PCP_CLIENT_DIST_URL = "http://pecaim.net/";
5252 static const char *PCP_CLIENT_VERSION_URL = "version.pecaim.net";