close Warning: Can't use blame annotator:
No changeset 2 in the repository

source: svn/newcon3bcm2_21bu/BSEAV/api/include/bsettop_stream.h

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 20.7 KB
RevLine 
1/***************************************************************************
2 *     Copyright (c) 2003-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: bsettop_stream.h $
11 * $brcm_Revision: 21 $
12 * $brcm_Date: 2/16/10 5:09p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /BSEAV/api/include/bsettop_stream.h $
19 *
20 * 21   2/16/10 5:09p vsilyaev
21 * SW3556-1051: Added bdecode_timestamp_order
22 *
23 * 20   5/11/09 1:35p vsilyaev
24 * PR54955: NW record of TTS streamer over HTTP: add a flag to stream
25 * status to indicate if this stream is associated w/ TTS content
26 *
27 * PR54955/1   5/11/09 1:17p ssood
28 * PR54955: NW record of TTS streamer over HTTP: add a flag to bstream
29 * status to indicate if this stream is associated w/ TTS content
30 *
31 * 19   2/12/08 5:20p vsilyaev
32 * PR 36787: Added M2 support
33 *
34 * 18   8/22/07 5:29p jgarrett
35 * PR 32044: Merging to main branch
36 *
37 * 17   8/22/07 5:26p jgarrett
38 * PR 31818: Adding external encryption algorithm support
39 *
40 * 7405_pip_support/1   8/21/07 2:38p katrep
41 * PR34204: Added mosaic mode support for 7405.
42 *
43 * PR32044/1   6/26/07 5:54p jgarrett
44 * PR 32044: Adding Mosaic Mode APIs
45 *
46 * 16   7/16/07 3:16p vsilyaev
47 * PR 32275: Added use_cps flag
48 *
49 * 15   7/10/07 5:05p vsilyaev
50 * PR 32849: Added list of streamer and input band object ID's
51 *
52 * 14   4/27/07 4:10p vsilyaev
53 * PR 29967: Added PCR monitor API
54 *
55 * 13   4/19/07 2:04p jgarrett
56 * PR 29901: Updating documentation for bstream_set_mpeg_parameters
57 *
58 * 12   3/14/07 3:27p vsilyaev
59 * PR 26200: Changes in bcrypto configuration structures
60 *
61 * 11   1/18/07 11:36a vsilyaev
62 * PR 27186: Differentiate between parser and input bands. AKA, fixing
63 * bmessage from playback source
64 *
65 * 10   11/27/06 4:26p mphillip
66 * PR26154: Fix bencryption_params for key structs
67 *
68 * 9   11/17/06 10:34a erickson
69 * PR24374: update docs
70 *
71 * 8   10/24/06 1:45a jrubio
72 * PR25112:Adding support for rec PID 0
73 *
74 * 7   10/18/06 1:31p mphillip
75 * PR24031: Separation of odd/even key setting for 7038, settop api-level
76 * CA change
77 *
78 * 6   7/11/06 5:47p mphillip
79 * PR19544: Initial commit of bcrypt_ stubs
80 *
81 * 5   7/11/06 9:58a jrubio
82 * PR20382: Added necessary structures for dual stream mode ( dual pes
83 * decode)
84 *
85 * 4   8/10/05 3:17p erickson
86 * PR16478: added bstream_set_mpeg_parameters
87 *
88 * 3   7/11/05 2:27p erickson
89 * PR16044: updated documentation for bmessage
90 *
91 * 2   5/19/05 6:53p mphillip
92 * PR15267: Basic SetTop API support for decryption of AES and DVB files
93 * for playback
94 *
95 * 1   2/7/05 7:06p dlwin
96 * Merge down for release 2005_REFSW_MERGETOMAIN:
97 *
98 * Irvine_BSEAVSW_Devel/24   10/28/04 7:43p vsilyaev
99 * PR 13097: Added video coding type.
100 *
101 * Irvine_BSEAVSW_Devel/23   9/23/04 3:59p marcusk
102 * PR12698: Use upper 8 bits of audio pid to specify track number for
103 * AC3/DTS in VOB streams.
104 *
105 * Irvine_BSEAVSW_Devel/22   9/23/04 2:28p marcusk
106 * PR12698: Updated with final comments. Store state of previous audio
107 * decode for remapping when switching audio between main and pip.
108 *
109 * Irvine_BSEAVSW_Devel/21   7/14/04 2:37p erickson
110 * PR11682: added support for changing encryption params during decode
111 *
112 * Irvine_BSEAVSW_Devel/20   7/8/04 3:16p erickson
113 * PR11655: clarified encryption documentation
114 *
115 * Irvine_BSEAVSW_Devel/19   6/25/04 9:15a erickson
116 * PR11135: updated comments
117 *
118 * Irvine_BSEAVSW_Devel/18   6/8/04 7:40a erickson
119 * PR11135: added iniital playpump impl for 97038
120 *
121 * Irvine_BSEAVSW_Devel/17   6/2/04 2:44p erickson
122 * PR11204: changed/removed deprecated settop api functions
123 *
124 * Irvine_BSEAVSW_Devel/16   5/25/04 11:42a erickson
125 * PR11204: added bband_get and bband_settings in preparation for
126 * deprecation of bband_t public impl
127 *
128 * Irvine_BSEAVSW_Devel/15   11/4/03 2:42p erickson
129 * documentation changes
130 *
131 * Irvine_BSEAVSW_Devel/14   10/31/03 11:58a erickson
132 * settop api changes after internal review
133 *
134 * Irvine_BSEAVSW_Devel/13   10/28/03 11:27a erickson
135 * settop api reworks after internal design view
136 *
137 * Irvine_BSEAVSW_Devel/12   10/22/03 11:23a erickson
138 * settop api pass-through type conversion
139 *
140 * Irvine_BSEAVSW_Devel/11   9/30/03 1:13a erickson
141 * updated docjet documentation
142 *
143 * Irvine_BSEAVSW_Devel/10   9/25/03 1:28p erickson
144 * added cpu-based encryption to settop api and util
145 *
146 * Irvine_BSEAVSW_Devel/9   9/17/03 5:04p erickson
147 * updated documentation for DocJet
148 *
149 * Irvine_BSEAVSW_Devel/8   8/22/03 1:22p erickson
150 * stream status uses ptr to mpeg
151 *
152 * Irvine_BSEAVSW_Devel/7   8/21/03 4:31p erickson
153 * fixed up comments
154 *
155 * Irvine_BSEAVSW_Devel/6   8/18/03 11:02a erickson
156 * initial bringup for brutus 7320, still in progress
157 *
158 * Irvine_BSEAVSW_Devel/5   7/30/03 1:43p erickson
159 * moved BSETTOP_MAX_PROGRAMS from bsettop_types.h
160 *
161 * Irvine_BSEAVSW_Devel/4   7/30/03 12:13p erickson
162 * support absoluted band selection
163 *
164 * Irvine_BSEAVSW_Devel/3   7/25/03 4:22p erickson
165 * in the middle of rework, does not compile
166 *
167 * Irvine_BSEAVSW_Devel/2   7/22/03 7:09p vsilyaev
168 * Renamed pidtype to the stream type.
169 *
170 * Irvine_BSEAVSW_Devel/1   7/9/03 5:19p erickson
171 * rework for new bband_t model
172 *
173 ***************************************************************************/
174#ifndef BSETTOP_STREAM_H__
175#define BSETTOP_STREAM_H__
176
177#ifdef __cplusplus
178extern "C" {
179#endif
180
181/*=****************************************
182The stream functions are needed to manipulate digital streams.
183
184The digital tuning functions (found in bsettop_tuner.h) will return a bband_t handle.
185That band handle represents a path of MPEG2 Transport in the chip.
186In order to decode a program, you need to provide MPEG2 data. The band and
187MPEG2 data are joined together using bstream_open in order to create
188a stream which can be decoded or recorded.
189
190Obtaining MPEG2 data must be done in an application-specific way. One way
191is to parse MPEG2 Transport data for PSI information. This can be done
192using the bsettop_message API and some PSI parsing software.
193*******************************************/
194
195/* There are three families of algorithms:
196Summary:
197Encryption types for use in bencryption_params.
198
199Description:
200
201Ciphers can be used to encrypt/decrypt streams of data, and they generally work on blocks of data.
202A cipher requires a block mode (bcrypt_blockmode).  Alignment requirements vary by algorithm,
203consult the bcrypt documentation for more.
204
205Hashes are used to create a fixed-size fingerprint value for a block of data. 
206These hashes can be used for verification, or as the data used for a sign/verify algorithm.
207
208Public key algorithms are used for digital signing and verifying of data.[*]
209These usually fall under public key systems, and often require some form of public key exchange.
210One type of usage involves signing e-mails using a certificate.
211
212Of the common algorithms listed, DSA/SHA1/DES/3DES are US Government algorithms devised for and used in
213governmental security applications.  Due to ongoing advances in cryptography and computing power, 3DES is an
214extension of DES to extend the life of the cipher.  There was a cryptographic competition held to create a
215replacement.  AES is the result.  Whereas DSA is not generally used for day to day sign/verify operations
216outside of the US government, DES, Triple DES, and SHA-1 all entered into regular usage.
217
218RSA is a public key algorithm devised outside the US Government.
219
220[*] To be precise, the sign/verify operations actually involve encryption/decryption, but the nature of the
221algorithms prevents them from being effective streaming ciphers.  As a result, an encrypted and signed block of data will
222usually have a random session key protected by the public key system used to sign the block of data in the first place.
223If one is operating at a "decrypt this stream" level, the above overview is sufficient.
224*/
225typedef enum bencryption_type {
226        bencryption_type_none = 0,      /* no encryption */
227        bencryption_type_3des,          /* 3DES Cipher ("Triple DES"), see FIPS */
228        bencryption_type_des,           /* DEA Cipher (Defense Encryption Algorithm, commonly known as DES), see FIPS 46-3 */
229        bencryption_type_aes,           /* AES Cipher (Advanced Encryption Standard, the DEA replacement), see FIPS  */
230        bencryption_type_dvb,           /* DVB-CS Cipher (SuperScrambler) */
231        bencryption_type_sha1,          /* SHA-1 hash (Secure Hash Algorith) */
232        bencryption_type_md5,           /* MD5 hash (*/
233        bencryption_type_rsa,           /* RSA public key sign/verify */
234        bencryption_type_dsa,           /* DSA public key sign/verify */
235        bencryption_type_rc4,           /* RC4 Cipher */
236        bencryption_type_c2,            /* Cryptomeria Cipher (C2) (Media-based cipher) */
237        bencryption_type_css,           /* CSS (DVD) */
238        bencryption_type_external,      /* external algorithm (encrypted PVR only, see bsettop_crypto.h for the long_key structure to use) */
239        bencryption_type_multi2         /* Multi2 (CA only) */
240} bencryption_type;
241
242/*
243Summary:
244CA residue mode enum
245
246Description:
247This enum selects a residue mode for certain conditional access operations.
248*/
249typedef enum bencryption_residue {
250        bencryption_residue_none = 0,   /* no residue mode */
251        bencryption_residue_block_term, /* residual block termination */
252        bencryption_residue_cipher_text /* cipher-text stealing */
253} bencryption_residue;
254
255/* Cipher block modes.  Not all block modes are supported by all cipher algorithms in all hardware implementations.
256 * See the bcrypto documentation for more detail.
257 */
258/*
259Summary:
260Cryptographic block mode selection
261Description:
262This controls which block mode to use with the chosen cipher.  As a general rule, ECB should not be used to encrypt
263more than a single block of data (8 bytes for most algorithms).  CBC is the usual choice here.
264*/
265typedef enum bcrypto_blockmode {
266        bcrypto_blockmode_ecb,
267        bcrypto_blockmode_cbc,
268        bcrypto_blockmode_cfb,
269        bcrypto_blockmode_ofb,
270        bcrypto_blockmode_ctr
271} bcrypto_blockmode;
272
273/*
274Summary:
275Encryption type and key for use in network encryption and PVR encryption.
276
277Description:
278type contains the algorithm type (see bencryption_type for details).
279
280key_length indicates the length of the key, in bits.
281
282key is a big-endian byte array of the key.  Only as many bytes as needed should be used.  For per-algorithm specificity, please consult the bcrypt documentation.
283
284iv contains initialization vectors for specific cipher block modes.  This is ignored on non-cipher algorithms, and in ECB mode.
285
286long_key should be used to point to the key if 256 bits is inadequate to store the desired key.  If key_length is greater than 256, the key will be pulled from this variable rather than key (to allow for very large keys while still keeping cipher usage simple).  Certain encryption modes (for instance, RSA) have a specific struct pointed to by this, key_length in this case will be the size of the struct (in bits) rather than necessarily the size of the key (which will be inside the struct).  See bsettop_crypto.h for details.
287
288Please consult the bcrypto documention for the precise key layout for any given algorithm.
289
290When used with bstream_set_encryption, the members odd, even, and pid control how the key is applied.  For instance, pid can specify an audio or video pid, and it can be applied to even, odd, or both (if both even and odd are true) packets.
291*/
292typedef struct bencryption_params {
293        bencryption_type type;      /* encryption type. If set to "none", all other values in this structure are ignored. */
294        bcrypto_blockmode blockmode;/* cipher block mode, e.g. CBC, ECB, etc. */
295        bencryption_residue residue;/* residue mode, should be bencryption_residue_none except in special cases */
296        bool odd;                   /* encryption keys are applied for 'odd' packets */
297        bool even;                  /* encryption keys are applied for 'even' packets */
298        bool key_ladder;            /* derive key via key_ladder (requires long_key to point to bcrypto_keyladder_data) */
299        bool use_cps;               /* only used in encrypted PVR under special circumstances */
300        uint16_t pid;               /* apply key to this pid, 0x1fff to apply to all pids in this bstream */
301        unsigned key_length;        /* the length of the encryption key, in bits, formerly called "keysize". */
302        uint8_t key[32];            /* encryption key. */
303        uint8_t iv[32];             /* initialization vector, used for some cipher block modes such as CBC. */
304        uint16_t m2_round;          /* used with multi2 */
305        uint8_t m2_key_select;      /* used with multi2 */
306        uint8_t m2_sys_key[32];     /* used with multi2 */
307        const void *long_key;       /* encryption key. */
308} bencryption_params;
309
310/*
311Summary:
312Initializes the bencryption_params data structure.
313*/
314void bencryption_params_init(
315        bencryption_params *encryption  /* [out] */
316);
317
318/*
319Summary:
320Maximum number of video or audio programs which the bstream_mpeg data structure stores.
321stores.
322Description:
323If your application needs more, you'll need to override this value.
324*/
325#define BSETTOP_MAX_PROGRAMS 8
326
327/*
328Summary:
329This number indicates to record the PAT PID 0. Please use this define
330only in the anciallary.pid section of bstream_mpeg
331Description:
332*/
333#define BSETTOP_PAT_PID 0x2000
334
335/*
336Summary:
337MPEG parameters for a single program with the same pcr pid which are passed to bstream_open and bplayback_start.
338
339Description:
340The reason for multiple video and audio pids is to support multiple elementary
341streams within the same program. All video and audio pids should use the same
342pcr pid.
343
344Multiple audio elementary streams are needed for multiple language support (i.e. English
345and Spanish). Multiple video elementary streams might be needed for multiple
346viewing angles of the same program.
347
348You should not use this structure to store mutliple programs for channel change.
349Each "channel" should have its own bstream_mpeg structure because each channel
350has its own pcr pid.
351
352For PES decode the pid value is used to represent the PES packet id.  Typically this
353will be 0xE0 for video, 0xC0 for mpeg audio, and 0xBD for ac3 audio. 
354
355For VOB decode, video and mpeg audio type streams are handled identically to a PES
356based decode.  AC3 and DTS tracks ares slightly different as the upper 8 bits
357of the pid value represent the substream id that is to be decoded.  For example:
358pid==0x00BD would correspond to AC3/DTS track 0, while 0x01BD would correspond to
359AC3/DTS track 1.
360*/
361typedef struct bstream_mpeg {
362  struct {
363        uint16_t pid;
364        bvideo_codec format;
365  } video[BSETTOP_MAX_PROGRAMS];        /* video stream pids */
366  struct {
367        uint16_t pid;
368        baudio_format format;
369  } audio[BSETTOP_MAX_PROGRAMS];        /* audio stream pids */
370  struct {
371          uint16_t pid;
372  } ancillary[BSETTOP_MAX_PROGRAMS];    /* data channels */
373  uint16_t pcr_pid;
374  bstream_mpeg_type mpeg_type;
375  bencryption_params encryption;
376  bdecode_timestamp_order timestamp_order;
377} bstream_mpeg;
378
379/*
380Summary:
381        Required to initialize int bstream_mpeg data structure.
382*/
383void bstream_mpeg_init(
384        bstream_mpeg *mpeg              /* [out] */
385        );
386
387/**
388Summary:
389        Get the input band for a streamer input.
390
391Description:
392        For now, the following id's have these meanings:
393        0 = streamer 1 (TS0_IN parallel input on board)
394        1 = streamer 2 (TS1_IN parallel input on board)
395        100..106 = absolute input band 0..6. used for system debug.
396
397        For platform portability reasons please consider using list of streamers and input_bands from the
398        bconfig_board_resources .
399
400        Notice that there is no streamer object. The streamer id is assigned to a band based on the
401        platform.
402
403**/
404bband_t bstreamer_attach(
405        bobject_t id,
406        bstream_mpeg_type mpeg_type     /* The known mpeg type for this streamer. Only the developer
407                                                                knows what this is. */
408        );
409
410/**
411Summary:
412Dynamically create a digital stream using a band and mpeg parameters.
413
414Description:
415This is used for digital streams which are created from a tuned band or streamer band.
416The application supplies MPEG parameters which are obtained from scanning PSI information
417or stored separately.
418
419On some platforms, you can call bstream_open on the same band more than once. In this case,
420the transport block routes the data from one input band to multiple parser bands.
421
422You must call bstream_close to release resources.
423**/
424bstream_t bstream_open(
425        bband_t band,   /* input band */
426        const bstream_mpeg *mpegparams  /* MPEG pids to filter */
427        );
428
429/**
430Summary:
431Update encryption parameters after a stream has been created.
432
433Description:
434This is used for switching odd/even network encryption keys during decode.
435**/
436bresult bstream_set_encryption(
437        bstream_t stream,
438        const bencryption_params *encryption
439        );
440
441/**
442Summary:
443Join a stream.
444
445Description:
446This joins a video stream and audio stream together. The
447combined stream is now the video_source.
448**/
449
450void bstream_join(bstream_t video_source, bstream_t audio_source);
451
452/**
453Summary:
454Open a child stream from a parent stream.
455
456Description:
457This will create a child stream utilizing the same internal transport pipe as
458the parent stream.  This is primarily used in mosaic mode, where streams
459are expected to be on the same transport pipe.  The parent stream can be from
460either bstream_open (live decode) or from bplayback/bplaypump (PVR/IP playback).
461The returned stream should be closed by bstream_close.
462**/
463
464bstream_t bstream_open_child(bstream_t parent, const bstream_mpeg *mpegparams);
465
466/**
467Summary:
468Close a stream.
469
470Description:
471This is required if you use bstream_open to obtain a stream.
472This is allowed but not required if you get an analog stream from btuner or
473any stream from bplayback or bplaypump.
474**/
475void bstream_close(
476        bstream_t stream        /* Handle returned by bstream_open, btuner_tune_rf,
477                                                        btuner_tune_linein or bplayback_start. */
478        );
479
480/*
481Summary:
482        Digital stream status returned by bstream_get_mpeg_parameters.
483**/
484typedef struct bstream_status {
485        bband_t band; /* This is an input band. It is never a prser band. For playback streams, this
486                        will always be NULL. Use bband_settings to get the input band number. */
487        unsigned parser_band; /* This is internal information about the parser band used for this
488                        and is included here for diagnostic information only. */
489        bstream_mpeg mpeg; 
490        bdecode_t decode; /* if the stream is being decoded */
491    bool timestamp_enabled; /* true if timestamp is being enabled for this stream */
492} bstream_status;
493
494/**
495Summary:
496        Get status information from a digital stream.
497Description:
498        This is useful for getting MPEG parameters from an encoded stream where the bsettop_mpeg structure
499        is created internally.
500        If the stream is analog, it will fail.
501**/
502bresult
503bstream_get_mpeg_parameters(
504        bstream_t stream,
505        bstream_status *status  /* [out]*/
506        );
507
508/*
509Summary:
510Update the bstream_mpeg parameters of a digital stream that is already open.
511 
512Description:
513Changes are incremental: new pids are added; unused pids are removed; unchanged
514pids are unaffected (i.e. no glitching or errors introduced).
515 
516For decode, either from live or playback, there will be no change in decode until a detach/attach
517of either video or audio is done. The application is responsible for resetting any audio or video program index before
518reattaching. See bdecode_set_audio_program and bdecode_set_video_program.
519This does not change the PCR being used for TSM. That cannot be changed without a stop/start.
520 
521For record, the addition or removal of the pids is immediate. Also, this does not change the video
522pid being indexed. That cannot be changed without a stop/start.
523 
524This is not supported on legacy platforms.
525*/
526bresult
527bstream_set_mpeg_parameters(
528        bstream_t stream,
529        const bstream_mpeg *mpeg
530        );
531       
532/**
533Summary:
534Settings for a input band.
535Description:
536These are read-only settings which can be obtained with bband_get.
537**/
538typedef struct bband_settings {
539        unsigned bandnum;                               /* The transport input band number. This is
540                                not a parser band. See bstream_status for parser band. */   
541        bstream_mpeg_type mpeg_type;    /* The type of data on that input band */
542        btuner_t tuner;                                 /* What tuner this band is associated with.
543                                                                                For steamers, this is NULL. */
544} bband_settings;
545
546/**
547Summary:
548Get settings for a band.
549**/
550void bband_get(
551        bband_t band,
552        bband_settings *settings /* [out] */
553        );
554
555
556/*
557 * Start PCR monitoring. get accumulated information with
558 * bstream_get_pcr_status.
559 * If the PCR block is already in use with a different stream, this function
560 * will fail.
561 * */
562bresult bstream_start_pcr_monitor(bstream_t stream);
563
564/* stop PCR monitoring.  */
565void bstream_stop_pcr_monitor(bstream_t stream);
566
567typedef struct bstream_pcr_status {
568        uint32_t pcr_count; /* number of PCR's received since call to bstream_start_pcr_monitor */
569        bool pcr_valid; /* valid PCR was captured from the stream since call to bstream_start_pcr_monitor */
570        bool monitor_started; /* indicated whether PCR monitor is enabled */   
571} bstream_pcr_status;
572
573/* get status of the PCR monitor */
574bresult bstream_get_pcr_status(bstream_t stream, bstream_pcr_status *status);
575
576#ifdef __cplusplus
577}
578#endif
579
580#endif /* BSETTOP_STREAM_H__ */
Note: See TracBrowser for help on using the repository browser.