[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-server-cvs
Subject:    [Server-cvs] protocol/http http_demux.cpp, 1.72, 1.73 httpprot.cpp, 1.165, 1.166
From:       mingda () helixcommunity ! org
Date:       2013-01-30 3:41:26
[Download RAW message or body]

Update of /cvsroot/server/protocol/http
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv20675

Modified Files:
	http_demux.cpp httpprot.cpp 
Log Message:
Committed to: SERVER_15_0_RN and HEAD
Reviewed by: Xiaocheng, James Li and Richard Yuan
Verification Build:



Synopsis:
=========
session manager for Helix server v15.02

iOS6 would open a new HTTP session every time it requests a new .m3u8 playlist. \
Previous versions of iOS did this only on rate shifts and user seeks. This means in \
practice that Session Manager generates a new SESSIONSTART event every 10 seconds of \
a live stream. The SESSIONSTART (and SESSIONSTOP) events therefore lose their meaning \
in regard to the playback session.

So the main target of this change is to generate only one SESSION_START or \
SESSION_STOP event for a client playback behavior, no matter how many http \
connections it creates.

There are 3 different ways to identify a player. 
1, ip address and src url
2, cookie, ip and src url
3, guid and src url


For the second ways, since safari browser and media player don't share theirs' \
cookies, we have to append the cookie to the url in 302 message. So that the session \
manager can get the cookie and send another set cookie command for apple media \
player.


Files affected
====================
server-restricted/protocol/http/httpallow.cpp
server-restricted/protocol/http/pub/httpallow.h
server/engine/core/Umakefil
server/engine/core/server_context.cpp
server/engine/core/pub/server_context.h
server/include/server_piids.h
common/include/hxiids.h
common/include/hxallow.h
protocol/http/Umakefil
server/protocol/http/http_demux.cpp
server/protocol/http/httpprot.cpp
server/protocol/http/pub/http_demux.h
sds/session/dauccfg.h
sds/session/daucplin.cpp
sds/session/daucplin.h
sds/session/proxyall
sds/session/serverall

new files:
protocol/http/httpcookie.cpp
protocol/http/pub/httpcookie.h
common/include/hxprocnumber.h
server/engine/core/server_procnumber.cpp
server/engine/core/pub/server_procnumber.h


Test perform
=====================
BVT 

Integration Tests:
None

Leak Tests: None
Performance Tests: N/A

Platforms Tested: win-x86_64-vc10.
Builds Verified: win-x86_64-vc10.

QA Hints
========
None.



Index: httpprot.cpp
===================================================================
RCS file: /cvsroot/server/protocol/http/httpprot.cpp,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -d -r1.165 -r1.166
--- httpprot.cpp	28 Jan 2013 10:26:20 -0000	1.165
+++ httpprot.cpp	30 Jan 2013 03:41:18 -0000	1.166
@@ -2008,6 +2008,52 @@
     if (pURL)
     {
         pMsg = makeResponseMessage("302");
+#if defined(HELIX_FEATURE_SERVER_MPEG2TS) || defined(HELIX_FEATURE_SERVER_DASH)
+        if (m_pRequest)
+        {
+            DPRINTF(D_INFO, ("HTTPP::makeResponseMessage -- Set Cookie\n"));
+            IHXValues* pResponseHeaders = NULL;
+
+            if (m_pRequest->GetResponseHeaders(pResponseHeaders) == HXR_OK &&
+                pResponseHeaders)
+            {
+                HX_RESULT result;
+                MIMEHeader* pMimeHeader;
+                const char* pName;
+                IHXBuffer* pValue;
+
+                m_bKeepAlive = FALSE;
+
+                HXBOOL bAddToMsg = TRUE;
+
+                result = pResponseHeaders->GetFirstPropertyCString(pName, pValue);
+
+                while (result == HXR_OK)
+                {
+                    if(strstr(pName, "Set-Cookie"))
+                    {
+                        pMsg->addHeader("Set-Cookie", (const \
char*)(pValue->GetBuffer())); +                        
+                        pURL->SetSize(pURL->GetSize() + 1 + pValue->GetSize());
+                        UCHAR* pNewURL = pURL->GetBuffer();
+                        if(strchr((const char*)pNewURL, '?') != NULL)
+                        {
+                            strcat((char*)pNewURL, "&");
+                        }
+                        else
+                        {
+                            strcat((char*)pNewURL, "?");
+                        }
+                        strcat((char*)pNewURL, (const char*)pValue->GetBuffer());
+                    }
+                    pValue->Release();
+                    result = pResponseHeaders->GetNextPropertyCString(pName,
+                                                                      pValue);
+                }
+            }
+            HX_RELEASE(pResponseHeaders);
+        }
+#endif
         pMsg->addHeader("Location", (char*)pURL->GetBuffer());
         if (SUCCEEDED(sendResponse(pMsg)))
         {
@@ -3327,7 +3373,7 @@
             return -1;
         }
         m_eOnURLState = ONURL_PROCESSING;
-        if (FAILED(pHTTPAllow->DoOnURL(m_pRequestHeaders, pMsg->url())))
+        if (FAILED(pHTTPAllow->DoOnURL(m_pRequest, pMsg->url())))
         {
             m_eOnURLState = ONURL_ERROR;
             pHTTPAllow->Cleanup();

Index: http_demux.cpp
===================================================================
RCS file: /cvsroot/server/protocol/http/http_demux.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- http_demux.cpp	29 Jan 2013 05:32:52 -0000	1.72
+++ http_demux.cpp	30 Jan 2013 03:41:18 -0000	1.73
@@ -107,8 +107,14 @@
 #include "drmhttpapi_handler.h"
 #endif
 
+#ifdef HELIX_FEATURE_SERVER_MPEG2TS
+#include "httpcookie.h"
+#endif
+
 #define PREFER_PROGRESSIVE_DOWNLOAD_WMP   "config.PreferProgressiveHTTP_WMP"
 
+extern UINT32* g_pNumStreamers;
+
 const int MAX_HTTP_MSG = 32768;
 const int MAX_HTTP_MSG_QUEUE = 32;
 
@@ -125,7 +131,8 @@
     m_uHTTPResponseCode(0),
     m_ulMsgLen(0),
     m_bHandlingMessage(FALSE),
-    m_pMessageQueue(NULL)
+    m_pMessageQueue(NULL),
+    m_bNormalHttp(FALSE)
 {
     m_pParser = new HTTPParser;
     m_pMessageQueue = new HTTPMessageQueue(MAX_HTTP_MSG_QUEUE);
@@ -673,7 +680,113 @@
                     m_ReadState = DEMUX_READ_DATA;
                 }
             }
+#if defined(HELIX_FEATURE_SERVER_MPEG2TS) || defined(HELIX_FEATURE_SERVER_DASH)
+            HTTPRequestMessage* pReq = (HTTPRequestMessage*)pMsg;
+            const char* pUrl = pReq->url();
+            INT32 nSessMgrEnabled = FALSE;
+            m_proc->pc->registry->GetInt("config.DAUCSessionMgr.Enabled",  
+                    &nSessMgrEnabled, m_proc);
+            IHXBuffer *pBuffer = NULL;
+            m_proc->pc->registry->GetStr("config.DAUCSessionMgr.URLKeywords.WebGuidKeyword",pBuffer, \
m_proc); + 
+            const char* pGUIDKeyword = NULL;
+            if(pBuffer != NULL)
+            {
+                pGUIDKeyword = (const char*)pBuffer->GetBuffer();
+            }
+            else
+            {
+                pGUIDKeyword = "guid";
+            }
+
+            if(nSessMgrEnabled && bFirstRun && m_bNormalHttp == TRUE &&
+                ( (HelixCookieIdUtility::IsHLSTsRequest(pUrl) 
+                    && \
HelixCookieIdUtility::IsNotDashRequest(pUrl,m_proc->pc->dashgen_mountpoint)) +        \
|| HelixCookieIdUtility::IsM3ugenRequest(pUrl, m_proc->pc->m3ugen_moutpoint) +        \
|| HelixCookieIdUtility::IsM3u8Request(pUrl))) +            {
+                m_pSavedMessage = pMsg;
+                char *pWebGuid = NULL;
+                if(HelixCookieIdUtility::GetWebGuid(pUrl, pGUIDKeyword, &pWebGuid) \
== HXR_OK) +                {
+                    //dispatch by web guid
+                    UINT32     nStreamerId = -1;
+                    MapGuidToStreamerId(pWebGuid, &nStreamerId);
+                    \
static_cast<CHXServSocket*>(m_pSock)->Dispatch(m_proc->pc->streamer_info->GetProcNum(nStreamerId));
 +                    break;
+                }
+                else
+                {
+                    HelixCookieId* pCookie = new HelixCookieId;
+                    HelixCookieId* pCookie2 = new HelixCookieId;
+                    INT32 nIPTableEabled = 0;
+                    \
m_proc->pc->registry->GetInt("config.DAUCSessionMgr.hls_session_validate_by_ip", +    \
&nIPTableEabled, m_proc); +                    CHXString strCookie = \
pMsg->getHeaderValue("Cookie"); +                    HX_RESULT ret = HXR_FAILED;
+                    HX_RESULT ret2 = HXR_FAILED;
+
+                    ret = HelixCookieIdUtility::Parser(strCookie, pCookie);
+
+                    char *pUrlCookie = NULL;
+                    HelixCookieIdUtility::GetURLCookie(pUrl, &pUrlCookie);
+                    if(pUrlCookie != NULL)
+                    {
+                        CHXString strCookie2 = pUrlCookie;
+                        ret2 = HelixCookieIdUtility::Parser(strCookie2, pCookie2);
+                    }
+ 
+                    if(HXR_OK == ret)
+                    {
+                        if(pCookie->streamer_number < Process::numprocs())
+                        {
+                            \
static_cast<CHXServSocket*>(m_pSock)->Dispatch(pCookie->streamer_number); +           \
} +                        else if (bFirstRun && m_pResponse->AutoDispatch())
+                        {
+                            static_cast<CHXServSocket*>(m_pSock)->Dispatch();
+                        }
+                    }
+                    else if(HXR_OK == ret2)
+                    {
+                        if(pCookie2->streamer_number < Process::numprocs())
+                        {
+                            \
static_cast<CHXServSocket*>(m_pSock)->Dispatch(pCookie2->streamer_number); +          \
} +                        else if (bFirstRun && m_pResponse->AutoDispatch())
+                        {
+                            static_cast<CHXServSocket*>(m_pSock)->Dispatch();
+                        }
+                    }
+                    else if(nIPTableEabled)
+                    {
+                        //dispatch by IP.
+                        UINT32  nStreamerId = -1;
+                        UCHAR*  pIP = NULL;
+                        //HelixCookieIdUtility::GetIP(pUrl, pIP);
+                        IHXSockAddr* pAddr = NULL;
+                        m_pSock->GetPeerAddr(&pAddr);
+                        IHXBuffer *pBuffer = NULL;
+                        pAddr->GetAddr(&pBuffer);
+                        pIP = pBuffer->GetBuffer();
+                        MapIPToStreamerId(pIP, &nStreamerId);
+                        \
static_cast<CHXServSocket*>(m_pSock)->Dispatch(m_proc->pc->streamer_info->GetProcNum(nStreamerId));
 +                        HX_RELEASE(pBuffer);
+                        HX_RELEASE(pAddr);
+                    }
+                    else if (bFirstRun && m_pResponse->AutoDispatch())
+                    {
+                        static_cast<CHXServSocket*>(m_pSock)->Dispatch();
+                    }
 
+                    HX_DELETE(pCookie);
+                    HX_DELETE(pCookie2);
+                    break;
+                }
+                HX_DELETE(pWebGuid);
+            }
+            else
+#endif
             if (bFirstRun && m_pResponse->AutoDispatch())
             {
                 m_pSavedMessage = pMsg;
@@ -696,7 +809,7 @@
                     // Drop the message since the queue overflowed.
                     // For safety, we'll terminate the connection immediately
                     // without processing the rest of the message queue.
-                    ERRMSG(m_pClient->m_pProc->pc->error_handler,
+                        ERRMSG(m_pClient->m_pProc->pc->error_handler,
                         "HTTP Message Queue size limit reached for client (%d)",
                         m_pClient->m_ulConnId);
                     Close(res);
@@ -984,6 +1097,7 @@
     {
         m_pResponse = new HTTPProtocol();
         m_pResponse->AddRef();
+        m_bNormalHttp = TRUE;
         return;
     }
 }
@@ -1131,6 +1245,34 @@
     }
 }
 
+
+HX_RESULT 
+CHTTPDemux::MapGuidToStreamerId(const char* pWebGuid, UINT32 *pStreamerId)
+{
+    int sum = 0;
+    while(*pWebGuid)
+    {
+        sum += *pWebGuid;
+        pWebGuid++;
+    }
+    *pStreamerId = sum % *g_pNumStreamers;
+    return HXR_OK;
+}
+
+HX_RESULT 
+CHTTPDemux::MapIPToStreamerId(const UCHAR* pIP, UINT32 *pStreamerId)
+{
+    int sum = 0;
+    while(*pIP)
+    {
+        sum += *pIP;
+        pIP++;
+    }
+    *pStreamerId = sum % *g_pNumStreamers;
+    return HXR_OK;
+}
+
+
 HTTPMessageQueue::HTTPMessageQueue(UINT32 ulSize)
     : m_pQueue(NULL)
     , m_nQueueSize(0)


_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic