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#ifndef PVMF_DOWNLOAD_DATA_SOURCE_H_INCLUDED
19#define PVMF_DOWNLOAD_DATA_SOURCE_H_INCLUDED
20
21#ifndef OSCL_BASE_H_INCLUDED
22#include "oscl_base.h"
23#endif
24#ifndef OSCL_STRING_H_INCLUDED
25#include "oscl_string.h"
26#endif
27#ifndef PV_UUID_H_INCLUDED
28#include "pv_uuid.h"
29#endif
30#ifndef PV_INTERFACE_H_INCLUDED
31#include "pv_interface.h"
32#endif
33
34#define PVMF_DOWNLOAD_DATASOURCE_HTTP_UUID PVUuid(0xdea36265,0x6a59,0x4d8b,0xb3,0xea,0xdf,0x68,0x4d,0x7e,0x0e,0x08)
35
36//Source data for HTTP Progressive download (format type PVMF_DATA_SOURCE_HTTP_URL)
37class PVMFDownloadDataSourceHTTP : public PVInterface
38{
39    public:
40        bool    bIsNewSession;              //true if the downloading a new file
41        //false if keep downloading a partial downloading file
42        OSCL_wString &iConfigFileName;      //download config file
43        OSCL_wString &iDownloadFileName;    //local file name of the downloaded clip
44        uint32  iMaxFileSize;               //the max size of the file.
45        OSCL_String &iProxyName;            //HTTP proxy name, either ip or dns
46        int32   iProxyPort;                 //HTTP proxy port
47
48        typedef enum        // For Download only
49        {
50            ENoPlayback         = 0,
51            EAfterDownload,
52            EAsap,
53            ENoSaveToFile,
54            EReserve
55        } TPVPlaybackControl;
56        TPVPlaybackControl  iPlaybackControl;
57
58        PVMFDownloadDataSourceHTTP(bool aIsNewSession
59                                   , OSCL_wString &aConfigFile
60                                   , OSCL_wString &aDownloadFileName
61                                   , uint32 aMaxSize
62                                   , OSCL_String &aProxyName
63                                   , int32 aProxyPort
64                                   , TPVPlaybackControl aPlaybackControl)
65                : bIsNewSession(aIsNewSession)
66                , iConfigFileName(aConfigFile)
67                , iDownloadFileName(aDownloadFileName)
68                , iMaxFileSize(aMaxSize)
69                , iProxyName(aProxyName)
70                , iProxyPort(aProxyPort)
71                , iPlaybackControl(aPlaybackControl)
72        {
73        }
74
75        /* From PVInterface */
76        void addRef()
77        {
78            iRefCounter++;
79        }
80        void removeRef()
81        {
82            iRefCounter--;
83        }
84        bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
85        {
86            if (uuid == PVUuid(PVMF_DOWNLOAD_DATASOURCE_HTTP_UUID))
87            {
88                iface = this;
89                return true;
90            }
91            else
92            {
93                iface = NULL;
94                return false;
95            }
96        }
97        int32 iRefCounter;
98};
99
100#define PVMF_DOWNLOAD_DATASOURCE_PVX_UUID PVUuid(0xc3873d74,0x5759,0x42da,0xaa,0x27,0xfa,0x63,0xb1,0xa0,0xef,0x4e)
101
102class CPVXInfo;
103
104//Source data for Fasttrack download (format type PVMF_DATA_SOURCE_PVX_FILE)
105class PVMFDownloadDataSourcePVX : public PVInterface
106{
107    public:
108        bool    bIsNewSession;              //true if the downloading a new file
109        //false if keep downloading a partial downloading file
110        OSCL_wString &iConfigFileName;      //download config file
111        OSCL_wString &iDownloadFileName;    //local file name of the downloaded clip
112        uint32  iMaxFileSize;               //the max size of the file.
113        OSCL_String &iProxyName;            //HTTP proxy name, either ip or dns
114        int32   iProxyPort;                 //HTTP proxy port
115
116        CPVXInfo &iPvxInfo;                 //class which contains all the info in the .pvx file except the URL
117
118        PVMFDownloadDataSourcePVX(bool aIsNewSession, OSCL_wString &aConfigFile, OSCL_wString &aDownloadFileName, uint32 aMaxSize, OSCL_String &aProxyName, int32 aProxyPort, CPVXInfo &p)
119                : bIsNewSession(aIsNewSession)
120                , iConfigFileName(aConfigFile)
121                , iDownloadFileName(aDownloadFileName)
122                , iMaxFileSize(aMaxSize)
123                , iProxyName(aProxyName)
124                , iProxyPort(aProxyPort)
125                , iPvxInfo(p)
126        {}
127
128        /* From PVInterface */
129        void addRef()
130        {
131            iRefCounter++;
132        }
133        void removeRef()
134        {
135            iRefCounter--;
136        }
137        bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
138        {
139            if (uuid == PVUuid(PVMF_DOWNLOAD_DATASOURCE_PVX_UUID))
140            {
141                iface = this;
142                return true;
143            }
144            else
145            {
146                iface = NULL;
147                return false;
148            }
149        }
150        int32 iRefCounter;
151};
152
153#endif //PVMF_DATA_SOURCE_INIT_EXTENSION_H_INCLUDED
154
155