Thread: [Redbutton-devel] SF.net SVN: redbutton: [8] redbutton-download/trunk/command.c
Brought to you by:
skilvington
|
From: <ski...@us...> - 2006-03-02 11:22:48
|
Revision: 8 Author: skilvington Date: 2006-03-02 03:22:44 -0800 (Thu, 02 Mar 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=8&view=rev Log Message: ----------- extra .. check when canonicalising ContentReferences Modified Paths: -------------- redbutton-download/trunk/command.c Modified: redbutton-download/trunk/command.c =================================================================== --- redbutton-download/trunk/command.c 2006-03-02 11:11:58 UTC (rev 7) +++ redbutton-download/trunk/command.c 2006-03-02 11:22:44 UTC (rev 8) @@ -245,7 +245,7 @@ canon_cref = canonical_filename(cref + 3); /* if the canonical name starts with "../", it is invalid */ - if(strncmp(canon_cref, "../", 3) == 0) + if(strcmp(canon_cref, "..") == 0 || strncmp(canon_cref, "../", 3) == 0) return NULL; /* create the carousel filename, ie prepend the servive gateway directory */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-03-02 11:50:46
|
Revision: 9 Author: skilvington Date: 2006-03-02 03:50:43 -0800 (Thu, 02 Mar 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=9&view=rev Log Message: ----------- remove // and /./ in canonical ContentReferences Modified Paths: -------------- redbutton-download/trunk/command.c Modified: redbutton-download/trunk/command.c =================================================================== --- redbutton-download/trunk/command.c 2006-03-02 11:22:44 UTC (rev 8) +++ redbutton-download/trunk/command.c 2006-03-02 11:50:43 UTC (rev 9) @@ -287,15 +287,24 @@ /* no more slashes => nothing left to do */ if(*slash == '\0') return _canon; - /* if the next path component is "../", eat the previous one */ - if(strncmp(slash, "/../", 4) == 0) + /* if this component is empty (ie ./ or /) remove it */ + if(strncmp(start, "./", 2) == 0 || *start == '/') { /* include \0 terminator */ - len = strlen(start) + 1; - memmove(start, slash + 4, len - ((slash - start) + 4)); + len = strlen(slash + 1) + 1; + memmove(start, slash + 1, len); /* restart the search */ start = _canon; } + /* if the next path component is "../", eat this one */ + else if(strncmp(slash, "/../", 4) == 0) + { + /* include \0 terminator */ + len = strlen(slash + 4) + 1; + memmove(start, slash + 4, len); + /* restart the search */ + start = _canon; + } else { /* move to the next component */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-03-15 14:47:22
|
Revision: 20 Author: skilvington Date: 2006-03-15 06:47:18 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=20&view=rev Log Message: ----------- expect correct number of args to stream commands Modified Paths: -------------- redbutton-download/trunk/command.c Modified: redbutton-download/trunk/command.c =================================================================== --- redbutton-download/trunk/command.c 2006-03-15 14:30:18 UTC (rev 19) +++ redbutton-download/trunk/command.c 2006-03-15 14:47:18 UTC (rev 20) @@ -144,7 +144,7 @@ int ts_fd; char hdr[64]; - CHECK_USAGE(1, "astream <ComponentTag>"); + CHECK_USAGE(2, "astream <ComponentTag>"); tag = strtol(argv[1], NULL, 0); @@ -204,7 +204,7 @@ int ts_fd; char hdr[64]; - CHECK_USAGE(1, "vstream <ComponentTag>"); + CHECK_USAGE(2, "vstream <ComponentTag>"); tag = strtol(argv[1], NULL, 0); @@ -267,7 +267,7 @@ int ts_fd; char hdr[64]; - CHECK_USAGE(2, "avstream <AudioTag> <VideoTag>"); + CHECK_USAGE(3, "avstream <AudioTag> <VideoTag>"); audio_tag = strtol(argv[1], NULL, 0); video_tag = strtol(argv[2], NULL, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-03-25 14:32:17
|
Revision: 29 Author: skilvington Date: 2006-03-25 06:31:57 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=29&view=rev Log Message: ----------- capitalisation Modified Paths: -------------- redbutton-download/trunk/command.c Modified: redbutton-download/trunk/command.c =================================================================== --- redbutton-download/trunk/command.c 2006-03-25 14:22:11 UTC (rev 28) +++ redbutton-download/trunk/command.c 2006-03-25 14:31:57 UTC (rev 29) @@ -38,10 +38,10 @@ { "astream", "<ComponentTag>", cmd_astream, "Stream the given audio component tag" }, { "avstream", "<AudioTag> <VideoTag>", cmd_avstream, "Stream the given audio and video component tags" }, { "check", "<ContentReference>", cmd_check, "Check if the given file exists on the carousel" }, - { "exit", "", cmd_quit, "close the connection" }, + { "exit", "", cmd_quit, "Close the connection" }, { "file", "<ContentReference>", cmd_file, "Retrieve the given file from the carousel" }, { "help", "", cmd_help, "List available commands" }, - { "quit", "", cmd_quit, "close the connection" }, + { "quit", "", cmd_quit, "Close the connection" }, { "vstream", "<ComponentTag>", cmd_vstream, "Stream the given video component tag" }, { NULL, NULL, NULL, NULL } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-05-15 10:55:56
|
Revision: 59 Author: skilvington Date: 2006-05-15 03:55:48 -0700 (Mon, 15 May 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=59&view=rev Log Message: ----------- return an error if default A/V streams cannot be found Modified Paths: -------------- redbutton-download/trunk/command.c Modified: redbutton-download/trunk/command.c =================================================================== --- redbutton-download/trunk/command.c 2006-05-15 08:49:45 UTC (rev 58) +++ redbutton-download/trunk/command.c 2006-05-15 10:55:48 UTC (rev 59) @@ -152,6 +152,12 @@ /* map the tag to a PID and stream type, or use the default */ if(tag == -1) { + /* check we have a default stream */ + if(car->audio_pid == 0) + { + SEND_RESPONSE(500, "Unable to find audio PID"); + return false; + } pid = car->audio_pid; type = car->audio_type; } @@ -220,6 +226,12 @@ /* map the tag to a PID and stream type, or use the default */ if(tag == -1) { + /* check we have a default stream */ + if(car->video_pid == 0) + { + SEND_RESPONSE(500, "Unable to find video PID"); + return false; + } pid = car->video_pid; type = car->video_type; } @@ -293,6 +305,12 @@ /* map the tags to PIDs and stream types, or use the defaults */ if(audio_tag == -1) { + /* check we have a default stream */ + if(car->audio_pid == 0) + { + SEND_RESPONSE(500, "Unable to find audio PID"); + return false; + } audio_pid = car->audio_pid; audio_type = car->audio_type; } @@ -304,6 +322,12 @@ if(video_tag == -1) { + /* check we have a default stream */ + if(car->video_pid == 0) + { + SEND_RESPONSE(500, "Unable to find video PID"); + return false; + } video_pid = car->video_pid; video_type = car->video_type; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-06-13 09:01:41
|
Revision: 99 Author: skilvington Date: 2006-06-13 02:01:31 -0700 (Tue, 13 Jun 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=99&view=rev Log Message: ----------- missing space Modified Paths: -------------- redbutton-download/trunk/command.c Modified: redbutton-download/trunk/command.c =================================================================== --- redbutton-download/trunk/command.c 2006-06-12 18:05:47 UTC (rev 98) +++ redbutton-download/trunk/command.c 2006-06-13 09:01:31 UTC (rev 99) @@ -363,7 +363,7 @@ SEND_RESPONSE(200, "OK"); /* 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); + snprintf(hdr, sizeof(hdr), "AudioPID %u AudioType %u VideoPID %u VideoType %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 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-06-22 09:07:02
|
Revision: 122 Author: skilvington Date: 2006-06-22 02:06:51 -0700 (Thu, 22 Jun 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=122&view=rev Log Message: ----------- add assoc command Modified Paths: -------------- redbutton-download/trunk/command.c Modified: redbutton-download/trunk/command.c =================================================================== --- redbutton-download/trunk/command.c 2006-06-21 11:01:49 UTC (rev 121) +++ redbutton-download/trunk/command.c 2006-06-22 09:06:51 UTC (rev 122) @@ -19,6 +19,7 @@ #define ARGV_MAX 10 /* the commands */ +bool cmd_assoc(struct listen_data *, FILE *, int, char **); bool cmd_astream(struct listen_data *, FILE *, int, char **); bool cmd_avstream(struct listen_data *, FILE *, int, char **); bool cmd_check(struct listen_data *, FILE *, int, char **); @@ -35,6 +36,7 @@ char *help; } command[] = { + { "assoc", "", cmd_assoc, "List component tag to PID mappings" }, { "astream", "<ComponentTag>", cmd_astream, "Stream the given audio component tag" }, { "avstream", "<AudioTag> <VideoTag>", cmd_avstream, "Stream the given audio and video component tags" }, { "check", "<ContentReference>", cmd_check, "Check if the given file exists on the carousel" }, @@ -127,6 +129,36 @@ } /* + * assoc + * show the association/component tag to PID mappings + * also shows the default audio and video PIDs + * (just for debugging) + */ + +bool +cmd_assoc(struct listen_data *listen_data, FILE *client, int argc, char *argv[]) +{ + struct carousel *car = listen_data->carousel; + unsigned int i; + + SEND_RESPONSE(200, "OK"); + + /* if this is ever used by rb-browser, you will need to send a length first */ + fprintf(client, "Tag\tPID\tType\n"); + fprintf(client, "===\t===\t====\n"); + + /* default audio and video PIDs */ + fprintf(client, "(audio)\t%u\t%u\n", car->audio_pid, car->audio_type); + fprintf(client, "(video)\t%u\t%u\n", car->video_pid, car->video_type); + + /* component tag mappings */ + for(i=0; i<car->assoc.nassocs; i++) + fprintf(client, "%u\t%u\t%u\n", car->assoc.sids[i], car->assoc.pids[i], car->assoc.types[i]); + + return false; +} + +/* * astream <tag> * send the given audio stream down the connection * the tag should be an association/component_tag number as found in the PMT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2007-01-12 17:23:41
|
Revision: 177
http://svn.sourceforge.net/redbutton/?rev=177&view=rev
Author: skilvington
Date: 2007-01-12 09:23:33 -0800 (Fri, 12 Jan 2007)
Log Message:
-----------
whitespace
Modified Paths:
--------------
redbutton-download/trunk/command.c
Modified: redbutton-download/trunk/command.c
===================================================================
--- redbutton-download/trunk/command.c 2007-01-12 14:59:27 UTC (rev 176)
+++ redbutton-download/trunk/command.c 2007-01-12 17:23:33 UTC (rev 177)
@@ -519,7 +519,6 @@
unsigned int service_id;
union sigval value;
-
CHECK_USAGE(2, "retune <ServiceID>");
service_id = strtoul(argv[1], NULL, 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-01-24 17:28:18
|
Revision: 195
http://svn.sourceforge.net/redbutton/?rev=195&view=rev
Author: skilvington
Date: 2007-01-24 09:28:12 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
only send regular files from the carousel
Modified Paths:
--------------
redbutton-download/trunk/command.c
Modified: redbutton-download/trunk/command.c
===================================================================
--- redbutton-download/trunk/command.c 2007-01-24 16:51:56 UTC (rev 194)
+++ redbutton-download/trunk/command.c 2007-01-24 17:28:12 UTC (rev 195)
@@ -9,6 +9,8 @@
#include <stdint.h>
#include <fcntl.h>
#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "command.h"
#include "assoc.h"
@@ -456,6 +458,7 @@
cmd_file(struct listen_data *listen_data, FILE *client, int argc, char *argv[])
{
char *filename;
+ struct stat info;
FILE *file;
long size;
char hdr[64];
@@ -471,6 +474,14 @@
return false;
}
+ /* check it is a regular file */
+ if(stat(filename, &info) < 0
+ || !S_ISREG(info.st_mode))
+ {
+ SEND_RESPONSE(500, "Invalid file");
+ return false;
+ }
+
if((file = fopen(filename, "r")) == NULL)
{
SEND_RESPONSE(404, "Not found");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-02-26 15:10:40
|
Revision: 230
http://svn.sourceforge.net/redbutton/?rev=230&view=rev
Author: skilvington
Date: 2007-02-26 07:10:33 -0800 (Mon, 26 Feb 2007)
Log Message:
-----------
dont send an empty a/v stream if we can't find the PIDs
Modified Paths:
--------------
redbutton-download/trunk/command.c
Modified: redbutton-download/trunk/command.c
===================================================================
--- redbutton-download/trunk/command.c 2007-02-25 10:21:50 UTC (rev 229)
+++ redbutton-download/trunk/command.c 2007-02-26 15:10:33 UTC (rev 230)
@@ -209,7 +209,10 @@
/* check we have a default stream */
if(streams->audio_pid == 0)
+ {
SEND_RESPONSE(500, "Unable to resolve audio PID");
+ return false;
+ }
/* add the PID to the demux device */
if((audio_fd = add_demux_filter(car->demux_device, streams->audio_pid, DMX_PES_AUDIO)) < 0)
@@ -281,7 +284,10 @@
/* check we have a default stream */
if(streams->video_pid == 0)
+ {
SEND_RESPONSE(500, "Unable to resolve video PID");
+ return false;
+ }
/* add the PID to the demux device */
if((video_fd = add_demux_filter(car->demux_device, streams->video_pid, DMX_PES_VIDEO)) < 0)
@@ -357,9 +363,15 @@
/* check we have a default stream */
if(streams->audio_pid == 0)
+ {
SEND_RESPONSE(500, "Unable to resolve audio PID");
+ return false;
+ }
if(streams->video_pid == 0)
+ {
SEND_RESPONSE(500, "Unable to resolve video PID");
+ return false;
+ }
/* add the PIDs to the demux device */
if((audio_fd = add_demux_filter(car->demux_device, streams->audio_pid, DMX_PES_AUDIO)) < 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-03-01 15:40:35
|
Revision: 233
http://svn.sourceforge.net/redbutton/?rev=233&view=rev
Author: skilvington
Date: 2007-03-01 07:40:32 -0800 (Thu, 01 Mar 2007)
Log Message:
-----------
try to make sure dvr device loses PID filters when we close demux devices
Modified Paths:
--------------
redbutton-download/trunk/command.c
Modified: redbutton-download/trunk/command.c
===================================================================
--- redbutton-download/trunk/command.c 2007-03-01 12:09:42 UTC (rev 232)
+++ redbutton-download/trunk/command.c 2007-03-01 15:40:32 UTC (rev 233)
@@ -11,6 +11,7 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
#include "command.h"
#include "findmheg.h"
@@ -240,8 +241,9 @@
stream_ts(ts_fd, client);
/* clean up */
+ ioctl(audio_fd, DMX_STOP);
+ close(audio_fd);
close(ts_fd);
- close(audio_fd);
/* close the connection */
return true;
@@ -315,8 +317,9 @@
stream_ts(ts_fd, client);
/* clean up */
+ ioctl(video_fd, DMX_STOP);
+ close(video_fd);
close(ts_fd);
- close(video_fd);
/* close the connection */
return true;
@@ -407,9 +410,11 @@
stream_ts(ts_fd, client);
/* clean up */
- close(ts_fd);
+ ioctl(audio_fd, DMX_STOP);
+ ioctl(video_fd, DMX_STOP);
close(audio_fd);
close(video_fd);
+ close(ts_fd);
/* close the connection */
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-03-25 08:35:08
|
Revision: 256
http://svn.sourceforge.net/redbutton/?rev=256&view=rev
Author: skilvington
Date: 2007-03-25 01:35:04 -0700 (Sun, 25 Mar 2007)
Log Message:
-----------
terminate assoc output
Modified Paths:
--------------
redbutton-download/trunk/command.c
Modified: redbutton-download/trunk/command.c
===================================================================
--- redbutton-download/trunk/command.c 2007-03-23 13:51:06 UTC (rev 255)
+++ redbutton-download/trunk/command.c 2007-03-25 08:35:04 UTC (rev 256)
@@ -158,7 +158,6 @@
SEND_RESPONSE(200, "OK");
- /* if this is ever used by rb-browser, you will need to send a length first */
fprintf(client, "Tag\tPID\tType\n");
fprintf(client, "===\t===\t====\n");
@@ -170,6 +169,9 @@
for(i=0; i<car->assoc.nassocs; i++)
fprintf(client, "%u\t%u\t%u\n", car->assoc.sids[i], car->assoc.pids[i], car->assoc.types[i]);
+ /* terminator */
+ fprintf(client, ".\n");
+
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-03-25 09:07:30
|
Revision: 257
http://svn.sourceforge.net/redbutton/?rev=257&view=rev
Author: skilvington
Date: 2007-03-25 02:07:27 -0700 (Sun, 25 Mar 2007)
Log Message:
-----------
add {a,v,av}demux commands
Modified Paths:
--------------
redbutton-download/trunk/command.c
Modified: redbutton-download/trunk/command.c
===================================================================
--- redbutton-download/trunk/command.c 2007-03-25 08:35:04 UTC (rev 256)
+++ redbutton-download/trunk/command.c 2007-03-25 09:07:27 UTC (rev 257)
@@ -25,13 +25,16 @@
/* the commands */
bool cmd_assoc(struct listen_data *, FILE *, int, char **);
+bool cmd_ademux(struct listen_data *, FILE *, int, char **);
bool cmd_astream(struct listen_data *, FILE *, int, char **);
+bool cmd_avdemux(struct listen_data *, FILE *, int, char **);
bool cmd_avstream(struct listen_data *, FILE *, int, char **);
bool cmd_check(struct listen_data *, FILE *, int, char **);
bool cmd_file(struct listen_data *, FILE *, int, char **);
bool cmd_help(struct listen_data *, FILE *, int, char **);
bool cmd_quit(struct listen_data *, FILE *, int, char **);
bool cmd_retune(struct listen_data *, FILE *, int, char **);
+bool cmd_vdemux(struct listen_data *, FILE *, int, char **);
bool cmd_vstream(struct listen_data *, FILE *, int, char **);
static struct
@@ -43,7 +46,9 @@
} command[] =
{
{ "assoc", "", cmd_assoc, "List component tag to PID mappings" },
+ { "ademux", "[<ServiceID>] <ComponentTag>", cmd_ademux, "Demux the given audio component tag" },
{ "astream", "[<ServiceID>] <ComponentTag>", cmd_astream, "Stream the given audio component tag" },
+ { "avdemux", "[<ServiceID>] <AudioTag> <VideoTag>", cmd_avdemux, "Demux the given audio and video component tags" },
{ "avstream", "[<ServiceID>] <AudioTag> <VideoTag>", cmd_avstream, "Stream the given audio and video component tags" },
{ "check", "<ContentReference>", cmd_check, "Check if the given file exists on the carousel" },
{ "exit", "", cmd_quit, "Close the connection" },
@@ -51,6 +56,7 @@
{ "help", "", cmd_help, "List available commands" },
{ "quit", "", cmd_quit, "Close the connection" },
{ "retune", "<ServiceID>", cmd_retune, "Start downloading the carousel from ServiceID" },
+ { "vdemux", "[<ServiceID>] <ComponentTag>", cmd_vdemux, "Demux the given video component tag" },
{ "vstream", "[<ServiceID>] <ComponentTag>", cmd_vstream, "Stream the given video component tag" },
{ NULL, NULL, NULL, NULL }
};
@@ -176,6 +182,80 @@
}
/*
+ * ademux [<service_id>] <tag>
+ * add the given audio stream to the PID filter
+ * return the name of the dvr device to read the transport stream from
+ * if service_id is not specified or is -1, use the service we are downloading the carousel from
+ * the tag should be an association/component_tag number as found in the PMT
+ * the tag is converted to a PID and that PID is used as a demux filter
+ * if tag is -1, the default audio stream for the service_id is used
+ */
+
+bool
+cmd_ademux(struct listen_data *listen_data, FILE *client, int argc, char *argv[])
+{
+ struct carousel *car = listen_data->carousel;
+ int service;
+ int tag;
+ struct avstreams *streams;
+ int audio_fd;
+ char hdr[64];
+
+ CHECK_VUSAGE(2, 3, "ademux [<ServiceID>] <ComponentTag>");
+
+ if(argc == 2)
+ {
+ service = -1;
+ tag = strtol(argv[1], NULL, 0);
+ }
+ else
+ {
+ service = strtol(argv[1], NULL, 0);
+ tag = strtol(argv[2], NULL, 0);
+ }
+
+ streams = find_avstreams(car, service, tag, -1);
+
+ /* check we have a default stream */
+ if(streams->audio_pid == 0)
+ {
+ SEND_RESPONSE(500, "Unable to resolve audio PID");
+ return false;
+ }
+
+ /* add the PID to the demux device */
+ if((audio_fd = add_demux_filter(car->demux_device, streams->audio_pid, DMX_PES_AUDIO)) < 0)
+ {
+ SEND_RESPONSE(500, "Unable to open audio PID");
+ return false;
+ }
+
+ /* send the OK code */
+ SEND_RESPONSE(200, "OK");
+
+ /* tell the client what PID and stream type the component tag resolved to */
+ snprintf(hdr, sizeof(hdr), "AudioPID %u AudioType %u\n", streams->audio_pid, streams->audio_type);
+ fputs(hdr, client);
+
+ /* tell the client where the dvr device is */
+ snprintf(hdr, sizeof(hdr), "Device %s\n", car->dvr_device);
+ fputs(hdr, client);
+
+ fflush(client);
+
+ /* keep the filter in place until the client closes or we get an error */
+ while(!feof(client))
+ sleep(1);
+
+ /* clean up */
+ ioctl(audio_fd, DMX_STOP);
+ close(audio_fd);
+
+ /* close the connection */
+ return true;
+}
+
+/*
* astream [<service_id>] <tag>
* send the given audio stream down the connection
* if service_id is not specified or is -1, use the service we are downloading the carousel from
@@ -252,6 +332,80 @@
}
/*
+ * vdemux [<service_id>] <tag>
+ * add the given video stream to the PID filter
+ * return the name of the dvr device to read the transport stream from
+ * if service_id is not specified or is -1, use the service we are downloading the carousel from
+ * the tag should be an association/component_tag number as found in the PMT
+ * the tag is converted to a PID and that PID is used as a demux filter
+ * if tag is -1, the default video stream for the service_id is used
+ */
+
+bool
+cmd_vdemux(struct listen_data *listen_data, FILE *client, int argc, char *argv[])
+{
+ struct carousel *car = listen_data->carousel;
+ int service;
+ int tag;
+ struct avstreams *streams;
+ int video_fd;
+ char hdr[64];
+
+ CHECK_VUSAGE(2, 3, "vdemux [<ServiceID>] <ComponentTag>");
+
+ if(argc == 2)
+ {
+ service = -1;
+ tag = strtol(argv[1], NULL, 0);
+ }
+ else
+ {
+ service = strtol(argv[1], NULL, 0);
+ tag = strtol(argv[2], NULL, 0);
+ }
+
+ streams = find_avstreams(car, service, -1, tag);
+
+ /* check we have a default stream */
+ if(streams->video_pid == 0)
+ {
+ SEND_RESPONSE(500, "Unable to resolve video PID");
+ return false;
+ }
+
+ /* add the PID to the demux device */
+ if((video_fd = add_demux_filter(car->demux_device, streams->video_pid, DMX_PES_VIDEO)) < 0)
+ {
+ SEND_RESPONSE(500, "Unable to open video PID");
+ return false;
+ }
+
+ /* send the OK code */
+ SEND_RESPONSE(200, "OK");
+
+ /* tell the client what PID and stream type the component tag resolved to */
+ snprintf(hdr, sizeof(hdr), "VideoPID %u VideoType %u\n", streams->video_pid, streams->video_type);
+ fputs(hdr, client);
+
+ /* tell the client where the dvr device is */
+ snprintf(hdr, sizeof(hdr), "Device %s\n", car->dvr_device);
+ fputs(hdr, client);
+
+ fflush(client);
+
+ /* keep the filter in place until the client closes or we get an error */
+ while(!feof(client))
+ sleep(1);
+
+ /* clean up */
+ ioctl(video_fd, DMX_STOP);
+ close(video_fd);
+
+ /* close the connection */
+ return true;
+}
+
+/*
* vstream [<service_id>] <tag>
* send the given video stream down the connection
* if service_id is not specified or is -1, use the service we are downloading the carousel from
@@ -328,6 +482,97 @@
}
/*
+ * avdemux <audio_tag> <video_tag>
+ * add the given audio and video streams to the PID filter
+ * if service_id is not specified or is -1, use the service we are downloading the carousel from
+ * the tags should be association/component_tag numbers as found in the PMT
+ * the tags are converted to PIDs and those PIDs are used as the demux filter
+ * if a tag is -1, the default audio or video stream for the service_id is used
+ */
+
+bool
+cmd_avdemux(struct listen_data *listen_data, FILE *client, int argc, char *argv[])
+{
+ struct carousel *car = listen_data->carousel;
+ int service;
+ int audio_tag;
+ int video_tag;
+ struct avstreams *streams;
+ int audio_fd;
+ int video_fd;
+ char hdr[64];
+
+ CHECK_VUSAGE(3, 4, "avdemux [<ServiceID>] <AudioTag> <VideoTag>");
+
+ if(argc == 3)
+ {
+ service = -1;
+ audio_tag = strtol(argv[1], NULL, 0);
+ video_tag = strtol(argv[2], NULL, 0);
+ }
+ else
+ {
+ service = strtol(argv[1], NULL, 0);
+ audio_tag = strtol(argv[2], NULL, 0);
+ video_tag = strtol(argv[3], NULL, 0);
+ }
+
+ streams = find_avstreams(car, service, audio_tag, video_tag);
+
+ /* check we have a default stream */
+ if(streams->audio_pid == 0)
+ {
+ SEND_RESPONSE(500, "Unable to resolve audio PID");
+ return false;
+ }
+ if(streams->video_pid == 0)
+ {
+ SEND_RESPONSE(500, "Unable to resolve video PID");
+ return false;
+ }
+
+ /* add the PIDs to the demux device */
+ if((audio_fd = add_demux_filter(car->demux_device, streams->audio_pid, DMX_PES_AUDIO)) < 0)
+ {
+ SEND_RESPONSE(500, "Unable to open audio PID");
+ return false;
+ }
+ if((video_fd = add_demux_filter(car->demux_device, streams->video_pid, DMX_PES_VIDEO)) < 0)
+ {
+ SEND_RESPONSE(500, "Unable to open video PID");
+ close(audio_fd);
+ return false;
+ }
+
+ /* send the OK code */
+ SEND_RESPONSE(200, "OK");
+
+ /* tell the client what PIDs and stream types the component tags resolved to */
+ snprintf(hdr, sizeof(hdr), "AudioPID %u AudioType %u VideoPID %u VideoType %u\n",
+ streams->audio_pid, streams->audio_type, streams->video_pid, streams->video_type);
+ fputs(hdr, client);
+
+ /* tell the client where the dvr device is */
+ snprintf(hdr, sizeof(hdr), "Device %s\n", car->dvr_device);
+ fputs(hdr, client);
+
+ fflush(client);
+
+ /* keep the filter in place until the client closes or we get an error */
+ while(!feof(client))
+ sleep(1);
+
+ /* clean up */
+ ioctl(audio_fd, DMX_STOP);
+ ioctl(video_fd, DMX_STOP);
+ close(audio_fd);
+ close(video_fd);
+
+ /* close the connection */
+ return true;
+}
+
+/*
* avstream <audio_tag> <video_tag>
* send the given audio and video streams down the connection
* if service_id is not specified or is -1, use the service we are downloading the carousel from
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-11 09:44:35
|
Revision: 280
http://svn.sourceforge.net/redbutton/?rev=280&view=rev
Author: skilvington
Date: 2007-04-11 02:44:27 -0700 (Wed, 11 Apr 2007)
Log Message:
-----------
add a command to show the current service ID
Modified Paths:
--------------
redbutton-download/trunk/command.c
Modified: redbutton-download/trunk/command.c
===================================================================
--- redbutton-download/trunk/command.c 2007-04-08 11:50:31 UTC (rev 279)
+++ redbutton-download/trunk/command.c 2007-04-11 09:44:27 UTC (rev 280)
@@ -34,6 +34,7 @@
bool cmd_help(struct listen_data *, FILE *, int, char **);
bool cmd_quit(struct listen_data *, FILE *, int, char **);
bool cmd_retune(struct listen_data *, FILE *, int, char **);
+bool cmd_service(struct listen_data *, FILE *, int, char **);
bool cmd_vdemux(struct listen_data *, FILE *, int, char **);
bool cmd_vstream(struct listen_data *, FILE *, int, char **);
@@ -56,6 +57,7 @@
{ "help", "", cmd_help, "List available commands" },
{ "quit", "", cmd_quit, "Close the connection" },
{ "retune", "<ServiceID>", cmd_retune, "Start downloading the carousel from ServiceID" },
+ { "service", "", cmd_service, "Show the current service ID" },
{ "vdemux", "[<ServiceID>] <ComponentTag>", cmd_vdemux, "Demux the given video component tag" },
{ "vstream", "[<ServiceID>] <ComponentTag>", cmd_vstream, "Stream the given video component tag" },
{ NULL, NULL, NULL, NULL }
@@ -801,6 +803,27 @@
}
/*
+ * service
+ * show the service ID we are downloading the carousel from
+ * will be in the form, "dvb://network_id..service_id"
+ */
+
+bool
+cmd_service(struct listen_data *listen_data, FILE *client, int argc, char *argv[])
+{
+ struct carousel *car = listen_data->carousel;
+
+ SEND_RESPONSE(200, "OK");
+
+/* TODO */
+printf("TODO: cmd_service network_id\n");
+
+ fprintf(client, "dvb://..%x\n", car->service_id);
+
+ return false;
+}
+
+/*
* help
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|