| 1 | |
|---|
| 2 | #include "bapp_hdmi.h" |
|---|
| 3 | #include "nexus_platform.h" |
|---|
| 4 | #include "nexus_pid_channel.h" |
|---|
| 5 | #include "nexus_parser_band.h" |
|---|
| 6 | #include "nexus_video_decoder.h" |
|---|
| 7 | #include "nexus_stc_channel.h" |
|---|
| 8 | #include "nexus_display.h" |
|---|
| 9 | #include "nexus_video_window.h" |
|---|
| 10 | #include "nexus_audio_dac.h" |
|---|
| 11 | #include "nexus_audio_decoder.h" |
|---|
| 12 | #include "nexus_audio_output.h" |
|---|
| 13 | #include "nexus_spdif_output.h" |
|---|
| 14 | #include "nexus_hdmi_output.h" |
|---|
| 15 | #include "nexus_component_output.h" |
|---|
| 16 | #include "bstd.h" |
|---|
| 17 | #include "bkni.h" |
|---|
| 18 | #include <stdio.h> |
|---|
| 19 | #include <stdlib.h> |
|---|
| 20 | #include <string.h> |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | static bool compressedHdmi = false, audioStarted = false; |
|---|
| 24 | static NEXUS_AudioDecoderHandle pcmDecoder, compressedDecoder; |
|---|
| 25 | static NEXUS_AudioDecoderStartSettings audioProgram; |
|---|
| 26 | |
|---|
| 27 | void bapp_hdmi_disconnect_audio(NEXUS_HdmiOutputHandle hdmi) |
|---|
| 28 | { |
|---|
| 29 | NEXUS_AudioDecoderHandle decoder; |
|---|
| 30 | |
|---|
| 31 | if ( compressedHdmi ) |
|---|
| 32 | { |
|---|
| 33 | decoder = compressedDecoder; |
|---|
| 34 | } |
|---|
| 35 | else |
|---|
| 36 | { |
|---|
| 37 | decoder = pcmDecoder; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | if ( audioStarted ) |
|---|
| 41 | NEXUS_AudioDecoder_Stop(decoder); |
|---|
| 42 | |
|---|
| 43 | NEXUS_AudioOutput_RemoveAllInputs(NEXUS_HdmiOutput_GetAudioConnector(hdmi)); |
|---|
| 44 | |
|---|
| 45 | if ( audioStarted ) |
|---|
| 46 | NEXUS_AudioDecoder_Start(decoder, &audioProgram); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | void bapp_hdmi_connect_audio(NEXUS_HdmiOutputHandle hdmi) |
|---|
| 50 | { |
|---|
| 51 | NEXUS_AudioDecoderHandle decoder; |
|---|
| 52 | NEXUS_AudioInput connector; |
|---|
| 53 | |
|---|
| 54 | if ( compressedHdmi ) |
|---|
| 55 | { |
|---|
| 56 | decoder = compressedDecoder; |
|---|
| 57 | connector = NEXUS_AudioDecoder_GetConnector(decoder, NEXUS_AudioDecoderConnectorType_eCompressed); |
|---|
| 58 | } |
|---|
| 59 | else |
|---|
| 60 | { |
|---|
| 61 | decoder = pcmDecoder; |
|---|
| 62 | connector = NEXUS_AudioDecoder_GetConnector(decoder, NEXUS_AudioDecoderConnectorType_eStereo); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | if ( audioStarted ) |
|---|
| 66 | NEXUS_AudioDecoder_Stop(decoder); |
|---|
| 67 | |
|---|
| 68 | NEXUS_AudioOutput_AddInput(NEXUS_HdmiOutput_GetAudioConnector(hdmi), connector); |
|---|
| 69 | |
|---|
| 70 | if ( audioStarted ) |
|---|
| 71 | NEXUS_AudioDecoder_Start(decoder, &audioProgram); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | void bapp_hdmi_hotplug_callback(void *pParam, int iParam) |
|---|
| 76 | { |
|---|
| 77 | NEXUS_HdmiOutputStatus status; |
|---|
| 78 | NEXUS_HdmiOutputHandle hdmi = pParam; |
|---|
| 79 | NEXUS_DisplayHandle display = (NEXUS_DisplayHandle)iParam; |
|---|
| 80 | |
|---|
| 81 | NEXUS_HdmiOutput_GetStatus(hdmi, &status); |
|---|
| 82 | fprintf(stderr, "HDMI hotplug event: %s\n", status.connected?"connected":"not connected"); |
|---|
| 83 | |
|---|
| 84 | /* the app can choose to switch to the preferred format, but it's not required. */ |
|---|
| 85 | if ( status.connected ) |
|---|
| 86 | { |
|---|
| 87 | NEXUS_DisplaySettings displaySettings; |
|---|
| 88 | NEXUS_Display_GetSettings(display, &displaySettings); |
|---|
| 89 | if ( !status.videoFormatSupported[displaySettings.format] ) |
|---|
| 90 | { |
|---|
| 91 | fprintf(stderr, "\nCurrent format not supported by attached monitor. Switching to preferred format %d\n", status.preferredVideoFormat); |
|---|
| 92 | displaySettings.format = status.preferredVideoFormat; |
|---|
| 93 | NEXUS_Display_SetSettings(display, &displaySettings); |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | static void bapp_hdmi_open(bapp_nexus_t *p_nexus) |
|---|
| 99 | { |
|---|
| 100 | |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | static void bapp_hdmi_close() |
|---|
| 104 | { |
|---|
| 105 | |
|---|
| 106 | } |
|---|
| 107 | |
|---|