Revision | f9238f2bf489d476ded8f4c5ef72eed91136615b (tree) |
---|---|
Time | 2010-10-23 03:24:46 |
Author | eru <eru01@user...> |
Commiter | eru |
Android OS内蔵プレイヤーからの再生に一応対応
@@ -1335,10 +1335,17 @@ bool Servent::handshakeStream(ChanInfo &chanInfo) | ||
1335 | 1335 | sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MMS); |
1336 | 1336 | }else |
1337 | 1337 | { |
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 | + } | |
1342 | 1349 | } |
1343 | 1350 | |
1344 | 1351 | } else if (outputProtocol == ChanInfo::SP_PCP) |
@@ -382,7 +382,59 @@ void Servent::handshakeHTTP(HTTP &http, bool isHTTP) | ||
382 | 382 | handshakeICY(Channel::SRC_ICECAST,isHTTP); |
383 | 383 | sock = NULL; // socket is taken over by channel, so don`t close it |
384 | 384 | |
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)) | |
386 | 438 | { |
387 | 439 | if (!isAllowed(ALLOW_BROADCAST)) |
388 | 440 | throw HTTPException(HTTP_SC_UNAVAILABLE,503); |
@@ -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 = 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)"; | |
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"; |
@@ -1335,10 +1335,17 @@ bool Servent::handshakeStream(ChanInfo &chanInfo) | ||
1335 | 1335 | sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_MMS); |
1336 | 1336 | }else |
1337 | 1337 | { |
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 | + } | |
1342 | 1349 | } |
1343 | 1350 | |
1344 | 1351 | } else if (outputProtocol == ChanInfo::SP_PCP) |
@@ -382,7 +382,59 @@ void Servent::handshakeHTTP(HTTP &http, bool isHTTP) | ||
382 | 382 | handshakeICY(Channel::SRC_ICECAST,isHTTP); |
383 | 383 | sock = NULL; // socket is taken over by channel, so don`t close it |
384 | 384 | |
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)) | |
386 | 438 | { |
387 | 439 | if (!isAllowed(ALLOW_BROADCAST)) |
388 | 440 | throw HTTPException(HTTP_SC_UNAVAILABLE,503); |
@@ -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 = 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)"; | |
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"; |