• 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 MP3_UTILS_H_INCLUDED
19 #define MP3_UTILS_H_INCLUDED
20 
21 //#include "oscl_string.h"
22 
23 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
24 #include "oscl_string_containers.h"
25 #endif
26 
27 #ifndef OSCL_MEM_H_INCLUDED
28 #include "oscl_mem.h"
29 #endif
30 
31 #ifndef PVFILE_H_INCLUDED
32 #include "pvfile.h"
33 #endif
34 
35 #ifndef IMP3FF_H_INCLUDED
36 #include "imp3ff.h"
37 #endif
38 
39 
40 typedef Oscl_File* MP3_FF_FILE_REFERENCE;
41 
42 class MP3_FF_FILE
43 {
44     public:
MP3_FF_FILE()45         MP3_FF_FILE()
46         {
47             _Ptr = NULL;
48             _Size = 0;
49             auditCB = NULL;
50             _streamID = 0;
51             int32 ret = -1;
52             ret = _fileServSession.Connect();
53             if (ret == 0)
54                 _fileServSessionConnected = true;   // connect success
55             else
56                 _fileServSessionConnected = false;
57 
58         }
59 
MP3_FF_FILE(const MP3_FF_FILE & a)60         MP3_FF_FILE(const MP3_FF_FILE& a)
61         {
62             _Ptr = a._Ptr;
63             _Size = a._Size;
64             auditCB = a.auditCB;
65             _pvfile = a._pvfile;
66             _streamID = a._streamID;
67         }
68 
~MP3_FF_FILE()69         ~MP3_FF_FILE()
70         {
71             _Ptr = NULL;
72             _Size = 0;
73             auditCB = NULL;
74             _streamID = 0;
75             if (_fileServSessionConnected == true)      // Still connected
76             {
77                 _fileServSession.Close();               // return from Close is always 0.
78                 _fileServSessionConnected = false;
79             }
80         }
81         /**
82          * The assignment operator
83          */
84         MP3_FF_FILE& operator=(const MP3_FF_FILE& a)
85         {
86             if (&a != this)
87             {
88                 _Ptr = a._Ptr;
89                 _Size = a._Size;
90                 auditCB = a.auditCB;
91                 _pvfile.Copy(a._pvfile);
92                 _streamID = a._streamID;
93             }
94             return *this;
95         }
96 
97         MP3_FF_FILE_REFERENCE _Ptr;
98         int32                 _Size;
99         OsclAuditCB*          auditCB;
100         Oscl_FileServer       _fileServSession;
101         PVFile                _pvfile;
102         uint8                 _streamID;
103         bool                  _fileServSessionConnected;
104 };
105 
106 
107 class MP3Utils
108 {
109 
110     public:
111 
112         static int32  getCurrentFilePosition(PVFile *fp);
113         static int32  OpenFile(OSCL_wHeapString<OsclMemAllocator> filename,
114                                uint32 mode,
115                                MP3_FF_FILE *fp);
116         static int32  CloseFile(PVFile *fp);
117         static int32  Flush(PVFile *fp);
118         static bool   getCurrentFileSize(PVFile *fp, uint32& aCurrentSize);
119         static MP3ErrorType SeektoOffset(PVFile *fp, int32 offset, Oscl_File::seek_type aSeekType);
120 };
121 
122 #endif // MP3_UTILS_H_INCLUDED
123