platform/upstream/v4l-utils.git
10 years agolibdvbv5: fix other error conditions for out of memory
Mauro Carvalho Chehab [Fri, 29 Nov 2013 02:36:33 +0000 (00:36 -0200)]
libdvbv5: fix other error conditions for out of memory

As Coverity points, there are other places where this error also occurs.

Fix them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: pack NIT table
Mauro Carvalho Chehab [Fri, 29 Nov 2013 02:15:19 +0000 (00:15 -0200)]
libdvbv5: pack NIT table

As all tables, this one should be packed.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: all tables should have an specified size
Mauro Carvalho Chehab [Fri, 29 Nov 2013 02:12:47 +0000 (00:12 -0200)]
libdvbv5/dvb-scan: all tables should have an specified size

If a table has a zero size, reject it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvb5-zap: Better handle the MPEG TS header
Mauro Carvalho Chehab [Fri, 29 Nov 2013 02:08:53 +0000 (00:08 -0200)]
dvb5-zap: Better handle the MPEG TS header

The code is now a little more elegant and easier to read.

No functional changes.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Fix other error conditions for out of memory
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:58:05 +0000 (09:58 -0200)]
libdvbv5: Fix other error conditions for out of memory

As Coverity points, there are other places where this error also occurs.

Fix all of them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix error condition on ISDBT delivery descriptor
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:53:45 +0000 (09:53 -0200)]
libdvbv5: fix error condition on ISDBT delivery descriptor

It should return if an error occur.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix error condition on ATSC service location descriptor
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:51:59 +0000 (09:51 -0200)]
libdvbv5: fix error condition on ATSC service location descriptor

It should return if an error occur.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-scan: fix detection of duplicated freqs at the input file
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:47:03 +0000 (09:47 -0200)]
dvbv5-scan: fix detection of duplicated freqs at the input file

As reported by Coverity, the dvb_scan_handler is always null on
that point. Just removing its check is enough to fix the issue.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: don't use realloc() inside pat.c
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:34:15 +0000 (09:34 -0200)]
libdvbv5: don't use realloc() inside pat.c

The usage of realloc() inside pat is wrong, as the newly reallocated
data could have a different address, and this is not returned back
to dvb-scan's dvb_read_section_with_id().

While we could do some other tricks to pass the new pointer back,
the entire logic is really not good. Also, the PAT handler uses a
different model than the other tables.

So, change it to use a linked list for the programs. This can, however,
break the API for other applications using it.

Fortunately, the dvb_pat_program_foreach() macro abstracts this
API difference, so, the breakage will not actually happen, if the
other apps use this macro (with is the case of tvdaemon).

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: Remove dead code and add a check after realloc()
Mauro Carvalho Chehab [Thu, 28 Nov 2013 10:50:51 +0000 (08:50 -0200)]
libdvbv5/dvb-scan: Remove dead code and add a check after realloc()

As reported by Coverity scan, the code just before the .init
if check warrants that tbl is always filled. So, checking it again
makes no sense. However, it makes sense to check after calling
realloc().

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: change log level for the two nit handler messages
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:53:22 +0000 (19:53 -0200)]
libdvbv5: change log level for the two nit handler messages

Those msgs are just warn for someone debuging the code. Don't
show them as errors.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix terrestrial delivery constellation table
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:23:23 +0000 (19:23 -0200)]
libdvbv5: fix terrestrial delivery constellation table

constellation == 2 means QAM64, according with ETSI EN 300 468 V1.11.1.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix dvb-scan handler for T2 descriptor
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:16:02 +0000 (19:16 -0200)]
libdvbv5: fix dvb-scan handler for T2 descriptor

The handler should take into account that not all descriptors
have all fields filled.

Also, while we don't have any sample of this descriptor
with a frequency table, better to not change the properties
for each new transponder's frequency.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix T2 delivery descriptor handler
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:13:14 +0000 (19:13 -0200)]
libdvbv5: fix T2 delivery descriptor handler

The data struct were not properly filled. Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix extension descriptor handler
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:11:33 +0000 (19:11 -0200)]
libdvbv5: fix extension descriptor handler

There are several issues at the extension handler:

1) the size is wrong, as it is getting data from
   descriptors.c, instead of from the extensions;

2) there are memory leaks;

3) It doesn't print the extension descriptors.

Fix them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: only handle SIGALRM if need
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:56:07 +0000 (14:56 -0200)]
dvbv5-zap: only handle SIGALRM if need

If timeout is not specified, or a SIGTERM/SIGINT was not received,
there's no need for handling SIGALRM.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-scan: handle SIGTERM/SIGINT nicely
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:36:05 +0000 (14:36 -0200)]
dvbv5-scan: handle SIGTERM/SIGINT nicely

Instead of just dying whenever a signal arrives, finish what it was
done. This way, already scanned channels will be written at the file.

At the worse case, after receiving a SIGTERM/SIGINT, it will die after
5 seconds, or after receiving a second SIGTERM/SIGINT.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: exit nicely on SIGTERM/SIGINT
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:20:46 +0000 (14:20 -0200)]
dvbv5-zap: exit nicely on SIGTERM/SIGINT

If the program is killed or aborted with CTRL-C, dies nicely.

That warrants that any data being processed to be handled, that
opened files will be closed and that the memory gets freed.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: handle timeout also while in monitor mode
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:11:54 +0000 (14:11 -0200)]
dvbv5-zap: handle timeout also while in monitor mode

The timeout parameter specifies the maximum time where the zap will
be looping. This works everywhere, except while in monitor mode.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-demux: fix CodingStyle
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:07:24 +0000 (14:07 -0200)]
libdvbv5/dvb-demux: fix CodingStyle

No functional changes.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: clear data before setting a dmx filter
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:04:02 +0000 (14:04 -0200)]
libdvbv5: clear data before setting a dmx filter

This fixes this Valgrind error:

==25172== Syscall param ioctl(generic) points to uninitialised byte(s)
==25172==    at 0x38CCAECEB7: ioctl (syscall-template.S:81)
==25172==    by 0x4043A8: dvb_set_pesfilter (dvb-demux.c:78)
==25172==    by 0x402F9D: do_traffic_monitor (dvbv5-zap.c:546)
==25172==    by 0x403AEA: main (dvbv5-zap.c:745)

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: make Valgrind happy
Mauro Carvalho Chehab [Wed, 27 Nov 2013 15:59:42 +0000 (13:59 -0200)]
dvbv5-zap: make Valgrind happy

Don't let leaks at the end: close all files, free all allocated
data.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: allow using transponder frequency while in monitor mode
Mauro Carvalho Chehab [Wed, 27 Nov 2013 15:10:38 +0000 (13:10 -0200)]
dvbv5-zap: allow using transponder frequency while in monitor mode

When this tool is using i monitor mode, we don't need audio or video
PID's. So, a "channel" type of file, with the transponders frequency,
plus the transponders parameters are enough. Add support for it.

This way, it is possible to do:

dvbv5-zap -I channel -c dvbc-test 573000000 -m

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors.c: fix two warnings
Mauro Carvalho Chehab [Wed, 27 Nov 2013 11:29:46 +0000 (09:29 -0200)]
libdvbv5/descriptors.c: fix two warnings

descriptors.c:134:4: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'int' [-Wformat=]
    dvb_logwarn("descriptor type 0x%02x is truncated: desc len %ld, section len %zd",
    ^
descriptors/desc_frequency_list.c: In function 'dvb_desc_frequency_list_init':
descriptors/desc_frequency_list.c:31:12: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
  char *p = buf;

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: some error handling improvements on dvb-file
Mauro Carvalho Chehab [Wed, 27 Nov 2013 11:18:14 +0000 (09:18 -0200)]
libdvbv5: some error handling improvements on dvb-file

All messages used during scan use the dvb_foo macros, excecpt for
those two places. Replace them.

Ok, ideally, all msgs should use this macro, but changing the other
ones is currently out of the scope.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Fix the size of the LCN descriptor
Mauro Carvalho Chehab [Wed, 27 Nov 2013 11:10:41 +0000 (09:10 -0200)]
libdvbv5: Fix the size of the LCN descriptor

Instead of using the main struct, it was using the channel number
struct. That's bad, especially since the size is not enough to store
the struct dvb_desc data on it, causing reading paste buffers.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Improve descriptor error logs
Mauro Carvalho Chehab [Wed, 27 Nov 2013 11:10:36 +0000 (09:10 -0200)]
libdvbv5: Improve descriptor error logs

When a descriptor is too small or too big, print a better log
message. Also, those are non-fatal errors. So, tag them as
WARNING.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: handle NIT descriptors when verbose is not enabled
Mauro Carvalho Chehab [Wed, 27 Nov 2013 10:13:00 +0000 (08:13 -0200)]
libdvbv5: handle NIT descriptors when verbose is not enabled

When verbose is enabled, the logic was supposed to check NIT
transport entries even without a callback, in order to print errors,
if a descriptor is found but not handled.

Unfortunately, the logic was wrong, effectively requiring verbose to
be on, in order to parse such descriptors.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: get rid of dvb-scan-table-handler.[ch]
Mauro Carvalho Chehab [Wed, 27 Nov 2013 09:41:53 +0000 (07:41 -0200)]
libdvbv5: get rid of dvb-scan-table-handler.[ch]

those files were useful during the transition to use the
descriptors library. However, after all code changes, they
became too tiny, and dependent of dvb-scan.[ch]. So, merge
the code and header back into them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: properly handle ISDB-T partial reception
Mauro Carvalho Chehab [Tue, 26 Nov 2013 20:20:59 +0000 (18:20 -0200)]
libdvbv5: properly handle ISDB-T partial reception

Tag the 1seg service IDs as partial reception.

That's IMHO the last missing bit from the descriptors library
porting logic.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: better implement the NIT parser
Mauro Carvalho Chehab [Tue, 26 Nov 2013 19:41:21 +0000 (17:41 -0200)]
libdvbv5: better implement the NIT parser

The code that were implementing the NIT parser were becoming too
complex, and had some common duplicated code.

Re-implement it, creating a helper routine to parse any NIT data,
and re-using the same routine to allow updating both the current
transponder and the detected transponders on a cleaner and saner
way.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: remove the remaining bits from the NIT parsers
Mauro Carvalho Chehab [Sun, 24 Nov 2013 23:16:02 +0000 (21:16 -0200)]
libdvbv5: remove the remaining bits from the NIT parsers

The previous NIT parser used to fill the entries data based on
the information detected on each transponder/channel.

Well, if the frontend was able to lock on the transponder, that
means that the parameters there at the entry are already correct
for the current channel, and that there's no need to use the NIT
table.

For new transponders frequencies, those data should be applied,
but this is done already inside dvb_add_scaned_transponders().

So, remove this code. As this is the last part using the old
descriptors logic, remove the struct definitions as well.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add support for DVB-T2 at NIT parser
Mauro Carvalho Chehab [Tue, 26 Nov 2013 12:24:37 +0000 (10:24 -0200)]
libdvbv5: add support for DVB-T2 at NIT parser

Add support on dvb-scan for DVB-T2 transponder parsing.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add support for DVB-S/S2 at NIT parser
Mauro Carvalho Chehab [Mon, 25 Nov 2013 00:43:39 +0000 (22:43 -0200)]
libdvbv5: add support for DVB-S/S2 at NIT parser

Add support on dvb-scan for DVB-S/S2 transponder parsing.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Re-add parser for ISDB-T NIT transponders addition
Mauro Carvalho Chehab [Mon, 25 Nov 2013 00:24:09 +0000 (22:24 -0200)]
libdvbv5: Re-add parser for ISDB-T NIT transponders addition

Add logic to handle NIT table for DVB-T on dvb-scan.c

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Re-add parser for ISDB-T NIT transponders addition
Mauro Carvalho Chehab [Sun, 24 Nov 2013 23:54:14 +0000 (21:54 -0200)]
libdvbv5: Re-add parser for ISDB-T NIT transponders addition

Add logic to handle NIT table for ISDB-T on dvb-scan.c

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Re-add NIT transponders addition
Mauro Carvalho Chehab [Sun, 24 Nov 2013 23:07:43 +0000 (21:07 -0200)]
libdvbv5: Re-add NIT transponders addition

Move the logic that add new transponders into the library and add
support there for DVB-C.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-scan: move scanning code into dvb_scan_transponder()
Mauro Carvalho Chehab [Sun, 24 Nov 2013 12:29:43 +0000 (10:29 -0200)]
dvbv5-scan: move scanning code into dvb_scan_transponder()

This makes the scan library more complete, and allows reusing the
code there into other applications.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: describe the service type on the logs
Mauro Carvalho Chehab [Sun, 24 Nov 2013 10:41:32 +0000 (08:41 -0200)]
libdvbv5/dvb-file: describe the service type on the logs

While we currently don't store the service type on the channel
file, it could be useful for the use to know what was found. So,
add the information there at the output information.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: improve debug messages
Mauro Carvalho Chehab [Sun, 24 Nov 2013 09:54:23 +0000 (07:54 -0200)]
libdvbv5: improve debug messages

Add several improvements at the debug messages:

- Without verbose, show only the Virtual channels or
  services to be stored in the file;

- instead of using fprintf for errors, use the error
  macros. That will make errors colored;

- With verbose=1, will show all parsed data;

- With verbose=2, will show all unparsed descriptors and
their hexdump contents;

- With verbose=3, will show all descriptors and their
hexdump contents, including the ones without a parser.

Verbose levels 2 and 3 helps to detect if some improvements would
be needed inside the descriptor parser's library.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: shut up a few compilation warnings
Mauro Carvalho Chehab [Sun, 24 Nov 2013 09:39:38 +0000 (07:39 -0200)]
libdvbv5: shut up a few compilation warnings

remove a couple compilation warnings:

descriptors/desc_extension.c:148:3: warning: passing argument 3 of 'init' from incompatible pointer type [enabled by default]
   init(parms, p, desc, ext->descriptor);
   ^
descriptors/desc_extension.c:148:3: note: expected 'struct dvb_extension_descriptor *' but argument is of type 'struct dvb_desc *'
descriptors/desc_extension.c: In function 'extension_descriptor_free':
descriptors/desc_extension.c:154:19: warning: unused variable 'desc' [-Wunused-variable]

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: be sure to not go past buffer on VCT parsing
Mauro Carvalho Chehab [Wed, 20 Nov 2013 16:11:22 +0000 (14:11 -0200)]
libdvbv5: be sure to not go past buffer on VCT parsing

Add checks to avoid read more data than available on buffer.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: be sure to not go past buffer on SDT parsing
Mauro Carvalho Chehab [Wed, 20 Nov 2013 16:03:58 +0000 (14:03 -0200)]
libdvbv5: be sure to not go past buffer on SDT parsing

Add checks to avoid read more data than available on buffer.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: be sure to not go past buffer on PMT parsing
Mauro Carvalho Chehab [Wed, 20 Nov 2013 15:57:48 +0000 (13:57 -0200)]
libdvbv5: be sure to not go past buffer on PMT parsing

Add checks to avoid read more data than available on buffer.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Add missing dvb_dmx_stop() on error handling
Mauro Carvalho Chehab [Wed, 20 Nov 2013 14:54:36 +0000 (12:54 -0200)]
libdvbv5: Add missing dvb_dmx_stop() on error handling

If the table can't be loaded, stop streaming.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: don't cause crash if NIT is missing on fe-file.c
Mauro Carvalho Chehab [Wed, 20 Nov 2013 14:54:11 +0000 (12:54 -0200)]
libdvbv5: don't cause crash if NIT is missing on fe-file.c

If NIT table is not read, it is not possible to get the vchannel
data from it.

Instead of crashing, fails nicely.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix debug msg for Network PID
Mauro Carvalho Chehab [Wed, 20 Nov 2013 12:08:36 +0000 (10:08 -0200)]
libdvbv5: fix debug msg for Network PID

When program_number is 0, the PID refers to the Network PID,
according with ISO 13.818-1. Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add multisection support for PAT table
Mauro Carvalho Chehab [Wed, 20 Nov 2013 10:24:42 +0000 (08:24 -0200)]
libdvbv5: add multisection support for PAT table

As PAT can be multisection, add support for it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: be sure to not go past buffer on PAT parsing
Mauro Carvalho Chehab [Wed, 20 Nov 2013 10:19:26 +0000 (08:19 -0200)]
libdvbv5: be sure to not go past buffer on PAT parsing

Add checks to avoid read more data than available on buffer.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: avoid nit to read out of the buffer
Mauro Carvalho Chehab [Wed, 20 Nov 2013 00:15:02 +0000 (22:15 -0200)]
libdvbv5: avoid nit to read out of the buffer

As reported by Valgrind:
==6709== Invalid write of size 8
==6709==    at 0x4099F2: dvb_parse_descriptors (descriptors.c:61)
==6709==    by 0x40B9CB: dvb_table_nit_init (nit.c:92)
==6709==    by 0x408F07: dvb_read_section_with_id (dvb-scan.c:200)
==6709==    by 0x40946A: dvb_get_ts_tables (dvb-scan.c:80)
==6709==    by 0x4025E2: run_scan (dvbv5-scan.c:477)

Sometimes, we're reading past of the buffer on NIT parser.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: Don't leave memory leaks on channel store failure
Mauro Carvalho Chehab [Tue, 19 Nov 2013 21:15:00 +0000 (19:15 -0200)]
libdvbv5/dvb-file: Don't leave memory leaks on channel store failure

If channel store fails, the channel var should be freed.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors: don't leak memory on error
Mauro Carvalho Chehab [Tue, 19 Nov 2013 20:26:11 +0000 (18:26 -0200)]
libdvbv5/descriptors: don't leak memory on error

Check buffer size before alloc, to avoid memory leaks.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors: Fix extension descriptor handling
Mauro Carvalho Chehab [Tue, 19 Nov 2013 17:34:05 +0000 (15:34 -0200)]
libdvbv5/descriptors: Fix extension descriptor handling

The extension descriptor handling was wrong. Rewrite the code,
in order to make it right.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors: Fix error handling routine
Mauro Carvalho Chehab [Tue, 19 Nov 2013 17:07:57 +0000 (15:07 -0200)]
libdvbv5/descriptors: Fix error handling routine

the "current" structure is not allocated yet. Don't use it too
early.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: Fix the logic for program found check
Mauro Carvalho Chehab [Tue, 19 Nov 2013 16:41:00 +0000 (14:41 -0200)]
libdvbv5/dvb-file: Fix the logic for program found check

The logic is broken, causing a crash. Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: require PAT also for ATSC
Mauro Carvalho Chehab [Tue, 19 Nov 2013 16:09:06 +0000 (14:09 -0200)]
libdvbv5/dvb-scan: require PAT also for ATSC

If the PAT table is not found, it can't proceed, even for ATSC.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvb/dvbv5-zap: Fix help message
Mauro Carvalho Chehab [Tue, 19 Nov 2013 16:08:51 +0000 (14:08 -0200)]
dvb/dvbv5-zap: Fix help message

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: avoid memory leak on table read timeout
Mauro Carvalho Chehab [Mon, 18 Nov 2013 09:52:53 +0000 (07:52 -0200)]
libdvbv5/dvb-scan: avoid memory leak on table read timeout

Free buf, if table read fails with timeout.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: Allow using SDT for ATSC
Mauro Carvalho Chehab [Mon, 18 Nov 2013 09:49:45 +0000 (07:49 -0200)]
libdvbv5/dvb-file: Allow using SDT for ATSC

When SDT table parsing is forced, allow using it for ATSC.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-scan: release resources on errors
Mauro Carvalho Chehab [Mon, 18 Nov 2013 09:41:43 +0000 (07:41 -0200)]
dvbv5-scan: release resources on errors

If an error occurs, release memory and close the file descriptor,
if opened.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvb-fe: don't cause memory leak on open errors
Mauro Carvalho Chehab [Mon, 18 Nov 2013 09:41:08 +0000 (07:41 -0200)]
dvb-fe: don't cause memory leak on open errors

If open fails, release memory.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: don't leak memory on ATSC service location
Mauro Carvalho Chehab [Sun, 17 Nov 2013 23:50:04 +0000 (21:50 -0200)]
libdvbv5: don't leak memory on ATSC service location

Call free routine for desc_atsc_service_location, in order
to avoid memory leaks.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: On ATSC, only try to get SDT if VCT is not found
Mauro Carvalho Chehab [Sun, 17 Nov 2013 23:23:55 +0000 (21:23 -0200)]
libdvbv5: On ATSC, only try to get SDT if VCT is not found

As, on ATSC, channels are described on VCT, don't try to read
SDT by default, if VCT is found.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add support for ATSC VCT table parsing
Mauro Carvalho Chehab [Sun, 17 Nov 2013 23:20:36 +0000 (21:20 -0200)]
libdvbv5: add support for ATSC VCT table parsing

On ATSC, the VCT table is used to describe the channels,
and SDT is generally not implemented.

Implement a function to fill the channel data from it, if
available. Otherwise, fall back to SDT parsing.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agoFix desc_frequency_list descriptor
Mauro Carvalho Chehab [Sun, 17 Nov 2013 22:40:38 +0000 (20:40 -0200)]
Fix desc_frequency_list descriptor

This descriptor is commented. Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: fix parameters for dvb_vchannel()
Mauro Carvalho Chehab [Sun, 17 Nov 2013 21:58:12 +0000 (19:58 -0200)]
libdvbv5/dvb-file: fix parameters for dvb_vchannel()

Passed parameters were wrong. Fix them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: fix allocation of dvb_file
Mauro Carvalho Chehab [Sun, 17 Nov 2013 21:31:55 +0000 (19:31 -0200)]
libdvbv5/dvb-file: fix allocation of dvb_file

Correct a few allocation issues reported by Valgrind:

- Size of dvb_file is wrong;
- getline requires a free after end using it;
- entries should be freed at dvb_file_free().

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: use the new descriptors for virtual channel
Mauro Carvalho Chehab [Sun, 17 Nov 2013 20:35:40 +0000 (18:35 -0200)]
libdvbv5/dvb-file: use the new descriptors for virtual channel

Search for the LCN and TS info descriptors at the NIT table, for
the virtual channel information.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: produce dvb data from the new structures
Mauro Carvalho Chehab [Sun, 17 Nov 2013 15:49:44 +0000 (13:49 -0200)]
libdvbv5: produce dvb data from the new structures

Now that dvb-scan uses the new descriptor structures, convert
dvb-file to rely on them to produce the scanned file data.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan-table-handler: remove free of unallocated structs
Mauro Carvalho Chehab [Sun, 17 Nov 2013 12:55:44 +0000 (10:55 -0200)]
libdvbv5/dvb-scan-table-handler: remove free of unallocated structs

While those old structs are still part of struct dvb_v5_descriptors,
they are not allocated anymore. So, we don't need to fix them. Get
rid of those structs.

We can't remove them from the main struct yet, as dvb-file and
dvbv5-scan still use.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: fix memory leak
Mauro Carvalho Chehab [Sun, 17 Nov 2013 12:51:03 +0000 (10:51 -0200)]
libdvbv5/dvb-scan: fix memory leak

As pointed by Valgrind, there are still some memory leaks at
dvb_get_ts_tables().

That happens because pmt is allocated by dvb_read_section().
Fix it.

While here, fix the error condition to not mangle with the main
dvb_scan_handler->program pointer.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors: descriptors data should always be freed
Mauro Carvalho Chehab [Sun, 17 Nov 2013 11:31:00 +0000 (09:31 -0200)]
libdvbv5/descriptors: descriptors data should always be freed

It is up to each descriptor's free function to free data allocated
during its init phase. However, the container of the descriptor
itself was allocated by dvb_parse_descriptors(). So, it should be
up to dvb_free_descriptors() to deallocate.

This error was detected by Valgrind.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-fe: make valgrind happy
Mauro Carvalho Chehab [Sun, 17 Nov 2013 11:18:25 +0000 (09:18 -0200)]
libdvbv5/dvb-fe: make valgrind happy

clean prop before using it. This makes valgrind happy.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Better handle program data
Mauro Carvalho Chehab [Sun, 17 Nov 2013 11:13:35 +0000 (09:13 -0200)]
libdvbv5: Better handle program data

Program data tables (pmt) are associated with the program
inside the pat table.

Keep that association, in order to make life easier for scanning
programs that may need it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Add some missing code to free data
Mauro Carvalho Chehab [Sat, 16 Nov 2013 11:39:12 +0000 (09:39 -0200)]
libdvbv5: Add some missing code to free data

On some descriptors that I added recently, the free function
is missing, causing memory leak.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan-table-handler:free the new table descriptors
Mauro Carvalho Chehab [Sat, 16 Nov 2013 11:10:20 +0000 (09:10 -0200)]
libdvbv5/dvb-scan-table-handler:free the new table descriptors

Free memory for the table descriptors.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: avoid playing with memory
Mauro Carvalho Chehab [Sat, 16 Nov 2013 10:56:08 +0000 (08:56 -0200)]
libdvbv5: avoid playing with memory

Instead of reallocating the memory size for every single table,
just use the known size of the structure, as this is fixed.

The pat table here is an special case, due to the way its struct
is mapped. It is probably a good idea to use malloc there for the
struct dvb_table_pat_program program, but this would break compatibility
with libdvbv5 apps. So, let's keep it as-is.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add suport for DVB-T2 delivery descriptor
Mauro Carvalho Chehab [Fri, 15 Nov 2013 20:35:06 +0000 (18:35 -0200)]
libdvbv5: add suport for DVB-T2 delivery descriptor

ETSI EN 300 468 V1.11.1 defines an special descriptor for DVB-T2.
Add support for it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Add support for partial reception
Mauro Carvalho Chehab [Fri, 15 Nov 2013 19:43:54 +0000 (17:43 -0200)]
libdvbv5: Add support for partial reception

Partial reception is a feature for ISDB streams. Add support for
its descriptor.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Add descriptors for virtual channel number
Mauro Carvalho Chehab [Fri, 15 Nov 2013 19:15:39 +0000 (17:15 -0200)]
libdvbv5: Add descriptors for virtual channel number

Those descriptors are present in some european countries and
in Brazil.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add parser for TS information descriptor
Mauro Carvalho Chehab [Fri, 15 Nov 2013 18:27:20 +0000 (16:27 -0200)]
libdvbv5: add parser for TS information descriptor

This descriptor is used on ISDB-T.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add support for ISDBT terrestrial system descriptor
Mauro Carvalho Chehab [Fri, 15 Nov 2013 14:38:03 +0000 (12:38 -0200)]
libdvbv5: add support for ISDBT terrestrial system descriptor

This descriptor contains the frequency tables on ISDB-T.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors: Make easier to read/edit the descriptors table
Mauro Carvalho Chehab [Fri, 15 Nov 2013 13:32:57 +0000 (11:32 -0200)]
libdvbv5/descriptors: Make easier to read/edit the descriptors table

Instead of one big line per descriptor, break it into several lines.

This was generated by this script:

cat lib/libdvbv5/descriptors.c |perl -ne 's/(\[.*\]\s*\=\s*\{)\s*([^\,]+)\,\s*([^\,]+)\,\s*([^\,]+)\,\s*([^\,]+)\,\s*(.*)\s+(\}\,)/$1\n\t\t.name  = $2,\n\t\t.init  = $3,\n\t\t.print = $4,\n\t\t.free  = $5\n\t\t.size  = $6,\n\t$7/g; print $_' >a && mv a lib/libdvbv5/descriptors.c
cat lib/libdvbv5/descriptors/desc_extension.c |perl -ne 's/(\[.*\]\s*\=\s*\{)\s*([^\,]+)\,\s*([^\,]+)\,\s*([^\,]+)\,\s*([^\,]+)\,\s*(.*)\s+(\}\,)/$1\n\t\t.name  = $2,\n\t\t.init  = $3,\n\t\t.print = $4,\n\t\t.free  = $5\n\t\t.size  = $6,\n\t$7/g; print $_' >a && mv a lib/libdvbv5/descriptors/desc_extension.c

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodescriptors/nit: byte struct should be packed
Mauro Carvalho Chehab [Fri, 15 Nov 2013 12:44:27 +0000 (10:44 -0200)]
descriptors/nit: byte struct should be packed

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors: print descriptor number in hexadecimal
Mauro Carvalho Chehab [Fri, 15 Nov 2013 12:42:20 +0000 (10:42 -0200)]
libdvbv5/descriptors: print descriptor number in hexadecimal

Descriptors are tabled in hexadecimal. Put them in this format,
to make easier to compare with DTV and MPEG tables.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: better handle memory errors
Mauro Carvalho Chehab [Fri, 15 Nov 2013 12:29:54 +0000 (10:29 -0200)]
libdvbv5: better handle memory errors

Avoid the risk of filling past of the buffers, by checking i
are there any space available before filling the buffers.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/parse_string: don't free twice
Mauro Carvalho Chehab [Fri, 15 Nov 2013 12:27:13 +0000 (10:27 -0200)]
libdvbv5/parse_string: don't free twice

As reported by valgrind, sometimes, it was freeing the same
data twice, with was causing random troubles elsewhere.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: Fix a series of checks at buffer handling
Mauro Carvalho Chehab [Fri, 15 Nov 2013 11:18:43 +0000 (09:18 -0200)]
libdvbv5/dvb-scan: Fix a series of checks at buffer handling

The logic inside dvb_read_section_with_id() is rather complex,
as the same buffer is de-allocated/re-allocated multiple times.

Simplify it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: be more verbose in debug mode
Mauro Carvalho Chehab [Fri, 15 Nov 2013 10:54:43 +0000 (08:54 -0200)]
libdvbv5/dvb-scan: be more verbose in debug mode

That helps to know what's happening, especially when there are
some crashes on it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: handle allocation errors
Mauro Carvalho Chehab [Fri, 15 Nov 2013 10:54:33 +0000 (08:54 -0200)]
libdvbv5/dvb-scan: handle allocation errors

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Add a parser for extension descriptors
Mauro Carvalho Chehab [Thu, 14 Nov 2013 02:57:00 +0000 (00:57 -0200)]
libdvbv5: Add a parser for extension descriptors

There are some descriptors that are extensions, e. g. they
use a new descriptor range.

Add support for them, as the DVB-T2 table is one of such
extensions.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fixup parsing of PMT tables
Mauro Carvalho Chehab [Thu, 14 Nov 2013 02:11:50 +0000 (00:11 -0200)]
libdvbv5: fixup parsing of PMT tables

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: move all tables structs to the handler data
Mauro Carvalho Chehab [Thu, 14 Nov 2013 01:29:26 +0000 (23:29 -0200)]
libdvbv5: move all tables structs to the handler data

As we'll use the data there, move everything parsed from
the MPEG TS tables into struct dvb_v5_descriptors.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: move handler code to a separate file
Mauro Carvalho Chehab [Thu, 14 Nov 2013 01:13:15 +0000 (23:13 -0200)]
libdvbv5: move handler code to a separate file

Move the functions that allocate/deallocate memory for the
DVB scan description data to a separate file, and better
name them, to avoid confusion with the dvb_desc used
inside the descriptors parsing API.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: move DVB scan handler code to a separate file
Mauro Carvalho Chehab [Thu, 14 Nov 2013 00:54:13 +0000 (22:54 -0200)]
libdvbv5: move DVB scan handler code to a separate file

This were polluting the DVB descriptors API. They don't belong
to it anymore, with the new descriptors parsing code.

Move to a separate file.

It should be noticed that, right now, the DVB scan code is
not producing a valid scan file anymore, as those structs are
not properly initialized.

Latter patches will fix that.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: Modify to use the newer TS tables parser
Mauro Carvalho Chehab [Thu, 14 Nov 2013 00:26:44 +0000 (22:26 -0200)]
libdvbv5/dvb-scan: Modify to use the newer TS tables parser

This code has an incomplete MPEG TS tables parser.

Also, it is not endiannes-aware.

Replace it by the newer one.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Add table ID of extra NIT/SDT tables
Mauro Carvalho Chehab [Thu, 14 Nov 2013 00:21:42 +0000 (22:21 -0200)]
libdvbv5: Add table ID of extra NIT/SDT tables

At least on dvb-apps, those two extra table IDs are present.
Add there at the header files, for completeness.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Fix compiler warning about signedness
Gregor Jasny [Tue, 19 Nov 2013 21:46:02 +0000 (22:46 +0100)]
libdvbv5: Fix compiler warning about signedness

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
10 years agobuildsystem: Fix configure.ac --disable-v4l-utils option
Alain VOLMAT [Tue, 19 Nov 2013 13:28:27 +0000 (14:28 +0100)]
buildsystem: Fix configure.ac --disable-v4l-utils option

When using AC_ARG_ENABLE with a string containing - in it, the variable created will contains a _ instead of the -.
Thus for AC_ARG_ENABLE(v4l-utils ..., the variable enable_v4l_utils must be checked.

Signed-off-by: Alain Volmat <alain.volmat@st.com>
Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
10 years agolibdvbv5: Add support for additional descriptors at VCT table
Mauro Carvalho Chehab [Wed, 13 Nov 2013 23:33:07 +0000 (21:33 -0200)]
libdvbv5: Add support for additional descriptors at VCT table

Document A/65:2009 allows extra descriptors at the Virtual
Channel Table.

While I don't have it on my test streams, it is better to
add support for it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>