source: svn/trunk/newcon3bcm2_21bu/magnum/syslib/synclib/7552/bsynclib.h @ 6

Last change on this file since 6 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 19.9 KB
Line 
1/***************************************************************************
2*     Copyright (c) 2004-2010, Broadcom Corporation
3*     All Rights Reserved
4*     Confidential Property of Broadcom Corporation
5*
6*  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7*  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8*  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9*
10* $brcm_Workfile: bsynclib.h $
11* $brcm_Revision: Hydra_Software_Devel/11 $
12* $brcm_Date: 3/22/10 5:42p $
13*
14* Revision History:
15*
16* $brcm_Log: /magnum/syslib/synclib/noarch/bsynclib.h $
17*
18* Hydra_Software_Devel/11   3/22/10 5:42p bandrews
19* sw7408-83: add unconditional video unmute timeout; fix comment for
20* audio
21*
22* Hydra_Software_Devel/10   1/26/10 9:00p bandrews
23* SW7405-3774: added mute control support
24*
25* Hydra_Software_Devel/9   12/10/09 9:18p bandrews
26* SW7401-3634: adding PWC (now JTI) support to synclib
27*
28* Hydra_Software_Devel/8   5/12/09 4:39p bandrews
29* PR47924: 24 Hz added
30*
31* Hydra_Software_Devel/7   11/26/08 5:09p bandrews
32* PR49294: Added precision lipsync flag
33*
34* Hydra_Software_Devel/6   10/30/08 10:34p bandrews
35* PR48566: Added support for preferred callback units
36*
37* Hydra_Software_Devel/5   10/15/08 2:50p bandrews
38* PR47923: Added support for 24 Hz units
39*
40* Hydra_Software_Devel/4   10/6/08 8:07p bandrews
41* PR44510: Implement delay capacity for video sinks
42*
43* Hydra_Software_Devel/3   10/6/08 6:13p bandrews
44* PR44510: Added ability to specify max applicable delay for sinks
45*
46* Hydra_Software_Devel/2   4/3/08 2:33p bandrews
47* PR40090: synclib needs to have different contexts for syslib callbacks
48* and synclib callbacks
49*
50* Hydra_Software_Devel/1   3/24/08 3:09p bandrews
51* PR40865: Fixed
52*
53* Hydra_Software_Devel/7   2/20/08 10:03p bandrews
54* PR37951: Updated based on feedback from usage
55*
56* Hydra_Software_Devel/6   1/3/08 5:17p bandrews
57* PR37951: Updated based on initial feedback
58*
59* Hydra_Software_Devel/5   12/17/07 3:42p bandrews
60* PR37951: More updates based on feedback
61*
62* Hydra_Software_Devel/4   12/17/07 1:14p bandrews
63* PR37951: Updated API per review during impl
64*
65* Hydra_Software_Devel/3   12/7/07 2:42p bandrews
66* PR37951: Fixed device counts
67*
68* Hydra_Software_Devel/2   12/6/07 5:03p bandrews
69* PR37951: Added timer create and destroy
70*
71* Hydra_Software_Devel/1   12/5/07 10:59p bandrews
72* PR37951: Check in stubs for external work
73***************************************************************************/
74
75#include "bstd.h"
76#include "bavc.h"
77#include "bsyslib.h"
78
79#ifndef BSYNCLIB_H__
80#define BSYNCLIB_H__
81
82/*
83Summary:
84A handle to the global/singleton sync module
85Description:
86*/
87typedef struct BSYNClib_Impl * BSYNClib_Handle;
88
89/*
90Summary:
91A handle to a sync channel.  A sync channel manages the following:
921 video decode
93up to 2 audio decodes (same content decode + passthru)
94up to N windows displaying the same content on different displays (1 window per display)
95up to N audio displays with the same content (either decoded or passed through) and independent delays
96Description:
97*/
98typedef struct BSYNClib_Channel_Impl * BSYNClib_Channel_Handle;
99
100/*
101Summary:
102Global settings for lip sync.
103*/
104typedef struct
105{
106        bool bEnabled; /* global enable for sync, defaults to true */
107        struct
108        {
109                bool bRequireFullScreen; /* is full screen video required before we sync? Defaults to true. */
110                unsigned int uiTsmLockTimeout; /* time to wait after receiving a video TSM callback before accepting the PTSSTCDiff value */
111                unsigned int uiUnmuteTimeout; /* time to wait before unmuting video after adjusting the PTS offset */
112                unsigned int uiUnconditionalUnmuteTimeout; /* time to wait before unconditionally unmuting video (in case of error with audio sample rate callback or failure to start audio) */
113
114                struct
115                {
116                        unsigned int uiTimeout; /* time to wait before checking the number of callbacks received vs the acceptable callback count for rate mismatch */
117                        unsigned int uiAcceptableMtbcLower; /* acceptable mean time between callbacks lower bound */
118                        unsigned int uiAcceptableMtbcUpper; /* acceptable mean time between callbacks upper bound */
119                        unsigned int uiAcceptableTtlc; /* acceptable time to last callback for mismatches */
120                } sRateMismatchDetection;
121                struct
122                {
123                        unsigned int uiTimeout; /* time to wait before checking the number of callbacks received vs the acceptable callback count for rate rematch */
124                        unsigned int uiAcceptableTtlc; /* acceptable time to last callback for rematches */
125                } sRateRematchDetection;
126        } sVideo;
127        struct
128        {
129                unsigned int uiUnmuteTimeout; /* time to wait before unmuting audio after accepting video TSM callback */
130                unsigned int uiReceiverDelayCompensation; /* compensate for external audio receiver delay */
131                unsigned int uiUnconditionalUnmuteTimeout; /* time to wait before unconditionally unmuting audio (in case of error with video TSM callback or failure to start video) */
132        } sAudio;
133} BSYNClib_Settings;
134
135/*
136Summary:
137Units of various measurements and parameters passed to synclib
138*/
139typedef enum BSYNClib_Units
140{
141        BSYNClib_Units_eMilliseconds = 0,
142        BSYNClib_Units_e24HzVsyncs, /* TODO: change 24,50,60 to just generic VSYNCS, use rate in config to find out rate */
143        BSYNClib_Units_e50HzVsyncs,
144        BSYNClib_Units_e60HzVsyncs,
145        BSYNClib_Units_e45KhzTicks,
146        BSYNClib_Units_e90KhzTicks,
147        BSYNClib_Units_e27MhzTicks,
148        BSYNClib_Units_eMax = 0x7fffffff
149} BSYNClib_Units;
150
151/*
152Summary:
153An unsigned value with its units
154*/
155typedef struct BSYNClib_UnsignedValue
156{
157        unsigned int uiValue;
158        BSYNClib_Units eUnits;
159} BSYNClib_UnsignedValue;
160
161/*
162Summary:
163Set mute state callback delegate
164Description:
165Sync expects the system to set the mute state of the device with the specifed
166index (and named in the callback name) to the specified mute state.
167This needs to happen before returning from the callback.
168*/
169typedef BERR_Code (*BSYNClib_Channel_SetMute)
170(
171        void * pvParm1, /* first user context parameter */
172        int iParm2, /* second user context parameter */
173        unsigned int uiDeviceIndex, /* device index */
174        bool bMute /* true means mute, false means unmute */
175);
176
177/*
178Summary:
179Encapsulation of mute state callback function and context
180*/
181typedef struct BSYNClib_Channel_MuteCallback
182{
183        BSYNClib_Channel_SetMute pfSetMute;
184        void * pvParm1;
185        int iParm2;
186} BSYNClib_Channel_MuteCallback;
187
188/*
189Summary:
190Set delay callback.
191Description:
192Sync expects the system to set the delay of the device with the specifed index
193(and named in the callback name) to the specified delay.
194This needs to happen before returning from the callback.
195*/
196typedef BERR_Code (*BSYNClib_Channel_SetDelay)
197(
198        void * pvParm1, /* first user context parameter */
199        int iParm2, /* second user context parameter */
200        unsigned int uiDeviceIndex, /* device index */
201        BSYNClib_UnsignedValue * psDelay /* the delay with which to program the device */
202);
203
204/*
205Summary:
206Set delay notification state callback.
207Description:
208Sync expects the system to set the delay notification of the device specified
209(and named in the callback name) to the specified delay notification state.
210This needs to happen before returning from the callback.
211bEnable = true means that delay notification is enabled. 
212bEnable = false means that delay notification is disabled.
213*/
214typedef BERR_Code (*BSYNClib_Channel_SetDelayNotification)
215(
216        void * pvParm1, /* first user context parameter */
217        int iParm2, /* second user context parameter */
218        unsigned int uiDeviceIndex, /* device index */
219        bool bEnable, /* true means enable delay notification, false means disable it */
220        BSYNClib_UnsignedValue * psThreshold /* delay notification threshold when enabled */
221);
222
223/*
224Summary:
225Encapsulation of delay and delay notification state callback functions and context
226*/
227typedef struct BSYNClib_Channel_DelayCallback
228{
229        BSYNClib_Channel_SetDelay pfSetDelay;
230        BSYNClib_Units preferredDelayUnits;
231        BSYNClib_Channel_SetDelayNotification pfSetDelayNotification;
232        BSYNClib_Units preferredNotificationThresholdUnits;
233        void * pvParm1;
234        int iParm2;
235} BSYNClib_Channel_DelayCallback;
236
237/*
238Summary:
239Sync channel settings.  Currently this encapsulates a multitude of callbacks
240*/
241typedef struct
242{
243        BSYSlib_TimerCallback cbTimer; /* timer-related callbacks */
244        BSYSlib_TimeCallback cbTime; /* system-time-related callbacks */
245
246        struct
247        {
248                struct 
249                {
250                        BSYNClib_Channel_MuteCallback cbMute;
251                        BSYNClib_Channel_DelayCallback cbDelay;
252                } sSource;
253                struct 
254                {
255                        BSYNClib_Channel_DelayCallback cbDelay;
256                } sSink;
257        } sVideo;
258        struct
259        {
260                struct
261                {
262                        BSYNClib_Channel_MuteCallback cbMute;
263                        BSYNClib_Channel_DelayCallback cbDelay;
264                } sSource;
265                struct
266                {
267                        BSYNClib_Channel_DelayCallback cbDelay;
268                } sSink;
269        } sAudio;
270} BSYNClib_Channel_Settings;
271
272/*
273Summary:
274The information required by the sync algorithms from the system.  Messages passed into the sync module are level-based.
275*/
276typedef struct
277{
278        bool bEnabled; /* is this sync channel enabled? Defaults to true. */
279        bool bPrecisionLipsyncEnabled; /* are subframe audio adjustments based on video feedback enabled? Defaults to true. */
280        struct
281        {
282                bool bEnabled; /* when this is enabled, sync will attempt to mute audio and video
283                while performing adjustments and unmute when finished.  This requires that the
284                source counts below accurately reflect exactly which of the decoders you plan
285                on using for this session.  For audio-only sessions, set the video source count to zero.
286                For video-only sessions, set the audio source count to zero. Defaults to false. */
287                bool bSimultaneousUnmute; /* this will cause all devices to unmute at the
288                same time.  This time will be the largest of all of the unmute timout values
289                set amongst the devices (excluding the audio unconditional unmute). Defaults to false. */
290        } sMuteControl;
291        unsigned int uiVideoSourceCount; /* how many video sources are there, defaults to 0. */
292        unsigned int uiVideoSinkCount; /* how many video sinks are there, defaults to 0. */
293        unsigned int uiAudioSourceCount; /* how many audio sources are there, defaults to 0. */
294        unsigned int uiAudioSinkCount; /* how many audio sinks are there, defaults to 0. */
295} BSYNClib_Channel_Config;
296
297/*
298Summary:
299Information about a video source (decoder or analog/hdmi input)
300*/
301typedef struct
302{
303        bool bStarted; /* has this delay path element been started? */
304        bool bDigital; /* is the video source digital or analog */
305        bool bSynchronize; /* should this element be synchronized? */
306
307        struct
308        {
309                bool bReceived; /* was a delay notification received this time (self-clearing) */
310                BSYNClib_UnsignedValue sMeasured; /* measured delay, defaults to 45 Khz ticks */
311                BSYNClib_UnsignedValue sCustom; /* delay supplied by user that isn't in the normal path delay, defaults to ms */
312        } sDelay;
313
314        struct
315        {
316                bool bReceived; /* did we received the format on this call? (self-clearing) */
317                unsigned int uiHeight; /* height of format, required to predict VDC MAD state changes */
318                bool bInterlaced; /* whether the format is interlaced */
319                BAVC_FrameRateCode eFrameRate; /* the frame rate of the format */
320        } sFormat;
321
322        bool bLastPictureHeld; /* is the decoder holding the last picture or blanking? */
323        BSYNClib_UnsignedValue sJitterToleranceImprovementThreshold; /* how much should the pts/stc difference change before we attempt jitter tolerance improvement, defaults to ms */
324} BSYNClib_VideoSource_Config;
325
326/*
327Summary:
328Information about a video sink (window and display)
329*/
330typedef struct
331{
332        bool bSynchronize; /* should this element be synchronized? */
333       
334        struct
335        {
336                bool bReceived; /* was a delay notification received this time (self-clearing) */
337                BSYNClib_UnsignedValue sMeasured; /* measured delay, defaults to vsyncs */
338                BSYNClib_UnsignedValue sCustom; /* delay supplied by user that isn't in the normal path delay in ms */
339                BSYNClib_UnsignedValue sMax; /* max applicable delay supported by memory allocated to this sink, defaults to 4 vsyncs */
340                /* TODO: add flag for drift callback so we can filter some values out */
341        } sDelay;
342       
343        struct
344        {
345                bool bReceived; /* did we received the format on this call? (self-clearing) */
346                unsigned int uiHeight; /* height of format, required to predict VDC MAD state changes */
347                bool bInterlaced; /* whether the format is interlaced */
348                BAVC_FrameRateCode eFrameRate; /* the frame rate of the format */
349        } sFormat;
350       
351        bool bForcedCaptureEnabled; /* is forced capture enabled on this window */
352        bool bMasterFrameRateEnabled; /* is master frame rate enabled on the main window for this display */
353        bool bFullScreen; /* does window rect match display rect? */
354        bool bVisible; /* is this window visible? */
355} BSYNClib_VideoSink_Config;
356
357/*
358Summary:
359Information about an audio source (decoder or analog/hdmi input)
360*/
361typedef struct
362{
363        bool bStarted; /* has this delay path element been started? */
364        bool bDigital; /* is the audio source digital or analog */
365        bool bSynchronize; /* should this element be synchronized? */
366
367        struct
368        {
369                bool bReceived; /* was a delay notification received this time (self-clearing) */
370                BSYNClib_UnsignedValue sMeasured; /* measured delay, defaults to ms */
371                BSYNClib_UnsignedValue sCustom; /* delay supplied by user that isn't in the normal path delay in ms */
372        } sDelay;
373
374        bool bSamplingRateReceived; /* has the audio sampling rate callback been received since audio start? (self-clearing) */
375} BSYNClib_AudioSource_Config;
376
377/*
378Summary:
379Information about an audio sink (output port)
380*/
381typedef struct
382{
383        bool bSynchronize; /* should this element be synchronized? */
384        bool bCompressed; /* is the audio sink compressed */
385
386        struct
387        {
388                bool bReceived; /* was a delay notification received this time (self-clearing) */
389                BSYNClib_UnsignedValue sMeasured; /* measured delay, defaults to ms */
390                BSYNClib_UnsignedValue sCustom; /* delay supplied by user that isn't in the normal path delay in ms */
391        } sDelay;
392
393        /* TODO: more analog params expected for DTV projects */
394        unsigned int uiSamplingRate; /* the audio sampling rate in Hz (for analog) */
395} BSYNClib_AudioSink_Config;
396
397/*
398Summary:
399Sync channel status
400Description:
401*/
402typedef struct
403{
404        struct
405        {
406                long lValue; /* the expected difference between audio and video assuming all delays have been applied as requested (in ms) */
407                long lError; /* the expected range of variation of the delay between audio and video assuming all delays have been applied as requested (in ms) */
408        } sExpectedAudioVisualDisparity;
409        struct
410        {
411                long lValue; /* the expected difference between audio and video assuming all delays have been applied as requested (in ms) */
412                long lError; /* the expected range of variation of the delay between audio and video assuming all delays have been applied as requested (in ms) */
413        } sExpectedVideoVisualDisparity;
414        struct
415        {
416                long lValue; /* the expected difference between audio and video assuming all delays have been applied as requested (in ms) */
417                long lError; /* the expected range of variation of the delay between audio and video assuming all delays have been applied as requested (in ms) */
418        } sExpectedAudioAuralDisparity;
419} BSYNClib_Channel_Status;
420
421/*
422Summary:
423Delay element source status.  This applies to video and audio sources.
424*/
425typedef struct
426{
427        bool bMuted;
428
429        struct
430        {
431                bool bEnabled;
432                BSYNClib_UnsignedValue sThreshold;
433        } sDelayNotification;
434
435        BSYNClib_UnsignedValue sAppliedDelay; /* defaults to ms */
436} BSYNClib_Source_Status;
437
438/*
439Summary:
440Delay element sink status.  This applies to video and audio sinks.
441*/
442typedef struct
443{
444        struct
445        {
446                bool bEnabled;
447                BSYNClib_UnsignedValue sThreshold;
448        } sDelayNotification;
449       
450        BSYNClib_UnsignedValue sAppliedDelay; /* defaults to ms */
451} BSYNClib_Sink_Status;
452
453/*
454Summary:
455Returns the default global sync lib module settings
456Description:
457*/
458void BSYNClib_GetDefaultSettings
459(
460        BSYNClib_Settings * psSettings /* [out] */
461);
462
463/*
464Summary:
465Opens the global sync lib module
466Description:
467*/
468BERR_Code BSYNClib_Open
469(
470        const BSYNClib_Settings * psSettings,
471        BSYNClib_Handle * phSync /* [out] */
472);
473
474/*
475Summary:
476Closes the global sync lib module
477Description:
478*/
479void BSYNClib_Close
480(
481        BSYNClib_Handle hSync
482);
483
484/*
485Summary:
486Returns the default settings for a sync channel
487Description:
488*/
489void BSYNClib_GetChannelDefaultSettings
490(
491        BSYNClib_Channel_Settings * psSettings /* [out] */
492);
493
494/*
495Summary:
496Creates a sync lib channel
497Description:
498*/
499BERR_Code BSYNClib_CreateChannel
500(
501        BSYNClib_Handle hSync, 
502        const BSYNClib_Channel_Settings * psSettings, 
503        BSYNClib_Channel_Handle * phChn /* [out] */
504);
505
506/*
507Summary:
508Closes a sync lib channel
509Description:
510*/
511void BSYNClib_DestroyChannel
512(
513        BSYNClib_Handle hSync, 
514        BSYNClib_Channel_Handle hChn
515);
516
517/*
518Summary:
519Returns the current settings for a sync lib channel
520*/
521void BSYNClib_Channel_GetSettings
522(
523        const BSYNClib_Channel_Handle hChn,
524        BSYNClib_Channel_Settings * psSettings /* [out] */
525);
526
527/*
528Summary:
529Sets the current settings for a sync lib channel
530*/
531BERR_Code BSYNClib_Channel_SetSettings
532(
533        BSYNClib_Channel_Handle hChn,
534        const BSYNClib_Channel_Settings * psSettings
535);
536
537/*
538Summary:
539Returns the current configuration of a sync lib channel
540*/
541void BSYNClib_Channel_GetConfig
542(
543        const BSYNClib_Channel_Handle hChn,
544        BSYNClib_Channel_Config * psConfig /* [out] */
545);
546
547/*
548Summary:
549Sets the current configuration of a sync lib channel
550*/
551BERR_Code BSYNClib_Channel_SetConfig
552(
553        BSYNClib_Channel_Handle hChn,
554        const BSYNClib_Channel_Config * psConfig
555);
556
557/*
558Summary:
559Returns the current status of a sync lib channel.
560*/
561void BSYNClib_Channel_GetStatus
562(
563        const BSYNClib_Channel_Handle hChn, 
564        BSYNClib_Channel_Status * psStatus /* [out] */
565);
566
567/*
568Summary:
569Returns the current configuration of a sync lib video source at isr time
570*/
571void BSYNClib_Channel_GetVideoSourceConfig_isr
572(
573        const BSYNClib_Channel_Handle hChn,
574        unsigned int uiSource,
575        BSYNClib_VideoSource_Config * psConfig /* [out] */
576);
577
578/*
579Summary:
580Sets the current configuration of a sync lib video source at isr time
581*/
582BERR_Code BSYNClib_Channel_SetVideoSourceConfig_isr
583(
584        BSYNClib_Channel_Handle hChn,
585        unsigned int uiSource,
586        const BSYNClib_VideoSource_Config * psConfig
587);
588
589/*
590Summary:
591Returns the current configuration of a sync lib video sink at isr time
592*/
593void BSYNClib_Channel_GetVideoSinkConfig_isr
594(
595        const BSYNClib_Channel_Handle hChn,
596        unsigned int uiSink,
597        BSYNClib_VideoSink_Config * psConfig /* [out] */
598);
599
600/*
601Summary:
602Sets the current configuration of a sync lib video sink at isr time
603*/
604BERR_Code BSYNClib_Channel_SetVideoSinkConfig_isr
605(
606        BSYNClib_Channel_Handle hChn,
607        unsigned int uiSink,
608        const BSYNClib_VideoSink_Config * psConfig
609);
610
611/*
612Summary:
613Returns the current configuration of a sync lib audio source at isr time
614*/
615void BSYNClib_Channel_GetAudioSourceConfig_isr
616(
617        const BSYNClib_Channel_Handle hChn,
618        unsigned int uiSource,
619        BSYNClib_AudioSource_Config * psConfig /* [out] */
620);
621
622/*
623Summary:
624Sets the current configuration of a sync lib audio source at isr time
625*/
626BERR_Code BSYNClib_Channel_SetAudioSourceConfig_isr
627(
628        BSYNClib_Channel_Handle hChn,
629        unsigned int uiSource,
630        const BSYNClib_AudioSource_Config * psConfig
631);
632
633/*
634Summary:
635Returns the current configuration of a sync lib audio sink at isr time
636*/
637void BSYNClib_Channel_GetAudioSinkConfig_isr
638(
639        const BSYNClib_Channel_Handle hChn,
640        unsigned int uiSink,
641        BSYNClib_AudioSink_Config * psConfig /* [out] */
642);
643
644/*
645Summary:
646Sets the current configuration of a sync lib audio sink at isr time
647*/
648BERR_Code BSYNClib_Channel_SetAudioSinkConfig_isr
649(
650        BSYNClib_Channel_Handle hChn,
651        unsigned int uiSink,
652        const BSYNClib_AudioSink_Config * psConfig
653);
654
655/*
656Summary:
657Returns the current status of a sync lib video source.
658*/
659void BSYNClib_Channel_GetVideoSourceStatus
660(
661        const BSYNClib_Channel_Handle hChn,
662        unsigned int uiSource,
663        BSYNClib_Source_Status * psStatus /* [out] */
664);
665
666/*
667Summary:
668Returns the current status of a sync lib video sink.
669*/
670void BSYNClib_Channel_GetVideoSinkStatus
671(
672        const BSYNClib_Channel_Handle hChn,
673        unsigned int uiSink,
674        BSYNClib_Sink_Status * psStatus /* [out] */
675);
676
677/*
678Summary:
679Returns the current status of a sync lib Audio source.
680*/
681void BSYNClib_Channel_GetAudioSourceStatus
682(
683        const BSYNClib_Channel_Handle hChn,
684        unsigned int uiSource,
685        BSYNClib_Source_Status * psStatus /* [out] */
686);
687
688/*
689Summary:
690Returns the current status of a sync lib Audio sink.
691*/
692void BSYNClib_Channel_GetAudioSinkStatus
693(
694        const BSYNClib_Channel_Handle hChn,
695        unsigned int uiSink,
696        BSYNClib_Sink_Status * psStatus /* [out] */
697);
698
699#endif /* BSYNCLIB_H__ */
700
Note: See TracBrowser for help on using the repository browser.