OSDN Git Service

2012/01/24 21:33:17
[nlite/nlite.git] / nlib / nlib_nicoLive.c
index 5237840..fb6e9d2 100644 (file)
@@ -76,7 +76,7 @@ static CRITICAL_SECTION heartBeatCs;
 ///
 ///\83v\83\8c\83C\83\84\81[\83X\83e\81[\83^\83X\8eæ\93¾
 ///
-static INLINE NLIB_RESULT GetPlayerStatus(NicoLivePlayerStatus_P pPlayerStatus,LPCWSTR userSession,HINTERNET hConnect,LPVOID buffer);
+static INLINE NLIB_RESULT GetPlayerStatus(NicoLivePlayerStatus_P pPlayerStatus,LPCTSTR userSession,HINTERNET hConnect,LPVOID buffer);
 
 ///
 ///nicoLiveHistory\8eæ\93¾
@@ -126,7 +126,7 @@ static unsigned int loopCommon(NicoLiveStream_P self,WSAEVENT sendEvent,WSAEVENT
 ///
 ///\83R\83\81\83\93\83g\89ð\90Í\8aÖ\90\94
 ///
-static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentBufSize);
+static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPTSTR commentBuf,UINT_PTR endSize,LPTSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentBufSize);
 
 static void NicoLiveError(void *buf);
 
@@ -138,7 +138,7 @@ static VOID OnSendKeepAllive(NicoLiveStream_P self);
 ///
 ///\83\\83P\83b\83g\8eæ\93¾\8aÖ\90\94
 ///
-static INLINE SOCKET GetConectedSocket(LPCWSTR nordName,LPCWSTR port,int socktype,int addr_famiry,int protocol);
+static INLINE SOCKET GetConectedSocket(LPCTSTR nordName,LPCTSTR port,int socktype,int addr_famiry,int protocol);
 
 
 StreamStatus_P NicoLiveStream_getStreamStatus(NicoLiveStream_P self){
@@ -154,12 +154,12 @@ BOOL Initialize_NicoLive(){
 
        //\83n\81[\83g\83r\81[\83g\83R\83\93\83e\83i\8f\89\8aú\89»
        ZeroMemory(&heartBeatContainer,sizeof(heartBeatContainer));
-       heartBeatContainer.is_restrictSize = sizeof(WCHAR) * LENGTH_1024;
-       heartBeatContainer.is_restrictBuff = (LPWSTR)calloc(1,heartBeatContainer.is_restrictSize);
+       heartBeatContainer.is_restrictSize = sizeof(TCHAR) * LENGTH_1024;
+       heartBeatContainer.is_restrictBuff = (LPTSTR)calloc(1,heartBeatContainer.is_restrictSize);
        heartBeatContainer.heartBeat.is_restrict = heartBeatContainer.is_restrictBuff;
 
-       heartBeatContainer.ticketSize = sizeof(WCHAR) * LENGTH_1024;
-       heartBeatContainer.ticketBuff = (LPWSTR)calloc(1,heartBeatContainer.ticketSize);
+       heartBeatContainer.ticketSize = sizeof(TCHAR) * LENGTH_1024;
+       heartBeatContainer.ticketBuff = (LPTSTR)calloc(1,heartBeatContainer.ticketSize);
        heartBeatContainer.heartBeat.ticket = heartBeatContainer.ticketBuff;
 
        InitializeCriticalSection(&heartBeatCs);
@@ -210,7 +210,7 @@ NicoLiveStream_P NicoLiveStream_new(){
 
        self->chatManager.keepAliveTime = 900000;
 
-       self->chatManager.keapALiveFlag = FALSE;
+       self->chatManager.keapALiveFlag = TRUE;
 
        self->isConnecting = FALSE;
 
@@ -407,12 +407,12 @@ INT_PTR NicoLiveStream_getResFrom(NicoLiveStream_P self){
        return (-1) * self->res_from;
 }
 
-NLIB_RESULT NicoLiveStream_connect(NicoLiveStream_P self,NicoVideoAuth_P nicoVideoAuth,LPCWSTR url,NicoRecvCallBack callback,LPVOID option){
+NLIB_RESULT NicoLiveStream_connect(NicoLiveStream_P self,NicoVideoAuth_P nicoVideoAuth,LPCTSTR url,NicoRecvCallBack callback,LPVOID option){
 
 #define NICOLIVE_CONNECTIONSTREAM_COOKIE_COUNT         1
 #define LIVENO_LENGTH                                                          LENGTH_NICOLIVEID
 
-       NLIB_RESULT rslt = NLIB_ERR_OK;
+       NLIB_RESULT rslt = NLIB_ERR_CODE_NOTSET;
 
 
 
@@ -421,10 +421,10 @@ NLIB_RESULT NicoLiveStream_connect(NicoLiveStream_P self,NicoVideoAuth_P nicoVid
 
 
        //url\82©\82ç\90Ú\91±\94Ô\8d\86\82ð\92\8a\8fo
-       LPCWSTR pInputLiveNo = url;
-       LPCWSTR psrech = wcsstr(url,L"http://");
-       LPCWSTR pInputLiveNoEnd;
-       WCHAR liveNo[LIVENO_LENGTH] = {0};
+       LPCTSTR pInputLiveNo = url;
+       LPCTSTR psrech = wcsstr(url,L"http://");
+       LPCTSTR pInputLiveNoEnd;
+       TCHAR liveNo[LIVENO_LENGTH] = {0};
        
 
        if(self == NULL)goto end;
@@ -454,7 +454,7 @@ NLIB_RESULT NicoLiveStream_connect(NicoLiveStream_P self,NicoVideoAuth_P nicoVid
 
        if(pInputLiveNo == NULL){
 
-               rslt = NLIB_LIVENO_FAILED_INPUT;
+               rslt = NLIB_LIVENO_IS_NULL;
                goto end;
 
        }else if(pInputLiveNoEnd - pInputLiveNo + 2 >= LIVENO_LENGTH - 1){
@@ -492,14 +492,14 @@ NLIB_RESULT NicoLiveStream_connect(NicoLiveStream_P self,NicoVideoAuth_P nicoVid
 
 
        {
-               WCHAR objectName[LENGTH_256] = {L"api/getplayerstatus?v="};
+               TCHAR objectName[LENGTH_256] = {L"api/getplayerstatus?v="};
                wcsncat(objectName,liveNo,sizeof(objectName) / sizeof(objectName[0]));
 
 
 
        
 
-               self->sessionManager.getPlayerStatusSession = WinHttpOpenRequest(hWatchLiveNicoConnect,L"GET",objectName,L"1.1",(LPCWSTR)WINHTTP_NO_REFERER,(LPCWSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
+               self->sessionManager.getPlayerStatusSession = WinHttpOpenRequest(hWatchLiveNicoConnect,L"GET",objectName,L"1.1",(LPCTSTR)WINHTTP_NO_REFERER,(LPCTSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
        }
 
        //\83v\83\8c\83C\83\84\81[\83X\83e\81[\83^\83X\8eæ\93¾
@@ -524,6 +524,8 @@ NLIB_RESULT NicoLiveStream_connect(NicoLiveStream_P self,NicoVideoAuth_P nicoVid
 
        self->isConnecting = TRUE;
 
+
+       rslt = NLIB_ERR_OK;
        //nicoLiveHistory\82ð\8eæ\93¾(\95K\97v\82È\82µ\81H)
        //GetNicoLiveHistory(self,hWatchLiveNicVideo);
 
@@ -537,10 +539,10 @@ end:
 NLIB_RESULT NicoLiveStream_sendHeartBeat(NicoLiveStream_P self){
 
        
-       NLIB_RESULT rslt = NLIB_ERR_OK;
+       NLIB_RESULT rslt = NLIB_ERR_CODE_NOTSET;
 
        if(self->isConnecting == FALSE){
-               rslt = NLIB_ERR_NOT_CONNECT;
+               rslt = NLIB_ERR_NOT_LIVECONNECT;
                goto end;
        }
        if(self == NULL || self->playerStatus.error != NLIB_ERR_OK){
@@ -558,9 +560,9 @@ NLIB_RESULT NicoLiveStream_sendHeartBeat(NicoLiveStream_P self){
                const UINT_PTR buflen = LENGTH_65536;
                LPVOID buffer = self->sessionManager.buffer;
         
-               LPWSTR objectName = (LPWSTR)buffer;
-               LPWSTR indexPtr;
-               //LPWSTR sendBuffer = (LPWSTR)&objectName[LENGTH_4096];
+               LPTSTR objectName = (LPTSTR)buffer;
+               LPTSTR indexPtr;
+               //LPTSTR sendBuffer = (LPTSTR)&objectName[LENGTH_4096];
                LPSTR recvBuffer = (LPSTR)&objectName[LENGTH_4096];
                DWORD readSize;
                DWORD statusCode;
@@ -579,7 +581,7 @@ NLIB_RESULT NicoLiveStream_sendHeartBeat(NicoLiveStream_P self){
 
        
                if(self->sessionManager.heartBeatSession == NULL){
-                       self->sessionManager.heartBeatSession = WinHttpOpenRequest(hWatchLiveNicoConnect,L"GET",objectName,L"1.1",(LPCWSTR)WINHTTP_NO_REFERER,(LPCWSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
+                       self->sessionManager.heartBeatSession = WinHttpOpenRequest(hWatchLiveNicoConnect,L"GET",objectName,L"1.1",(LPCTSTR)WINHTTP_NO_REFERER,(LPCTSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
                
                }
                if(WinHttpSendRequest(self->sessionManager.heartBeatSession,self->userSession,-1,WINHTTP_NO_REQUEST_DATA,0,0,0) == FALSE){
@@ -645,6 +647,8 @@ NLIB_RESULT NicoLiveStream_sendHeartBeat(NicoLiveStream_P self){
 
 
                }
+
+               rslt = NLIB_ERR_OK;
 connectend:
                ZeroMemory(self->sessionManager.buffer,sizeof(self->sessionManager.buffer));
                LeaveCriticalSection(&self->sessionManager.cs);
@@ -700,9 +704,9 @@ end:
 #define NICOLIVE_SENDCHATBUFLEN                        LENGTH_4096
 #define NICOLIVE_SENDFORMAT                            "<chat thread=\"%d\" ticket=\"%S\"  postkey=\"%s\" user_id=\"%S\" premium=\"%d\" locale=\"%S\" vpos=\"%ld\"%s>%S</chat>"
 
-NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWSTR *mail,LPCWSTR *extends){
+NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCTSTR chatbuf,LPCTSTR *mail,LPCTSTR *extends){
 
-       NLIB_RESULT rslt = NLIB_ERR_OK;
+       NLIB_RESULT rslt = NLIB_ERR_CODE_NOTSET;
        EnterCriticalSection(&self->sessionManager.cs);
        
        {
@@ -711,8 +715,8 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
 
                LPSTR postKey;
                LPSTR postKeyBuf = (LPSTR)chunk;
-               LPWSTR postKeyReqBuf = (LPWSTR)&postKeyBuf[NICOLIVE_SENDCHATBUFLEN];
-               LPWSTR cookieBuf = &postKeyReqBuf[NICOLIVE_SENDCHATBUFLEN];
+               LPTSTR postKeyReqBuf = (LPTSTR)&postKeyBuf[NICOLIVE_SENDCHATBUFLEN];
+               LPTSTR cookieBuf = &postKeyReqBuf[NICOLIVE_SENDCHATBUFLEN];
                DWORD statusCode;
                DWORD statusCodeSize = sizeof(statusCode);
                DWORD readSize;
@@ -722,13 +726,13 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
                
 
                if(self->isConnecting == FALSE){
-                       rslt = NLIB_ERR_NOT_CONNECT;
-                       goto end;
+                       rslt = NLIB_ERR_NOT_LIVECONNECT;
+                       goto errorend;
                }
                if(chatbuf == NULL || wcslen(chatbuf) >= LENGTH_1024){
 
                        rslt = NLIB_ERR_BUFFER_TOOLITTLE;
-                       goto end;
+                       goto errorend;
 
                }
 
@@ -737,7 +741,7 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
                _swprintf(postKeyReqBuf,L"api/getpostkey?thread=%u&block_no=%u",self->playerStatus.ms.thread,self->chatManager.chatNo / 100);
 
                //hWatchLiveNicoVideo = WinHttpConnect(hHttpSession,WTEXT(WATCH_LIVE_NICO_VIDEO_DOMEINNAME),INTERNET_DEFAULT_HTTP_PORT,0);
-               hGetPostKeySession = WinHttpOpenRequest(hWatchLiveNicoConnect,L"GET",postKeyReqBuf,L"1.1",(LPCWSTR)WINHTTP_NO_REFERER,(LPCWSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
+               hGetPostKeySession = WinHttpOpenRequest(hWatchLiveNicoConnect,L"GET",postKeyReqBuf,L"1.1",(LPCTSTR)WINHTTP_NO_REFERER,(LPCTSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
 
 
                //_swprintf(cookieBuf,L"Cookie: %s; %s",self->userSession,self->nicoLiveHistory);
@@ -745,29 +749,29 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
 
                if(WinHttpSendRequest(hGetPostKeySession,self->userSession,-1,WINHTTP_NO_REQUEST_DATA,0,0,0) == FALSE){
 
-                       rslt = NLIB_GETPLAYERSTATUS_FAILED_CONNECT;
-                       goto end;
+                       rslt = NLIB_ERR_LIVE_GETPOSTKEY_FAILED;
+                       goto errorend;
 
                }
 
 
                if(WinHttpReceiveResponse(hGetPostKeySession,NULL) == FALSE){
 
-                       rslt = NLIB_GETPLAYERSTATUS_FAILED_CONNECT;
-                       goto end;
+                       rslt = NLIB_ERR_LIVE_GETPOSTKEY_FAILED;
+                       goto errorend;
 
                }
 
 
                if (WinHttpQueryHeaders(hGetPostKeySession,WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,WINHTTP_HEADER_NAME_BY_INDEX,&statusCode,&statusCodeSize,WINHTTP_NO_HEADER_INDEX) == FALSE){
-                       rslt = NLIB_GETPLAYERSTATUS_FAILED_CONNECT;
-                       goto end;
+                       rslt = NLIB_ERR_LIVE_GETPOSTKEY_FAILED;
+                       goto errorend;
                }
 
 
                if (HTTP_STATUS_OK != statusCode){
-                       rslt = NLIB_GETPLAYERSTATUS_FAILED_CONNECT;
-                       goto end;
+                       rslt = NLIB_ERR_LIVE_GETPOSTKEY_FAILED;
+                       goto errorend;
                }
 
 
@@ -776,8 +780,8 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
 
                if(ReadHttpBody(hGetPostKeySession,(LPBYTE)postKeyBuf,buflen,&readSize) == FALSE){
 
-                       rslt = NLIB_GETPLAYERSTATUS_FAILED_CONNECT;
-                       goto end;
+                       rslt = NLIB_ERR_LIVE_GETPOSTKEY_FAILED;
+                       goto errorend;
 
                }
                postKeyBuf[readSize] = '\0';
@@ -805,7 +809,7 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
                                len = NICOLIVE_SENDCHATBUFLEN - (indexPtr - mailBuf) - 1;
                                if(GetLenToMB(CP_UTF8,mail[0]) >= len){
                                        rslt = NLIB_ERR_BUFFER_TOOLITTLE;
-                                       goto end;
+                                       goto errorend;
 
                                }
 
@@ -823,7 +827,7 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
 
                                                if(GetLenToMB(CP_UTF8,mail[0]) >= len){
                                                        rslt = NLIB_ERR_BUFFER_TOOLITTLE;
-                                                       goto end;
+                                                       goto errorend;
 
                                                }
 
@@ -854,7 +858,7 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
 
                                if(GetLenToMB(CP_UTF8,extends[0]) >= len){
                                        rslt = NLIB_ERR_BUFFER_TOOLITTLE;
-                                       goto end;
+                                       goto errorend;
 
                                }
                                WideToMB(CP_UTF8,extends[0],indexPtr,len);
@@ -869,7 +873,7 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
 
                                if(GetLenToMB(CP_UTF8,extends[1]) >= len){
                                        rslt = NLIB_ERR_BUFFER_TOOLITTLE;
-                                       goto end;
+                                       goto errorend;
 
                                }
                                WideToMB(CP_UTF8,extends[1],indexPtr,len);
@@ -884,7 +888,7 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
 
                                        if(GetLenToMB(CP_UTF8,extends[0]) >= len){
                                                rslt = NLIB_ERR_BUFFER_TOOLITTLE;
-                                               goto end;
+                                               goto errorend;
 
                                        }
                                        WideToMB(CP_UTF8,extends[0],indexPtr,len);
@@ -899,7 +903,7 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
 
                                        if(GetLenToMB(CP_UTF8,extends[1]) >= len){
                                                rslt = NLIB_ERR_BUFFER_TOOLITTLE;
-                                               goto end;
+                                               goto errorend;
 
                                        }
                                        WideToMB(CP_UTF8,extends[1],indexPtr,len);
@@ -983,9 +987,9 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
                                strcpy(indexPtr,">");
                                indexPtr += strlen(indexPtr);
                                {
-                                       LPWSTR sendBuf = (LPWSTR)&buffer[NICOLIVE_SENDCHATBUFLEN * 4];
-                                       LPWSTR sendPtr = sendBuf;
-                                       LPCWSTR endPtr= chatbuf + wcslen(chatbuf);
+                                       LPTSTR sendBuf = (LPTSTR)&buffer[NICOLIVE_SENDCHATBUFLEN * 4];
+                                       LPTSTR sendPtr = sendBuf;
+                                       LPCTSTR endPtr= chatbuf + wcslen(chatbuf);
 
 
                                        //convertTEXT(indexPtr,chatbuf,indexPtr,endPtr);
@@ -1043,14 +1047,15 @@ NLIB_RESULT NicoLiveStream_sendChat(NicoLiveStream_P self,LPCWSTR chatbuf,LPCWST
                        }
                }
 
+               rslt = NLIB_ERR_OK;
                
-end:
+errorend:
        
-       WinHttpCloseHandle(hGetPostKeySession);
+               WinHttpCloseHandle(hGetPostKeySession);
 
-       ZeroMemory(self->sessionManager.buffer,sizeof(self->sessionManager.buffer));
-       LeaveCriticalSection(&self->sessionManager.cs);
-       }
+               ZeroMemory(self->sessionManager.buffer,sizeof(self->sessionManager.buffer));
+               LeaveCriticalSection(&self->sessionManager.cs);
+               }
 
 
 
@@ -1070,17 +1075,15 @@ end:
 
 
 
-NLIB_RESULT GetPlayerStatus(NicoLivePlayerStatus_P self,LPCWSTR userSession,HINTERNET hConnect,LPVOID buffer){
+NLIB_RESULT GetPlayerStatus(NicoLivePlayerStatus_P self,LPCTSTR userSession,HINTERNET hConnect,LPVOID buffer){
 
        NLIB_RESULT rslt = NLIB_ERR_OK;
 
        
        {
-               //HINTERNET hWatchLiveNicoSession = NULL;
-               //HINTERNET hGetPlayerStatusRequest = NULL;
+               
                const UINT_PTR buflen = LENGTH_65536;
-               //LPVOID buffer = ;
-               //LPWSTR sendBuffer;
+               
                LPSTR recvBuffer = (LPSTR)buffer;
                DWORD readSize;
                DWORD statusCode;
@@ -1116,7 +1119,6 @@ NLIB_RESULT GetPlayerStatus(NicoLivePlayerStatus_P self,LPCWSTR userSession,HINT
                }
 
 
-               //recvBuffer = (LPSTR)sendBuffer;
 
 
                if(ReadHttpBody(hConnect,(LPBYTE)recvBuffer,buflen,&readSize) == FALSE){
@@ -1161,12 +1163,12 @@ static INLINE NLIB_RESULT GetNicoLiveHistory(NicoLiveStream_P self,HINTERNET hCo
 
        EnterCriticalSection(&self->sessionManager.cs);
        {
-       //HINTERNET hNicoVideoConnect = NULL;
+       
        HINTERNET hStreamBrowse = NULL;
 
 
-       WCHAR objectName[GETNICOLIVEHIS_OBJNAMELENGTH] = {L"/watch/"};
-       WCHAR cookie[GETNICOLIVEHIS_COOKIELENGTH] = {L"Cookie: "};
+       TCHAR objectName[GETNICOLIVEHIS_OBJNAMELENGTH] = {L"/watch/"};
+       TCHAR cookie[GETNICOLIVEHIS_COOKIELENGTH] = {L"Cookie: "};
        DWORD statusCode;
        DWORD statusCodeSize = sizeof(statusCode);
        DWORD chunkSize = LENGTH_65536;
@@ -1174,7 +1176,7 @@ static INLINE NLIB_RESULT GetNicoLiveHistory(NicoLiveStream_P self,HINTERNET hCo
        
 
 
-       LPWSTR buffer = (LPWSTR)chunkSize;
+       LPTSTR buffer = (LPTSTR)chunkMemory;
 
 
 
@@ -1187,13 +1189,11 @@ static INLINE NLIB_RESULT GetNicoLiveHistory(NicoLiveStream_P self,HINTERNET hCo
        wcscat(objectName,self->playerStatus.stream.id);
        wcscat(cookie,self->userSession);
 
-       
 
-       //hNicoVideoConnect = hConnect;
 
        
 
-       hStreamBrowse = WinHttpOpenRequest(hNicoVideoConnect,L"GET",objectName,L"1.1",(LPCWSTR)WINHTTP_NO_REFERER,(LPCWSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
+       hStreamBrowse = WinHttpOpenRequest(hNicoVideoConnect,L"GET",objectName,L"1.1",(LPCTSTR)WINHTTP_NO_REFERER,(LPCTSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
 
 
 
@@ -1231,9 +1231,9 @@ static INLINE NLIB_RESULT GetNicoLiveHistory(NicoLiveStream_P self,HINTERNET hCo
        }
 
        {
-               LPWSTR start =wcsstr(buffer,L"nicolivehistory=");
+               LPTSTR start =wcsstr(buffer,L"nicolivehistory=");
 
-               LPWSTR end = wcsstr(start,L";");
+               LPTSTR end = wcsstr(start,L";");
 
                UINT_PTR length = end - start;
 
@@ -1389,7 +1389,7 @@ static VOID OnSendHeartBeat(NicoLiveStream_P self){
 static VOID OnSendKeepAllive(NicoLiveStream_P self){
        
        if(self->chatManager.keapALiveFlag){
-               LPCWSTR mail[2] = {L"184",NULL};
+               LPCTSTR mail[2] = {L"184",NULL};
                NicoLiveStream_sendChat(self,L"/keapalive",mail,NULL);
        }
 
@@ -1402,9 +1402,9 @@ static unsigned int WINAPI NicoLiveRecvChat(void* lpBuffer){
 
        unsigned int rslt = 0;
 
-       //LPWSTR user_id = NULL;
-       //LPWSTR name = NULL;
-       //LPWSTR chatBuf = NULL;
+       //LPTSTR user_id = NULL;
+       //LPTSTR name = NULL;
+       //LPTSTR chatBuf = NULL;
 
 
 
@@ -1543,8 +1543,8 @@ static BOOL NicoLiveRecvChatLoop(NicoLiveStream_P self){
        //\83R\83\81\83\93\83g\8eó\90M\8f\88\97\9d
        //
        BOOL rslt = TRUE;                                                                               //\8c\8b\89Ê
-       LPWSTR commentBuf = NULL;                                                               //\83R\83\81\83\93\83g\83o\83b\83t\83@
-       LPWSTR* mailCountBuf = NULL;                                                    //\83\81\81[\83\8b\83|\83C\83\93\83^\83o\83b\83t\83@
+       LPTSTR commentBuf = NULL;                                                               //\83R\83\81\83\93\83g\83o\83b\83t\83@
+       LPTSTR* mailCountBuf = NULL;                                                    //\83\81\81[\83\8b\83|\83C\83\93\83^\83o\83b\83t\83@
        INT_PTR recevedLen;                                                                             //\8eó\90M\95\8e\9a\97ñ\92·
        INT_PTR messageBufLen;                                                                  //\83o\83b\83t\83@\92·
 
@@ -1555,8 +1555,8 @@ static BOOL NicoLiveRecvChatLoop(NicoLiveStream_P self){
        DWORD dwResult;                                                                                 //\83C\83x\83\93\83g\82ª\83E\83F\83C\83g\8aÖ\90\94\82Ì\8c\8b\89Ê\82ð\8ai\94[\82·\82é\95Ï\90\94
 
        
-       SIZE_T commentBufSize = sizeof(WCHAR) * LENGTH_2048;    //\83R\83\81\83\93\83g\83o\83b\83t\83@\92·
-       SIZE_T mailCountBufSize = sizeof(LPWSTR) * LENGTH_256;  //\83\81\81[\83\8b\82Ì\83|\83C\83\93\83^\97p\83o\83b\83t\83@\92·
+       SIZE_T commentBufSize = sizeof(TCHAR) * LENGTH_2048;    //\83R\83\81\83\93\83g\83o\83b\83t\83@\92·
+       SIZE_T mailCountBufSize = sizeof(LPTSTR) * LENGTH_256;  //\83\81\81[\83\8b\82Ì\83|\83C\83\93\83^\97p\83o\83b\83t\83@\92·
 
 
        WSAEVENT hRecvEvent = NULL;
@@ -1569,8 +1569,8 @@ static BOOL NicoLiveRecvChatLoop(NicoLiveStream_P self){
        hEventArray[0] = hRecvEvent;
        hEventArray[1] = self->chatManager.endEvent;
 
-       commentBuf = (LPWSTR)malloc(commentBufSize);
-       mailCountBuf = (LPWSTR*)malloc(mailCountBufSize);
+       commentBuf = (LPTSTR)malloc(commentBufSize);
+       mailCountBuf = (LPTSTR*)malloc(mailCountBufSize);
 
        //\90Ø\92f\82³\82ê\82é\82Ü\82Å\83\8b\81[\83v
        while(1){
@@ -1651,24 +1651,24 @@ end:
 
 
 
-static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentBufSize){
+static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPTSTR commentBuf,UINT_PTR endSize,LPTSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentBufSize){
 
-       LPWSTR indexPtr;                                                                                //\89ð\90Í\8e\9e\82Ì\8ew\95W\83|\83C\83\93\83^
+       LPTSTR indexPtr;                                                                                //\89ð\90Í\8e\9e\82Ì\8ew\95W\83|\83C\83\93\83^
        NicoLiveChat nicoLiveChat;                                                              //\83`\83\83\83b\83g\83R\83\81\83\93\83g\8ai\94[\97p\8d\\91¢\91Ì
        NicoLiveThreadComment nicoLiveThreadComment;                    //\90Ú\91±\89\9e\93\9a\83R\83\81\83\93\83g\8ai\94[\97p\8d\\91¢\91Ì
        NicoLiveSendResultComment nicoLiveSendResultComment;    //\91\97\90M\89\9e\93\9a\83R\83\81\83\93\83g\8ai\94[\97p\8d\\91¢\91Ì
        NicoLiveChat nicoLiveChatBase;                                                  //\83`\83\83\83b\83g\83R\83\81\83\93\83g\8aî\92ê\8d\\91¢\91Ì
        NicoLiveThreadComment nicoLiveThreadCommentBase;                //\90Ú\91±\89\9e\93\9a\83R\83\81\83\93\83g\8aî\92ê\8d\\91¢\91Ì
        NicoLiveSendResultComment nicoLiveSendResultCommentBase;//\91\97\90M\89\9e\93\9a\83R\83\81\83\93\83g\8aî\92ê\8d\\91¢\91Ì
-       LPWSTR attrNameStart;                                                                   //\91®\90«\96¼\8aJ\8en\83|\83C\83\93\83^
-       LPWSTR attrNameEnd;                                                                             //\91®\90«\96¼\8fI\97¹\83|\83C\83\93\83^
-       LPWSTR attrValueStart;                                                                  //\91®\90«\92l\8aJ\8en\83|\83C\83\93\83^
-       LPWSTR attrValueEnd;                                                                    //\91®\90«\92l\8fI\97¹\83|\83C\83\93\83^
+       LPTSTR attrNameStart;                                                                   //\91®\90«\96¼\8aJ\8en\83|\83C\83\93\83^
+       LPTSTR attrNameEnd;                                                                             //\91®\90«\96¼\8fI\97¹\83|\83C\83\93\83^
+       LPTSTR attrValueStart;                                                                  //\91®\90«\92l\8aJ\8en\83|\83C\83\93\83^
+       LPTSTR attrValueEnd;                                                                    //\91®\90«\92l\8fI\97¹\83|\83C\83\93\83^
        INT_PTR nameLen;                                                                                //\91®\90«\82Ì\96¼\91O\82Ì\92·\82³
-       LPWSTR mailIndexPtr;                                                                    //\83\81\81[\83\8b\91®\90«\92l\89ð\90Í\97p\8ew\95W\83|\83C\83\93\83^
-       LPWSTR xmlTextPtr;                                                                              //xml\83e\83L\83X\83g\8c`\8e®\82Ì\83f\81[\83^\89ð\90Í\8e\9e\82É\8eg\97p\82·\82é\83|\83C\83\93\83^
-       LPWSTR xmlTextEnd;                                                                              //xml\83e\83L\83X\83g\8fI\97¹\83|\83C\83\93\83^
-       LPWSTR* mailIndex;                                                                              //\83\81\81[\83\8b\83R\83}\83\93\83h\83\8a\83X\83g\83|\83C\83\93\83^
+       LPTSTR mailIndexPtr;                                                                    //\83\81\81[\83\8b\91®\90«\92l\89ð\90Í\97p\8ew\95W\83|\83C\83\93\83^
+       LPTSTR xmlTextPtr;                                                                              //xml\83e\83L\83X\83g\8c`\8e®\82Ì\83f\81[\83^\89ð\90Í\8e\9e\82É\8eg\97p\82·\82é\83|\83C\83\93\83^
+       LPTSTR xmlTextEnd;                                                                              //xml\83e\83L\83X\83g\8fI\97¹\83|\83C\83\93\83^
+       LPTSTR* mailIndex;                                                                              //\83\81\81[\83\8b\83R\83}\83\93\83h\83\8a\83X\83g\83|\83C\83\93\83^
        BOOL isReceveChat = FALSE;                                                              //\83`\83\83\83b\83g\8eó\90M\83t\83\89\83O
        SIZE_T commentSizeCh;                                                                   //\8eó\90M\82µ\82½\83R\83\81\83\93\83g\82ð\83\86\83j\83R\81[\83h\82É\95Ï\8a·\82·\82é\82Æ\82«\82Ì\92·\82³
        LPSTR recvBufTmp;                                                                               //\8eó\90M\95\8e\9a\97ñ\91\80\8dì\97p\83|\83C\83\93\83^
@@ -1710,8 +1710,8 @@ static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_P
        for (;recvBufTmp + strlen(recvBufTmp) < recvEndPoint;recvBufTmp += strlen(recvBufTmp) + 1){
 
 
-               commentSizeCh = sizeof(WCHAR) * GetLenToWide(CP_UTF8,recvBufTmp);
-               extendMalloc(commentBuf,LPWSTR,*commentBufSize,commentSizeCh);
+               commentSizeCh = sizeof(TCHAR) * GetLenToWide(CP_UTF8,recvBufTmp);
+               extendMalloc(commentBuf,LPTSTR,*commentBufSize,commentSizeCh);
                MBToWide(CP_UTF8,recvBufTmp,commentBuf,*commentBufSize);
 
                traceln(TEXT("comment:\r\n%s"),commentBuf);
@@ -1831,7 +1831,7 @@ static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_P
 
                                        }
 
-                                       extendMalloc(mailCountBuf,LPWSTR*,*mailCountBufSize,nicoLiveChat.mailCount);
+                                       extendMalloc(mailCountBuf,LPTSTR*,*mailCountBufSize,nicoLiveChat.mailCount);
 
                                        nicoLiveChat.mail = mailCountBuf;
                                        mailCountBuf[0] = NULL;
@@ -1911,7 +1911,7 @@ static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_P
                        }
 
                        //\83L\81[\83v\83A\83\89\83C\83u\83\8a\83Z\83b\83g
-                       WSAResetEvent(self->chatManager.setKeepAliveTimeEvent);
+                       WSASetEvent(self->chatManager.setKeepAliveTimeEvent);
 
                        self->callBack(NICOLIVE_EVENT_RECEVE_CHATSENDRESULT,self,self->option,(NICOLIVE_PARAM)&nicoLiveSendResultComment,(NICOLIVE_PARAM)NULL);
 
@@ -1973,7 +1973,7 @@ static void NicoLiveSelfDisconnect(void *buf){
 
 }
 
-static INLINE SOCKET GetConectedSocket(LPCWSTR nordName,LPCWSTR port,int socktype,int addr_famiry,int protocol){
+static INLINE SOCKET GetConectedSocket(LPCTSTR nordName,LPCTSTR port,int socktype,int addr_famiry,int protocol){
 
 
        SOCKET rslt = INVALID_SOCKET;
@@ -2032,4 +2032,138 @@ static INLINE SOCKET GetConectedSocket(LPCWSTR nordName,LPCWSTR port,int socktyp
 
        return rslt;
 
+}
+
+
+//
+//\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\8aÖ\98A
+//
+
+///
+///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\82ÌID\82ð\8eæ\93¾
+///
+NLIB_DECLSPEC LPCTSTR StreamStatus_getId(StreamStatus_P self){
+
+       return self->id;
+}
+
+
+///
+///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\82Ì\83R\83~\83\85\83j\83e\83B\94Ô\8d\86\82ð\8eæ\93¾
+///
+NLIB_DECLSPEC LPCTSTR StreamStatus_getDefaultCommunity(StreamStatus_P self){
+
+       return self->default_community;
+}
+
+
+///
+///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\82Ì\83v\83\8d\83o\83C\83_\83^\83C\83v\82ð\8eæ\93¾
+///
+PROVIDERTYPE StreamStatus_getProviderType(StreamStatus_P self){
+
+       return self->provider_type;
+}
+
+
+///
+///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\82Ì\83I\81[\83i\81[\83t\83\89\83O\82ð\8eæ\93¾
+///
+BOOL StreamStatus_isOwner(StreamStatus_P self){
+
+       return self->is_owner;
+}
+
+///
+///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\82Ì\8aJ\8en\8e\9e\8d\8f\82ð\8eæ\93¾
+///
+time_t StreamStatus_getStartTime(StreamStatus_P self){
+
+       return self->start_time;
+}
+
+///
+///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\82Ì\8fI\97¹\8e\9e\8d\8f\82ð\8eæ\93¾
+///
+time_t StreamStatus_getEndTime(StreamStatus_P self){
+
+       return self->end_time;
+}
+
+///
+///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\82Ì\8aJ\8fê\8e\9e\8d\8f\82ð\8eæ\93¾
+///
+time_t StreamStatus_getOpenTime(StreamStatus_P self){
+
+       return self->open_time;
+
+}
+
+///
+///\83X\83g\83\8a\81[\83\80\83X\83e\81[\83^\83X\82Ì\83x\81[\83X\8e\9e\8d\8f\82ð\8eæ\93¾
+///
+time_t StreamStatus_getBaseTime(StreamStatus_P self){
+
+       return self->base_time;
+}
+
+
+///
+///\90Ú\91±\92\86\82Ì\95ú\91\97\8fî\95ñ\82ð\96â\82¢\8d\87\82í\82¹\82é
+///
+StreamInfo_P NicoLiveStream_queryStreamInfo(NicoLiveStream_P self){
+       
+       StreamInfo_P rslt = NULL;
+       HINTERNET hRequest = NULL;
+       if(self == NULL || self->isConnecting == FALSE)goto end;
+       EnterCriticalSection(&self->sessionManager.cs);
+       {
+               TCHAR objectName[LENGTH_256] = {TEXT("/api/getplayerstatus?v=")};
+               DWORD statusCode;
+               DWORD statusCodeSize = sizeof(statusCode);
+               LPSTR recvBuffer = (LPSTR)self->sessionManager.buffer;
+               SIZE_T buflen = sizeof(self->sessionManager.buffer);
+               DWORD readSize;
+               _tcscat(objectName,self->playerStatus.stream.id);
+               
+               hRequest = WinHttpOpenRequest(hWatchLiveNicoConnect,TEXT("GET"),objectName,TEXT("1.1"),(LPCTSTR)WINHTTP_NO_REFERER,(LPCTSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
+               
+
+               if(WinHttpSendRequest(hRequest,self->userSession,-1,WINHTTP_NO_REQUEST_DATA,0,0,0) == FALSE){
+                       goto connectend;
+
+               }
+
+               if(WinHttpReceiveResponse(hRequest,NULL) == FALSE){
+                       goto connectend;
+
+               }
+
+
+               if (WinHttpQueryHeaders(hRequest,WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,WINHTTP_HEADER_NAME_BY_INDEX,&statusCode,&statusCodeSize,WINHTTP_NO_HEADER_INDEX) == FALSE){
+                       goto connectend;
+               }
+
+
+               if (HTTP_STATUS_OK != statusCode){
+                       goto connectend;
+               }
+
+
+               if(ReadHttpBody(hRequest,(LPBYTE)recvBuffer,buflen,&readSize) == FALSE){
+                       goto connectend;
+
+               }
+
+               
+       }
+       LeaveCriticalSection(&self->sessionManager.cs);
+connectend:
+       WinHttpCloseHandle(hRequest);
+
+
+end:
+       return rslt;
+
+       
 }
\ No newline at end of file