Author: fejj
Date: 2008-01-27 12:53:18 -0500 (Sun, 27 Jan 2008)
New Revision: 94061
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/pipeline-ffmpeg.h
trunk/moon/src/pipeline.cpp
trunk/moon/src/pipeline.h
Log:
2008-01-27 Jeffrey Stedfast <[EMAIL PROTECTED]>
* pipeline.cpp: IMediaDemuxer ctors now take an IMediaSource
argument to use in place of media->GetSource().
(Media::Open): Don't set this->source unless we successfully open
the source.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2008-01-27 17:50:56 UTC (rev 94060)
+++ trunk/moon/src/ChangeLog 2008-01-27 17:53:18 UTC (rev 94061)
@@ -1,3 +1,10 @@
+2008-01-27 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ * pipeline.cpp: IMediaDemuxer ctors now take an IMediaSource
+ argument to use in place of media->GetSource().
+ (Media::Open): Don't set this->source unless we successfully open
+ the source.
+
2008-01-26 Jeffrey Stedfast <[EMAIL PROTECTED]>
* media.cpp (MediaElement::TryOpen): In the DownloadComplete case,
Modified: trunk/moon/src/pipeline-ffmpeg.h
===================================================================
--- trunk/moon/src/pipeline-ffmpeg.h 2008-01-27 17:50:56 UTC (rev 94060)
+++ trunk/moon/src/pipeline-ffmpeg.h 2008-01-27 17:53:18 UTC (rev 94061)
@@ -34,7 +34,7 @@
class FfmpegDemuxer : public IMediaDemuxer {
public:
- FfmpegDemuxer (Media* media) : IMediaDemuxer (media) {}
+ FfmpegDemuxer (Media *media, IMediaSource *source) : IMediaDemuxer
(media, source) {}
};
class FfmpegDecoder : public IMediaDecoder {
Modified: trunk/moon/src/pipeline.cpp
===================================================================
--- trunk/moon/src/pipeline.cpp 2008-01-27 17:50:56 UTC (rev 94060)
+++ trunk/moon/src/pipeline.cpp 2008-01-27 17:53:18 UTC (rev 94061)
@@ -87,7 +87,7 @@
pthread_cond_signal (&queue_condition);
pthread_mutex_unlock (&queue_mutex);
- if (source->GetType () == MediaSourceTypeProgressive) {
+ if (source && source->GetType () == MediaSourceTypeProgressive) {
ProgressiveSource *ps = (ProgressiveSource *) source;
ps->CancelWait ();
}
@@ -96,10 +96,10 @@
pthread_mutex_destroy (&queue_mutex);
pthread_cond_destroy (&queue_condition);
pthread_detach (queue_thread);
-
+
+ g_free (file_or_url);
delete source;
delete demuxer;
- g_free (file_or_url);
delete queue_closure;
@@ -336,8 +336,6 @@
if (source == NULL || IsOpened ()) // Initialize wasn't called (or
didn't succeed) or already open.
return MEDIA_INVALID_ARGUMENT;
- this->source = source;
-
// Select a demuxer
DemuxerInfo *demuxerInfo = registered_demuxers;
while (demuxerInfo != NULL) {
@@ -349,17 +347,35 @@
}
if (demuxerInfo == NULL) {
- AddMessage (MEDIA_UNKNOWN_MEDIA_TYPE, g_strdup_printf ("No
demuxers registered to handle the media file '%s'.", file_or_url));
+ const char *source_name = file_or_url;
+
+ if (!source_name) {
+ switch (source->GetType ()) {
+ case MediaSourceTypeProgressive:
+ case MediaSourceTypeFile:
+ source_name = ((FileSource *)
source)->GetFileName ();
+ break;
+ case MediaSourceTypeLive:
+ source_name = "live source";
+ break;
+ default:
+ source_name = "unknown source";
+ break;
+ }
+ }
+
+ AddMessage (MEDIA_UNKNOWN_MEDIA_TYPE,
+ g_strdup_printf ("No demuxers registered to handle
the media source `%s'.",
+ source_name));
return MEDIA_UNKNOWN_MEDIA_TYPE;
}
// Found a demuxer
- demuxer = demuxerInfo->Create (this);
+ demuxer = demuxerInfo->Create (this, source);
result = demuxer->ReadHeader ();
- if (!MEDIA_SUCCEEDED (result)) {
+ if (!MEDIA_SUCCEEDED (result))
return result;
- }
//printf ("Media::Open (): Found %i streams in this source.\n",
demuxer->GetStreamCount ());
@@ -369,28 +385,30 @@
// Select codecs for each stream
for (int i = 0; i < demuxer->GetStreamCount (); i++) {
- IMediaStream* stream = demuxer->GetStream (i);
+ IMediaStream *stream = demuxer->GetStream (i);
if (stream == NULL)
return MEDIA_INVALID_STREAM;
- const char* codec = stream->GetCodec ();
- IMediaDecoder* decoder = NULL;
+ const char *codec = stream->GetCodec ();
+ IMediaDecoder *decoder = NULL;
//printf ("Media::Open (): Selecting codec for codec %s, id
%i.\n", codec, stream->codec_id);
- DecoderInfo* current_decoder = registered_decoders;
+ DecoderInfo *current_decoder = registered_decoders;
while (current_decoder != NULL && !current_decoder->Supports
(codec)) {
- //printf ("Checking registered decoder '%s' if it
supports codec '%s': no.\n", current_decoder->GetName (), codec);
+ //printf ("Checking registered decoder '%s' if it
supports codec '%s': no.\n",
+ // current_decoder->GetName (), codec);
current_decoder = (DecoderInfo*) current_decoder->next;
}
if (current_decoder == NULL) {
AddMessage (MEDIA_UNKNOWN_CODEC, g_strdup_printf
("Unknown codec: '%s'.", codec));
} else {
- //printf ("Checking registered decoder '%s' if it
supports codec '%s': yes.\n", current_decoder->GetName (), codec);
+ //printf ("Checking registered decoder '%s' if it
supports codec '%s': yes.\n",
+ // current_decoder->GetName (), codec);
decoder = current_decoder->Create (this, stream);
}
-
+
if (decoder != NULL) {
result = decoder->Open ();
if (!MEDIA_SUCCEEDED (result)) {
@@ -407,14 +425,18 @@
ConverterInfo* current_conv =
registered_converters;
while (current_conv != NULL &&
!current_conv->Supports (decoder->pixel_format, MoonPixelFormatRGB32)) {
- //printf ("Checking registered
converter '%s' if it supports input '%i' and output '%i': no.\n",
current_conv->GetName (), decoder->pixel_format, MoonPixelFormatRGB32);
+ //printf ("Checking whether '%s'
supports input '%d' and output '%d': no.\n",
+ // current_conv->GetName (),
decoder->pixel_format, MoonPixelFormatRGB32);
current_conv = (ConverterInfo*)
current_conv->next;
}
-
+
if (current_conv == NULL) {
- AddMessage (MEDIA_UNKNOWN_CONVERTER,
g_strdup_printf ("Can't convert from %i to %i: No converter found.",
vs->decoder->pixel_format, MoonPixelFormatRGB32));
+ AddMessage (MEDIA_UNKNOWN_CONVERTER,
+ g_strdup_printf ("Can't
convert from %d to %d: No converter found.",
+
vs->decoder->pixel_format, MoonPixelFormatRGB32));
} else {
- //printf ("Checking registered
converter '%s' if it supports input '%i' and output '%i': yes.\n",
current_conv->GetName (), decoder->pixel_format, MoonPixelFormatRGB32);
+ //printf ("Checking whether '%s'
supports input '%d' and output '%d': yes.\n",
+ // current_conv->GetName (),
decoder->pixel_format, MoonPixelFormatRGB32);
converter = current_conv->Create (this,
vs);
converter->input_format =
decoder->pixel_format;
converter->output_format =
MoonPixelFormatRGB32;
@@ -423,8 +445,8 @@
converter = NULL;
}
}
-
- if (converter != NULL) {
+
+ if (converter != NULL) {
vs->converter = converter;
} else {
delete decoder;
@@ -439,7 +461,10 @@
}
}
- opened = true;
+ if (result == MEDIA_SUCCESS) {
+ this->source = source;
+ opened = true;
+ }
return result;
}
@@ -670,7 +695,7 @@
* ASFDemuxer
*/
-ASFDemuxer::ASFDemuxer (Media *media) : IMediaDemuxer (media)
+ASFDemuxer::ASFDemuxer (Media *media, IMediaSource *source) : IMediaDemuxer
(media, source)
{
stream_to_asf_index = NULL;
reader = NULL;
@@ -799,7 +824,7 @@
ASFDemuxer::ReadHeader ()
{
MediaResult result = MEDIA_SUCCESS;
- ASFSource *asf_source = new ASFMediaSource (NULL, GetMedia
()->GetSource ());
+ ASFSource *asf_source = new ASFMediaSource (NULL, source);
ASFParser *asf_parser = new ASFParser (asf_source);
int32_t *stream_to_asf_index = NULL;
IMediaStream **streams = NULL;
@@ -1043,9 +1068,9 @@
}
IMediaDemuxer *
-ASFDemuxerInfo::Create (Media *media)
+ASFDemuxerInfo::Create (Media *media, IMediaSource *source)
{
- return new ASFDemuxer (media);
+ return new ASFDemuxer (media, source);
}
@@ -1550,7 +1575,7 @@
* Mp3Demuxer
*/
-Mp3Demuxer::Mp3Demuxer (Media *media) : IMediaDemuxer (media)
+Mp3Demuxer::Mp3Demuxer (Media *media, IMediaSource *source) : IMediaDemuxer
(media, source)
{
reader = NULL;
}
@@ -1573,7 +1598,6 @@
MediaResult
Mp3Demuxer::ReadHeader ()
{
- IMediaSource *source = GetMedia ()->GetSource ();
IMediaStream **streams = NULL;
int64_t stream_start;
IMediaStream *stream;
@@ -1720,9 +1744,9 @@
}
IMediaDemuxer *
-Mp3DemuxerInfo::Create (Media *media)
+Mp3DemuxerInfo::Create (Media *media, IMediaSource *source)
{
- return new Mp3Demuxer (media);
+ return new Mp3Demuxer (media, source);
}
Modified: trunk/moon/src/pipeline.h
===================================================================
--- trunk/moon/src/pipeline.h 2008-01-27 17:50:56 UTC (rev 94060)
+++ trunk/moon/src/pipeline.h 2008-01-27 17:53:18 UTC (rev 94061)
@@ -207,7 +207,7 @@
// <buffer> points to the first <length> bytes of a file.
// <length> is guaranteed to be at least 16 bytes.
virtual bool Supports (IMediaSource *source) = 0;
- virtual IMediaDemuxer *Create (Media *media) = 0;
+ virtual IMediaDemuxer *Create (Media *media, IMediaSource *source) = 0;
};
class ConverterInfo : public MediaInfo {
@@ -394,7 +394,7 @@
Media *media;
public:
- IMediaObject (Media *med);
+ IMediaObject (Media *media);
virtual ~IMediaObject ();
Media *GetMedia () { return media; }
@@ -422,7 +422,7 @@
// User defined context value.
void *GetContext () { return context; }
- void SetContext (void* context) { this->context = context; }
+ void SetContext (void *context) { this->context = context; }
void *extra_data;
int extra_data_size;
@@ -446,10 +446,18 @@
int stream_count;
protected:
+ IMediaSource *source;
+
void SetStreams (IMediaStream **streams, int count);
public:
- IMediaDemuxer (Media *media) : IMediaObject (media), streams (NULL),
stream_count (0) {}
+ IMediaDemuxer (Media *media, IMediaSource *source) : IMediaObject
(media)
+ {
+ this->source = source;
+ stream_count = 0;
+ streams = NULL;
+ }
+
virtual ~IMediaDemuxer ();
virtual MediaResult ReadHeader () = 0;
@@ -660,7 +668,7 @@
void ReadMarkers ();
public:
- ASFDemuxer (Media *media);
+ ASFDemuxer (Media *media, IMediaSource *source);
~ASFDemuxer ();
virtual MediaResult ReadHeader ();
@@ -673,7 +681,7 @@
class ASFDemuxerInfo : public DemuxerInfo {
public:
virtual bool Supports (IMediaSource *source);
- virtual IMediaDemuxer *Create (Media *media);
+ virtual IMediaDemuxer *Create (Media *media, IMediaSource *source);
virtual const char *GetName () { return "ASFDemuxer"; }
};
@@ -739,7 +747,7 @@
Mp3FrameReader *reader;
public:
- Mp3Demuxer (Media *media);
+ Mp3Demuxer (Media *media, IMediaSource *source);
~Mp3Demuxer ();
virtual MediaResult ReadHeader ();
@@ -750,7 +758,7 @@
class Mp3DemuxerInfo : public DemuxerInfo {
public:
virtual bool Supports (IMediaSource *source);
- virtual IMediaDemuxer *Create (Media *media);
+ virtual IMediaDemuxer *Create (Media *media, IMediaSource *source);
virtual const char *GetName () { return "Mp3Demuxer"; }
};
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches