summaryrefslogtreecommitdiffstats
path: root/libvideoeditor/osal/inc/M4OSA_FileReader.h
blob: c22756d847e6d5851c7fe59e7702b2aef6c2386b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 ************************************************************************
 * @file         M4OSA_FileReader.h
 * @ingroup      OSAL
 * @brief        File reader
 * @note         This file declares functions and types to read a file.
 ************************************************************************
*/


#ifndef M4OSA_FILEREADER_H
#define M4OSA_FILEREADER_H


#include "M4OSA_Types.h"
#include "M4OSA_Error.h"
#include "M4OSA_FileCommon.h"
#include "M4OSA_Memory.h"



/** This enum defines the option ID to be used in M4OSA_FileReadGetOption()
    and M4OSA_FileReadSetOption()*/
typedef enum M4OSA_FileReadOptionID
{
   /** Get the file size (M4OSA_fpos*)*/
   M4OSA_kFileReadGetFileSize
                  = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x01),

      /** Get the file attributes (M4OSA_FileAttribute*)*/
   M4OSA_kFileReadGetFileAttribute
                  = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x02),

   /** Get the file URL, provided by the M4OSA_FileReadOpen (M4OSA_Char*)*/
   M4OSA_kFileReadGetURL
                  = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x03),

   /** Get the file position (M4OSA_fpos*)*/
   M4OSA_kFileReadGetFilePosition
                  = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x04),

   /** Check end of file: TRUE if the EOF has been reached, FALSE else
       (M4OSA_Bool*)*/
   M4OSA_kFileReadIsEOF
                  = M4OSA_OPTION_ID_CREATE(M4_READ, M4OSA_FILE_READER, 0x05),

   /** Check lock of file */
   M4OSA_kFileReadLockMode
                  = M4OSA_OPTION_ID_CREATE(M4_READWRITE, M4OSA_FILE_READER, 0x06)

} M4OSA_FileReadOptionID;





/** This structure stores the set of the function pointer to access to a
    file in read mode*/
typedef struct
{
   M4OSA_ERR (*openRead)   (M4OSA_Context* context,
                            M4OSA_Void* fileDescriptor,
                            M4OSA_UInt32 fileModeAccess);

   M4OSA_ERR (*readData)   (M4OSA_Context context,
                            M4OSA_MemAddr8 buffer,
                            M4OSA_UInt32* size);

   M4OSA_ERR (*seek)       (M4OSA_Context context,
                            M4OSA_FileSeekAccessMode seekMode,
                            M4OSA_FilePosition* position);

   M4OSA_ERR (*closeRead)  (M4OSA_Context context);

   M4OSA_ERR (*setOption)  (M4OSA_Context context,
                            M4OSA_FileReadOptionID optionID,
                            M4OSA_DataOption optionValue);

   M4OSA_ERR (*getOption)  (M4OSA_Context context,
                            M4OSA_FileReadOptionID optionID,
                            M4OSA_DataOption *optionValue);
} M4OSA_FileReadPointer;

#ifdef __cplusplus
extern "C"
{
#endif

M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadOpen        (M4OSA_Context* context,
                                     M4OSA_Void* fileDescriptor,
                                     M4OSA_UInt32 fileModeAccess);

M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadData        (M4OSA_Context context,
                                     M4OSA_MemAddr8 buffer,
                                     M4OSA_UInt32* size);

M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadSeek        (M4OSA_Context context,
                                     M4OSA_FileSeekAccessMode seekMode,
                                     M4OSA_FilePosition* position);

M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadClose       (M4OSA_Context context);

M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadGetOption   (M4OSA_Context context,
                                     M4OSA_FileReadOptionID optionID,
                                     M4OSA_DataOption *optionValue);

M4OSAL_FILE_EXPORT_TYPE M4OSA_ERR M4OSA_fileReadSetOption   (M4OSA_Context context,
                                     M4OSA_FileReadOptionID optionID,
                                     M4OSA_DataOption optionValue);

#ifdef __cplusplus
}
#endif

#endif   /*M4OSA_FILEREADER_H*/