source: svn/newcon3bcm2_21bu/nexus/modules/file/include/nexus_file.h @ 66

Last change on this file since 66 was 66, checked in by megakiss, 11 years ago

키패드 기능 연결

전원키 누르고 리모콘 누르면 학습
CH+ 간격 1초 증가 MAX:15
CH- 간격 1초 감소 MIN :1

  • Property svn:executable set to *
File size: 13.0 KB
Line 
1/***************************************************************************
2 *     (c)2007-2011 Broadcom Corporation
3 *
4 *  This program is the proprietary software of Broadcom Corporation and/or its licensors,
5 *  and may only be used, duplicated, modified or distributed pursuant to the terms and
6 *  conditions of a separate, written license agreement executed between you and Broadcom
7 *  (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8 *  no license (express or implied), right to use, or waiver of any kind with respect to the
9 *  Software, and Broadcom expressly reserves all rights in and to the Software and all
10 *  intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11 *  HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12 *  NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.
13 *
14 *  Except as expressly set forth in the Authorized License,
15 *
16 *  1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17 *  secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18 *  and to use this information only in connection with your use of Broadcom integrated circuit products.
19 *
20 *  2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21 *  AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22 *  WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23 *  THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24 *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25 *  LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26 *  OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27 *  USE OR PERFORMANCE OF THE SOFTWARE.
28 *
29 *  3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30 *  LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31 *  EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32 *  USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33 *  THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34 *  ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35 *  LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36 *  ANY LIMITED REMEDY.
37 *
38 * $brcm_Workfile: nexus_file.h $
39 * $brcm_Revision: 12 $
40 * $brcm_Date: 11/30/11 1:37p $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /nexus/modules/file/include/nexus_file.h $
47 *
48 * 12   11/30/11 1:37p vsilyaev
49 * SW7425-1790: Added support for S/G file mux I/O
50 *
51 * SW7425-324/1   11/21/11 1:01p vsilyaev
52 * SW7425-1790: Added support for S/G file mux I/O
53 *
54 * 11   4/6/11 6:53p vsilyaev
55 * SW7425-232: Removed MuxFileIo API to avoid naming clashes
56 *
57 * 10   4/6/11 4:45p vsilyaev
58 * SW7425-232: Added MuxFile interface
59 *
60 * 9   1/13/11 9:18a erickson
61 * SW7405-4419: clarify comments
62 *
63 * 8   9/22/10 6:59p vsilyaev
64 * SW7405-4419: Added API for file editing
65 *
66 * 7   12/15/09 3:41p erickson
67 * SW3556-913: add implementation notes for NEXUS_File_AsyncRead
68 *
69 * 6   1/6/09 11:50p erickson
70 * PR35457: coding convention, comments
71 *
72 * 5   12/3/08 12:33p vsilyaev
73 * PR 49501: Added NEXUS_FileRecord_AppendPosix
74 *
75 * 4   11/18/08 4:55p erickson
76 * PR47854: added NEXUS_FilePlay_Cancel to recover from hung threads due
77 *  to bad I/O
78 *
79 * 3   1/23/08 8:37p vobadm
80 * PR35457: update docs
81 *
82 * 2   1/23/08 5:16p erickson
83 * PR35457: update docs
84 *
85 * 1   1/18/08 2:16p jgarrett
86 * PR 38808: Merging to main branch
87 *
88 * Nexus_Devel/5   11/29/07 2:24p erickson
89 * PR35457: doc update for 0.5 release
90 *
91 * Nexus_Devel/4   11/7/07 5:34p vsilyaev
92 * PR 36788: Updated file API
93 *
94 * Nexus_Devel/3   10/12/07 5:11p vsilyaev
95 * PR 35824: Added O_DIRECT flag, fixed lock/unlock order
96 *
97 * Nexus_Devel/2   10/10/07 4:03p vsilyaev
98 * PR 35824: Added syncthunk support
99 *
100 * Nexus_Devel/1   10/10/07 3:57p vsilyaev
101 * PR 35824: File I/O module
102 *
103 **************************************************************************/
104#ifndef NEXUS_FILE_H__
105#define NEXUS_FILE_H__
106
107#include "nexus_file_types.h"
108
109#ifndef DIRECT_IO_SUPPORT
110#define DIRECT_IO_SUPPORT 1
111#endif
112
113#ifdef __cplusplus
114extern "C" {
115#endif
116
117/**
118Summary:
119NEXUS_FileReadHandle is used for a file I/O read interface.
120**/
121typedef struct bfile_io_read *NEXUS_FileReadHandle;
122
123/**
124Summary:
125NEXUS_FileWriteHandle is used for a file I/O write interface.
126**/
127typedef struct bfile_io_write *NEXUS_FileWriteHandle;
128
129
130/*
131Summary:
132This is an object to retrieve data from the media.
133
134Description:
135This object has support for two independent data flows.
136Usually it implemented by read(2) and seek(2) functions
137This is used by NEXUS_Playback_Start.
138*/
139typedef struct NEXUS_FilePlay *NEXUS_FilePlayHandle;
140
141/*
142Summary:
143This is an object to store data to the media.
144
145Description:
146Usually it implemented by write(2) function.
147This object has support for two independent data flows.
148This is used by NEXUS_Record_Start.
149*/
150typedef struct NEXUS_FileRecord *NEXUS_FileRecordHandle;
151
152/**
153Summary:
154Callback used for NEXUS_File_AsyncRead and NEXUS_File_AsyncWrite
155**/
156typedef void (*NEXUS_File_Callback)(void *cntx, ssize_t size);
157
158/**
159Summary:
160This value is used to indicate if timestamp or index position is invalid
161**/
162#define NEXUS_FILE_INVALID_POSITION ((unsigned long)-1)
163
164/**
165Summary:
166NEXUS_FilePosition is used to define the position in the recorded file
167**/
168typedef struct NEXUS_FilePosition {
169    off_t mpegFileOffset;       /*  Position in the mpeg file, in bytes. */
170    unsigned long indexOffset;  /*  Offset of the current index entry in the index, in bytes.
171                                    This field is set to NEXUS_FILE_INVALID_POSITION if index is invalid */
172
173    unsigned long timestamp;    /*  Timestamp of the current index entry in the index.
174                                    Timestamp is different from PTS. Timestamp is generated
175                                    by bcmindexer, it begins at 0 for any recorded stream,
176                                    and is guaranteed to be continuous increasing throughout
177                                    the stream. The units of the timestamp depend on the
178                                    implementation of bcmindexer, but they are defaulted
179                                    to milliseconds.
180                                    This field is set to NEXUS_FILE_INVALID_POSITION if index is invalid */
181} NEXUS_FilePosition;
182
183
184/**
185Summary:
186Asynchronous read
187
188Description:
189The following are notes about writing a new NEXUS_File implementation:
190
191The callback parameter will be invoked when the file read is complete.
192NEXUS_File_AsyncRead is not required to read the full amount of data specified by the length parameter.
193The caller's state machine may block while waiting for NEXUS_File_AsyncRead to complete its transaction,
194so it is best for File to be non-blocking. A blocking implementation of File is permitted,
195but it will likely cause ill effects in other parts of the system.
196
197The callback size parameter should follow these rules:
198- If there is no data available but the file is not at the end (e.g. streaming data), callback should return size == BFILE_ERROR_NO_DATA.
199- If there is no data available because the file is at the end, callback should return size == 0. The caller should then initiate end-of-file processing.
200- If there is an error in the file I/O, callback should return size == -1. The caller should then terminate file processing.
201
202The caller expects that the callback will be invoked from another thread.
203The caller will be holding the module mutex when calling NEXUS_File_AsyncRead and the function passed in as a callback
204will likely try to acquire the same module mutex. Unless there is a context switch allowing NEXUS_File_AsyncRead to return, a deadlock will result.
205**/
206void NEXUS_File_AsyncRead(
207    NEXUS_FileReadHandle file,
208    void *buf,
209    size_t length, /* length of memory pointed to by buf in bytes. NEXUS_File_AsyncRead can read <= this amount. */
210    NEXUS_ModuleHandle module, /* module lock will be acquired before callback is called */
211    NEXUS_File_Callback callback, /* will be called when I/O is complete */
212    void *cntx /* context passed to callback */
213    );
214
215/**
216Summary:
217Asynchronous write
218**/
219void NEXUS_File_AsyncWrite(
220    NEXUS_FileWriteHandle file,
221    const void *buf,
222    size_t length, /* length of data pointed to by buf in bytes */
223    NEXUS_ModuleHandle module, /* module lock will be acquired before callback is called */
224    NEXUS_File_Callback callback, /* will be called when I/O is complete */
225    void *cntx /* context passed to callback */
226    );
227
228/**
229Summary:
230Synchronous file I/O using posix open/read calls.
231
232Description:
233This is used for reading indexes.
234**/
235NEXUS_FilePlayHandle NEXUS_FilePlay_OpenPosix(
236    const char *dataFileName,
237    const char *indexFileName
238    );
239
240/**
241Summary:
242Synchronous file I/O using posix open/write calls.
243
244Description:
245This is used for recording indexes.
246**/
247NEXUS_FileRecordHandle NEXUS_FileRecord_OpenPosix(
248    const char *dataFileName,
249    const char *indexFileName
250    );
251
252
253/**
254Summary:
255Synchronous file I/O using posix open/write calls that appends to the existing file.
256**/
257NEXUS_FileRecordHandle NEXUS_FileRecord_AppendPosix(
258    const char *dataFileName,
259    const char *indexFileName
260    );
261
262/**
263Summary:
264Cancel a stuck play file thread
265
266Description:
267If a file thread becomes stuck (e.g. NEXUS_File_Callback not received), you can cancel it by calling this function.
268The thread will be marked as cancelled. Any pending result will be lost. A new thread will be created in its place.
269**/
270void NEXUS_FilePlay_Cancel(
271    NEXUS_FilePlayHandle file
272    );
273
274/**
275Summary:
276Close a play file
277**/
278void NEXUS_FilePlay_Close(
279    NEXUS_FilePlayHandle file
280    );
281
282/**
283Summary:
284Close a record file
285**/
286void NEXUS_FileRecord_Close(
287    NEXUS_FileRecordHandle file
288    );
289
290/*
291Summary:
292This function returns bounds of the play file
293
294Description:
295This function could be used for files that were previously recorded using NEXUS_Record.
296*/
297NEXUS_Error NEXUS_FilePlay_GetBounds(
298    NEXUS_FilePlayHandle file, /* Handle returned by NEXUS_FifoRecord_Create */
299    NEXUS_FilePosition *pFirst,  /* [out] first position in the file */
300    NEXUS_FilePosition *pLast    /* [out] last position in the file */
301    );
302
303/*
304Summary:
305This function returns bounds of the play file
306
307Description:
308This function could be used for files that were previously recorded using NEXUS_Record.
309*/
310NEXUS_Error NEXUS_FilePlay_GetLocation(
311    NEXUS_FilePlayHandle file, /* Handle returned by NEXUS_FifoRecord_Create */
312    unsigned long timestamp,    /* Timestamp of requested position, units of milliseconds */
313    NEXUS_FilePosition *pPosition  /* [out] position in the file of closest random access point */
314    );
315
316/*
317Summary:
318This structure is used to communicate user settings for NEXUS_FilePlayOffset_Open
319*/
320typedef struct NEXUS_FilePlayOffset_Settings {
321    off_t dataOffset; /* sets new "beginning of file" for the data file, in units of bytes */
322    unsigned long indexOffset; /* sets new "beginning of file" for the index file, in units of bytes */
323} NEXUS_FilePlayOffset_Settings;
324
325/*
326Summary:
327This function initializes NEXUS_FilePlayOffset_Settings structure
328*/
329void NEXUS_FilePlayOffset_GetDefaultSettings(
330    NEXUS_FilePlayOffset_Settings *pSettings /* [out] */
331    );
332
333/*
334Summary:
335This function is used to wrap NEXUS_FilePlay object to apply an offset for index and data
336*/
337NEXUS_FilePlayHandle NEXUS_FilePlayOffset_Open(
338    NEXUS_FilePlayHandle file,
339    const NEXUS_FilePlayOffset_Settings *pSettings
340    );
341
342
343/**
344Summary:
345NEXUS_MuxFileHandle used to save mux data
346**/
347typedef struct NEXUS_MuxFile *NEXUS_MuxFileHandle;
348
349/**
350Summary:
351NEXUS_MuxFileHandle used for a file I/O mux interface.
352**/
353typedef struct bfile_io_mux *NEXUS_MuxFileIoHandle;
354
355/**
356Summary:
357Close a mux file
358**/
359void NEXUS_MuxFile_Close(NEXUS_MuxFileHandle file);
360
361/**
362Summary:
363Synchronous file I/O using posix open/write calls.
364
365Description:
366This is used for a file mux .
367**/
368NEXUS_MuxFileHandle NEXUS_MuxFile_OpenPosix(
369    const char *fileName
370    );
371
372/**
373Summary:
374Asynchronous mux read
375**/
376void NEXUS_File_AsyncMuxWrite(
377    NEXUS_MuxFileIoHandle file,
378    off_t offset,
379    const NEXUS_FileMuxIoWriteAtom *atoms, /* pointer to elements to be written */
380    size_t atom_count, /* number of elements */
381    NEXUS_ModuleHandle module, /* module lock will be acquired before callback is called */
382    NEXUS_File_Callback callback, /* will be called when I/O is complete */
383    void *cntx /* context passed to callback */
384    );
385
386
387/**
388Summary:
389Asynchronous mux read
390**/
391void NEXUS_File_AsyncMuxRead (
392    NEXUS_MuxFileIoHandle file,
393    off_t offset,
394    const NEXUS_FileMuxIoReadAtom *atoms, /* pointer to elements to be read */
395    size_t atom_count, /* number of elements */
396    NEXUS_ModuleHandle module, /* module lock will be acquired before callback is called */
397    NEXUS_File_Callback callback, /* will be called when I/O is complete */
398    void *cntx /* context passed to callback */
399    );
400
401
402#ifdef __cplusplus
403}
404#endif
405
406#endif /* NEXUS_FILE_H__ */
407
Note: See TracBrowser for help on using the repository browser.