Thread: [Redbutton-devel] SF.net SVN: redbutton: [48] redbutton-download/trunk/findmheg.c
Brought to you by:
skilvington
|
From: <ski...@us...> - 2006-05-10 13:36:23
|
Revision: 48 Author: skilvington Date: 2006-05-10 06:36:14 -0700 (Wed, 10 May 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=48&view=rev Log Message: ----------- allow more audio stream types Modified Paths: -------------- redbutton-download/trunk/findmheg.c Modified: redbutton-download/trunk/findmheg.c =================================================================== --- redbutton-download/trunk/findmheg.c 2006-05-10 11:07:12 UTC (rev 47) +++ redbutton-download/trunk/findmheg.c 2006-05-10 13:36:14 UTC (rev 48) @@ -38,8 +38,9 @@ #define TID_PMT 0x02 /* stream_types we are interested in */ -#define STREAM_TYPE_VIDEO 0x02 -#define STREAM_TYPE_AUDIO 0x03 +#define STREAM_TYPE_VIDEO_MPEG2 0x02 +#define STREAM_TYPE_AUDIO_MPEG1 0x03 +#define STREAM_TYPE_AUDIO_MPEG2 0x04 #define STREAM_TYPE_ISO13818_6_B 0x0b /* descriptors we want */ @@ -64,6 +65,20 @@ uint8_t audio_type; } __attribute__((__packed__)); +bool +is_audio_stream(uint8_t stream_type) +{ + switch(stream_type) + { + case STREAM_TYPE_AUDIO_MPEG1: + case STREAM_TYPE_AUDIO_MPEG2: + return true; + + default: + return false; + } +} + /* * fills in a struct carousel based on the given service_id * returns a ptr to a static struct that will be overwritten be the next call to this routine @@ -157,7 +172,7 @@ elementary_pid = ((pmt[offset] & 0x1f) << 8) + pmt[offset+1]; offset += 2; /* is it the default video stream for this service */ - if(stream_type == STREAM_TYPE_VIDEO) + if(stream_type == STREAM_TYPE_VIDEO_MPEG2) _car.video_pid = elementary_pid; /* read the descriptors */ info_length = ((pmt[offset] & 0x0f) << 8) + pmt[offset+1]; @@ -187,7 +202,7 @@ // printf("pid=0x%x component_tag=0x%x\n", elementary_pid, component_tag); add_assoc(&_car.assoc, elementary_pid, desc->component_tag); } - else if(desc_tag == TAG_LANGUAGE_DESCRIPTOR && stream_type == STREAM_TYPE_AUDIO) + else if(desc_tag == TAG_LANGUAGE_DESCRIPTOR && is_audio_stream(stream_type)) { struct language_descriptor *desc; desc = (struct language_descriptor *) &pmt[offset]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-06-24 09:31:55
|
Revision: 124 Author: skilvington Date: 2006-06-24 02:31:49 -0700 (Sat, 24 Jun 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=124&view=rev Log Message: ----------- show all PMT descriptors in -vv mode Modified Paths: -------------- redbutton-download/trunk/findmheg.c Modified: redbutton-download/trunk/findmheg.c =================================================================== --- redbutton-download/trunk/findmheg.c 2006-06-24 08:55:47 UTC (rev 123) +++ redbutton-download/trunk/findmheg.c 2006-06-24 09:31:49 UTC (rev 124) @@ -218,6 +218,11 @@ _car.audio_type = stream_type; } } + else + { + vverbose("pid=0x%x descriptor=0x%x", elementary_pid, desc_tag); + vhexdump(&pmt[offset], desc_length); + } offset += desc_length; info_length -= desc_length; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-12-14 13:44:44
|
Revision: 158
http://svn.sourceforge.net/redbutton/?rev=158&view=rev
Author: skilvington
Date: 2006-12-14 05:44:43 -0800 (Thu, 14 Dec 2006)
Log Message:
-----------
output PIDs in decimal rather than hex in verbose mode
Modified Paths:
--------------
redbutton-download/trunk/findmheg.c
Modified: redbutton-download/trunk/findmheg.c
===================================================================
--- redbutton-download/trunk/findmheg.c 2006-12-14 13:39:40 UTC (rev 157)
+++ redbutton-download/trunk/findmheg.c 2006-12-14 13:44:43 UTC (rev 158)
@@ -149,9 +149,9 @@
}
if(!found)
- fatal("Unable to find programme_map_PID for service_id %u", service_id);
+ fatal("Unable to find PMT PID for service_id %u", service_id);
- vverbose("programme_map_PID: 0x%x", map_pid);
+ vverbose("PMT PID: %u", map_pid);
/* get the PMT */
if((pmt = read_table(_car.demux_device, map_pid, TID_PMT, timeout)) == NULL)
@@ -196,7 +196,7 @@
{
_car.carousel_id = ntohl(desc->carousel_id);
add_dsmcc_pid(&_car, elementary_pid);
- vverbose("pid=0x%x carousel_id=%u", elementary_pid, _car.carousel_id);
+ vverbose("PID=%u carousel_id=%u", elementary_pid, _car.carousel_id);
}
}
else if(desc_tag == TAG_STREAM_ID_DESCRIPTOR)
@@ -204,7 +204,7 @@
struct stream_id_descriptor *desc;
desc = (struct stream_id_descriptor *) &pmt[offset];
component_tag = desc->component_tag;
- vverbose("pid=0x%x component_tag=0x%x", elementary_pid, component_tag);
+ vverbose("PID=%u component_tag=%u", elementary_pid, component_tag);
add_assoc(&_car.assoc, elementary_pid, desc->component_tag, stream_type);
}
else if(desc_tag == TAG_LANGUAGE_DESCRIPTOR && is_audio_stream(stream_type))
@@ -220,7 +220,7 @@
}
else
{
- vverbose("pid=0x%x descriptor=0x%x", elementary_pid, desc_tag);
+ vverbose("PID=%u descriptor=0x%x", elementary_pid, desc_tag);
vhexdump(&pmt[offset], desc_length);
}
offset += desc_length;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-01-26 16:37:44
|
Revision: 198
http://svn.sourceforge.net/redbutton/?rev=198&view=rev
Author: skilvington
Date: 2007-01-26 08:37:38 -0800 (Fri, 26 Jan 2007)
Log Message:
-----------
show audio and video stream types in -vv mode
Modified Paths:
--------------
redbutton-download/trunk/findmheg.c
Modified: redbutton-download/trunk/findmheg.c
===================================================================
--- redbutton-download/trunk/findmheg.c 2007-01-26 16:33:59 UTC (rev 197)
+++ redbutton-download/trunk/findmheg.c 2007-01-26 16:37:38 UTC (rev 198)
@@ -193,6 +193,7 @@
{
_car.video_pid = elementary_pid;
_car.video_type = stream_type;
+ vverbose("PID=%u video stream_type=0x%x", elementary_pid, stream_type);
}
/* it's not the boot PID yet */
desc_boot_pid = -1;
@@ -253,6 +254,7 @@
{
_car.audio_pid = elementary_pid;
_car.audio_type = stream_type;
+ vverbose("PID=%u audio stream_type=0x%x", elementary_pid, stream_type);
}
}
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-02-12 17:31:15
|
Revision: 210
http://svn.sourceforge.net/redbutton/?rev=210&view=rev
Author: skilvington
Date: 2007-02-12 09:31:11 -0800 (Mon, 12 Feb 2007)
Log Message:
-----------
allow streaming a/v from different service IDs
Modified Paths:
--------------
redbutton-download/trunk/findmheg.c
Modified: redbutton-download/trunk/findmheg.c
===================================================================
--- redbutton-download/trunk/findmheg.c 2007-02-12 10:07:32 UTC (rev 209)
+++ redbutton-download/trunk/findmheg.c 2007-02-12 17:31:11 UTC (rev 210)
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
+#include <string.h>
#include <netinet/in.h>
#include "carousel.h"
@@ -78,6 +79,10 @@
#define DATA_BROADCAST_ID 0x0106
#define APPLICATION_TYPE_CODE 0x0101
+static struct avstreams *find_current_avstreams(struct carousel *, int, int);
+static struct avstreams *find_service_avstreams(struct carousel *, int, int, int);
+static unsigned char *read_pmt(char *, uint16_t, unsigned int);
+
bool
is_audio_stream(uint8_t stream_type)
{
@@ -102,12 +107,9 @@
struct carousel *
find_mheg(unsigned int adapter, unsigned int timeout, uint16_t service_id, int carousel_id)
{
- unsigned char *pat;
+ unsigned char *pmt;
uint16_t section_length;
uint16_t offset;
- uint16_t map_pid = 0;
- bool found;
- unsigned char *pmt;
uint8_t stream_type;
uint16_t elementary_pid;
uint16_t info_length;
@@ -141,36 +143,8 @@
_car.nmodules = 0;
_car.modules = NULL;
- /* get the PAT */
- if((pat = read_table(_car.demux_device, PID_PAT, TID_PAT, timeout)) == NULL)
- fatal("Unable to read PAT");
-
- section_length = 3 + (((pat[1] & 0x0f) << 8) + pat[2]);
-
- /* find the PMT for this service_id */
- found = false;
- offset = 8;
- /* -4 for the CRC at the end */
- while((offset < (section_length - 4)) && !found)
- {
- if((pat[offset] << 8) + pat[offset+1] == service_id)
- {
- map_pid = ((pat[offset+2] & 0x1f) << 8) + pat[offset+3];
- found = true;
- }
- else
- {
- offset += 4;
- }
- }
-
- if(!found)
- fatal("Unable to find PMT PID for service_id %u", service_id);
-
- vverbose("PMT PID: %u", map_pid);
-
/* get the PMT */
- if((pmt = read_table(_car.demux_device, map_pid, TID_PMT, timeout)) == NULL)
+ if((pmt = read_pmt(_car.demux_device, service_id, timeout)) == NULL)
fatal("Unable to read PMT");
section_length = 3 + (((pmt[1] & 0x0f) << 8) + pmt[2]);
@@ -288,8 +262,15 @@
struct avstreams *
find_avstreams(struct carousel *car, int service_id, int audio_tag, int video_tag)
{
-if(service_id != -1) printf("TODO: find_avstreams %d\n", service_id);
+ if(service_id == -1)
+ return find_current_avstreams(car, audio_tag, video_tag);
+ else
+ return find_service_avstreams(car, service_id, audio_tag, video_tag);
+}
+static struct avstreams *
+find_current_avstreams(struct carousel *car, int audio_tag, int video_tag)
+{
/* map the tags to PIDs and stream types, or use the defaults */
if(audio_tag == -1)
{
@@ -318,3 +299,152 @@
return &_streams;
}
+static struct avstreams *
+find_service_avstreams(struct carousel *car, int service_id, int audio_tag, int video_tag)
+{
+ unsigned char *pmt;
+ uint16_t section_length;
+ uint16_t offset;
+ uint8_t stream_type;
+ uint16_t elementary_pid;
+ uint16_t info_length;
+ uint8_t desc_tag;
+ uint8_t desc_length;
+ uint16_t component_tag;
+
+ verbose("find_service_avstreams: %d %d %d", service_id, audio_tag, video_tag);
+
+ /* in case we don't find them */
+ bzero(&_streams, sizeof(_streams));
+
+ /* get the PMT */
+ if((pmt = read_pmt(car->demux_device, service_id, car->timeout)) == NULL)
+ fatal("Unable to read PMT");
+
+ section_length = 3 + (((pmt[1] & 0x0f) << 8) + pmt[2]);
+
+ /* skip the program_info descriptors */
+ offset = 10;
+ info_length = ((pmt[offset] & 0x0f) << 8) + pmt[offset+1];
+ offset += 2 + info_length;
+
+ /* find the streams */
+ while(offset < (section_length - 4))
+ {
+ stream_type = pmt[offset];
+ offset += 1;
+ elementary_pid = ((pmt[offset] & 0x1f) << 8) + pmt[offset+1];
+ offset += 2;
+ /* do we want the default video stream for this service */
+ if(video_tag == -1 && stream_type == STREAM_TYPE_VIDEO_MPEG2)
+ {
+ _streams.video_pid = elementary_pid;
+ _streams.video_type = stream_type;
+ vverbose("PID=%u video stream_type=0x%x", elementary_pid, stream_type);
+ }
+ /* read the descriptors */
+ info_length = ((pmt[offset] & 0x0f) << 8) + pmt[offset+1];
+ offset += 2;
+ while(info_length != 0)
+ {
+ desc_tag = pmt[offset];
+ desc_length = pmt[offset+1];
+ offset += 2;
+ info_length -= 2;
+ if(desc_tag == TAG_STREAM_ID_DESCRIPTOR)
+ {
+ struct stream_id_descriptor *desc;
+ desc = (struct stream_id_descriptor *) &pmt[offset];
+ component_tag = desc->component_tag;
+ vverbose("PID=%u component_tag=%u", elementary_pid, component_tag);
+ /* is it one we want */
+ if(audio_tag == component_tag)
+ {
+ _streams.audio_pid = elementary_pid;
+ _streams.audio_type = stream_type;
+ vverbose("PID=%u audio stream_type=0x%x", elementary_pid, stream_type);
+ }
+ else if(video_tag == component_tag)
+ {
+ _streams.video_pid = elementary_pid;
+ _streams.video_type = stream_type;
+ vverbose("PID=%u video stream_type=0x%x", elementary_pid, stream_type);
+ }
+ }
+ /* do we want the default audio */
+ else if(audio_tag == -1 && desc_tag == TAG_LANGUAGE_DESCRIPTOR && is_audio_stream(stream_type))
+ {
+ struct language_descriptor *desc;
+ desc = (struct language_descriptor *) &pmt[offset];
+ /* only remember the normal audio stream (not visually impaired stream) */
+ if(desc->audio_type == 0)
+ {
+ _streams.audio_pid = elementary_pid;
+ _streams.audio_type = stream_type;
+ vverbose("PID=%u audio stream_type=0x%x", elementary_pid, stream_type);
+ }
+ }
+ else
+ {
+ vverbose("PID=%u descriptor=0x%x", elementary_pid, desc_tag);
+ vhexdump(&pmt[offset], desc_length);
+ }
+ offset += desc_length;
+ info_length -= desc_length;
+ }
+ }
+
+ verbose("Audio PID=%u type=0x%x", _streams.audio_pid, _streams.audio_type);
+ verbose("Video PID=%u type=0x%x", _streams.video_pid, _streams.video_type);
+
+ return &_streams;
+}
+
+static unsigned char *
+read_pmt(char *demux, uint16_t service_id, unsigned int timeout)
+{
+ unsigned char *pat;
+ uint16_t section_length;
+ uint16_t offset;
+ uint16_t map_pid = 0;
+ bool found;
+ unsigned char *pmt;
+
+ /* get the PAT */
+ if((pat = read_table(_car.demux_device, PID_PAT, TID_PAT, timeout)) == NULL)
+ {
+ error("Unable to read PAT");
+ return NULL;
+ }
+
+ section_length = 3 + (((pat[1] & 0x0f) << 8) + pat[2]);
+
+ /* find the PMT for this service_id */
+ found = false;
+ offset = 8;
+ /* -4 for the CRC at the end */
+ while((offset < (section_length - 4)) && !found)
+ {
+ if((pat[offset] << 8) + pat[offset+1] == service_id)
+ {
+ map_pid = ((pat[offset+2] & 0x1f) << 8) + pat[offset+3];
+ found = true;
+ }
+ else
+ {
+ offset += 4;
+ }
+ }
+
+ if(!found)
+ fatal("Unable to find PMT PID for service_id %u", service_id);
+
+ vverbose("PMT PID: %u", map_pid);
+
+ /* get the PMT */
+ if((pmt = read_table(_car.demux_device, map_pid, TID_PMT, timeout)) == NULL)
+ error("Unable to read PMT");
+
+ return pmt;
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-02-19 13:25:12
|
Revision: 225
http://svn.sourceforge.net/redbutton/?rev=225&view=rev
Author: skilvington
Date: 2007-02-19 05:25:10 -0800 (Mon, 19 Feb 2007)
Log Message:
-----------
style
Modified Paths:
--------------
redbutton-download/trunk/findmheg.c
Modified: redbutton-download/trunk/findmheg.c
===================================================================
--- redbutton-download/trunk/findmheg.c 2007-02-19 13:17:28 UTC (rev 224)
+++ redbutton-download/trunk/findmheg.c 2007-02-19 13:25:10 UTC (rev 225)
@@ -447,8 +447,7 @@
vverbose("PMT PID: %u", map_pid);
/* get the PMT */
- rc = read_table(_car.demux_device, map_pid, TID_PMT, timeout, out);
- if(!rc)
+ if(!(rc = read_table(_car.demux_device, map_pid, TID_PMT, timeout, out)))
error("Unable to read PMT");
return rc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-02-19 13:30:28
|
Revision: 226
http://svn.sourceforge.net/redbutton/?rev=226&view=rev
Author: skilvington
Date: 2007-02-19 05:30:26 -0800 (Mon, 19 Feb 2007)
Log Message:
-----------
cut 'n' paste error
Modified Paths:
--------------
redbutton-download/trunk/findmheg.c
Modified: redbutton-download/trunk/findmheg.c
===================================================================
--- redbutton-download/trunk/findmheg.c 2007-02-19 13:25:10 UTC (rev 225)
+++ redbutton-download/trunk/findmheg.c 2007-02-19 13:30:26 UTC (rev 226)
@@ -416,7 +416,7 @@
bool rc;
/* get the PAT */
- if(!read_table(_car.demux_device, PID_PAT, TID_PAT, timeout, pat))
+ if(!read_table(demux, PID_PAT, TID_PAT, timeout, pat))
{
error("Unable to read PAT");
return false;
@@ -447,7 +447,7 @@
vverbose("PMT PID: %u", map_pid);
/* get the PMT */
- if(!(rc = read_table(_car.demux_device, map_pid, TID_PMT, timeout, out)))
+ if(!(rc = read_table(demux, map_pid, TID_PMT, timeout, out)))
error("Unable to read PMT");
return rc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-03-12 12:21:21
|
Revision: 242
http://svn.sourceforge.net/redbutton/?rev=242&view=rev
Author: skilvington
Date: 2007-03-12 05:21:15 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
don't be so specific about the application_type_code we accept
Modified Paths:
--------------
redbutton-download/trunk/findmheg.c
Modified: redbutton-download/trunk/findmheg.c
===================================================================
--- redbutton-download/trunk/findmheg.c 2007-03-09 16:40:47 UTC (rev 241)
+++ redbutton-download/trunk/findmheg.c 2007-03-12 12:21:15 UTC (rev 242)
@@ -77,8 +77,9 @@
} __attribute__((__packed__));
/* data_broadcast_id_descriptor values we want */
-#define DATA_BROADCAST_ID 0x0106
-#define APPLICATION_TYPE_CODE 0x0101
+#define DATA_BROADCAST_ID 0x0106
+#define UK_APPLICATION_TYPE_CODE 0x0101
+#define NZ_APPLICATION_TYPE_CODE 0x0505
static struct avstreams *find_current_avstreams(struct carousel *, int, int);
static struct avstreams *find_service_avstreams(struct carousel *, int, int, int);
@@ -189,11 +190,17 @@
{
struct data_broadcast_id_descriptor *desc;
desc = (struct data_broadcast_id_descriptor *) &pmt[offset];
- if(ntohs(desc->data_broadcast_id) == DATA_BROADCAST_ID
- && ntohs(desc->application_type_code) == APPLICATION_TYPE_CODE)
+ if(ntohs(desc->data_broadcast_id) == DATA_BROADCAST_ID)
{
desc_boot_pid = elementary_pid;
vverbose("PID=%u boot_priority_hint=%u", elementary_pid, desc->boot_priority_hint);
+ /* haven't seen the NZ MHEG Profile, but let's download the data anyway */
+ if(ntohs(desc->application_type_code) == UK_APPLICATION_TYPE_CODE)
+ vverbose("UK application_type_code (0x%04x)", UK_APPLICATION_TYPE_CODE);
+ else if(ntohs(desc->application_type_code) == NZ_APPLICATION_TYPE_CODE)
+ vverbose("NZ application_type_code (0x%04x)", NZ_APPLICATION_TYPE_CODE);
+ else
+ vverbose("Unknown application_type_code (0x%04x)", ntohs(desc->application_type_code));
}
else
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|