[Redbutton-devel] SF.net SVN: redbutton: [52] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2006-05-11 11:02:56
|
Revision: 52 Author: skilvington Date: 2006-05-11 04:02:42 -0700 (Thu, 11 May 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=52&view=rev Log Message: ----------- return MPEG stream types to client Modified Paths: -------------- redbutton-browser/trunk/MHEGBackend.c redbutton-browser/trunk/MHEGBackend.h redbutton-browser/trunk/MHEGEngine.c redbutton-browser/trunk/MHEGEngine.h redbutton-download/trunk/assoc.c redbutton-download/trunk/assoc.h redbutton-download/trunk/command.c redbutton-download/trunk/findmheg.c redbutton-download/trunk/module.h Modified: redbutton-browser/trunk/MHEGBackend.c =================================================================== --- redbutton-browser/trunk/MHEGBackend.c 2006-05-11 08:54:07 UTC (rev 51) +++ redbutton-browser/trunk/MHEGBackend.c 2006-05-11 11:02:42 UTC (rev 52) @@ -17,7 +17,7 @@ bool local_checkContentRef(MHEGBackend *, ContentReference *); bool local_loadFile(MHEGBackend *, OctetString *, OctetString *); FILE *local_openFile(MHEGBackend *, OctetString *); -FILE *local_openStream(MHEGBackend *, bool, int *, bool, int *); +FILE *local_openStream(MHEGBackend *, bool, int *, int *, bool, int *, int *); static struct MHEGBackendFns local_backend_fns = { @@ -31,7 +31,7 @@ bool remote_checkContentRef(MHEGBackend *, ContentReference *); bool remote_loadFile(MHEGBackend *, OctetString *, OctetString *); FILE *remote_openFile(MHEGBackend *, OctetString *); -FILE *remote_openStream(MHEGBackend *, bool, int *, bool, int *); +FILE *remote_openStream(MHEGBackend *, bool, int *, int *, bool, int *, int *); static struct MHEGBackendFns remote_backend_fns = { @@ -327,11 +327,12 @@ * the *audio_tag and *video_tag numbers refer to Component/Association Tag values from the DVB PMT * if *audio_tag or *video_tag is -1, the default audio and/or video stream for the current Service ID is used * updates *audio_tag and/or *video_tag to the actual PIDs in the Transport Stream + * updates *audio_type and/or *video_type to the stream type IDs * returns NULL on error */ FILE * -local_openStream(MHEGBackend *t, bool have_audio, int *audio_tag, bool have_video, int *video_tag) +local_openStream(MHEGBackend *t, bool have_audio, int *audio_tag, int *audio_type, bool have_video, int *video_tag, int *video_type) { /* * we need to convert the audio/video_tag into PIDs @@ -341,7 +342,7 @@ * 3. just stream the TS from the backend * we choose 3, to avoid duplicating code and having to pass "-d <device>" options etc */ - return remote_openStream(t, have_audio, audio_tag, have_video, video_tag); + return remote_openStream(t, have_audio, audio_tag, audio_type, have_video, video_tag, video_type); } /* @@ -475,11 +476,12 @@ * the *audio_tag and *video_tag numbers refer to Component/Association Tag values from the DVB PMT * if *audio_tag or *video_tag is -1, the default audio and/or video stream for the current Service ID is used * updates *audio_tag and/or *video_tag to the actual PIDs in the Transport Stream + * updates *audio_type and/or *video_type to the stream type IDs * returns NULL on error */ FILE * -remote_openStream(MHEGBackend *t, bool have_audio, int *audio_tag, bool have_video, int *video_tag) +remote_openStream(MHEGBackend *t, bool have_audio, int *audio_tag, int *audio_type, bool have_video, int *video_tag, int *video_type) { char cmd[PATH_MAX]; FILE *sock; @@ -515,11 +517,12 @@ /* update the PID variables */ if(have_audio && have_video) - err = (sscanf(pids, "AudioPID %u VideoPID %u", &audio_pid, &video_pid) != 2); + err = (sscanf(pids, "AudioPID %u AudioType %u VideoPID %u VideoType %u", + &audio_pid, audio_type, &video_pid, video_type) != 4); else if(have_audio) - err = (sscanf(pids, "AudioPID %u", &audio_pid) != 1); + err = (sscanf(pids, "AudioPID %u AudioType %u", &audio_pid, audio_type) != 2); else - err = (sscanf(pids, "VideoPID %u", &video_pid) != 1); + err = (sscanf(pids, "VideoPID %u VideoType %u", &video_pid, video_type) != 2); if(!err) { Modified: redbutton-browser/trunk/MHEGBackend.h =================================================================== --- redbutton-browser/trunk/MHEGBackend.h 2006-05-11 08:54:07 UTC (rev 51) +++ redbutton-browser/trunk/MHEGBackend.h 2006-05-11 11:02:42 UTC (rev 52) @@ -20,10 +20,14 @@ /* function pointers */ struct MHEGBackendFns { - bool (*checkContentRef)(struct MHEGBackend *, ContentReference *); /* check a carousel file exists */ - bool (*loadFile)(struct MHEGBackend *, OctetString *, OctetString *); /* load a carousel file */ - FILE *(*openFile)(struct MHEGBackend *, OctetString *); /* open a carousel file */ - FILE *(*openStream)(struct MHEGBackend *, bool, int *, bool, int *); /* open an MPEG Transport Stream */ + /* check a carousel file exists */ + bool (*checkContentRef)(struct MHEGBackend *, ContentReference *); + /* load a carousel file */ + bool (*loadFile)(struct MHEGBackend *, OctetString *, OctetString *); + /* open a carousel file */ + FILE *(*openFile)(struct MHEGBackend *, OctetString *); + /* open an MPEG Transport Stream */ + FILE *(*openStream)(struct MHEGBackend *, bool, int *, int *, bool, int *, int *); } *fns; } MHEGBackend; Modified: redbutton-browser/trunk/MHEGEngine.c =================================================================== --- redbutton-browser/trunk/MHEGEngine.c 2006-05-11 08:54:07 UTC (rev 51) +++ redbutton-browser/trunk/MHEGEngine.c 2006-05-11 11:02:42 UTC (rev 52) @@ -1340,9 +1340,11 @@ */ FILE * -MHEGEngine_openStream(bool have_audio, int *audio_tag, bool have_video, int *video_tag) +MHEGEngine_openStream(bool have_audio, int *audio_tag, int *audio_type, bool have_video, int *video_tag, int *video_type) { - return (*(engine.backend.fns->openStream))(&engine.backend, have_audio, audio_tag, have_video, video_tag); + return (*(engine.backend.fns->openStream))(&engine.backend, + have_audio, audio_tag, audio_type, + have_video, video_tag, video_type); } /* Modified: redbutton-browser/trunk/MHEGEngine.h =================================================================== --- redbutton-browser/trunk/MHEGEngine.h 2006-05-11 08:54:07 UTC (rev 51) +++ redbutton-browser/trunk/MHEGEngine.h 2006-05-11 11:02:42 UTC (rev 52) @@ -221,7 +221,7 @@ bool MHEGEngine_checkContentRef(ContentReference *); bool MHEGEngine_loadFile(OctetString *, OctetString *); FILE *MHEGEngine_openFile(OctetString *); -FILE *MHEGEngine_openStream(bool, int *, bool, int *); +FILE *MHEGEngine_openStream(bool, int *, int *, bool, int *, int *); char *MHEGEngine_absoluteFilename(OctetString *); Modified: redbutton-download/trunk/assoc.c =================================================================== --- redbutton-download/trunk/assoc.c 2006-05-11 08:54:07 UTC (rev 51) +++ redbutton-download/trunk/assoc.c 2006-05-11 11:02:42 UTC (rev 52) @@ -35,20 +35,23 @@ a->nassocs = 0; a->pids = NULL; a->sids = NULL; + a->types = NULL; return; } void -add_assoc(struct assoc *a, uint16_t elementary_pid, uint16_t stream_id) +add_assoc(struct assoc *a, uint16_t elementary_pid, uint16_t stream_id, uint8_t stream_type) { a->nassocs ++; a->pids = safe_realloc(a->pids, a->nassocs * sizeof(uint16_t)); a->sids = safe_realloc(a->sids, a->nassocs * sizeof(uint16_t)); + a->types = safe_realloc(a->types, a->nassocs * sizeof(uint8_t)); a->pids[a->nassocs - 1] = elementary_pid; a->sids[a->nassocs - 1] = stream_id; + a->types[a->nassocs - 1] = stream_type; return; } @@ -69,4 +72,19 @@ return 0; } +uint8_t +stream2type(struct assoc *a, uint16_t stream_id) +{ + unsigned int i; + for(i=0; i<a->nassocs; i++) + { + if(a->sids[i] == stream_id) + return a->types[i]; + } + + error("Unknown stream type for association tag 0x%x", stream_id); + + return 0; +} + Modified: redbutton-download/trunk/assoc.h =================================================================== --- redbutton-download/trunk/assoc.h 2006-05-11 08:54:07 UTC (rev 51) +++ redbutton-download/trunk/assoc.h 2006-05-11 11:02:42 UTC (rev 52) @@ -32,12 +32,14 @@ unsigned int nassocs; uint16_t *pids; uint16_t *sids; + uint8_t *types; /* stream type */ }; void init_assoc(struct assoc *); -void add_assoc(struct assoc *, uint16_t, uint16_t); +void add_assoc(struct assoc *, uint16_t, uint16_t, uint8_t); uint16_t stream2pid(struct assoc *, uint16_t); +uint8_t stream2type(struct assoc *, uint16_t); #endif /* __ASSOC_H__ */ Modified: redbutton-download/trunk/command.c =================================================================== --- redbutton-download/trunk/command.c 2006-05-11 08:54:07 UTC (rev 51) +++ redbutton-download/trunk/command.c 2006-05-11 11:02:42 UTC (rev 52) @@ -140,6 +140,7 @@ struct carousel *car = listen_data->carousel; int tag; uint16_t pid; + uint8_t type; int audio_fd; int ts_fd; char hdr[64]; @@ -148,11 +149,17 @@ tag = strtol(argv[1], NULL, 0); - /* map the tag to a PID, or use the default */ + /* map the tag to a PID and stream type, or use the default */ if(tag == -1) + { pid = car->audio_pid; + type = car->audio_type; + } else + { pid = stream2pid(&car->assoc, tag); + type = stream2type(&car->assoc, tag); + } /* add the PID to the demux device */ if((audio_fd = add_demux_filter(car->demux_device, pid, DMX_PES_AUDIO)) < 0) @@ -172,8 +179,8 @@ /* send the OK code */ SEND_RESPONSE(200, "OK"); - /* tell the client what PID the component tag resolved to */ - snprintf(hdr, sizeof(hdr), "AudioPID %u\n", pid); + /* tell the client what PID and stream type the component tag resolved to */ + snprintf(hdr, sizeof(hdr), "AudioPID %u AudioType %u\n", pid, type); fputs(hdr, client); /* shovel the transport stream to client until the client closes or we get an error */ @@ -201,6 +208,7 @@ struct carousel *car = listen_data->carousel; int tag; uint16_t pid; + uint8_t type; int video_fd; int ts_fd; char hdr[64]; @@ -209,11 +217,17 @@ tag = strtol(argv[1], NULL, 0); - /* map the tag to a PID, or use the default */ + /* map the tag to a PID and stream type, or use the default */ if(tag == -1) + { pid = car->video_pid; + type = car->video_type; + } else + { pid = stream2pid(&car->assoc, tag); + type = stream2type(&car->assoc, tag); + } /* add the PID to the demux device */ if((video_fd = add_demux_filter(car->demux_device, pid, DMX_PES_VIDEO)) < 0) @@ -233,8 +247,8 @@ /* send the OK code */ SEND_RESPONSE(200, "OK"); - /* tell the client what PID the component tag resolved to */ - snprintf(hdr, sizeof(hdr), "VideoPID %u\n", pid); + /* tell the client what PID and stream type the component tag resolved to */ + snprintf(hdr, sizeof(hdr), "VideoPID %u VideoType %u\n", pid, type); fputs(hdr, client); /* shovel the transport stream down client_sock until the client closes it or we get an error */ @@ -264,6 +278,8 @@ int video_tag; uint16_t audio_pid; uint16_t video_pid; + uint8_t audio_type; + uint8_t video_type; int audio_fd; int video_fd; int ts_fd; @@ -274,16 +290,28 @@ audio_tag = strtol(argv[1], NULL, 0); video_tag = strtol(argv[2], NULL, 0); - /* map the tags to PIDs, or use the defaults */ + /* map the tags to PIDs and stream types, or use the defaults */ if(audio_tag == -1) + { audio_pid = car->audio_pid; + audio_type = car->audio_type; + } else + { audio_pid = stream2pid(&car->assoc, audio_tag); + audio_type = stream2type(&car->assoc, audio_tag); + } if(video_tag == -1) + { video_pid = car->video_pid; + video_type = car->video_type; + } else + { video_pid = stream2pid(&car->assoc, video_tag); + video_type = stream2type(&car->assoc, video_tag); + } /* add the PIDs to the demux device */ if((audio_fd = add_demux_filter(car->demux_device, audio_pid, DMX_PES_AUDIO)) < 0) @@ -310,8 +338,8 @@ /* send the OK code */ SEND_RESPONSE(200, "OK"); - /* tell the client what PIDs the component tags resolved to */ - snprintf(hdr, sizeof(hdr), "AudioPID %u VideoPID %u\n", audio_pid, video_pid); + /* tell the client what PIDs and stream types the component tags resolved to */ + snprintf(hdr, sizeof(hdr), "AudioPID %u AudioType %u VideoPID %uVideoType %u\n", audio_pid, audio_type, video_pid, video_type); fputs(hdr, client); /* shovel the transport stream down client_sock until the client closes it or we get an error */ Modified: redbutton-download/trunk/findmheg.c =================================================================== --- redbutton-download/trunk/findmheg.c 2006-05-11 08:54:07 UTC (rev 51) +++ redbutton-download/trunk/findmheg.c 2006-05-11 11:02:42 UTC (rev 52) @@ -111,7 +111,9 @@ /* unknown */ _car.carousel_id = 0; _car.audio_pid = 0; + _car.audio_type = 0; _car.video_pid = 0; + _car.video_type = 0; _car.current_pid = 0; /* map between stream_id_descriptors and elementary_PIDs */ init_assoc(&_car.assoc); @@ -173,7 +175,10 @@ offset += 2; /* is it the default video stream for this service */ if(stream_type == STREAM_TYPE_VIDEO_MPEG2) + { _car.video_pid = elementary_pid; + _car.video_type = stream_type; + } /* read the descriptors */ info_length = ((pmt[offset] & 0x0f) << 8) + pmt[offset+1]; offset += 2; @@ -200,7 +205,7 @@ desc = (struct stream_id_descriptor *) &pmt[offset]; component_tag = desc->component_tag; // printf("pid=0x%x component_tag=0x%x\n", elementary_pid, component_tag); - add_assoc(&_car.assoc, elementary_pid, desc->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)) { @@ -208,7 +213,10 @@ desc = (struct language_descriptor *) &pmt[offset]; /* only remember the normal audio stream (not visually impaired stream) */ if(desc->audio_type == 0) + { _car.audio_pid = elementary_pid; + _car.audio_type = stream_type; + } } offset += desc_length; info_length -= desc_length; Modified: redbutton-download/trunk/module.h =================================================================== --- redbutton-download/trunk/module.h 2006-05-11 08:54:07 UTC (rev 51) +++ redbutton-download/trunk/module.h 2006-05-11 11:02:42 UTC (rev 52) @@ -61,7 +61,9 @@ uint16_t service_id; uint32_t carousel_id; uint16_t audio_pid; /* PID of default audio stream for this service_id */ + uint8_t audio_type; /* type ID of default audio stream */ uint16_t video_pid; /* PID of default video stream for this service_id */ + uint8_t video_type; /* type ID of default video stream */ uint16_t current_pid; /* PID we downloaded the last table from */ struct assoc assoc; /* map stream_id's to elementary_pid's */ int32_t npids; /* PIDs we are reading data from */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |