From: Mauro Carvalho Chehab <m.chehab@samsung.com>
To: "André Roth" <neolynx@gmail.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 02/18] libdvbv5: service location descriptor support
Date: Tue, 07 Jan 2014 14:38:18 -0200 [thread overview]
Message-ID: <20140107143818.7d2e3b27@samsung.com> (raw)
In-Reply-To: <1388407731-24369-2-git-send-email-neolynx@gmail.com>
Em Mon, 30 Dec 2013 13:48:35 +0100
André Roth <neolynx@gmail.com> escreveu:
> Implement the service location descriptor (0xa1), and small cleanups.
>
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors.h | 4 +-
> lib/include/descriptors/desc_service_location.h | 69 +++++++++++++++++++++++
> lib/libdvbv5/Makefile.am | 3 +-
> lib/libdvbv5/descriptors.c | 2 +-
> lib/libdvbv5/descriptors/desc_service_location.c | 70 ++++++++++++++++++++++++
> 5 files changed, 145 insertions(+), 3 deletions(-)
> create mode 100644 lib/include/descriptors/desc_service_location.h
> create mode 100644 lib/libdvbv5/descriptors/desc_service_location.c
>
> diff --git a/lib/include/descriptors.h b/lib/include/descriptors.h
> index 2e614f0..5ab29a0 100644
> --- a/lib/include/descriptors.h
> +++ b/lib/include/descriptors.h
> @@ -1,4 +1,4 @@
> - /*
> +/*
> * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
> *
> * This program is free software; you can redistribute it and/or
> @@ -216,6 +216,8 @@ enum descriptors {
> /* SCTE 35 2004 */
> CUE_identifier_descriptor = 0x8a,
>
> + extended_channel_name = 0xa0,
> + service_location = 0xa1,
> /* From http://www.etherguidesystems.com/Help/SDOs/ATSC/Semantics/Descriptors/Default.aspx */
> component_name_descriptor = 0xa3,
>
> diff --git a/lib/include/descriptors/desc_service_location.h b/lib/include/descriptors/desc_service_location.h
> new file mode 100644
> index 0000000..89ed055
> --- /dev/null
> +++ b/lib/include/descriptors/desc_service_location.h
> @@ -0,0 +1,69 @@
> +/*
> + * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation version 2
> + * of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> + *
> + */
> +
> +#ifndef _SERVICE_LOCATION_H
> +#define _SERVICE_LOCATION_H
> +
> +#include <stdint.h>
> +#include <unistd.h> /* ssize_t */
> +
> +struct dvb_desc_service_location_element {
> + uint8_t stream_type;
> + union {
> + uint16_t bitfield;
> + struct {
> + uint16_t elementary_pid:13;
> + uint16_t reserved:3;
> + };
> + };
> + uint8_t language[4];
> +} __attribute__((packed));
> +
> +struct dvb_desc_service_location {
> + uint8_t type;
> + uint8_t length;
> + struct dvb_desc *next;
> +
> + union {
> + uint16_t bitfield;
> + struct {
> + uint16_t pcr_pid:13;
> + uint16_t reserved:3;
> + };
> + };
> + uint8_t elements;
> + struct dvb_desc_service_location_element *element;
> +} __attribute__((packed));
> +
> +struct dvb_v5_fe_parms;
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +void dvb_desc_service_location_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc);
> +void dvb_desc_service_location_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc);
> +void dvb_desc_service_location_free (struct dvb_desc *desc);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 2ad5902..80e8adb 100644
> --- a/lib/libdvbv5/Makefile.am
> +++ b/lib/libdvbv5/Makefile.am
> @@ -48,7 +48,8 @@ libdvbv5_la_SOURCES = \
> descriptors/nit.c ../include/descriptors/nit.h \
> descriptors/sdt.c ../include/descriptors/sdt.h \
> descriptors/vct.c ../include/descriptors/vct.h \
> - descriptors/eit.c ../include/descriptors/eit.h
> + descriptors/eit.c ../include/descriptors/eit.h \
> + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h
>
> libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC)
> libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
> diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
> index 5ce9241..437b2f4 100644
> --- a/lib/libdvbv5/descriptors.c
> +++ b/lib/libdvbv5/descriptors.c
> @@ -69,7 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, st
>
> void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
> {
> - dvb_log("| %s (0x%02x)", dvb_descriptors[desc->type].name, desc->type);
> + dvb_log("| %s (%#02x)", dvb_descriptors[desc->type].name, desc->type);
> hexdump(parms, "| ", desc->data, desc->length);
> }
>
> diff --git a/lib/libdvbv5/descriptors/desc_service_location.c b/lib/libdvbv5/descriptors/desc_service_location.c
> new file mode 100644
> index 0000000..3759665
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/desc_service_location.c
> @@ -0,0 +1,70 @@
> +/*
> + * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation version 2
> + * of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> + *
> + */
> +
> +#include "descriptors/desc_service_location.h"
> +#include "descriptors.h"
> +#include "dvb-fe.h"
> +
> +void dvb_desc_service_location_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc)
> +{
> + struct dvb_desc_service_location *service_location = (struct dvb_desc_service_location *) desc;
please add a blank line here.
> + /* copy from .next */
> + memcpy(((uint8_t *) service_location )
> + + sizeof(service_location->type)
> + + sizeof(service_location->length)
> + + sizeof(service_location->next),
> + buf,
> + sizeof(service_location->bitfield) + sizeof(service_location->elements));
> + buf += sizeof(service_location->bitfield) + sizeof(service_location->elements);
Use offsetof().
> +
> + bswap16(service_location->bitfield);
> +
> + // FIXME: handle elements == 0
no C99 comments
> + service_location->element = malloc(service_location->elements * sizeof(struct dvb_desc_service_location_element));
> + int i;
> + struct dvb_desc_service_location_element *element = service_location->element;
> + for(i = 0; i < service_location->elements; i++) {
> + memcpy(element, buf, sizeof(struct dvb_desc_service_location_element) - 1); /* no \0 in lang */
Please test before copy.
> + buf += sizeof(struct dvb_desc_service_location_element) - 1;
> + element->language[3] = '\0';
> + bswap16(element->bitfield);
> + element++;
> + }
> +}
> +
> +void dvb_desc_service_location_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
> +{
> + const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc;
> + dvb_log("| pcr pid %d", service_location->pcr_pid);
> + dvb_log("| streams:");
> + int i;
blank line.
> + struct dvb_desc_service_location_element *element = service_location->element;
Please reorder: variable declarations should come before the dvb_log() calls.
> + for(i = 0; i < service_location->elements; i++) {
Space after "for". No need for {}, as there's just one statement on this for.
> + dvb_log("| pid %d, type %d: %s", element[i].elementary_pid, element[i].stream_type, element[i].language);
> + }
> + dvb_log("| %d elements", service_location->elements);
> +}
> +
> +void dvb_desc_service_location_free(struct dvb_desc *desc)
> +{
> + const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc;
Please add a blank line.
> + free(service_location->element);
> +}
> +
--
Cheers,
Mauro
next prev parent reply other threads:[~2014-01-07 16:38 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
2013-12-30 12:48 ` [PATCH 02/18] libdvbv5: service location descriptor support André Roth
2014-01-07 16:38 ` Mauro Carvalho Chehab [this message]
2013-12-30 12:48 ` [PATCH 03/18] libdvbv5: VCT table cleanup André Roth
2013-12-30 12:48 ` [PATCH 04/18] libdvbv5: mpeg elementary stream parsers André Roth
2014-01-07 16:47 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 05/18] libdvbv5: fix NIT structures André Roth
2013-12-30 12:48 ` [PATCH 06/18] libdvbv5: implement dvb_fe_dummy for logging André Roth
2013-12-30 12:48 ` [PATCH 07/18] libdvbv5: fix EIT parsing André Roth
2014-01-07 17:00 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 08/18] libdvbv5: implement MGT parser André Roth
2014-01-07 17:05 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 09/18] libdvbv5: implement ATSC EIT André Roth
2014-01-07 17:12 ` Mauro Carvalho Chehab
2014-01-08 11:09 ` André Roth
2013-12-30 12:48 ` [PATCH 10/18] libdvbv5: prefix VCT with atsc_ instead of dvb_ André Roth
2013-12-30 12:48 ` [PATCH 11/18] libdvbv5: cleanup coding style André Roth
2014-01-07 17:23 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 12/18] libdvbv5: fix missing includes André Roth
2013-12-30 12:48 ` [PATCH 13/18] libdvbv5: improve TS parsing André Roth
2014-01-07 17:27 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 14/18] libdvbv5: cleanup dvb_nit_transport_foreach macro André Roth
2013-12-30 12:48 ` [PATCH 15/18] libdvbv5: remove c99 comments André Roth
2014-01-07 17:29 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 17/18] libdvbv5: remove header files from SOURCES in Makefile.am André Roth
2014-01-07 17:30 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 18/18] libdvbv5: README updated for shared libdvbv5 André Roth
2014-01-07 18:12 ` Mauro Carvalho Chehab
2014-01-07 16:32 ` [PATCH 01/18] libdvbv5: fix reading multisection tables Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140107143818.7d2e3b27@samsung.com \
--to=m.chehab@samsung.com \
--cc=linux-media@vger.kernel.org \
--cc=neolynx@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.