summaryrefslogtreecommitdiff
path: root/src/libmpeg2/xine_decoder.c
diff options
context:
space:
mode:
authorJames Courtier-Dutton <jcdutton@users.sourceforge.net>2002-10-18 16:46:23 +0000
committerJames Courtier-Dutton <jcdutton@users.sourceforge.net>2002-10-18 16:46:23 +0000
commit8bb89fd2610320780a1db6763451492ded6bdccb (patch)
tree2e05cf021a9f4aa3748a7605a9327865d4af95e2 /src/libmpeg2/xine_decoder.c
parenta6f73d008c8ba9f07f4c3cff3603ed99c517e04d (diff)
downloadxine-lib-8bb89fd2610320780a1db6763451492ded6bdccb.tar.gz
xine-lib-8bb89fd2610320780a1db6763451492ded6bdccb.tar.bz2
Enable libmpeg2 for new api.
EVENTS and metainfo might not be sent yet. CVS patchset: 2852 CVS date: 2002/10/18 16:46:23
Diffstat (limited to 'src/libmpeg2/xine_decoder.c')
-rw-r--r--src/libmpeg2/xine_decoder.c93
1 files changed, 52 insertions, 41 deletions
diff --git a/src/libmpeg2/xine_decoder.c b/src/libmpeg2/xine_decoder.c
index f3a548c1e..65d6276a1 100644
--- a/src/libmpeg2/xine_decoder.c
+++ b/src/libmpeg2/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.40 2002/09/05 22:18:57 mroi Exp $
+ * $Id: xine_decoder.c,v 1.41 2002/10/18 16:46:24 jcdutton Exp $
*
* stuff needed to turn libmpeg2 into a xine decoder plugin
*/
@@ -39,36 +39,20 @@
/*
#define LOG
*/
+typedef struct {
+ video_decoder_class_t decoder_class;
+} mpeg2_class_t;
+
typedef struct mpeg2dec_decoder_s {
video_decoder_t video_decoder;
mpeg2dec_t mpeg2;
+ mpeg2_class_t *class;
+ xine_stream_t *stream;
vo_instance_t *video_out;
pthread_mutex_t lock; /* mutex for async flush */
} mpeg2dec_decoder_t;
-static void mpeg2dec_init (video_decoder_t *this_gen, vo_instance_t *video_out) {
-
- mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
-
-#ifdef LOG
- printf ("libmpeg2: init... \n");
-#endif
-
- pthread_mutex_lock (&this->lock);
-
- mpeg2_init (&this->mpeg2, video_out);
- video_out->open(video_out);
- this->video_out = video_out;
- this->mpeg2.force_aspect = 0;
-
- pthread_mutex_unlock (&this->lock);
-
-#ifdef LOG
- printf ("libmpeg2: init...done\n");
-#endif
-}
-
static void mpeg2dec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
@@ -129,7 +113,7 @@ static void mpeg2dec_reset (video_decoder_t *this_gen) {
}
-static void mpeg2dec_close (video_decoder_t *this_gen) {
+static void mpeg2dec_dispose (video_decoder_t *this_gen) {
mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
@@ -144,41 +128,68 @@ static void mpeg2dec_close (video_decoder_t *this_gen) {
this->video_out->close(this->video_out);
pthread_mutex_unlock (&this->lock);
-}
-
-static char *mpeg2dec_get_id(void) {
- return "mpeg2dec";
-}
-
-static void mpeg2dec_dispose (video_decoder_t *this_gen) {
- mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
pthread_mutex_destroy (&this->lock);
free (this);
}
-static void *init_video_decoder_plugin (xine_t *xine, void *data) {
-
+static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
mpeg2dec_decoder_t *this ;
this = (mpeg2dec_decoder_t *) malloc (sizeof (mpeg2dec_decoder_t));
memset(this, 0, sizeof (mpeg2dec_decoder_t));
- this->video_decoder.init = mpeg2dec_init;
this->video_decoder.decode_data = mpeg2dec_decode_data;
this->video_decoder.flush = mpeg2dec_flush;
this->video_decoder.reset = mpeg2dec_reset;
- this->video_decoder.close = mpeg2dec_close;
- this->video_decoder.get_identifier = mpeg2dec_get_id;
this->video_decoder.dispose = mpeg2dec_dispose;
-
- this->mpeg2.xine = xine;
+ this->stream = stream;
+ this->class = (mpeg2_class_t *) class_gen;
+ this->mpeg2.stream = stream;
pthread_mutex_init (&this->lock, NULL);
- return this;
+ pthread_mutex_lock (&this->lock);
+
+ mpeg2_init (&this->mpeg2, stream->video_out);
+ stream->video_out->open(stream->video_out);
+ this->video_out = stream->video_out;
+ this->mpeg2.force_aspect = 0;
+
+ pthread_mutex_unlock (&this->lock);
+
+ return &this->video_decoder;
}
/*
+ * mpeg2 plugin class
+ */
+
+static char *get_identifier (video_decoder_class_t *this) {
+ return "mpeg2dec";
+}
+
+static char *get_description (video_decoder_class_t *this) {
+ return "mpeg2 based video decoder plugin";
+}
+
+static void dispose_class (video_decoder_class_t *this) {
+ free (this);
+}
+
+static void *init_plugin (xine_t *xine, void *data) {
+
+ mpeg2_class_t *this;
+
+ this = (mpeg2_class_t *) malloc (sizeof (mpeg2_class_t));
+
+ this->decoder_class.open_plugin = open_plugin;
+ this->decoder_class.get_identifier = get_identifier;
+ this->decoder_class.get_description = get_description;
+ this->decoder_class.dispose = dispose_class;
+
+ return this;
+}
+/*
* exported plugin catalog entry
*/
@@ -191,6 +202,6 @@ static decoder_info_t dec_info_mpeg2 = {
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 10, "mpeg2", XINE_VERSION_CODE, &dec_info_mpeg2, init_video_decoder_plugin },
+ { PLUGIN_VIDEO_DECODER, 11, "mpeg2", XINE_VERSION_CODE, &dec_info_mpeg2, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};