| 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_chunk.h $ |
|---|
| 39 | * $brcm_Revision: 2 $ |
|---|
| 40 | * $brcm_Date: 8/15/11 3:48p $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * |
|---|
| 45 | * Revision History: |
|---|
| 46 | * |
|---|
| 47 | * |
|---|
| 48 | * |
|---|
| 49 | * |
|---|
| 50 | ***************************************************************************/ |
|---|
| 51 | #ifndef NEXUS_FILE_FIFO_CHUNK_H__ |
|---|
| 52 | #define NEXUS_FILE_FIFO_CHUNK_H__ |
|---|
| 53 | |
|---|
| 54 | #include "nexus_file.h" |
|---|
| 55 | |
|---|
| 56 | #ifdef __cplusplus |
|---|
| 57 | extern "C" { |
|---|
| 58 | #endif |
|---|
| 59 | |
|---|
| 60 | /* |
|---|
| 61 | Summary: |
|---|
| 62 | Type of record file suitable for timeshifting |
|---|
| 63 | */ |
|---|
| 64 | typedef struct NEXUS_ChunkedFifoRecord *NEXUS_ChunkedFifoRecordHandle; |
|---|
| 65 | |
|---|
| 66 | /* |
|---|
| 67 | Summary: |
|---|
| 68 | Configuration parameters for the timeshifting buffer |
|---|
| 69 | |
|---|
| 70 | Description: |
|---|
| 71 | Those numbers are used to limit size of the timishifting buffer to be occupied on the disk. |
|---|
| 72 | Usually software stack would try do not exceed soft limit of the timeshifting buffer, however |
|---|
| 73 | in certain cases, for example, if bitrates of the recorded stream suddenly increases, it could |
|---|
| 74 | go up to hardlimit. Once hardlimit is reached it would result in the overflow error. |
|---|
| 75 | */ |
|---|
| 76 | typedef struct NEXUS_ChunkedFifoRecordLimit { |
|---|
| 77 | off_t soft; /* soft limit of the timeshifting buffer, in bytes */ |
|---|
| 78 | off_t hard; /* hard limit of the timeshifting buffer, in bytes */ |
|---|
| 79 | off_t chunkSize; /* Maximum size of the single chunk, 0 - unlimited size */ |
|---|
| 80 | } NEXUS_ChunkedFifoRecordLimit; |
|---|
| 81 | |
|---|
| 82 | /* |
|---|
| 83 | Summary: |
|---|
| 84 | Configuration parameters for the timeshifting file |
|---|
| 85 | */ |
|---|
| 86 | typedef struct NEXUS_ChunkedFifoRecordSettings { |
|---|
| 87 | unsigned interval; /* Size of the timeshifting buffer, in seconds */ |
|---|
| 88 | unsigned snapshotInterval; /* interval between metadata writes, in seconds. 0 means metadata written only when file is closed */ |
|---|
| 89 | NEXUS_ChunkedFifoRecordLimit data; /* Limits for the timeshifting data file */ |
|---|
| 90 | NEXUS_ChunkedFifoRecordLimit index; /* Limits for the timeshifting index file */ |
|---|
| 91 | char chunkTemplate[128]; /* template for the individual chunk file names, e.g. "chunk_%04.mpg" */ |
|---|
| 92 | } NEXUS_ChunkedFifoRecordSettings; |
|---|
| 93 | |
|---|
| 94 | /* |
|---|
| 95 | Summary: |
|---|
| 96 | Get default settings |
|---|
| 97 | */ |
|---|
| 98 | void NEXUS_ChunkedFifoRecord_GetDefaultSettings( |
|---|
| 99 | NEXUS_ChunkedFifoRecordSettings *pSettings /* [out] */ |
|---|
| 100 | ); |
|---|
| 101 | |
|---|
| 102 | /* |
|---|
| 103 | Summary: |
|---|
| 104 | This function opens new timeshifting buffer |
|---|
| 105 | |
|---|
| 106 | Description: |
|---|
| 107 | The NEXUS_ChunkedFifoRecordHandle can be used for only one record at a time. |
|---|
| 108 | The files will be created if they don't already exist, and truncated if they do. |
|---|
| 109 | The index file is mandatory for the timeshifting. |
|---|
| 110 | */ |
|---|
| 111 | NEXUS_ChunkedFifoRecordHandle NEXUS_ChunkedFifoRecord_Create( |
|---|
| 112 | const char *mpegFileName, /* mpeg file name to create */ |
|---|
| 113 | const char *indexFileName /* index file name to create */ |
|---|
| 114 | ); |
|---|
| 115 | |
|---|
| 116 | /* |
|---|
| 117 | Summary: |
|---|
| 118 | This function returns a handle to be passed into the NEXUS_Record_Start(). |
|---|
| 119 | */ |
|---|
| 120 | NEXUS_FileRecordHandle NEXUS_ChunkedFifoRecord_GetFile( |
|---|
| 121 | NEXUS_ChunkedFifoRecordHandle fifo /* Handle returned by NEXUS_ChunkedFifoRecord_Create */ |
|---|
| 122 | ); |
|---|
| 123 | |
|---|
| 124 | /** |
|---|
| 125 | Summary: |
|---|
| 126 | This value is returned by NEXUS_ChunkedFifoRecord_GetPosition to indicate if timestamp or index position is invalid |
|---|
| 127 | **/ |
|---|
| 128 | #define NEXUS_FILE_INVALID_POSITION ((unsigned long)-1) |
|---|
| 129 | |
|---|
| 130 | /* |
|---|
| 131 | Summary: |
|---|
| 132 | This function returns current position of the recorded file |
|---|
| 133 | */ |
|---|
| 134 | NEXUS_Error NEXUS_ChunkedFifoRecord_GetPosition( |
|---|
| 135 | NEXUS_ChunkedFifoRecordHandle fifo, /* Handle returned by NEXUS_ChunkedFifoRecord_Create */ |
|---|
| 136 | NEXUS_FilePosition *pFirst, /* [out] first position in the file */ |
|---|
| 137 | NEXUS_FilePosition *pLast /* [out] last position in the file */ |
|---|
| 138 | ); |
|---|
| 139 | |
|---|
| 140 | /* |
|---|
| 141 | Summary: |
|---|
| 142 | Open a playback file to pass to NEXUS_Playback_Start(). |
|---|
| 143 | |
|---|
| 144 | Description: |
|---|
| 145 | This function shall be used only for files created by NEXUS_ChunkedFifoRecord_Create. |
|---|
| 146 | The NEXUS_FilePlayHandle can be used for only one playback at a time. |
|---|
| 147 | */ |
|---|
| 148 | NEXUS_FilePlayHandle NEXUS_ChunkedFifoPlay_Open( |
|---|
| 149 | const char *mpegFileName, |
|---|
| 150 | const char *indexFileName, |
|---|
| 151 | NEXUS_ChunkedFifoRecordHandle writer /* Handle returned by NEXUS_ChunkedFifoRecord_Create */ |
|---|
| 152 | ); |
|---|
| 153 | |
|---|
| 154 | /* |
|---|
| 155 | Summary: |
|---|
| 156 | This function returns current configuration of the timeshifting fifo |
|---|
| 157 | */ |
|---|
| 158 | void NEXUS_ChunkedFifoRecord_GetSettings( |
|---|
| 159 | NEXUS_ChunkedFifoRecordHandle fifo, /* Handle returned by NEXUS_ChunkedFifoRecord_Create */ |
|---|
| 160 | NEXUS_ChunkedFifoRecordSettings *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_ChunkedFifoRecord_SetSettings( |
|---|
| 168 | NEXUS_ChunkedFifoRecordHandle fifo, /* Handle returned by NEXUS_ChunkedFifoRecord_Create */ |
|---|
| 169 | const NEXUS_ChunkedFifoRecordSettings *pSettings /* new settings of timeshifting buffer */ |
|---|
| 170 | ); |
|---|
| 171 | |
|---|
| 172 | #ifdef __cplusplus |
|---|
| 173 | } |
|---|
| 174 | #endif |
|---|
| 175 | |
|---|
| 176 | #endif /* NEXUS_FILE_FIFO_CHUNK_H__ */ |
|---|