Home | History | Annotate | Download | only in include
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /**
     19  * @file pvmfprotocolenginenode_extension.h
     20  * @brief Extension interface for PVMFProtocolEngineNode
     21  */
     22 
     23 #ifndef PVMFPROTOCOLENGINENODE_EXTENSION_H_INCLUDED
     24 #define PVMFPROTOCOLENGINENODE_EXTENSION_H_INCLUDED
     25 
     26 #ifndef OSCL_BASE_H_INCLUDED
     27 #include "oscl_base.h"
     28 #endif
     29 #ifndef PV_INTERFACE_H
     30 #include "pv_interface.h"
     31 #endif
     32 #ifndef PV_UUID_H_INCLUDED
     33 #include "pv_uuid.h"
     34 #endif
     35 #ifndef OSCL_VECTOR_H_INCLUDED
     36 #include "oscl_vector.h"
     37 #endif
     38 #ifndef OSCL_REFCOUNTER_MEMFRAG_H_INCLUDED
     39 #include "oscl_refcounter_memfrag.h"
     40 #endif
     41 #ifndef OSCL_STRING_CONSTAINERS_H_INCLUDED
     42 #include "oscl_string_containers.h"
     43 #endif
     44 #ifndef PVMF_EVENT_HANDLING_H_INCLUDED
     45 #include "pvmf_event_handling.h"
     46 #endif
     47 #ifndef PVMF_PORT_INTERFACE_H_INCLUDED
     48 #include "pvmf_port_interface.h"
     49 #endif
     50 
     51 // default number of redirect trials
     52 #define PVPROTOCOLENGINE_DEFAULT_NUMBER_OF_REDIRECT_TRIALS 10
     53 #define PVPROTOCOLENGINE_DEFAULT_MAXIMUM_ASF_HEADER_SIZE 262144 // 256K
     54 
     55 
     56 
     57 #define PVMF_PROTOCOL_ENGINE_GENERIC_EXTENSION_MIMETYPE "pvxxx/PVMFProtocolEngineNode/GenericExtensionInterface"
     58 #define KPVMFProtocolEngineNodeExtensionUuid PVUuid(0xca27cb64,0x83ed,0x40d6,0x96,0xa3,0xed,0x1d,0x8b,0x60,0x11,0x38)
     59 
     60 enum HttpVersion
     61 {
     62     HTTP_V10 = 0, // Http version 1.0
     63     HTTP_V11    // Http version 1.1
     64 };
     65 
     66 enum HttpMethod
     67 {
     68     HTTP_GET = 0,
     69     HTTP_POST,
     70     HTTP_HEAD,
     71     HTTP_ALLMETHOD
     72 };
     73 
     74 enum DownloadProgressMode
     75 {
     76     DownloadProgressMode_TimeBased = 0,
     77     DownloadProgressMode_ByteBased
     78 };
     79 
     80 /**
     81  * PVMFProtocolEngineNodeExtensionInterface allows a client to do exercise extended functions
     82  * of a PVMFProtocolEngineNode
     83  */
     84 class PVMFProtocolEngineNodeExtensionInterface : public PVInterface
     85 {
     86     public:
     87 
     88         /**
     89          * Retrieves the HTTP header. The memory persists until node gets destroyed or reset
     90          *
     91          * @param aHeader pointer to header data.
     92          * @param aHeaderLen length of header data.
     93          * @return true if config info is provided, else false.
     94          */
     95         virtual PVMFStatus GetHTTPHeader(uint8*& aHeader, uint32& aHeaderLen) = 0;
     96 
     97         /**
     98          * Retrieves the file size. The file size is retrieved from http header
     99          * But server might not announce the file size info. In this case, file size
    100          * is not available, and set to zero.
    101          * @param aFileSize returned download file size.
    102          */
    103         virtual void GetFileSize(uint32& aFileSize) = 0;
    104 
    105         /**
    106          * Retrieves the host name and port number for socket node port request
    107          * set up by download manager node
    108          *
    109          * @param aPortConfig string of IP/DNS address + port number, like "TCP/remote_address=pvserveroha.pv.com;remote_port=554"
    110          * @return true if config info is provided, else false.
    111          * Note that this extension interface must be called AFTER data source
    112          * initialization interface (url is provided) gets called, otherwise it would fail
    113          */
    114         virtual bool GetSocketConfig(OSCL_String &aPortConfig) = 0;
    115 
    116         /**
    117          * Set the user agent field for a http request. Basically there are two modes, by default,
    118          * the new user agent field will be attached to the default user agent field (PVPlayer 4.0(Beta Release)).
    119          * Another one is the new user agent will replace our default one
    120          *
    121          * @param aUserAgent wide-character string of user agent
    122          * @param aOverwritable, flag to show whether the input user agent will replace or append the default one
    123          *        aOverwritable=true => replace
    124          * @return true if user agent is set successfully, else false.
    125          */
    126         virtual bool SetUserAgent(OSCL_wString &aUserAgent, const bool isOverwritable = true) = 0;
    127 
    128         /**
    129          * Set the http version number (HTTP/1.0 or HTTP/1.1) for a http request.
    130          * @param aHttpVersion, a http version. The version is defined as an enum (see above)
    131          */
    132         virtual void SetHttpVersion(const uint32 aHttpVersion = HTTP_V11) = 0;
    133 
    134         /**
    135          * Set the NetworkTimeout for a http request/response. The unit of NetworkTimeout value is SECOND
    136          * @param aTimeout, timeout value in SECONDS
    137          */
    138         virtual void SetNetworkTimeout(const uint32 aTimeout) = 0;
    139 
    140         /**
    141          * Set the number of trials for redirect to avoid rediret looping. If the actual number redirect trials exceeds
    142          * the specified number, then there will be an error out.
    143          * @param aNumTrials, specified number of redirect trials
    144          */
    145         virtual void SetNumRedirectTrials(const uint32 aNumTrials) = 0;
    146 
    147         /**
    148          * Set the http extension header field. Three inputs, field key & field value plus method (field belongs to which HTTP method),
    149          * are needed for composing like "key: value"
    150          * @param aFieldKey, extension field key
    151          * @param aFieldValue, extension field value
    152          * @param aMethod, HTTP method, GET, POST or both
    153          * @param aPurgeOnRedirect - boolean indicating whether this header is carried over across redirects
    154          */
    155         virtual void SetHttpExtensionHeaderField(OSCL_String &aFieldKey,
    156                 OSCL_String &aFieldValue,
    157                 const HttpMethod aMethod = HTTP_GET,
    158                 const bool aPurgeOnRedirect = false) = 0;
    159 
    160         /**
    161          * Set the download progress mode, i.e. the download percentage is time-based or byte-based
    162          * @param aMode, specified download progress mode
    163          */
    164         virtual void SetDownloadProgressMode(const DownloadProgressMode aMode = DownloadProgressMode_TimeBased) = 0;
    165 
    166         /**
    167          * Disable HTTP HEAD request
    168          * @param aDisableHeadRequest, flag to disabling sending HTTP HEAD request
    169          */
    170         virtual void DisableHttpHeadRequest(const bool aDisableHeadRequest = true) = 0;
    171 
    172 };
    173 
    174 #define PVMF_PROTOCOL_ENGINE_MSHTTP_STREAMING_EXTENSION_MIMETYPE "pvxxx/PVMFProtocolEngineNod/MSHTTPStreamingExtensionInterface"
    175 #define KPVMFProtocolEngineNodeMSHTTPStreamingExtensionUuid PVUuid(0xe3fb7c31,0x9fb4,0x4263,0x8f,0x1f,0xa0,0xbc,0x77,0x86,0x10,0xea)
    176 
    177 class PVMFProtocolEngineNodeMSHTTPStreamingParams
    178 {
    179     public:
    180         PVMFProtocolEngineNodeMSHTTPStreamingParams()
    181         {
    182             reset();
    183         };
    184 
    185         ~PVMFProtocolEngineNodeMSHTTPStreamingParams()
    186         {
    187             reset();
    188         };
    189 
    190         // reset to default values
    191         void reset()
    192         {
    193             iStreamRate = 1;
    194             iStreamByteOffset = 0xFFFFFFFF;
    195             iStreamStartPacketNumber = 0xFFFFFFFF;
    196             iStreamStartTimeInMS = 0;
    197             iMaxStreamDurationInMS = 0x800188A3;
    198             iPacketGrouping = 0;
    199             iNumStreams = 1;
    200             iPlayBackMode = 1;
    201             iStreamIDList.clear();
    202             iStreamPlayBackModeList.clear();
    203         }
    204 
    205         // copy constructor
    206         PVMFProtocolEngineNodeMSHTTPStreamingParams(const PVMFProtocolEngineNodeMSHTTPStreamingParams &x)
    207         {
    208             iStreamRate                 = x.iStreamRate;
    209             iStreamByteOffset           = x.iStreamByteOffset;
    210             iStreamStartTimeInMS        = x.iStreamStartTimeInMS;
    211             iMaxStreamDurationInMS      = x.iMaxStreamDurationInMS;
    212             iStreamStartPacketNumber    = x.iStreamStartPacketNumber;
    213             iPacketGrouping             = x.iPacketGrouping;
    214             iNumStreams                 = x.iNumStreams;
    215             iPlayBackMode               = x.iPlayBackMode;
    216             iStreamIDList               = x.iStreamIDList;
    217             iStreamPlayBackModeList     = x.iStreamPlayBackModeList;
    218         }
    219 
    220         // assignment operator
    221         PVMFProtocolEngineNodeMSHTTPStreamingParams& operator=(const PVMFProtocolEngineNodeMSHTTPStreamingParams& x)
    222         {
    223             iStreamRate                 = x.iStreamRate;
    224             iStreamByteOffset           = x.iStreamByteOffset;
    225             iStreamStartTimeInMS        = x.iStreamStartTimeInMS;
    226             iMaxStreamDurationInMS      = x.iMaxStreamDurationInMS;
    227             iStreamStartPacketNumber    = x.iStreamStartPacketNumber;
    228             iPacketGrouping             = x.iPacketGrouping;
    229             iNumStreams                 = x.iNumStreams;
    230             iPlayBackMode               = x.iPlayBackMode;
    231             iStreamIDList               = x.iStreamIDList;
    232             iStreamPlayBackModeList     = x.iStreamPlayBackModeList;
    233             return *this;
    234         }
    235 
    236         uint32 iPlayBackMode;
    237         uint32 iStreamRate;
    238         uint32 iStreamByteOffset;
    239         uint32 iStreamStartTimeInMS;
    240         uint32 iMaxStreamDurationInMS;
    241         uint32 iStreamStartPacketNumber;
    242         uint32 iPacketGrouping;
    243         uint32 iNumStreams;
    244         Oscl_Vector<uint32, OsclMemAllocator> iStreamIDList;
    245         Oscl_Vector<uint32, OsclMemAllocator> iStreamPlayBackModeList;
    246 };
    247 
    248 /**
    249  * PVMFProtocolEngineNodeMSHTTPStreamingExtensionInterface allows a client to exercise
    250  * MS HTTP Streaming extended functions of a PVMFProtocolEngineNode
    251  */
    252 class PVMFProtocolEngineNodeMSHTTPStreamingExtensionInterface : public PVInterface
    253 {
    254     public:
    255 
    256         /**
    257          * Retrieves the ASF header. The ASF header can be retrieved in fragments
    258          *
    259          * @param aHeader a vector of fragments
    260          * @param aHeaderLen length of header data.
    261          * @return true if the asf header is provided, else false.
    262          */
    263         virtual bool GetASFHeader(Oscl_Vector<OsclRefCounterMemFrag, OsclMemAllocator> &aHeader) = 0;
    264 
    265         /**
    266          * Sets ASF streaming params, viz rate, start time, start packet num etc
    267          * Used by HTTP PE Node to compose GET request
    268          *
    269          * @param aParams class containing all the params
    270          * @return true if params are accepted by PE Node, else false.
    271          */
    272         virtual bool SetStreamParams(const PVMFProtocolEngineNodeMSHTTPStreamingParams &aParams) = 0;
    273 
    274         /**
    275          * Retrieves the host name and port number for socket node port request
    276          * set up by streaming manager node
    277          *
    278          * @param aPortConfig string of IP/DNS address + port number, like "TCP/remote_address=pvserveroha.pv.com;remote_port=554"
    279          * @return true if config info is provided, else false.
    280          * Note that this extension interface must be called AFTER data source
    281          * initialization interface (url is provided) gets called, otherwise it would fail
    282          */
    283         virtual bool GetSocketConfig(OSCL_String &aPortConfig) = 0;
    284 
    285         /**
    286          * Retrieves the host name and port number for socket node port request, based on logging URL
    287          * set up by streaming manager node
    288          *
    289          * @param aPortConfig string of IP/DNS address + port number, like "TCP/remote_address=pvserveroha.pv.com;remote_port=554"
    290          * @return true if config info is provided, else false.
    291          * Note that this extension interface must be called AFTER data source
    292          * initialization interface (url is provided) gets called, otherwise it would fail
    293          */
    294         virtual bool GetSocketConfigForLogging(OSCL_String &aPortConfig) = 0;
    295 
    296         /**
    297          * Sends a Seek request to the server (HTTP GET) and returns seq number of
    298          * first data packet after seek. The API is asynchronous
    299          *
    300          * @param aNPTInMS Seek NPT in milliseconds .
    301          * @param aFirstSeqNumAfterSeek
    302          * @param aContext - Opaque data provided by caller, to be returned as part of
    303          * command completion.
    304          * @return PVMFCommandId
    305          */
    306         virtual PVMFCommandId Seek(PVMFSessionId aSessionId,
    307                                    uint64 aNPTInMS,
    308                                    uint32& aFirstSeqNumAfterSeek,
    309                                    OsclAny* aContext) = 0;
    310 
    311         /**
    312          * Sends a BitstreamSwitch request to the PE node and PE node will send a seek request
    313          * (HTTP GET) and returns seq number of first data packet after seek. The API is asynchronous
    314          *
    315          * @param aNPTInMS Seek NPT in milliseconds .
    316          * @param aFirstSeqNumAfterSwitch
    317          * @param aContext - Opaque data provided by caller, to be returned as part of
    318          * command completion.
    319          * @return PVMFCommandId
    320          */
    321         virtual PVMFCommandId BitstreamSwitch(PVMFSessionId aSessionId,
    322                                               uint64 aNPTInMS,
    323                                               uint32& aFirstSeqNumAfterSwitch,
    324                                               OsclAny* aContext) = 0;
    325         /**
    326          * Sets the size of the mem pool interms of number of memory buffers
    327          * for the media msg allocator associated with the port.
    328          *
    329          * @param aPort Port pointer .
    330          * @param aNumBuffersInAllocator - Number of buffers in allocator
    331          * @return PVMFStatus - PVMFSuccess or PVMFFailure
    332          */
    333         virtual PVMFStatus SetMediaMsgAllocatorNumBuffers(PVMFPortInterface* aPort,
    334                 uint32 aNumBuffersInAllocator) = 0;
    335 
    336         /**
    337          * Set the user agent field for a http request. Basically there are two modes, by default,
    338          * the new user agent field will be attached to the default user agent field (PVPlayer 4.0(Beta Release)).
    339          * Another one is the new user agent will replace our default one
    340          *
    341          * @param aUserAgent wide-character string of user agent
    342          * @param aOverwritable, flag to show whether the input user agent will replace or append the default one
    343          *        aOverwritable=true => replace
    344          * @return true if user agent is set successfully, else false.
    345          */
    346         virtual bool SetUserAgent(OSCL_wString &aUserAgent, const bool isOverwritable = true) = 0;
    347 
    348         /**
    349          * Set the NetworkTimeout for a http request/response. The unit of NetworkTimeout value is SECOND
    350          * @param aTimeout, timeout value in SECONDS
    351          */
    352         virtual void SetNetworkTimeout(const uint32 aTimeout) = 0;
    353 
    354         /**
    355          * Set the NetworkLoggingTimeout for MS streaming Logging POST request/response at stop or EOS. The unit of NetworkLoggingTimeout value is SECOND
    356          * @param aTimeout, timeout value in SECONDS
    357          */
    358         virtual void SetNetworkLoggingTimeout(const uint32 aTimeout) = 0;
    359 
    360         /**
    361          * Set the timeout value for Keep-Alive message. The unit of KeepAliveTimeout value is SECOND
    362          * @param aTimeout, timeout value in SECONDS
    363          */
    364         virtual void SetKeepAliveTimeout(const uint32 aTimeout) = 0;
    365 
    366         /**
    367          * Set the number of trials for redirect to avoid rediret looping. If the actual number redirect trials exceeds
    368          * the specified number, then there will be an error out.
    369          * @param aNumTrials, specified number of redirect trials
    370          */
    371         virtual void SetNumRedirectTrials(const uint32 aNumTrials) = 0;
    372 
    373         /**
    374          * Set the http extension header field. Three inputs, field key & field value plus method (field belongs to which HTTP method),
    375          * are needed for composing like "key: value"
    376          * @param aFieldKey, extension field key
    377          * @param aFieldValue, extension field value
    378          * @param aMethod, HTTP method, GET, POST or both
    379          * @param aPurgeOnRedirect - boolean indicating whether this header is carried over across redirects
    380          */
    381         virtual void SetHttpExtensionHeaderField(OSCL_String &aFieldKey,
    382                 OSCL_String &aFieldValue,
    383                 const HttpMethod aMethod = HTTP_GET,
    384                 const bool aPurgeOnRedirect = false) = 0;
    385 
    386         /**
    387          * Set the logging URL
    388          * @param aSourceURL, a different URL for logging statistics
    389          */
    390         virtual void SetLoggingURL(OSCL_wString& aSourceURL) = 0;
    391 
    392         /**
    393          * Set the proxy URL and the port
    394          * @param aProxyURL, a proxy URL for streaming
    395          * @param aProxyPort, proxy number
    396          * @return true if proxy is set successfully, else false.
    397          */
    398         virtual bool SetStreamingProxy(OSCL_wString& aProxyURL, const uint32 aProxyPort) = 0;
    399 
    400         /**
    401          * Set the maximum ASF header size
    402          * @param aMaxASFHeaderSize, upper limit for ASF header supported
    403          */
    404         virtual void SetMaxASFHeaderSize(const uint32 aMaxASFHeaderSize = PVPROTOCOLENGINE_DEFAULT_MAXIMUM_ASF_HEADER_SIZE) = 0;
    405 
    406         /**
    407          * Set user authentication information, such as userID and password
    408          * @param aUserID, user id
    409          * @param aPasswd, password
    410          * @param aMaxASFHeaderSize, upper limit for ASF header supported
    411          */
    412         virtual void SetUserAuthInfo(OSCL_String &aUserID, OSCL_String &aPasswd) = 0;
    413 
    414         /**
    415          * Check the WM server 4.1 or not
    416          * @return true if the streaming server is wms4.1 else false.
    417          */
    418         virtual bool IsWMServerVersion4() = 0;
    419 
    420         /**
    421          * Set the accel bitrate for fast cache.
    422          * @param aAccelBitrate, specified accel bitrate
    423          */
    424         virtual void SetAccelBitrate(const uint32 aAccelBitrate) = 0;
    425 
    426         /**
    427          * Set the accel duration for fast cache.
    428          * @param aAccelDuration, specified accel duration
    429          */
    430         virtual void SetAccelDuration(const uint32 aAccelDuration) = 0;
    431 
    432         /**
    433          * Set number of buffers to be allocated for media data pool
    434          * @param aVal, the number calculated by SM node
    435          * @return void
    436          */
    437         virtual void SetNumBuffersInMediaDataPoolSMCalc(uint32 aVal) = 0;
    438 
    439         /**
    440          * Set the max http stremaing size.
    441          * @param aMaxHttpStreamingSize
    442          */
    443         virtual void SetMaxHttpStreamingSize(const uint32 aMaxHttpStreamingSize) = 0;
    444 
    445 };
    446 
    447 #endif // PVMFPROTOCOLENGINENODE_EXTENSION_H_INCLUDED
    448 
    449 
    450