| 1 | /****************************************************************************** |
|---|
| 2 | * (c)2008-2009 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: $ |
|---|
| 39 | * $brcm_Revision: $ |
|---|
| 40 | * $brcm_Date: $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Utility to handle the frontend configuration and tuning. |
|---|
| 45 | * |
|---|
| 46 | * Revision History: |
|---|
| 47 | * |
|---|
| 48 | * Created: 09/28/2009 by Jeff Fisher |
|---|
| 49 | * |
|---|
| 50 | * $brcm_Log: $ |
|---|
| 51 | * |
|---|
| 52 | * |
|---|
| 53 | *****************************************************************************/ |
|---|
| 54 | #include "bapp_av.h" |
|---|
| 55 | #include "bapp_util.h" |
|---|
| 56 | #include "bapp_hdmi.h" |
|---|
| 57 | #include "bsettop_p_stream.h" |
|---|
| 58 | #include "nexus_timebase.h" |
|---|
| 59 | #include "ts_psi.h" |
|---|
| 60 | |
|---|
| 61 | BDBG_MODULE(bapp_av); /* Register software module with debug interface */ |
|---|
| 62 | #define MAX_DECODE_CHANNELS BSETTOP_MAX_STREAMS |
|---|
| 63 | |
|---|
| 64 | struct bapp_av |
|---|
| 65 | { |
|---|
| 66 | bapp_nexus_t *p_nexus; |
|---|
| 67 | bool video_decoding; |
|---|
| 68 | bool audio_decoding; |
|---|
| 69 | bool start_compressed; |
|---|
| 70 | |
|---|
| 71 | /* Decode */ |
|---|
| 72 | NEXUS_VideoDecoderHandle videoDecodeHandle; |
|---|
| 73 | NEXUS_VideoWindowHandle window; |
|---|
| 74 | NEXUS_AudioDecoderHandle pcmDecoder; |
|---|
| 75 | NEXUS_AudioDecoderHandle compressedDecoder; |
|---|
| 76 | NEXUS_AudioDecoderStartSettings audioSettings; |
|---|
| 77 | bsettop_p_stream_t *p_stream_info; |
|---|
| 78 | }; |
|---|
| 79 | |
|---|
| 80 | /** |
|---|
| 81 | Summary: |
|---|
| 82 | Supported audio and video formats |
|---|
| 83 | */ |
|---|
| 84 | const bapp_av_stream_type_t s_video_stream_types[] = |
|---|
| 85 | { |
|---|
| 86 | { TS_PSI_ST_13818_2_Video, NEXUS_VideoCodec_eMpeg2, 0,"MPEG-2" }, |
|---|
| 87 | { TS_PSI_ST_ATSC_Video, NEXUS_VideoCodec_eMpeg2, 0,"MPEG-2" }, |
|---|
| 88 | { TS_PSI_ST_AVS_Video, NEXUS_VideoCodec_eAvs, 0,"AVS" }, |
|---|
| 89 | { TS_PSI_ST_14496_10_Video, NEXUS_VideoCodec_eH264, 0,"H.264" }, |
|---|
| 90 | { TS_PSI_ST_SMPTE_VC1, NEXUS_VideoCodec_eVc1, 0,"VC1" }, |
|---|
| 91 | { TS_PSI_ST_14496_2_Video, NEXUS_VideoCodec_eMpeg4Part2, 0,"MP4p2" } |
|---|
| 92 | }; |
|---|
| 93 | const int s_video_stream_types_num = sizeof(s_video_stream_types)/sizeof(s_video_stream_types[0]); |
|---|
| 94 | |
|---|
| 95 | const bapp_av_stream_type_t s_audio_stream_types[] = |
|---|
| 96 | { |
|---|
| 97 | { TS_PSI_ST_11172_3_Audio, NEXUS_AudioCodec_eMpeg, 0,"MPEG" }, |
|---|
| 98 | { TS_PSI_ST_13818_3_Audio, NEXUS_AudioCodec_eMpeg, 0,"MPEG" }, |
|---|
| 99 | { TS_PSI_ST_ATSC_AC3, NEXUS_AudioCodec_eAc3, 0,"AC3" }, |
|---|
| 100 | { TS_PSI_ST_AVS_Audio, NEXUS_AudioCodec_eAvs, 0,"AVS" }, |
|---|
| 101 | { TS_PSI_ST_ATSC_EAC3, NEXUS_AudioCodec_eAc3Plus, 0,"AC3+" } |
|---|
| 102 | }; |
|---|
| 103 | const int s_audio_stream_types_num = sizeof(s_audio_stream_types)/sizeof(s_audio_stream_types[0]); |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | /** |
|---|
| 107 | Summary: |
|---|
| 108 | Return a bapp_av_t handle. |
|---|
| 109 | **/ |
|---|
| 110 | bapp_result_t bapp_av_open(bapp_av_t *p_av, |
|---|
| 111 | bapp_nexus_t *p_nexus) |
|---|
| 112 | { |
|---|
| 113 | NEXUS_VideoDecoderSettings settings; |
|---|
| 114 | bapp_av_t p_tmp_av = (bapp_av_t)bapp_util_malloc(sizeof(struct bapp_av)); |
|---|
| 115 | |
|---|
| 116 | if (!p_tmp_av) |
|---|
| 117 | return eBAPP_RESULT_ALLOC_FAILURE; |
|---|
| 118 | |
|---|
| 119 | BKNI_Memset(p_tmp_av,0,sizeof(struct bapp_av)); |
|---|
| 120 | |
|---|
| 121 | p_tmp_av->p_nexus = p_nexus; |
|---|
| 122 | |
|---|
| 123 | /* Bring up audio decoders and connect to outputs */ |
|---|
| 124 | p_tmp_av->pcmDecoder = NEXUS_AudioDecoder_Open(0, NULL); |
|---|
| 125 | p_tmp_av->compressedDecoder = NEXUS_AudioDecoder_Open(1, NULL); |
|---|
| 126 | |
|---|
| 127 | p_tmp_av->window = NEXUS_VideoWindow_Open(p_nexus->display, 0); |
|---|
| 128 | |
|---|
| 129 | p_tmp_av->videoDecodeHandle = NEXUS_VideoDecoder_Open(0, NULL); /* take default capabilities */ |
|---|
| 130 | BDBG_ASSERT(p_tmp_av->videoDecodeHandle); |
|---|
| 131 | NEXUS_VideoDecoder_GetSettings(p_tmp_av->videoDecodeHandle,&settings); |
|---|
| 132 | settings.channelChangeMode = NEXUS_VideoDecoder_ChannelChangeMode_eHoldUntilFirstPicture; |
|---|
| 133 | NEXUS_VideoDecoder_SetSettings(p_tmp_av->videoDecodeHandle,&settings); |
|---|
| 134 | |
|---|
| 135 | bstream_init(p_tmp_av->videoDecodeHandle); |
|---|
| 136 | |
|---|
| 137 | NEXUS_VideoWindow_AddInput(p_tmp_av->window, NEXUS_VideoDecoder_GetConnector(p_tmp_av->videoDecodeHandle)); |
|---|
| 138 | |
|---|
| 139 | /* Force a hotplug to switch to preferred format */ |
|---|
| 140 | bapp_hdmi_hotplug_callback(p_tmp_av->p_nexus->platformConfig.outputs.hdmi[0], (int)p_tmp_av->p_nexus->display); |
|---|
| 141 | |
|---|
| 142 | *p_av = p_tmp_av; |
|---|
| 143 | return eBAPP_RESULT_OK; |
|---|
| 144 | } |
|---|
| 145 | /** |
|---|
| 146 | Summary: |
|---|
| 147 | Release resources. |
|---|
| 148 | **/ |
|---|
| 149 | bapp_result_t bapp_av_close(bapp_av_t p_av) |
|---|
| 150 | { |
|---|
| 151 | BDBG_ASSERT(p_av); |
|---|
| 152 | |
|---|
| 153 | if (p_av->window) |
|---|
| 154 | NEXUS_VideoWindow_Close(p_av->window); |
|---|
| 155 | |
|---|
| 156 | if (p_av->videoDecodeHandle) |
|---|
| 157 | NEXUS_VideoDecoder_Close(p_av->videoDecodeHandle); /* take default capabilities */ |
|---|
| 158 | |
|---|
| 159 | if (p_av->pcmDecoder) |
|---|
| 160 | NEXUS_AudioDecoder_Close(p_av->pcmDecoder); |
|---|
| 161 | if (p_av->compressedDecoder) |
|---|
| 162 | NEXUS_AudioDecoder_Close(p_av->compressedDecoder); |
|---|
| 163 | if (p_av->window) |
|---|
| 164 | NEXUS_VideoWindow_Close(p_av->window); |
|---|
| 165 | |
|---|
| 166 | bapp_util_free(p_av); |
|---|
| 167 | return eBAPP_RESULT_OK; |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | /** |
|---|
| 171 | Summary: |
|---|
| 172 | Lock the frontend. |
|---|
| 173 | **/ |
|---|
| 174 | bapp_result_t bapp_audio_start(bapp_av_t p_av,bstream_t p_stream) |
|---|
| 175 | { |
|---|
| 176 | NEXUS_Error nerr; |
|---|
| 177 | bstream_status status; |
|---|
| 178 | bsettop_p_stream_t *p_stream_info; |
|---|
| 179 | NEXUS_HdmiOutputStatus hdmi_status; |
|---|
| 180 | NEXUS_TimebaseSettings timebaseSettings; |
|---|
| 181 | |
|---|
| 182 | bstream_get_status(p_stream,&status); |
|---|
| 183 | p_stream_info = bstream_get_info(p_stream); |
|---|
| 184 | |
|---|
| 185 | if ((status.mpeg.audio[0].pid == 0) || !p_stream_info) |
|---|
| 186 | { |
|---|
| 187 | return eBAPP_RESULT_FAILURE; |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | if (p_av->audio_decoding) |
|---|
| 191 | bapp_audio_stop(p_av); |
|---|
| 192 | |
|---|
| 193 | BDBG_ASSERT(p_stream_info->audioPidChannel); |
|---|
| 194 | BDBG_ASSERT(p_stream_info->stcChannel); |
|---|
| 195 | |
|---|
| 196 | NEXUS_AudioDecoder_GetDefaultStartSettings(&p_av->audioSettings); |
|---|
| 197 | p_av->audioSettings.codec = status.mpeg.audio[0].format; |
|---|
| 198 | p_av->audioSettings.pidChannel = p_stream_info->audioPidChannel; |
|---|
| 199 | |
|---|
| 200 | p_av->audioSettings.stcChannel = p_stream_info->stcChannel; |
|---|
| 201 | BDBG_MSG(("%s(0x%04x,0x%04x) %d\n",__FUNCTION__,status.mpeg.audio[0].pid,status.mpeg.pcr_pid)); |
|---|
| 202 | |
|---|
| 203 | if (!p_av->video_decoding) |
|---|
| 204 | { |
|---|
| 205 | NEXUS_Timebase_GetSettings(NEXUS_Timebase_e0, &timebaseSettings); |
|---|
| 206 | timebaseSettings.sourceType = NEXUS_TimebaseSourceType_ePcr; |
|---|
| 207 | timebaseSettings.sourceSettings.pcr.pidChannel = p_stream_info->pcrPidChannel; |
|---|
| 208 | timebaseSettings.sourceSettings.pcr.maxPcrError = 0xff; |
|---|
| 209 | timebaseSettings.sourceSettings.pcr.trackRange = NEXUS_TimebaseTrackRange_e61ppm; |
|---|
| 210 | NEXUS_Timebase_SetSettings(NEXUS_Timebase_e0, &timebaseSettings); |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | NEXUS_AudioOutput_RemoveAllInputs(NEXUS_AudioDac_GetConnector(p_av->p_nexus->platformConfig.outputs.audioDacs[0])); |
|---|
| 214 | NEXUS_AudioOutput_RemoveAllInputs(NEXUS_SpdifOutput_GetConnector(p_av->p_nexus->platformConfig.outputs.spdif[0])); |
|---|
| 215 | NEXUS_AudioOutput_AddInput(NEXUS_AudioDac_GetConnector(p_av->p_nexus->platformConfig.outputs.audioDacs[0]), |
|---|
| 216 | NEXUS_AudioDecoder_GetConnector(p_av->pcmDecoder, NEXUS_AudioDecoderConnectorType_eStereo)); |
|---|
| 217 | #if 1 |
|---|
| 218 | NEXUS_HdmiOutput_GetStatus(p_av->p_nexus->platformConfig.outputs.hdmi[0], &hdmi_status); |
|---|
| 219 | if ( hdmi_status.connected ) |
|---|
| 220 | { |
|---|
| 221 | NEXUS_AudioOutput_RemoveAllInputs(NEXUS_HdmiOutput_GetAudioConnector(p_av->p_nexus->platformConfig.outputs.hdmi[0])); |
|---|
| 222 | |
|---|
| 223 | NEXUS_AudioOutput_AddInput(NEXUS_HdmiOutput_GetAudioConnector(p_av->p_nexus->platformConfig.outputs.hdmi[0]), |
|---|
| 224 | NEXUS_AudioDecoder_GetConnector(p_av->pcmDecoder, NEXUS_AudioDecoderConnectorType_eStereo)); |
|---|
| 225 | } |
|---|
| 226 | #endif |
|---|
| 227 | p_av->start_compressed = false; |
|---|
| 228 | if ( p_av->audioSettings.codec == NEXUS_AudioCodec_eAc3 ) |
|---|
| 229 | { |
|---|
| 230 | /* Only pass through AC3 */ |
|---|
| 231 | NEXUS_AudioOutput_AddInput(NEXUS_SpdifOutput_GetConnector(p_av->p_nexus->platformConfig.outputs.spdif[0]), |
|---|
| 232 | NEXUS_AudioDecoder_GetConnector(p_av->compressedDecoder, NEXUS_AudioDecoderConnectorType_eCompressed)); |
|---|
| 233 | p_av->start_compressed = true; |
|---|
| 234 | } |
|---|
| 235 | else |
|---|
| 236 | { |
|---|
| 237 | NEXUS_AudioOutput_AddInput(NEXUS_SpdifOutput_GetConnector(p_av->p_nexus->platformConfig.outputs.spdif[0]), |
|---|
| 238 | NEXUS_AudioDecoder_GetConnector(p_av->pcmDecoder, NEXUS_AudioDecoderConnectorType_eStereo)); |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | nerr = NEXUS_AudioDecoder_Start(p_av->pcmDecoder,&p_av->audioSettings); |
|---|
| 243 | |
|---|
| 244 | if (nerr != NEXUS_SUCCESS) |
|---|
| 245 | { |
|---|
| 246 | BDBG_ERR(("%s NEXUS_AudioDecoder_Start pcm failed %d\n",__FUNCTION__,nerr)); |
|---|
| 247 | } |
|---|
| 248 | else |
|---|
| 249 | { |
|---|
| 250 | p_av->audio_decoding = true; |
|---|
| 251 | } |
|---|
| 252 | |
|---|
| 253 | if (p_av->start_compressed) |
|---|
| 254 | { |
|---|
| 255 | nerr = NEXUS_AudioDecoder_Start(p_av->compressedDecoder,&p_av->audioSettings); |
|---|
| 256 | if (nerr != NEXUS_SUCCESS) |
|---|
| 257 | { |
|---|
| 258 | BDBG_ERR(("%s NEXUS_AudioDecoder_Start compressed failed %d\n",__FUNCTION__,nerr)); |
|---|
| 259 | } |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | return eBAPP_RESULT_OK; |
|---|
| 263 | } |
|---|
| 264 | /** |
|---|
| 265 | Summary: |
|---|
| 266 | Unlock the frontend. |
|---|
| 267 | **/ |
|---|
| 268 | bapp_result_t bapp_audio_stop(bapp_av_t p_av) |
|---|
| 269 | { |
|---|
| 270 | if (!p_av->audio_decoding) |
|---|
| 271 | return eBAPP_RESULT_OK; |
|---|
| 272 | |
|---|
| 273 | NEXUS_AudioDecoder_Stop(p_av->pcmDecoder); |
|---|
| 274 | if (p_av->start_compressed) |
|---|
| 275 | { |
|---|
| 276 | NEXUS_AudioDecoder_Stop(p_av->compressedDecoder); |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | p_av->audio_decoding = false; |
|---|
| 280 | return eBAPP_RESULT_OK; |
|---|
| 281 | } |
|---|
| 282 | /** |
|---|
| 283 | Summary: |
|---|
| 284 | Lock the frontend. |
|---|
| 285 | **/ |
|---|
| 286 | bapp_result_t bapp_video_start(bapp_av_t p_av,bstream_t p_stream) |
|---|
| 287 | { |
|---|
| 288 | bstream_status status; |
|---|
| 289 | NEXUS_TimebaseSettings timebaseSettings; |
|---|
| 290 | |
|---|
| 291 | bstream_get_status(p_stream,&status); |
|---|
| 292 | |
|---|
| 293 | if (status.mpeg.video[0].pid == 0) |
|---|
| 294 | { |
|---|
| 295 | BDBG_ERR(("%s(0x%04x,0x%04x)\n",__FUNCTION__,status.mpeg.video[0].pid,status.mpeg.pcr_pid)); |
|---|
| 296 | return eBAPP_RESULT_FAILURE; |
|---|
| 297 | } |
|---|
| 298 | |
|---|
| 299 | if (p_av->video_decoding) |
|---|
| 300 | { |
|---|
| 301 | BDBG_ERR(("%s(0x%04x,0x%04x) already decoding\n",__FUNCTION__,status.mpeg.video[0].pid,status.mpeg.pcr_pid)); |
|---|
| 302 | return eBAPP_RESULT_FAILURE; |
|---|
| 303 | } |
|---|
| 304 | |
|---|
| 305 | p_av->p_stream_info = bstream_get_info(p_stream); |
|---|
| 306 | if (!p_av->p_stream_info) |
|---|
| 307 | { |
|---|
| 308 | BDBG_ERR(("%s(0x%04x,0x%04x) invalid stream info\n",__FUNCTION__,status.mpeg.video[0].pid,status.mpeg.pcr_pid)); |
|---|
| 309 | return eBAPP_RESULT_FAILURE; |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | BDBG_ASSERT(p_av->p_stream_info->videoPidChannel); |
|---|
| 313 | BDBG_ASSERT(p_av->p_stream_info->stcChannel); |
|---|
| 314 | |
|---|
| 315 | NEXUS_VideoDecoder_GetDefaultStartSettings(&(p_av->p_stream_info->decodeSettings)); |
|---|
| 316 | p_av->p_stream_info->decodeSettings.codec = status.mpeg.video[0].format; |
|---|
| 317 | p_av->p_stream_info->decodeSettings.pidChannel = p_av->p_stream_info->videoPidChannel; |
|---|
| 318 | p_av->p_stream_info->decodeSettings.stcChannel = p_av->p_stream_info->stcChannel; |
|---|
| 319 | p_av->p_stream_info->decodeSettings.prerollRate = 1; |
|---|
| 320 | |
|---|
| 321 | NEXUS_Timebase_GetSettings(NEXUS_Timebase_e0, &timebaseSettings); |
|---|
| 322 | timebaseSettings.sourceType = NEXUS_TimebaseSourceType_ePcr; |
|---|
| 323 | timebaseSettings.sourceSettings.pcr.pidChannel = p_av->p_stream_info->pcrPidChannel; |
|---|
| 324 | timebaseSettings.sourceSettings.pcr.maxPcrError = 0xff; |
|---|
| 325 | timebaseSettings.sourceSettings.pcr.trackRange = NEXUS_TimebaseTrackRange_e61ppm; |
|---|
| 326 | NEXUS_Timebase_SetSettings(NEXUS_Timebase_e0, &timebaseSettings); |
|---|
| 327 | |
|---|
| 328 | BDBG_ERR(("NEXUS_VideoDecoder_StartDecodeWithPrimer(0x%08x)\n",p_av->p_stream_info->primerHandle)); |
|---|
| 329 | BDBG_ASSERT(p_av->p_stream_info->decodeSettings.stcChannel); |
|---|
| 330 | NEXUS_VideoDecoder_StartDecodeWithPrimer(p_av->videoDecodeHandle, p_av->p_stream_info->primerHandle); |
|---|
| 331 | |
|---|
| 332 | p_av->video_decoding = true; |
|---|
| 333 | return eBAPP_RESULT_OK; |
|---|
| 334 | } |
|---|
| 335 | /** |
|---|
| 336 | Summary: |
|---|
| 337 | Unlock the frontend. |
|---|
| 338 | **/ |
|---|
| 339 | bapp_result_t bapp_video_stop(bapp_av_t p_av) |
|---|
| 340 | { |
|---|
| 341 | if (!p_av->video_decoding) |
|---|
| 342 | return eBAPP_RESULT_OK; |
|---|
| 343 | |
|---|
| 344 | BDBG_ASSERT(p_av->p_stream_info); |
|---|
| 345 | BDBG_ASSERT(p_av->p_stream_info->primerHandle); |
|---|
| 346 | BDBG_ERR(("NEXUS_VideoDecoder_Stop(0x%08x)\n",p_av->videoDecodeHandle)); |
|---|
| 347 | NEXUS_VideoDecoder_Stop(p_av->videoDecodeHandle); |
|---|
| 348 | BDBG_ERR(("NEXUS_VideoDecoder_StartPrimer(0x%08x)\n",p_av->p_stream_info->primerHandle)); |
|---|
| 349 | NEXUS_VideoDecoder_StartPrimer(p_av->videoDecodeHandle, p_av->p_stream_info->primerHandle,&(p_av->p_stream_info->decodeSettings)); |
|---|
| 350 | |
|---|
| 351 | p_av->video_decoding = false; |
|---|
| 352 | return eBAPP_RESULT_OK; |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| 355 | /** |
|---|
| 356 | Summary: |
|---|
| 357 | Supported video format. Returns NULL if stream_type (from PMT) not supported. |
|---|
| 358 | **/ |
|---|
| 359 | bapp_av_stream_type_t *bapp_av_supported_video(unsigned char stream_type) |
|---|
| 360 | { |
|---|
| 361 | int i; |
|---|
| 362 | for (i = 0; i < s_video_stream_types_num; ++i) |
|---|
| 363 | { |
|---|
| 364 | if (stream_type == s_video_stream_types[i].format) |
|---|
| 365 | { |
|---|
| 366 | BDBG_WRN(("Video format[0x%02x]: %s\n",s_video_stream_types[i].format,s_video_stream_types[i].format_name)); |
|---|
| 367 | return &s_video_stream_types[i]; |
|---|
| 368 | } |
|---|
| 369 | } |
|---|
| 370 | BDBG_WRN(("Unsupported Video format[0x%02x]\n",stream_type)); |
|---|
| 371 | return NULL; |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | |
|---|
| 375 | /** |
|---|
| 376 | Summary: |
|---|
| 377 | Supported audio format. Returns NULL if stream_type (from PMT) not supported. |
|---|
| 378 | **/ |
|---|
| 379 | bapp_av_stream_type_t *bapp_av_supported_audio(unsigned char stream_type) |
|---|
| 380 | { |
|---|
| 381 | int i; |
|---|
| 382 | for (i = 0; i < s_audio_stream_types_num; ++i) |
|---|
| 383 | { |
|---|
| 384 | if (stream_type == s_audio_stream_types[i].format) |
|---|
| 385 | { |
|---|
| 386 | BDBG_WRN(("Audio format[0x%02x]: %s\n",s_audio_stream_types[i].format,s_audio_stream_types[i].format_name)); |
|---|
| 387 | return &s_audio_stream_types[i]; |
|---|
| 388 | } |
|---|
| 389 | } |
|---|
| 390 | BDBG_WRN(("Unsupported Audio format[0x%02x]\n",stream_type)); |
|---|
| 391 | return NULL; |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | /** |
|---|
| 396 | Summary: |
|---|
| 397 | Return decode status. |
|---|
| 398 | **/ |
|---|
| 399 | bapp_result_t bapp_av_status(bapp_av_t p_av, |
|---|
| 400 | NEXUS_VideoDecoderStatus *p_vStatus, |
|---|
| 401 | NEXUS_AudioDecoderStatus *p_aStatus) |
|---|
| 402 | { |
|---|
| 403 | BDBG_ASSERT (p_av); |
|---|
| 404 | BDBG_ASSERT (p_av->videoDecodeHandle); |
|---|
| 405 | BDBG_ASSERT (p_av->pcmDecoder); |
|---|
| 406 | BDBG_ASSERT (p_vStatus); |
|---|
| 407 | BDBG_ASSERT (p_aStatus); |
|---|
| 408 | NEXUS_VideoDecoder_GetStatus(p_av->videoDecodeHandle,p_vStatus); |
|---|
| 409 | NEXUS_AudioDecoder_GetStatus(p_av->pcmDecoder,p_aStatus); |
|---|
| 410 | return eBAPP_RESULT_OK; |
|---|
| 411 | } |
|---|
| 412 | |
|---|