comparison recpt1/decoder.c @ 5:97fd2315114e

- now it can handle options. - applied channel patch. - some cleanups.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 17 Feb 2009 05:58:36 +0900
parents 43d177fa65c9
children b6607f6e2851
comparison
equal deleted inserted replaced
4:43d177fa65c9 5:97fd2315114e
1 #include <stdlib.h> 1 #include <stdlib.h>
2 #include <stdio.h>
2 3
3 #include "decoder.h" 4 #include "decoder.h"
4 5
5 decoder * 6 decoder *
6 b25_startup(void) 7 b25_startup(decoder_options *opt)
7 { 8 {
8 decoder *dec = calloc(1, sizeof(decoder)); 9 decoder *dec = calloc(1, sizeof(decoder));
9 int code; 10 int code;
11 const char *err = NULL;
10 12
11 dec->b25 = create_arib_std_b25(); 13 dec->b25 = create_arib_std_b25();
12 dec->b25->set_multi2_round(dec->b25, 4); //xxx round should be configurable 14 if(!dec->b25) {
13 dec->b25->set_strip(dec->b25, 0); //ditto 15 err = "create_arib_std_b25 failed";
14 dec->b25->set_emm_proc(dec->b25, 0); //ditto 16 goto error;
17 }
18
19 code = dec->b25->set_multi2_round(dec->b25, opt->round);
20 if(code < 0) {
21 err = "set_multi2_round failed";
22 goto error;
23 }
24
25 code = dec->b25->set_strip(dec->b25, opt->strip);
26 if(code < 0) {
27 err = "set_strip failed";
28 goto error;
29 }
30
31 code = dec->b25->set_emm_proc(dec->b25, opt->emm);
32 if(code < 0) {
33 err = "set_emm_proc failed";
34 goto error;
35 }
36
15 dec->bcas = create_b_cas_card(); 37 dec->bcas = create_b_cas_card();
38 if(!dec->bcas) {
39 err = "create_b_cas_card failed";
40 goto error;
41 }
16 code = dec->bcas->init(dec->bcas); 42 code = dec->bcas->init(dec->bcas);
43 if(code < 0) {
44 err = "bcas->init failed";
45 goto error;
46 }
47
17 code = dec->b25->set_b_cas_card(dec->b25, dec->bcas); 48 code = dec->b25->set_b_cas_card(dec->b25, dec->bcas);
49 if(code < 0) {
50 err = "set_b_cas_card failed";
51 goto error;
52 }
18 53
19 return dec; 54 return dec;
55
56 error:
57 fprintf(stderr, "%s\n", err);
58 free(dec);
59 return NULL;
20 } 60 }
21 61
22 int 62 int
23 b25_shutdown(decoder *dec) 63 b25_shutdown(decoder *dec)
24 { 64 {
30 } 70 }
31 71
32 int 72 int
33 b25_decode(decoder *dec, ARIB_STD_B25_BUFFER *sbuf, ARIB_STD_B25_BUFFER *dbuf) 73 b25_decode(decoder *dec, ARIB_STD_B25_BUFFER *sbuf, ARIB_STD_B25_BUFFER *dbuf)
34 { 74 {
35 int code; 75 int code;
36 76
37 code = dec->b25->put(dec->b25, sbuf); 77 code = dec->b25->put(dec->b25, sbuf);
38 if(code < 0) 78 if(code < 0) {
39 return code; 79 fprintf(stderr, "b25->put failed\n");
80 return code;
81 }
40 82
41 code = dec->b25->get(dec->b25, dbuf); 83 code = dec->b25->get(dec->b25, dbuf);
42 return code; 84 if(code < 0) {
85 fprintf(stderr, "b25->get failed\n");
86 return code;
87 }
88
89 return code;
43 } 90 }
44 91
45 int 92 int
46 b25_finish(decoder *dec, ARIB_STD_B25_BUFFER *sbuf, ARIB_STD_B25_BUFFER *dbuf) 93 b25_finish(decoder *dec, ARIB_STD_B25_BUFFER *sbuf, ARIB_STD_B25_BUFFER *dbuf)
47 { 94 {
48 int code; 95 int code;
49 96
50 code = dec->b25->flush(dec->b25); 97 code = dec->b25->flush(dec->b25);
51 if(code < 0) 98 if(code < 0) {
52 return code; 99 fprintf(stderr, "b25->flush failed\n");
100 return code;
101 }
53 102
54 code = dec->b25->get(dec->b25, dbuf); 103 code = dec->b25->get(dec->b25, dbuf);
55 return code; 104 if(code < 0) {
105 fprintf(stderr, "b25->get failed\n");
106 return code;
107 }
108
109 return code;
56 } 110 }