[Redbutton-devel] SF.net SVN: redbutton: [205] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-02-08 11:55:49
|
Revision: 205
http://svn.sourceforge.net/redbutton/?rev=205&view=rev
Author: skilvington
Date: 2007-02-08 03:55:44 -0800 (Thu, 08 Feb 2007)
Log Message:
-----------
prepare to allow streaming a/v from different service IDs
Modified Paths:
--------------
redbutton-browser/trunk/ElementaryAction.c
redbutton-browser/trunk/MHEGBackend.c
redbutton-browser/trunk/MHEGBackend.h
redbutton-browser/trunk/MHEGEngine.c
redbutton-browser/trunk/MHEGEngine.h
redbutton-browser/trunk/MHEGStreamPlayer.c
redbutton-browser/trunk/MHEGStreamPlayer.h
redbutton-browser/trunk/StreamClass.c
redbutton-browser/trunk/StreamClass.h
redbutton-browser/trunk/der_decode.c
redbutton-browser/trunk/der_decode.h
Modified: redbutton-browser/trunk/ElementaryAction.c
===================================================================
--- redbutton-browser/trunk/ElementaryAction.c 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/ElementaryAction.c 2007-02-08 11:55:44 UTC (rev 205)
@@ -1205,6 +1205,8 @@
TokenGroupClass_SetData((TokenGroupClass *) obj, &e->u.set_data, caller_gid);
else if(obj->inst.rtti == RTTI_ListGroupClass)
ListGroupClass_SetData((ListGroupClass *) obj, &e->u.set_data, caller_gid);
+ else if(obj->inst.rtti == RTTI_StreamClass)
+ StreamClass_SetData((StreamClass *) obj, &e->u.set_data, caller_gid);
else
error("SetData: unexpected target: %s", ExternalReference_name(&obj->inst.ref));
}
Modified: redbutton-browser/trunk/MHEGBackend.c
===================================================================
--- redbutton-browser/trunk/MHEGBackend.c 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/MHEGBackend.c 2007-02-08 11:55:44 UTC (rev 205)
@@ -18,7 +18,7 @@
bool local_checkContentRef(MHEGBackend *, ContentReference *);
bool local_loadFile(MHEGBackend *, OctetString *, OctetString *);
FILE *local_openFile(MHEGBackend *, OctetString *);
-FILE *local_openStream(MHEGBackend *, bool, int *, int *, bool, int *, int *);
+FILE *local_openStream(MHEGBackend *, int, bool, int *, int *, bool, int *, int *);
void local_retune(MHEGBackend *, OctetString *);
static struct MHEGBackendFns local_backend_fns =
@@ -34,7 +34,7 @@
bool remote_checkContentRef(MHEGBackend *, ContentReference *);
bool remote_loadFile(MHEGBackend *, OctetString *, OctetString *);
FILE *remote_openFile(MHEGBackend *, OctetString *);
-FILE *remote_openStream(MHEGBackend *, bool, int *, int *, bool, int *, int *);
+FILE *remote_openStream(MHEGBackend *, int, bool, int *, int *, bool, int *, int *);
void remote_retune(MHEGBackend *, OctetString *);
static struct MHEGBackendFns remote_backend_fns =
@@ -333,14 +333,15 @@
* return a read-only FILE handle for an MPEG Transport Stream
* the TS will contain an audio stream (if have_audio is true) and a video stream (if have_video is true)
* 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
+ * if *audio_tag or *video_tag is -1, the default audio and/or video stream for the given Service ID is used
+ * if service_id is -1, it uses the Service ID we are downloading the carousel from
* 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, int *audio_type, bool have_video, int *video_tag, int *video_type)
+local_openStream(MHEGBackend *t, int service_id, 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
@@ -350,7 +351,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, audio_type, have_video, video_tag, video_type);
+ return remote_openStream(t, service_id, have_audio, audio_tag, audio_type, have_video, video_tag, video_type);
}
/*
@@ -522,14 +523,15 @@
* return a read-only FILE handle for an MPEG Transport Stream
* the TS will contain an audio stream (if have_audio is true) and a video stream (if have_video is true)
* 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
+ * if *audio_tag or *video_tag is -1, the default audio and/or video stream for the given Service ID is used
+ * if service_id is -1, it uses the Service ID we are downloading the carousel from
* 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, int *audio_type, bool have_video, int *video_tag, int *video_type)
+remote_openStream(MHEGBackend *t, int service_id, bool have_audio, int *audio_tag, int *audio_type, bool have_video, int *video_tag, int *video_type)
{
char cmd[PATH_MAX];
FILE *sock;
@@ -538,6 +540,9 @@
unsigned int video_pid = 0;
bool err;
+/* TODO */
+if(service_id != -1) printf("TODO: openStream: service_id=%d\n", service_id);
+
/* no PIDs required */
if(!have_audio && !have_video)
return NULL;
Modified: redbutton-browser/trunk/MHEGBackend.h
===================================================================
--- redbutton-browser/trunk/MHEGBackend.h 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/MHEGBackend.h 2007-02-08 11:55:44 UTC (rev 205)
@@ -29,7 +29,7 @@
/* open a carousel file */
FILE *(*openFile)(struct MHEGBackend *, OctetString *);
/* open an MPEG Transport Stream */
- FILE *(*openStream)(struct MHEGBackend *, bool, int *, int *, bool, int *, int *);
+ FILE *(*openStream)(struct MHEGBackend *, int, bool, int *, int *, bool, int *, int *);
/* tune to the given service */
void (*retune)(struct MHEGBackend *, OctetString *);
} *fns;
Modified: redbutton-browser/trunk/MHEGEngine.c
===================================================================
--- redbutton-browser/trunk/MHEGEngine.c 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/MHEGEngine.c 2007-02-08 11:55:44 UTC (rev 205)
@@ -1416,9 +1416,10 @@
*/
FILE *
-MHEGEngine_openStream(bool have_audio, int *audio_tag, int *audio_type, bool have_video, int *video_tag, int *video_type)
+MHEGEngine_openStream(int service_id, 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,
+ service_id,
have_audio, audio_tag, audio_type,
have_video, video_tag, video_type);
}
Modified: redbutton-browser/trunk/MHEGEngine.h
===================================================================
--- redbutton-browser/trunk/MHEGEngine.h 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/MHEGEngine.h 2007-02-08 11:55:44 UTC (rev 205)
@@ -239,7 +239,7 @@
bool MHEGEngine_checkContentRef(ContentReference *);
bool MHEGEngine_loadFile(OctetString *, OctetString *);
FILE *MHEGEngine_openFile(OctetString *);
-FILE *MHEGEngine_openStream(bool, int *, int *, bool, int *, int *);
+FILE *MHEGEngine_openStream(int, bool, int *, int *, bool, int *, int *);
void MHEGEngine_retune(OctetString *);
char *MHEGEngine_absoluteFilename(OctetString *);
Modified: redbutton-browser/trunk/MHEGStreamPlayer.c
===================================================================
--- redbutton-browser/trunk/MHEGStreamPlayer.c 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/MHEGStreamPlayer.c 2007-02-08 11:55:44 UTC (rev 205)
@@ -91,6 +91,9 @@
p->video = NULL;
p->audio = NULL;
+ /* stream a/v components from the service we are currently tuned to */
+ p->service_id = -1;
+
p->audio_codec = NULL;
pthread_mutex_init(&p->base_lock, NULL);
@@ -119,7 +122,21 @@
return;
}
+/*
+ * service ID is used to resolve the stream component tags
+ * -1 => use the service we are currently tuned to,
+ * ie the service we are downloading the carousel from
+ */
+
void
+MHEGStreamPlayer_setServiceID(MHEGStreamPlayer *p, int id)
+{
+ p->service_id = id;
+
+ return;
+}
+
+void
MHEGStreamPlayer_setVideoStream(MHEGStreamPlayer *p, VideoClass *video)
{
if(p->have_video)
@@ -174,7 +191,8 @@
p->audio_pid = p->audio_tag;
p->video_pid = p->video_tag;
- if((p->ts = MHEGEngine_openStream(p->have_audio, &p->audio_pid, &p->audio_type,
+ if((p->ts = MHEGEngine_openStream(p->service_id,
+ p->have_audio, &p->audio_pid, &p->audio_type,
p->have_video, &p->video_pid, &p->video_type)) == NULL)
{
error("Unable to open MPEG stream");
Modified: redbutton-browser/trunk/MHEGStreamPlayer.h
===================================================================
--- redbutton-browser/trunk/MHEGStreamPlayer.h 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/MHEGStreamPlayer.h 2007-02-08 11:55:44 UTC (rev 205)
@@ -57,6 +57,7 @@
bool have_audio; /* false if we have no audio stream */
VideoClass *video; /* output size/position, maybe NULL if audio only */
AudioClass *audio; /* output volume, maybe NULL if video only */
+ int service_id; /* service containing the audio/video components (-1 => what we are currently tuned to) */
int video_tag; /* video stream component tag (-1 => default for current service ID) */
int video_pid; /* PID in MPEG Transport Stream (-1 => not yet known) */
int video_type; /* video stream type (-1 => not yet known) */
@@ -81,6 +82,7 @@
void MHEGStreamPlayer_init(MHEGStreamPlayer *);
void MHEGStreamPlayer_fini(MHEGStreamPlayer *);
+void MHEGStreamPlayer_setServiceID(MHEGStreamPlayer *, int);
void MHEGStreamPlayer_setVideoStream(MHEGStreamPlayer *, VideoClass *);
void MHEGStreamPlayer_setAudioStream(MHEGStreamPlayer *, AudioClass *);
Modified: redbutton-browser/trunk/StreamClass.c
===================================================================
--- redbutton-browser/trunk/StreamClass.c 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/StreamClass.c 2007-02-08 11:55:44 UTC (rev 205)
@@ -7,6 +7,7 @@
#include "StreamComponent.h"
#include "ExternalReference.h"
#include "ContentBody.h"
+#include "si.h"
#include "utils.h"
void
@@ -93,12 +94,29 @@
StreamClass_Preparation(t);
}
- /* assume default is "rec://svc/cur", ie current channel */
+ /* assume default is "rec://svc/def", ie current channel */
if(t->have_original_content
- && (service = ContentBody_getReference(&t->original_content)) != NULL
- && OctetString_strcmp(service, "rec://svc/cur") != 0)
+ && (service = ContentBody_getReference(&t->original_content)) != NULL)
{
+ /*
+ * service can be:
+ * "dvb://<original_network_id>.[<transport_stream_id>].<service_id>"
+ * "rec://svc/def" - use the service we are downloading the carousel from
+ * "rec://svc/cur" - use the current service
+ * this will be the same as "def" unless SetData has been called on the StreamClass
+ * "rec://svc/lcn/X" - use logical channel number X (eg 1 for BBC1, 3 for ITV1, etc)
+ */
+ if(OctetString_strncmp(service, "dvb:", 4) == 0)
+ {
+ MHEGStreamPlayer_setServiceID(&t->inst.player, si_get_service_id(service));
+ }
+ /* leave player's service ID as it is for "cur" and "def" */
+ else if(OctetString_strcmp(service, "rec://svc/cur") != 0
+ && OctetString_strcmp(service, "rec://svc/def") != 0)
+ {
+/* TODO */
printf("TODO: StreamClass: service='%.*s'\n", service->size, service->data);
+ }
}
/* start playing all active StreamComponents */
@@ -201,7 +219,22 @@
return;
}
+/*
+ * corrigendum says StreamClass can be the target of SetData
+ * this changes the multiplex (ie service ID)
+ */
+
void
+StreamClass_SetData(StreamClass *t, SetData *set, OctetString *caller_gid)
+{
+ verbose("StreamClass: %s; SetData", ExternalReference_name(&t->rootClass.inst.ref));
+
+/* TODO */
+printf("TODO: StreamClass_SetData not yet implemented\n");
+ return;
+}
+
+void
StreamClass_SetCounterTrigger(StreamClass *t, SetCounterTrigger *params, OctetString *caller_gid)
{
verbose("StreamClass: %s; SetCounterTrigger", ExternalReference_name(&t->rootClass.inst.ref));
Modified: redbutton-browser/trunk/StreamClass.h
===================================================================
--- redbutton-browser/trunk/StreamClass.h 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/StreamClass.h 2007-02-08 11:55:44 UTC (rev 205)
@@ -12,6 +12,7 @@
void StreamClass_Deactivation(StreamClass *);
void StreamClass_Destruction(StreamClass *);
+void StreamClass_SetData(StreamClass *, SetData *, OctetString *);
void StreamClass_SetCounterTrigger(StreamClass *, SetCounterTrigger *, OctetString *);
void StreamClass_SetSpeed(StreamClass *, SetSpeed *, OctetString *);
void StreamClass_SetCounterPosition(StreamClass *, SetCounterPosition *, OctetString *);
Modified: redbutton-browser/trunk/der_decode.c
===================================================================
--- redbutton-browser/trunk/der_decode.c 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/der_decode.c 2007-02-08 11:55:44 UTC (rev 205)
@@ -234,6 +234,19 @@
}
/*
+ * compare the first n characters of the OctetString with the given C string
+ */
+
+int
+OctetString_strncmp(OctetString *oct, char *str, size_t n)
+{
+ if(oct->size < n)
+ return oct->size - n;
+ else
+ return memcmp(oct->data, str, n);
+}
+
+/*
* assumes its okay to call der_realloc(dst->data, x)
* if dst is not initialised, you should use OctetString_dup instead
* src can be NULL, but dst must be valid
Modified: redbutton-browser/trunk/der_decode.h
===================================================================
--- redbutton-browser/trunk/der_decode.h 2007-01-29 17:00:12 UTC (rev 204)
+++ redbutton-browser/trunk/der_decode.h 2007-02-08 11:55:44 UTC (rev 205)
@@ -51,6 +51,7 @@
int OctetString_cmp(OctetString *, OctetString *);
int OctetString_strcmp(OctetString *, char *);
+int OctetString_strncmp(OctetString *, char *, size_t);
bool OctetString_copy(OctetString *, OctetString *);
void OctetString_dup(OctetString *, OctetString *);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|