| [2] | 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2011, 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: $ |
|---|
| 11 | * $brcm_Revision: $ |
|---|
| 12 | * $brcm_Date: $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: $ |
|---|
| 19 | * |
|---|
| 20 | ****************************************************************************/ |
|---|
| 21 | |
|---|
| 22 | #include "bstd.h" |
|---|
| 23 | #include "bkni.h" |
|---|
| 24 | #include "ts_priv.h" |
|---|
| 25 | #include "ts_psi.h" |
|---|
| 26 | #include "ministd.h" |
|---|
| 27 | #include "dvb_parser.h" |
|---|
| 28 | |
|---|
| 29 | #include "si.h" |
|---|
| 30 | #include "si_util.h" |
|---|
| 31 | |
|---|
| 32 | BDBG_MODULE(dvb_rst); |
|---|
| 33 | |
|---|
| 34 | #define RST_ENTRY_LEN 9 |
|---|
| 35 | void dvb_rst_init(void) |
|---|
| 36 | { |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | int dvb_rst_parse(const uint8_t *rst_buf, size_t *psize) |
|---|
| 40 | { |
|---|
| 41 | uint8_t tid, running_status; |
|---|
| 42 | uint16_t parsed, section_len, network_id; |
|---|
| 43 | uint16_t service_id, event_id, stream_id; |
|---|
| 44 | struct bit_state_t bs; |
|---|
| 45 | eit_entry_t *p_eit_entry; |
|---|
| 46 | |
|---|
| 47 | BDBG_ASSERT(rst_buf && psize); |
|---|
| 48 | BDBG_MSG(("%s: enter", __FUNCTION__)); |
|---|
| 49 | |
|---|
| 50 | bs.data = (unsigned char *)rst_buf; |
|---|
| 51 | bs.bindex = 0; |
|---|
| 52 | |
|---|
| 53 | tid = get_bits(8, &bs); |
|---|
| 54 | if (tid != DVB_TID_RST) { |
|---|
| 55 | BDBG_WRN(("%s: invalid table id (0x%x)", __FUNCTION__, tid)); |
|---|
| 56 | return 0; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | get_bits(4, &bs); /* skip section_syntax_indicator, reserved field */ |
|---|
| 60 | section_len = get_bits(12, &bs); |
|---|
| 61 | |
|---|
| 62 | parsed = 0; |
|---|
| 63 | while (parsed < section_len) |
|---|
| 64 | { |
|---|
| 65 | stream_id = get_bits(16, &bs); |
|---|
| 66 | network_id = get_bits(16, &bs); |
|---|
| 67 | service_id = get_bits(16, &bs); |
|---|
| 68 | event_id = get_bits(16, &bs); |
|---|
| 69 | get_bits(5, &bs); |
|---|
| 70 | running_status = get_bits(3, &bs); |
|---|
| 71 | /* update running status */ |
|---|
| 72 | p_eit_entry = dvb_eit_get_entry(stream_id, service_id); |
|---|
| 73 | if (p_eit_entry) { |
|---|
| 74 | /* find the event */ |
|---|
| 75 | if (p_eit_entry->eit_present.event_id == event_id) { |
|---|
| 76 | p_eit_entry->eit_present.running_status = running_status; |
|---|
| 77 | } |
|---|
| 78 | else if (p_eit_entry->eit_following.event_id == event_id) { |
|---|
| 79 | p_eit_entry->eit_following.running_status = running_status; |
|---|
| 80 | } |
|---|
| 81 | } |
|---|
| 82 | else { |
|---|
| 83 | BDBG_WRN(("EIT entry is not registered yet")); |
|---|
| 84 | } |
|---|
| 85 | parsed += RST_ENTRY_LEN; |
|---|
| 86 | } |
|---|
| 87 | return 1; |
|---|
| 88 | } |
|---|