Mercurial > pt1.oyama
annotate src/decoder.c @ 177:1d6674183e76
Fix problem: If do not specify DLNA, will not call pthread_join(stream_thread,)
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Wed, 07 Nov 2012 22:54:19 +0900 |
parents | 9c7bc6c0327e |
children |
rev | line source |
---|---|
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
1 #include <stdlib.h> |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
2 #include <stdio.h> |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
3 |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
4 #include "decoder.h" |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
5 |
74
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
6 #ifdef HAVE_LIBARIB25 |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
7 |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
8 decoder * |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
9 b25_startup(decoder_options *opt) |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
10 { |
4 | 11 decoder *dec = calloc(1, sizeof(decoder)); |
12 int code; | |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
13 const char *err = NULL; |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
14 |
4 | 15 dec->b25 = create_arib_std_b25(); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
16 if(!dec->b25) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
17 err = "create_arib_std_b25 failed"; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
18 goto error; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
19 } |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
20 |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
21 code = dec->b25->set_multi2_round(dec->b25, opt->round); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
22 if(code < 0) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
23 err = "set_multi2_round failed"; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
24 goto error; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
25 } |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
26 |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
27 code = dec->b25->set_strip(dec->b25, opt->strip); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
28 if(code < 0) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
29 err = "set_strip failed"; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
30 goto error; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
31 } |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
32 |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
33 code = dec->b25->set_emm_proc(dec->b25, opt->emm); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
34 if(code < 0) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
35 err = "set_emm_proc failed"; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
36 goto error; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
37 } |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
38 |
4 | 39 dec->bcas = create_b_cas_card(); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
40 if(!dec->bcas) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
41 err = "create_b_cas_card failed"; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
42 goto error; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
43 } |
4 | 44 code = dec->bcas->init(dec->bcas); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
45 if(code < 0) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
46 err = "bcas->init failed"; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
47 goto error; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
48 } |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
49 |
4 | 50 code = dec->b25->set_b_cas_card(dec->b25, dec->bcas); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
51 if(code < 0) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
52 err = "set_b_cas_card failed"; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
53 goto error; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
54 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
55 |
4 | 56 return dec; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
57 |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
58 error: |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
59 fprintf(stderr, "%s\n", err); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
60 free(dec); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
61 return NULL; |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
62 } |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
63 |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
64 int |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
65 b25_shutdown(decoder *dec) |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
66 { |
4 | 67 dec->b25->release(dec->b25); |
68 dec->bcas->release(dec->bcas); | |
69 free(dec); | |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
70 |
4 | 71 return 0; |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
72 } |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
73 |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
74 int |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
75 b25_decode(decoder *dec, ARIB_STD_B25_BUFFER *sbuf, ARIB_STD_B25_BUFFER *dbuf) |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
76 { |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
77 int code; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
78 |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
79 code = dec->b25->put(dec->b25, sbuf); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
80 if(code < 0) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
81 fprintf(stderr, "b25->put failed\n"); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
82 return code; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
83 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
84 |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
85 code = dec->b25->get(dec->b25, dbuf); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
86 if(code < 0) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
87 fprintf(stderr, "b25->get failed\n"); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
88 return code; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
89 } |
4 | 90 |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
91 return code; |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
92 } |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
93 |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
94 int |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
95 b25_finish(decoder *dec, ARIB_STD_B25_BUFFER *sbuf, ARIB_STD_B25_BUFFER *dbuf) |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
96 { |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
97 int code; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
98 |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
99 code = dec->b25->flush(dec->b25); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
100 if(code < 0) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
101 fprintf(stderr, "b25->flush failed\n"); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
102 return code; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
103 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
104 |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
105 code = dec->b25->get(dec->b25, dbuf); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
106 if(code < 0) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
107 fprintf(stderr, "b25->get failed\n"); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
108 return code; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
109 } |
4 | 110 |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
111 return code; |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
112 } |
74
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
113 |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
114 #else |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
115 |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
116 /* functions */ |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
117 decoder *b25_startup(decoder_options *opt) |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
118 { |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
119 return NULL; |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
120 } |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
121 |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
122 int b25_shutdown(decoder *dec) |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
123 { |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
124 return 0; |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
125 } |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
126 |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
127 int b25_decode(decoder *dec, |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
128 ARIB_STD_B25_BUFFER *sbuf, |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
129 ARIB_STD_B25_BUFFER *dbuf) |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
130 { |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
131 return 0; |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
132 } |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
133 |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
134 int b25_finish(decoder *dec, |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
135 ARIB_STD_B25_BUFFER *sbuf, |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
136 ARIB_STD_B25_BUFFER *dbuf) |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
137 { |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
138 return 0; |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
139 } |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
140 |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
5
diff
changeset
|
141 #endif |