| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2005-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_fifo.h $ |
|---|
| 39 | * $brcm_Revision: 7 $ |
|---|
| 40 | * $brcm_Date: 5/26/11 7:01p $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $old_brcm_Log: /BSEAV/api/include/bsettop_fileio_fifo.h $ |
|---|
| 47 | * |
|---|
| 48 | * 5 4/12/06 2:16p vsilyaev |
|---|
| 49 | * PR 20680: Promoted bsettop_fileio_fifo API |
|---|
| 50 | * |
|---|
| 51 | * 4 12/23/05 4:10p vsilyaev |
|---|
| 52 | * PR 18183: Renamed API functions |
|---|
| 53 | * |
|---|
| 54 | * 2 11/21/05 3:42p vsilyaev |
|---|
| 55 | * PR 18183: Renamed size function to bounds, so it would remain useful |
|---|
| 56 | * with trimmed files |
|---|
| 57 | * |
|---|
| 58 | * 1 11/17/05 4:22p vsilyaev |
|---|
| 59 | * PR 18183: Added circular(FIFO) file |
|---|
| 60 | * |
|---|
| 61 | ***************************************************************************/ |
|---|
| 62 | #ifndef NEXUS_FILE_FIFO_H__ |
|---|
| 63 | #define NEXUS_FILE_FIFO_H__ |
|---|
| 64 | |
|---|
| 65 | #ifdef __cplusplus |
|---|
| 66 | extern "C" { |
|---|
| 67 | #endif |
|---|
| 68 | |
|---|
| 69 | #include "nexus_file.h" |
|---|
| 70 | |
|---|
| 71 | /* |
|---|
| 72 | Summary: |
|---|
| 73 | Type of record file suitable for timeshifting |
|---|
| 74 | */ |
|---|
| 75 | typedef struct NEXUS_FifoRecord *NEXUS_FifoRecordHandle; |
|---|
| 76 | |
|---|
| 77 | /* |
|---|
| 78 | Summary: |
|---|
| 79 | Configuration parameters for the timeshifting buffer |
|---|
| 80 | |
|---|
| 81 | Description: |
|---|
| 82 | Those numbers are used to limit size of the timishifting buffer to be occupied on the disk. |
|---|
| 83 | Usually software stack would try do not exceed soft limit of the timeshifting buffer, however |
|---|
| 84 | in certain cases, for example, if bitrates of the recorded stream suddenly increases, it could |
|---|
| 85 | go up to hardlimit. Once hardlimit is reached it would result in the overflow error. |
|---|
| 86 | */ |
|---|
| 87 | typedef struct NEXUS_FifoRecordLimit { |
|---|
| 88 | off_t soft; /* soft limit of the timeshifting buffer, in bytes */ |
|---|
| 89 | off_t hard; /* hard limit of the timeshifting buffer, in bytes */ |
|---|
| 90 | } NEXUS_FifoRecordLimit; |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | /* |
|---|
| 94 | Summary: |
|---|
| 95 | Configuration parameters for the timeshifting file |
|---|
| 96 | */ |
|---|
| 97 | typedef struct NEXUS_FifoRecordSettings { |
|---|
| 98 | unsigned interval; /* Size of the timeshifting buffer, in seconds */ |
|---|
| 99 | unsigned snapshotInterval; /* interval between metadata writes, in seconds. 0 means metadata written only when file is closed */ |
|---|
| 100 | NEXUS_FifoRecordLimit data; /* Limits for the timeshifting data file */ |
|---|
| 101 | NEXUS_FifoRecordLimit index; /* Limits for the timeshifting index file */ |
|---|
| 102 | } NEXUS_FifoRecordSettings; |
|---|
| 103 | |
|---|
| 104 | /* |
|---|
| 105 | Summary: |
|---|
| 106 | This function opens new timeshifting buffer |
|---|
| 107 | |
|---|
| 108 | Description: |
|---|
| 109 | The NEXUS_FifoRecordHandle can be used for only one record at a time. |
|---|
| 110 | The files will be created if they don't already exist, and truncated if they do. |
|---|
| 111 | The index file is mandatory for the timeshifting. |
|---|
| 112 | |
|---|
| 113 | You close this handle by calling NEXUS_FileRecord_Close. |
|---|
| 114 | */ |
|---|
| 115 | NEXUS_FifoRecordHandle NEXUS_FifoRecord_Create( |
|---|
| 116 | const char *mpegFileName, /* mpeg file name to create */ |
|---|
| 117 | const char *indexFileName /* index file name to create */ |
|---|
| 118 | ); |
|---|
| 119 | |
|---|
| 120 | /* |
|---|
| 121 | Summary: |
|---|
| 122 | This function returns a handle to be passed into the NEXUS_Record_Start(). |
|---|
| 123 | */ |
|---|
| 124 | NEXUS_FileRecordHandle NEXUS_FifoRecord_GetFile( |
|---|
| 125 | NEXUS_FifoRecordHandle fifo /* Handle returned by NEXUS_FifoRecord_Create */ |
|---|
| 126 | ); |
|---|
| 127 | |
|---|
| 128 | /* |
|---|
| 129 | Summary: |
|---|
| 130 | This function returns current position of the recorded file |
|---|
| 131 | */ |
|---|
| 132 | NEXUS_Error NEXUS_FifoRecord_GetPosition( |
|---|
| 133 | NEXUS_FifoRecordHandle fifo, /* Handle returned by NEXUS_FifoRecord_Create */ |
|---|
| 134 | NEXUS_FilePosition *pFirst, /* [out] first position in the file */ |
|---|
| 135 | NEXUS_FilePosition *pLast /* [out] last position in the file */ |
|---|
| 136 | ); |
|---|
| 137 | |
|---|
| 138 | /* |
|---|
| 139 | Summary: |
|---|
| 140 | Open a playback file to pass to NEXUS_Playback_Start(). |
|---|
| 141 | |
|---|
| 142 | Description: |
|---|
| 143 | This function shall be used only for files created by NEXUS_FifoRecord_Create. |
|---|
| 144 | The NEXUS_FilePlayHandle can be used for only one playback at a time. |
|---|
| 145 | |
|---|
| 146 | You close this handle by calling NEXUS_FilePlay_Close. |
|---|
| 147 | */ |
|---|
| 148 | NEXUS_FilePlayHandle NEXUS_FifoPlay_Open( |
|---|
| 149 | const char *mpegFileName, |
|---|
| 150 | const char *indexFileName, |
|---|
| 151 | NEXUS_FifoRecordHandle writer /* Handle returned by NEXUS_FifoRecord_Create */ |
|---|
| 152 | ); |
|---|
| 153 | |
|---|
| 154 | /* |
|---|
| 155 | Summary: |
|---|
| 156 | This function returns current configuration of the timeshifting fifo |
|---|
| 157 | */ |
|---|
| 158 | void NEXUS_FifoRecord_GetSettings( |
|---|
| 159 | NEXUS_FifoRecordHandle fifo, /* Handle returned by NEXUS_FifoRecord_Create */ |
|---|
| 160 | NEXUS_FifoRecordSettings *pSettings /* [out] current settings of timeshifting buffer */ |
|---|
| 161 | ); |
|---|
| 162 | |
|---|
| 163 | /* |
|---|
| 164 | Summary: |
|---|
| 165 | This function sets the new configuration of the timeshifting fifo |
|---|
| 166 | */ |
|---|
| 167 | NEXUS_Error NEXUS_FifoRecord_SetSettings( |
|---|
| 168 | NEXUS_FifoRecordHandle fifo, /* Handle returned by NEXUS_FifoRecord_Create */ |
|---|
| 169 | const NEXUS_FifoRecordSettings *pSettings /* new settings of timeshifting buffer */ |
|---|
| 170 | ); |
|---|
| 171 | |
|---|
| 172 | #ifdef __cplusplus |
|---|
| 173 | } |
|---|
| 174 | #endif |
|---|
| 175 | |
|---|
| 176 | #endif /* NEXUS_FILE_FIFO_H__ */ |
|---|
| 177 | |
|---|
| 178 | |
|---|