• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FILEBUFFERDATASTREAM_FACTORY_H_INCLUDED
19 #define PVMF_FILEBUFFERDATASTREAM_FACTORY_H_INCLUDED
20 
21 #ifndef OSCL_BASE_H_INCLUDED
22 #include "oscl_base.h"
23 #endif
24 #ifndef OSCL_ERROR_CODES_H_INCLUDED
25 #include "oscl_error_codes.h"
26 #endif
27 #ifndef OSCL_TYPES_H_INCLUDED
28 #include "oscl_types.h"
29 #endif
30 #ifndef OSCL_FILE_IO_H_INCLUDED
31 #include "oscl_file_io.h"
32 #endif
33 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
34 #include "oscl_string_containers.h"
35 #endif
36 #ifndef PVLOGGER_H_INCLUDED
37 #include "pvlogger.h"
38 #endif
39 #ifndef PVMF_EVENT_HANDLING_H_INCLUDED
40 #include "pvmf_event_handling.h"
41 #endif
42 #ifndef PVMI_DATA_STREAM_INTERFACE_H_INCLUDED
43 #include "pvmi_data_stream_interface.h"
44 #endif
45 #ifndef PVMF_CPMPLUGIN_ACCESS_INTERFACE_FACTORY_H_INCLUDED
46 #include "pvmf_cpmplugin_access_interface_factory.h"
47 #endif
48 #ifndef PVMI_DATASTREAMUSER_INTERFACE_H_INCLUDED
49 #include "pvmi_datastreamuser_interface.h"
50 #endif
51 #ifndef PVMF_MEDIA_DATA_H_INCLUDED
52 #include "pvmf_media_data.h"
53 #endif
54 
55 #define MAX_NUMBER_OF_READ_CONNECTIONS 4
56 #define MAX_NUMBER_OF_WRITE_CONNECTIONS 1
57 #define MAX_NUMBER_OF_TOTAL_CONNECTIONS  MAX_NUMBER_OF_WRITE_CONNECTIONS+MAX_NUMBER_OF_READ_CONNECTIONS
58 
59 class PVMFFileBufferWriteDataStreamImpl;
60 class PVMFFileBufferReadDataStreamImpl;
61 
62 //////////////////////////////////////////////////////////////////////
63 // PVMFFileBufferDataStreamReadDataStreamFactoryImpl
64 //////////////////////////////////////////////////////////////////////
65 class PVMFFileBufferDataStreamReadDataStreamFactoryImpl : public PVMFDataStreamFactory
66 {
67     public:
68         OSCL_IMPORT_REF PVMFFileBufferDataStreamReadDataStreamFactoryImpl(OSCL_wString& aFileName);
69 
70         OSCL_IMPORT_REF void SetWriteDataStreamPtr(PVInterface* aWriteDataStream);
71         OSCL_IMPORT_REF PVMFStatus QueryAccessInterfaceUUIDs(Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids);
72         OSCL_IMPORT_REF PVInterface* CreatePVMFCPMPluginAccessInterface(PVUuid& aUuid);
73         OSCL_IMPORT_REF void DestroyPVMFCPMPluginAccessInterface(PVUuid& aUuid, PVInterface* aPtr);
74 
75         OSCL_IMPORT_REF void NotifyDownloadComplete();
76 
77     private:
addRef()78         void addRef() {};
removeRef()79         void removeRef() {};
queryInterface(const PVUuid &,PVInterface * &)80         bool queryInterface(const PVUuid&, PVInterface*&)
81         {
82             return false;
83         };
84 
85         OSCL_wHeapString<OsclMemAllocator> iFileName;
86         PVMFFileBufferWriteDataStreamImpl *iWriteDataStream;
87 
88         bool iDownloadComplete;
89         Oscl_Vector<PVMFFileBufferReadDataStreamImpl*, OsclMemAllocator> iReadStreamVec;
90 };
91 
92 
93 //////////////////////////////////////////////////////////////////////
94 // PVMFFileBufferDataStreamWriteDataStreamFactoryImpl
95 //////////////////////////////////////////////////////////////////////
96 class PVMFFileBufferDataStreamWriteDataStreamFactoryImpl : public PVMFDataStreamFactory,
97         public PVMFDataStreamReadCapacityObserver
98 {
99     public:
100         OSCL_IMPORT_REF PVMFFileBufferDataStreamWriteDataStreamFactoryImpl(OSCL_wString& aFileName);
101         OSCL_IMPORT_REF ~PVMFFileBufferDataStreamWriteDataStreamFactoryImpl();
102 
103         OSCL_IMPORT_REF PVMFStatus QueryAccessInterfaceUUIDs(Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids);
104         OSCL_IMPORT_REF PVInterface* CreatePVMFCPMPluginAccessInterface(PVUuid& aUuid);
105         OSCL_IMPORT_REF void DestroyPVMFCPMPluginAccessInterface(PVUuid& aUuid, PVInterface* aPtr);
106 
107         virtual PvmiDataStreamStatus GetStreamReadCapacity(uint32& aCapacity);
108 
109     private:
addRef()110         void addRef() {};
removeRef()111         void removeRef() {};
queryInterface(const PVUuid &,PVInterface * &)112         bool queryInterface(const PVUuid&, PVInterface*&)
113         {
114             return false;
115         };
116 
117         OSCL_wHeapString<OsclMemAllocator> iFileName;
118         PVMFFileBufferWriteDataStreamImpl *iWriteDataStream;
119         bool iDownloadComplete;
120 };
121 
122 
123 //////////////////////////////////////////////////////////////////////
124 // PVMFFileBufferReadDataStreamImpl
125 //////////////////////////////////////////////////////////////////////
126 class PVMFFileBufferReadDataStreamImpl : public PVMIDataStreamSyncInterface
127 {
128     public:
129         OSCL_IMPORT_REF PVMFFileBufferReadDataStreamImpl(PVMFFileBufferWriteDataStreamImpl* aWriteDataStream,
130                 OSCL_wString& aFileName);
131         OSCL_IMPORT_REF ~PVMFFileBufferReadDataStreamImpl();
132 
133         // From PVInterface
addRef()134         void addRef() {};
removeRef()135         void removeRef() {};
136 
137         OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid,
138                                             PVInterface*& iface);
139 
140         OSCL_IMPORT_REF
141         PvmiDataStreamStatus OpenSession(PvmiDataStreamSession& aSessionID,
142                                          PvmiDataStreamMode aMode,
143                                          bool nonblocking = false);
144 
145         OSCL_IMPORT_REF
146         PvmiDataStreamStatus CloseSession(PvmiDataStreamSession aSessionID);
147 
148         OSCL_IMPORT_REF
149         PvmiDataStreamRandomAccessType QueryRandomAccessCapability();
150 
151         OSCL_IMPORT_REF
152         PvmiDataStreamStatus QueryReadCapacity(PvmiDataStreamSession aSessionID,
153                                                uint32& capacity);
154 
155         OSCL_IMPORT_REF
156         PvmiDataStreamCommandId RequestReadCapacityNotification(PvmiDataStreamSession aSessionID,
157                 PvmiDataStreamObserver& observer,
158                 uint32 capacity,
159                 OsclAny* aContextData = NULL);
160 
161         OSCL_IMPORT_REF
162         PvmiDataStreamStatus QueryWriteCapacity(PvmiDataStreamSession aSessionID,
163                                                 uint32& capacity);
164 
165         OSCL_IMPORT_REF
166         PvmiDataStreamCommandId RequestWriteCapacityNotification(PvmiDataStreamSession aSessionID,
167                 PvmiDataStreamObserver& observer,
168                 uint32 capacity,
169                 OsclAny* aContextData = NULL);
170 
171         OSCL_IMPORT_REF
172         PvmiDataStreamCommandId CancelNotification(PvmiDataStreamSession aSessionID,
173                 PvmiDataStreamObserver& observer,
174                 PvmiDataStreamCommandId aID,
175                 OsclAny* aContextData = NULL);
176 
177         OSCL_IMPORT_REF
178         PvmiDataStreamStatus CancelNotificationSync(PvmiDataStreamSession aSessionID);
179 
180         OSCL_IMPORT_REF
181         PvmiDataStreamStatus Read(PvmiDataStreamSession aSessionID,
182                                   uint8* buffer,
183                                   uint32 size,
184                                   uint32& numelements);
185 
186         OSCL_IMPORT_REF
187         PvmiDataStreamStatus Write(PvmiDataStreamSession aSessionID,
188                                    uint8* buffer,
189                                    uint32 size,
190                                    uint32& numelements);
191 
192         OSCL_IMPORT_REF
193         PvmiDataStreamStatus Write(PvmiDataStreamSession aSessionID,
194                                    OsclRefCounterMemFrag* frag,
195                                    uint32& aNumElements);
196 
197         OSCL_IMPORT_REF
198         PvmiDataStreamStatus Seek(PvmiDataStreamSession aSessionID,
199                                   int32 offset,
200                                   PvmiDataStreamSeekType origin);
201 
202         OSCL_IMPORT_REF
203         uint32 GetCurrentPointerPosition(PvmiDataStreamSession aSessionID) ;
204 
205         OSCL_IMPORT_REF
206         PvmiDataStreamStatus Flush(PvmiDataStreamSession aSessionID);
207 
208         OSCL_IMPORT_REF void NotifyDownloadComplete();
209 
SetContentLength(uint32 aContentLength)210         void SetContentLength(uint32 aContentLength)
211         {
212             OSCL_UNUSED_ARG(aContentLength);
213         }
214 
GetContentLength()215         uint32 GetContentLength()
216         {
217             return 0;
218         }
219 
QueryBufferingCapacity()220         uint32 QueryBufferingCapacity()
221         {
222             return 0;
223         }
224 
SetSourceRequestObserver(PvmiDataStreamRequestObserver & aObserver)225         PvmiDataStreamStatus SetSourceRequestObserver(PvmiDataStreamRequestObserver& aObserver)
226         {
227             OSCL_UNUSED_ARG(aObserver);
228             return PVDS_NOT_SUPPORTED;
229         }
230 
SourceRequestCompleted(const PVMFCmdResp & aResponse)231         void SourceRequestCompleted(const PVMFCmdResp& aResponse)
232         {
233             OSCL_UNUSED_ARG(aResponse);
234         }
235 
MakePersistent(int32 aOffset,uint32 aSize)236         PvmiDataStreamStatus MakePersistent(int32 aOffset, uint32 aSize)
237         {
238             OSCL_UNUSED_ARG(aOffset);
239             OSCL_UNUSED_ARG(aSize);
240             return PVDS_NOT_SUPPORTED;
241         }
242 
243     public:
244         bool iDownloadComplete;
245 
246     private:
247         PVMFFileBufferWriteDataStreamImpl* iWriteDataStream;
248 
249         Oscl_File *iFileObject;
250         OsclFileHandle* iFileHandle;
251         Oscl_FileServer iFs;
252         OSCL_wHeapString<OsclMemAllocator> iFileName;
253 
254         PvmiDataStreamSession iSessionID;
255 
256         int32 iFileNumBytes;
257 
258         PVLogger* iLogger;
259 };
260 
261 
262 //////////////////////////////////////////////////////////////////////
263 // PVMFFileBufferWriteDataStreamImpl
264 //////////////////////////////////////////////////////////////////////
265 class PVMFFileBufferWriteDataStreamImpl : public PVMIDataStreamSyncInterface
266 {
267     public:
268         OSCL_IMPORT_REF PVMFFileBufferWriteDataStreamImpl(OSCL_wString& aFileName);
269         OSCL_IMPORT_REF ~PVMFFileBufferWriteDataStreamImpl();
270 
271         // From PVInterface
addRef()272         void addRef() {};
273 
removeRef()274         void removeRef() {};
275 
276         OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid,
277                                             PVInterface*& iface);
278 
279         OSCL_IMPORT_REF
280         PvmiDataStreamStatus OpenSession(PvmiDataStreamSession& aSessionID,
281                                          PvmiDataStreamMode aMode,
282                                          bool nonblocking = false);
283 
284         OSCL_IMPORT_REF
285         PvmiDataStreamStatus CloseSession(PvmiDataStreamSession aSessionID);
286 
287         OSCL_IMPORT_REF
288         PvmiDataStreamRandomAccessType QueryRandomAccessCapability();
289 
290         OSCL_IMPORT_REF
291         PvmiDataStreamStatus QueryReadCapacity(PvmiDataStreamSession aSessionID,
292                                                uint32& capacity);
293 
294         OSCL_IMPORT_REF
295         PvmiDataStreamCommandId RequestReadCapacityNotification(PvmiDataStreamSession aSessionID,
296                 PvmiDataStreamObserver& observer,
297                 uint32 capacity,
298                 OsclAny* aContextData = NULL);
299 
300         OSCL_IMPORT_REF
301         PvmiDataStreamStatus QueryWriteCapacity(PvmiDataStreamSession aSessionID,
302                                                 uint32& capacity);
303 
304         OSCL_IMPORT_REF
305         PvmiDataStreamCommandId RequestWriteCapacityNotification(PvmiDataStreamSession aSessionID,
306                 PvmiDataStreamObserver& observer,
307                 uint32 capacity,
308                 OsclAny* aContextData = NULL);
309 
310         OSCL_IMPORT_REF
311         PvmiDataStreamCommandId CancelNotification(PvmiDataStreamSession aSessionID,
312                 PvmiDataStreamObserver& observer,
313                 PvmiDataStreamCommandId aID,
314                 OsclAny* aContextData = NULL);
315 
316         OSCL_IMPORT_REF
317         PvmiDataStreamStatus CancelNotificationSync(PvmiDataStreamSession aSessionID);
318 
319         OSCL_IMPORT_REF
320         PvmiDataStreamStatus Read(PvmiDataStreamSession aSessionID,
321                                   uint8* buffer,
322                                   uint32 size,
323                                   uint32& numelements);
324 
325         OSCL_IMPORT_REF
326         PvmiDataStreamStatus Write(PvmiDataStreamSession aSessionID,
327                                    uint8* buffer,
328                                    uint32 size,
329                                    uint32& numelements);
330 
331         OSCL_IMPORT_REF
332         PvmiDataStreamStatus Write(PvmiDataStreamSession aSessionID,
333                                    OsclRefCounterMemFrag* frag,
334                                    uint32& aNumElements);
335 
336         OSCL_IMPORT_REF
337         PvmiDataStreamStatus Seek(PvmiDataStreamSession aSessionID,
338                                   int32 offset,
339                                   PvmiDataStreamSeekType origin);
340 
341         OSCL_IMPORT_REF
342         uint32 GetCurrentPointerPosition(PvmiDataStreamSession aSessionID) ;
343 
344         OSCL_IMPORT_REF
345         PvmiDataStreamStatus Flush(PvmiDataStreamSession aSessionID);
346 
347         OSCL_IMPORT_REF void NotifyDownloadComplete();
348 
SetContentLength(uint32 aContentLength)349         void SetContentLength(uint32 aContentLength)
350         {
351             OSCL_UNUSED_ARG(aContentLength);
352         }
353 
GetContentLength()354         uint32 GetContentLength()
355         {
356             return 0;
357         }
358 
QueryBufferingCapacity()359         uint32 QueryBufferingCapacity()
360         {
361             return 0;
362         }
363 
SetSourceRequestObserver(PvmiDataStreamRequestObserver & aObserver)364         PvmiDataStreamStatus SetSourceRequestObserver(PvmiDataStreamRequestObserver& aObserver)
365         {
366             OSCL_UNUSED_ARG(aObserver);
367             return PVDS_NOT_SUPPORTED;
368         }
369 
SourceRequestCompleted(const PVMFCmdResp & aResponse)370         void SourceRequestCompleted(const PVMFCmdResp& aResponse)
371         {
372             OSCL_UNUSED_ARG(aResponse);
373         }
374 
MakePersistent(int32 aOffset,uint32 aSize)375         PvmiDataStreamStatus MakePersistent(int32 aOffset, uint32 aSize)
376         {
377             OSCL_UNUSED_ARG(aOffset);
378             OSCL_UNUSED_ARG(aSize);
379             return PVDS_NOT_SUPPORTED;
380         }
381 
382     public:
383         bool iDownloadComplete;
384 
385     private:
386 
387         struct ReadCapacityNotificationStruct
388         {
389             bool ReadStructValid;
390             PvmiDataStreamSession iReadSessionID;
391             PvmiDataStreamObserver *iReadObserver;
392             uint32 iFilePosition;
393             uint32 iReadCapacity;
394             OsclAny* iContextData;
395             PVMFCommandId iCommandID;
396             PVMFCommandId iCurrentCommandID;
397         };
398         PvmiDataStreamSession iLastSessionID;
399         ReadCapacityNotificationStruct iReadNotifications[MAX_NUMBER_OF_READ_CONNECTIONS];
400 
401         Oscl_File *iFileObject;
402         OsclFileHandle* iFileHandle;
403         Oscl_FileServer iFs;
404         OSCL_wHeapString<OsclMemAllocator> iFileName;
405 
406         PvmiDataStreamSession iSessionID;
407 
408         int32 iFileNumBytes;
409 
410         PVLogger* iLogger;
411 };
412 
413 
414 //////////////////////////////////////////////////////////////////////
415 // PVMFFileBufferWriteDataStreamImpl
416 //////////////////////////////////////////////////////////////////////
417 class PVMFFileBufferDataStream
418 {
419     public:
420         OSCL_IMPORT_REF PVMFFileBufferDataStream(OSCL_wString& aFileName);
421         OSCL_IMPORT_REF ~PVMFFileBufferDataStream();
422 
423         OSCL_IMPORT_REF
424         PVMFDataStreamFactory* GetReadDataStreamFactoryPtr();
425 
426         OSCL_IMPORT_REF
427         PVMFDataStreamFactory* GetWriteDataStreamFactoryPtr();
428 
429         OSCL_IMPORT_REF void NotifyDownloadComplete();
430 
431     private:
432         PVMFFileBufferDataStreamReadDataStreamFactoryImpl* iReadDataStreamFactory;
433         PVMFFileBufferDataStreamWriteDataStreamFactoryImpl* iWriteDataStreamFactory;
434         PVInterface* iWriteDataStream;
435         OSCL_wHeapString<OsclMemAllocator> iFileName;
436 
437 };
438 
439 #endif // PVMF_FILEBUFFERDATASTREAM_FACTORY_H_INCLUDED
440 
441 
442 
443